Incompatible mode of HNFileAdapter. Occurs when HNFileAdapter.AutoMode was set
[Get/Set]),
but HNQueue object was not predetermined (see
HNFileAdapter.Queue
[Get/Set]).
HNERR_MEM_ALLOC_ERROR
The memory for the traffic processing is not allocated. This can happen either because of the
insufficient operating system resources or in case of
HNQueue component using (see
QueAllocItems).
HNERR_OPEN_FILE
CAP file opening error.
HNERR_READ_FILE
File reading error.
HNERR_BAD_FILE_FORMAT
Unknown CAP file format.
HNERR_FORMAT_VER
This version of CAP file is not supported.
HNERR_BAD_MEDIUM_TYPE
The adapter type, in format of which packets was dumped to CAP file, is not supported.
hFAdp parameter is not the HNFileAdapter object handle.
Description:
Use FAdpOpenFile to open an existing CAP file. If the function succeeds, you can begin to
dump network traffic to this CAP file using FAdpGetNextPacket function.
If HNFileAdapter.Queue property
[Get/Set] was
set before the network adapter opening, and HNFileAdapter object
Automode was set (see HNFileAdapter.AutoMode [Get/
Set]), then the traffic will be processed in the
HNFileAdapter internal thread context together with HNQueue
component.
On executing FAdpOpenFile function
HNFileAdapter component attempts to close the CAP file which was
opened earlier. So, one instance of HNFileAdapter object can open
only one CAP file.
If you need to open/create several CAP files simultaneously, you may create several
HNFileAdapter objects with appropriate settings.
To create a new CAP file please use FAdpCreateFile function.
Example of using HNFileAdpater object AutoMode for reading packets from the first CAP file and dumping
packets to the second CAP file:
// OnFileClose event handler
void __stdcall OnFileClose(DWORD_PTR Param, DWORD_PTR ThParam, DWORD Result)
{
if (Result == HNERR_FILE_SIZE_LIMIT)
{
...
}
}
...
// Create the first HNFileAdapter object
HANDLE hFAdp1 = FAdpCreate();
// Create the second HNFileAdapter object
HANDLE hFÀdp2 = FAdpCreate();
// Create HNQueue object
HANDLE hQue = QueCreate();
...
// Set HNQueue object to HNFileAdapter objects
FAdpSetQueue(hFAdp1, hQue);
FAdpSetQueue(hFAdp2, hQue);
// HNFileAdapter additional settings
FAdpSetAutoMode(hFAdp1, TRUE);
FAdpSetAutoMode(hFAdp2, TRUE);
FAdpSetSizeLimit(hFAdp1, 1000000);
FAdpSetOnFileClose(hFAdp1, OnFileClose, 0);
// Create CAP file
DWORD Res = FAdpCreateFile(hFAdp1, "packets2.cap");
...
// Start internal queue thread
Res = QueStart(hQue);
...
// Open CAP file
Res = FAdpOpenFile(hFAdp2, "packets1.cap");
...
Requirements:
Unicode
Implemented as FAdpOpenFileW (Unicode) and FAdpOpenFileA (ANSI).