Packet Sniffer SDK DLL Edition

HNAdapter :: Methods :: AdpAsyncRequest

 Previous Next

Execute asynchronous NDIS request.

Syntax:

DWORD __stdcall AdpAsyncRequestHANDLE hAdp, DWORD RequestType, DWORD Oid, 
   LPVOID pBuffer, DWORD BufferSize, DWORD_PTR Key);

Parameters:

hAdp

[in] HNAdapter object handle.

RequestType

[in] NDIS request type (see NDIS REQUEST TYPE).

Oid

[in] NDIS request code (see NDIS OIDs).

pBuffer

[in,out] Buffer for NDIS request input parameters, also is used for request result.

BufferSize

[in] Data buffer size.

Key

[in] A user-defined parameter.

Return values:

HNERR_OKThe packet has been sent successfully.
HNERR_ADAPTER_NOT_OPENEDThe adapter has not been opened, see the AdpOpenAdapter function.
HNERR_ADAPTER_REQ_ERRAn internal driver request error.
HNERR_INVALID_HANDLEhAdp parameter is not the HNAdapter object handle.

Description:

Description:

NDIS technology is significant part of the network stack in the Windows OS family, it is realized as OS driver NDIS.VXD for Windows 9x/Me or NDIS.SYS for Windows NT/2k/XP/2k3/Vista.

NDIS provides interconnection between NIC drivers and protocol drivers (internal PSSDK driver is a protocol driver). Protocol driver can manage NIC driver by NDIS requests, also protocol driver can obtain necessary information from the NIC driver.

After successfully opening of the network adapter by AdpOpenAdapter function you can execute synchronous NDIS request to the NIC driver. The main difference of the AdpAsyncRequest function from the AdpSyncRequest function is that the NDIS request is completed in the OnAsyncRequest event handler, in the context of the PSSDK internal thread. So, you can make NDIS/NIC driver requests and process returned results in different threads: your application and PSSDK respectively.

For details please refer to MSDN, DDK documentation, and NIC vendor's specifications.

// Get quantity of the succesfully sent packets.

#define OID_802_3_CURRENT_ADDRESS 0x01010102

static char MacAddrr[6];

HANDLE hAdp = AdpOpenAdapter();
...
DWORD Res = AdpAsyncRequest(hAdp,NdisRequestQueryInformation,
             OID_802_3_CURRENT_ADDRESS,&MacAddrr,sizeof(MacAddrr),0);
...
VOID __stdcall OnAsyncRequest(DWORD_PTR Param, DWORD_PTR Key, DWORD RequestType, DWORD Oid, 
   LPVOID pBuffer, DWORD BufferSize, DWORD BytesUsed, DWORD BytesNeeded, DWORD NdisStatus)
 {
   if(Oid == OID_802_3_CURRENT_ADDRESS)
    {
      char *pMacAddr = (char *)pBuffer;
      ...
    } 
 }
See also:HNAdapter, AdpOpenAdapter, AdpSyncRequest, AdpSetOnAsyncRequest, NDIS_REQUEST_TYPE, NDIS_OIDs