Packet Sniffer SDK DLL Edition

HNFileAdapter :: Methods :: FAdpGetNextPacket

 Previous Next

Retrieve next packet from CAP file opened for reading.

Syntax:

DWORD __stdcall FAdpGetNextPacket(HANDLE hFAdp, HANDLE hPkt);

Parameters:

hFAdp

[in] HNFileAdapter object handle.

hPkt

[in, out] The handle of the HNPacket object.

Return values:

HNERR_OKCAP file opening has been completed successfully.
HNERR_ADAPTER_NOT_OPENEDCAP file has not been opened, see the FAdpOpenFile function.
HNERR_ADDR_ERRhPkt has the wrong value (a memory write error).
HNERR_INCOMPATIBLE_MODEIncompatible mode of HNFileAdapter. Occurs when HNFileAdapter.AutoMode was set [Get/Set]), or if the CAP file was opened for data writing (see FAdpCreateFile function).
HNERR_READ_FILEFile read error.
HNERR_BAD_PACKET_LENHNPacket.IncPacketSize property [Get/Set] for hPkt parameter is set incorrectly.
HNERR_EOFEnd of CAP file.
HNERR_INVALID_HANDLEhFAdp parameter is not the HNFileAdapter object handle.

Description:

Use this function to get access to the packets stored in a CAP file. This function may be called only after successfull call of the FAdpOpenFile function.

If you already read packets from certain file, and need to read the first packet, please use FAdpRewindFile.

Example of reading packets from CAP file using FAdpGetNextPacket function:

// Create HNPacket object
HANDLE hPkt = PktCreate(1514); 

// Open CAP file
DWORD Res = FAdpOpenFile(hFAdp, "packets.cap");
...
do 
{      
   // Read packet from file
   Res = FAdpGetNextPacket(hFAdp,hPkt);
   
   // Getting access to the HNPacket properties and functions
   ... 
} 
while (Res == HNERR_OK);
See also:HNFileAdapter, FAdpOpenFile, FAdpRewindFile, HNPacket, PktCreate, PktGetIncPacketSize, PktSetIncPacketSize