Packet Sniffer SDK DLL Edition

HNFileAdapter :: Properties :: FAdpSetAutoMode

 Previous Next

Set HNFileAdapter object automatic mode flag status.

Syntax:

BOOL __stdcall FAdpSetAutoMode(HANDLE hAdp, BOOL bAutoMode);

Parameters:

hAdp

[in] HNFileAdapter object handle.

bAutoMode

[in] New value of the HNFileAdapter object automatic mode flag status.

Return values:

If the function succeeds the return value will be the bAutoMode parameter value.

Description:

Use FAdpSetAutoMode to change status of the flag which indicates that HNFileAdapter works in automatic mode.

Automatic mode of the HNFileAdapter object sets its working in the context of its internal thread. For read/write operations in the automatic mode please use FAdpOpenFile/FAdpCreateFile respectively.

To get AutoMode flag status please use FAdpGetAutoMode function.

To work with HNFileAdapter in AutoMode you should use HNQueue together with it (see HNFileAdapter.Queue property [Get/Set]).

Example of using HNFileAdpater AutoMode for dumping packets to a CAP file:

// OnFileClose event handler
void __stdcall OnFileClose(DWORD_PTR Param, DWORD_PTR ThParam, DWORD Result)
{
    if (Result == HNERR_FILE_SIZE_LIMIT)
    {
      ...
    }
}
...
// Create HNAdapter object
HANDLE hAdp = AdpCreate(); 
// Create HNQueue object
HANDLE hQue = QueCreate(); 
// Create HNFileAdapter object
HANDLE hFÀdp = FAdpCreate(); 
...
// Set HNQueue object for HNAdapter and HNFileAdapter
AdpSetReceiveQueue(hAdp, hQue);
FAdpSetQueue(hFAdp, hQue);

// HNFileAdapter additional settings
FAdpSetAutoMode(hFAdp, TRUE);
FAdpSetSizeLimit(hFAdp, 1000000);
FAdpSetOnFileClose(hFAdp, OnFileClose, 0);

// Create CAP file
DWORD Res = FAdpCreateFile(hFAdp, "packets.cap");
...
// Start queue internal thread
Res = QueStart(hQue);
...
// Open network adapter
Res = AdpOpenAdapter(hAdp);
...
See also:HNFileAdapter, FAdpOpenFile, FAdpCreateFile, HNQueue, FAdpGetQueue, FAdpSetQueue, FAdpGetAutoMode