AirPcap functions


Functions

void AirpcapGetVersion (PUINT VersionMajor, PUINT VersionMinor, PUINT VersionRev, PUINT VersionBuild)
 Returns a string with the API version.
PCHAR AirpcapGetLastError (PAirpcapHandle AdapterHandle)
 Returns the last error related to the specified handle.
BOOL AirpcapGetDeviceList (PAirpcapDeviceDescription *PPAllDevs, PCHAR Ebuf)
 Returns the list of available devices.
VOID AirpcapFreeDeviceList (PAirpcapDeviceDescription PAllDevs)
 Frees a list of devices returned by AirpcapGetDeviceList().
PAirpcapHandle AirpcapOpen (PCHAR DeviceName, PCHAR Ebuf)
 Opens an adapter.
VOID AirpcapClose (PAirpcapHandle AdapterHandle)
 Closes an adapter.
BOOL AirpcapGetDeviceCapabilities (PAirpcapHandle AdapterHandle, PAirpcapDeviceCapabilities *PCapabilities)
 Get the capabilties of a device.
BOOL AirpcapSetDeviceMacFlags (PAirpcapHandle AdapterHandle, UINT AirpcapMacFlags)
 Sets the device's monitor mode and acknowledgment settings.
BOOL AirpcapGetDeviceMacFlags (PAirpcapHandle AdapterHandle, PUINT PAirpcapMacFlags)
 Gets the device's monitor mode and acknowledgement settings.
BOOL AirpcapSetLinkType (PAirpcapHandle AdapterHandle, AirpcapLinkType NewLinkType)
 Sets the link type of an adapter.
BOOL AirpcapGetLinkType (PAirpcapHandle AdapterHandle, PAirpcapLinkType PLinkType)
 Gets the link type of the specified adapter.
BOOL AirpcapSetFcsPresence (PAirpcapHandle AdapterHandle, BOOL IsFcsPresent)
 Configures the adapter on whether to include the MAC Frame Check Sequence in the captured packets.
BOOL AirpcapGetFcsPresence (PAirpcapHandle AdapterHandle, PBOOL PIsFcsPresent)
 Returns TRUE if the specified adapter includes the MAC Frame Check Sequence in the captured packets.
BOOL AirpcapSetFcsValidation (PAirpcapHandle AdapterHandle, AirpcapValidationType ValidationType)
 Configures the adapter to accept or drop frames with an incorrect Frame Check sequence (FCS).
BOOL AirpcapGetFcsValidation (PAirpcapHandle AdapterHandle, PAirpcapValidationType ValidationType)
 Checks if the specified adapter is configured to capture frames with incorrect an incorrect Frame Check Sequence (FCS).
BOOL AirpcapSetDeviceKeys (PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection)
 Sets the list of decryption keys that AirPcap is going to use with the specified device.
BOOL AirpcapGetDeviceKeys (PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, PUINT PKeysCollectionSize)
 Returns the list of decryption keys that are currently associated with the specified device.
BOOL AirpcapSetDriverKeys (PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection)
 Set the global list of decryption keys that AirPcap is going to use with all the devices.
BOOL AirpcapGetDriverKeys (PAirpcapHandle AdapterHandle, PAirpcapKeysCollection KeysCollection, PUINT PKeysCollectionSize)
 Returns the global list of decryption keys that AirPcap is using with all the devices.
BOOL AirpcapSetDecryptionState (PAirpcapHandle AdapterHandle, AirpcapDecryptionState Enable)
 Turns on or off the decryption of the incoming frames with the device-specific keys.
BOOL AirpcapGetDecryptionState (PAirpcapHandle AdapterHandle, PAirpcapDecryptionState PEnable)
 Tells if this open instance is configured to perform the decryption of the incoming frames with the device-specific keys.
BOOL AirpcapSetDriverDecryptionState (PAirpcapHandle AdapterHandle, AirpcapDecryptionState Enable)
 Turns on or off the decryption of the incoming frames with the global set of keys.
BOOL AirpcapGetDriverDecryptionState (PAirpcapHandle AdapterHandle, PAirpcapDecryptionState PEnable)
 Tells if this open instance is configured to perform the decryption of the incoming frames with the global set of keys.
BOOL AirpcapSetDeviceChannel (PAirpcapHandle AdapterHandle, UINT Channel)
 Sets the radio channel of a device.
BOOL AirpcapGetDeviceChannel (PAirpcapHandle AdapterHandle, PUINT PChannel)
 Gets the radio channel of a device.
BOOL AirpcapSetDeviceChannelEx (PAirpcapHandle AdapterHandle, AirpcapChannelInfo ChannelInfo)
 Sets the channel of a device through its radio frequency. In case of 802.11n enabled devices, it sets the extension channel, if used.
BOOL AirpcapGetDeviceChannelEx (PAirpcapHandle AdapterHandle, PAirpcapChannelInfo PChannelInfo)
 Gets the channel of a device through its radio frequency. In case of 802.11n enabled devices, it gets the extension channel, if in use.
BOOL AirpcapGetDeviceSupportedChannels (PAirpcapHandle AdapterHandle, PAirpcapChannelInfo *ppChannelInfo, PUINT pNumChannelInfo)
 Gets the list of supported channels for a given device. In case of a 802.11n capable device, information related to supported extension channels is also reported.
BOOL AirpcapConvertFrequencyToChannel (UINT Frequency, PUINT PChannel, PAirpcapChannelBand PBand)
 Converts a given frequency to the corresponding channel.
BOOL AirpcapConvertChannelToFrequency (UINT Channel, PUINT PFrequency)
 Converts a given channel to the corresponding frequency.
BOOL AirpcapSetKernelBuffer (PAirpcapHandle AdapterHandle, UINT BufferSize)
 Sets the size of the kernel packet buffer for this adapter.
BOOL AirpcapGetKernelBufferSize (PAirpcapHandle AdapterHandle, PUINT PSizeBytes)
 Gets the size of the kernel packet buffer for this adapter.
BOOL AirpcapSetTxPower (PAirpcapHandle AdapterHandle, UINT Power)
 Sets the power of the frames are transmitted by adapter.
BOOL AirpcapGetTxPower (PAirpcapHandle AdapterHandle, PUINT PPower)
 Returns the current transmit power level of the adapter.
BOOL AirpcapStoreCurConfigAsAdapterDefault (PAirpcapHandle AdapterHandle)
 Saves the configuration of the specified adapter in the registry, so that it becomes the default for this adapter.
BOOL AirpcapSetFilter (PAirpcapHandle AdapterHandle, PVOID Instructions, UINT Len)
 Sets the BPF kernel filter for an adapter.
BOOL AirpcapGetMacAddress (PAirpcapHandle AdapterHandle, PAirpcapMacAddress PMacAddress)
 Returns the MAC address of a device.
BOOL AirpcapSetMacAddress (PAirpcapHandle AdapterHandle, PAirpcapMacAddress PMacAddress)
 Sets the MAC address of a device.
BOOL AirpcapSetMinToCopy (PAirpcapHandle AdapterHandle, UINT MinToCopy)
 Sets the mintocopy parameter for an open adapter.
BOOL AirpcapGetReadEvent (PAirpcapHandle AdapterHandle, HANDLE *PReadEvent)
 Gets an event that is signalled when packets are available in the kernel buffer (see AirpcapSetMinToCopy()).
BOOL AirpcapRead (PAirpcapHandle AdapterHandle, PBYTE Buffer, UINT BufSize, PUINT PReceievedBytes)
 Fills a user-provided buffer with zero or more packets that have been captured on the referenced adapter.
BOOL AirpcapWrite (PAirpcapHandle AdapterHandle, PCHAR TxPacket, ULONG PacketLen)
 Transmits a packet.
BOOL AirpcapGetStats (PAirpcapHandle AdapterHandle, PAirpcapStats PStats)
 Gets per-adapter WinPcap-compatible capture statistics.
BOOL AirpcapGetLedsNumber (PAirpcapHandle AdapterHandle, PUINT NumberOfLeds)
 Gets the number of LEDs the referenced adapter has available.
BOOL AirpcapTurnLedOn (PAirpcapHandle AdapterHandle, UINT LedNumber)
 Turns on one of the adapter's LEDs.
BOOL AirpcapTurnLedOff (PAirpcapHandle AdapterHandle, UINT LedNumber)
 Turns off one of the adapter's LEDs.
BOOL AirpcapGetDeviceTimestamp (PAirpcapHandle AdapterHandle, PAirpcapDeviceTimestamp PTimestamp)
 Gets the current value of the device counter used to timestamp packets.

Function Documentation

void AirpcapGetVersion ( PUINT  VersionMajor,
PUINT  VersionMinor,
PUINT  VersionRev,
PUINT  VersionBuild 
)

Returns a string with the API version.

Parameters:
VersionMajor Pointer to a variable that will be filled with the major version number.
VersionMinor Pointer to a variable that will be filled with the minor version number.
VersionRev Pointer to a variable that will be filled with the revision number.
VersionBuild Pointer to a variable that will be filled with the build number.

PCHAR AirpcapGetLastError ( PAirpcapHandle  AdapterHandle  ) 

Returns the last error related to the specified handle.

Parameters:
AdapterHandle Handle to an open adapter.
Returns:
The string with the last error.

BOOL AirpcapGetDeviceList ( PAirpcapDeviceDescription PPAllDevs,
PCHAR  Ebuf 
)

Returns the list of available devices.

Parameters:
PPAllDevs Address to a caller allocated pointer. On success this pointer will receive the head of a list of available devices.
Ebuf String that will contain error information if FALSE is returned. The size of the string must be AIRPCAP_ERRBUF_SIZE bytes.
Returns:
TRUE on success. FALSE is returned on failure, in which case Ebuf is filled in with an appropriate error message.
Here's a snippet of code that shows how to use AirpcapGetDeviceList():

    CHAR Ebuf[AIRPCAP_ERRBUF_SIZE];
    AirpcapDeviceDescription *Desc, *tDesc;

    if(AirpcapGetDeviceList(&Desc, Ebuf) == -1)
    {
        printf("Unable to get the list of devices: %s\n", Ebuf);
        return -1;
    }
    
    for(tDesc = Desc; tDesc; tDesc = tDesc->next)
    {
        printf("%u) %s (%s)\n",
        ++i,
        tDesc->Name,
        tDesc->Description);
    }

    AirpcapFreeDeviceList(Desc);

VOID AirpcapFreeDeviceList ( PAirpcapDeviceDescription  PAllDevs  ) 

Frees a list of devices returned by AirpcapGetDeviceList().

Parameters:
PAllDevs Head of the list of devices returned by AirpcapGetDeviceList().

PAirpcapHandle AirpcapOpen ( PCHAR  DeviceName,
PCHAR  Ebuf 
)

Opens an adapter.

Parameters:
DeviceName Name of the device to open. Use AirpcapGetDeviceList() to get the list of devices.
Ebuf String that will contain error information in case of failure. The size of the string must be AIRPCAP_ERRBUF_SIZE bytes.
Returns:
A PAirpcapHandle handle on success. NULL is returned on failure, in which case Ebuf is filled in with an appropriate error message.

VOID AirpcapClose ( PAirpcapHandle  AdapterHandle  ) 

Closes an adapter.

Parameters:
AdapterHandle Handle to the adapter to close.

BOOL AirpcapGetDeviceCapabilities ( PAirpcapHandle  AdapterHandle,
PAirpcapDeviceCapabilities PCapabilities 
)

Get the capabilties of a device.

Parameters:
AdapterHandle Handle to the adapter.
PCapabilities Pointer to a library-allocated AirpcapDeviceCapabilities structure that contains the capabilities of the adapter.
Returns:
TRUE on success.
Note:
The PCapabilities structure returned by AirpcapGetDeviceCapabilities() must be considered invalid after the adapter has been closed.

BOOL AirpcapSetDeviceMacFlags ( PAirpcapHandle  AdapterHandle,
UINT  AirpcapMacFlags 
)

Sets the device's monitor mode and acknowledgment settings.

Parameters:
AdapterHandle Handle to the adapter.
AirpcapMacFlags Flags word, that contains a bitwise-OR combination of the following flags: AIRPCAP_MF_MONITOR_MODE_ON and AIRPCAP_MF_ACK_FRAMES_ON .
Returns:
TRUE on success.
When an adapter is plugged into the system, it's always configured with monitor mode ON and acknowledgment settings OFF. These values are not stored persistently, so if you want to turn monitor mode off, you will need to do it every time you attach the adapter.

Note:
currently, the AirPcap adapter supports frames acknowleging when the adapter is NOT in monitor mode. This means that the combinations in which the two flags have the same value will cause AirpcapSetDeviceMacFlags() to fail.

BOOL AirpcapGetDeviceMacFlags ( PAirpcapHandle  AdapterHandle,
PUINT  PAirpcapMacFlags 
)

Gets the device's monitor mode and acknowledgement settings.

Parameters:
AdapterHandle Handle to the adapter.
PAirpcapMacFlags User-provided flags word, that will be filled by the function with an OR combination of the following flags: AIRPCAP_MF_MONITOR_MODE_ON and AIRPCAP_MF_ACK_FRAMES_ON.
Returns:
TRUE on success.
When an adapter is plugged into the system, it's always configured with monitor mode ON and acknowledgment settings OFF. These values are not stored persistently, so if you want to turn monitor mode off, you will need to do it every time you attach the adapter.

BOOL AirpcapSetLinkType ( PAirpcapHandle  AdapterHandle,
AirpcapLinkType  NewLinkType 
)

Sets the link type of an adapter.

Parameters:
AdapterHandle Handle to the adapter.
NewLinkType the "link type", i.e. the format of the frames that will be received from the adapter.
Returns:
TRUE on success.
the "link type" determines how the driver will encode the packets captured from the network. Aircap supports two link types:
  • AIRPCAP_LT_802_11, to capture 802.11 frames (including control frames) without any power information. Look at the "Capture_no_radio" example application in the developer's pack for a reference on how to decode 802.11 frames with this link type.
  • AIRPCAP_LT_802_11_PLUS_RADIO, to capture 802.11 frames (including control frames) with a radiotap header that contains power and channel information. More information about the radiotap header can be found in the Information About the Radiotap Header section. Moreover, the "Capture_radio" example application in the developer's pack can be used as a reference on how to decode 802.11 frames with radiotap headers.
  • AIRPCAP_LT_802_11_PLUS_PPI, to capture 802.11 frames (including control frames) with a Per Packet Information (PPI) header that contains per-packet meta information like channel and power information. More details on the PPI header can be found in the PPI online documentation (TODO).

BOOL AirpcapGetLinkType ( PAirpcapHandle  AdapterHandle,
PAirpcapLinkType  PLinkType 
)

Gets the link type of the specified adapter.

Parameters:
AdapterHandle Handle to the adapter.
PLinkType Pointer to a caller allocated AirpcapLinkType variable that will contain the link type of the adapter.
Returns:
TRUE on success.
the "link type" determines how the driver will encode the packets captured from the network. Aircap supports two link types:
  • AIRPCAP_LT_802_11, to capture 802.11 frames (including control frames) without any power information. Look at the "Capture_no_radio" example application in the developer's pack for a reference on how to decode 802.11 frames with this link type.
  • AIRPCAP_LT_802_11_PLUS_RADIO, to capture 802.11 frames (including control frames) with a radiotap header that contains power and channel information. More information about the radiotap header can be found int the Information About the Radiotap Header section. Moreover, the "Capture_radio" example application in the developer's pack can be used as a reference on how to decode 802.11 frames with radiotap headers.
  • AIRPCAP_LT_802_11_PLUS_PPI, to capture 802.11 frames (including control frames) with a Per Packet Information (PPI) header that contains per-packet meta information like channel and power information. More details on the PPI header can be found in the PPI online documentation (TODO).

BOOL AirpcapSetFcsPresence ( PAirpcapHandle  AdapterHandle,
BOOL  IsFcsPresent 
)

Configures the adapter on whether to include the MAC Frame Check Sequence in the captured packets.

Parameters:
AdapterHandle Handle to the adapter.
IsFcsPresent TRUE if the packets should include the FCS. FALSE otherwise
Returns:
TRUE on success.
In the default configuration, the adapter includes the FCS in the captured packets. The MAC Frame Check Sequence is 4 bytes and is located at the end of the 802.11 packet, with AIRPCAP_LT_802_11, AIRPCAP_LT_802_11_PLUS_RADIO and AIRPCAP_LT_802_11_PLUS_PPI link types. When the FCS inclusion is turned on, and if the link type is AIRPCAP_LT_802_11_PLUS_RADIO, the radiotap header that precedes each frame has two additional fields at the end: Padding and FCS. These two fields are not present when FCS inclusion is off.

BOOL AirpcapGetFcsPresence ( PAirpcapHandle  AdapterHandle,
PBOOL  PIsFcsPresent 
)

Returns TRUE if the specified adapter includes the MAC Frame Check Sequence in the captured packets.

Parameters:
AdapterHandle Handle to the adapter.
PIsFcsPresent User-provided variable that will be set to true if the adapter is including the FCS.
Returns:
TRUE if the operation is successful. FALSE otherwise.
In the default configuration, the adapter includes the FCS in the captured packets. The MAC Frame Check Sequence is 4 bytes and is located at the end of the 802.11 packet, with AIRPCAP_LT_802_11, AIRPCAP_LT_802_11_PLUS_RADIO and AIRPCAP_LT_802_11_PLUS_PPI link types. When the FCS inclusion is turned on, and if the link type is AIRPCAP_LT_802_11_PLUS_RADIO, the radiotap header that precedes each frame has two additional fields at the end: Padding and FCS. These two fields are not present when FCS inclusion is off.

BOOL AirpcapSetFcsValidation ( PAirpcapHandle  AdapterHandle,
AirpcapValidationType  ValidationType 
)

Configures the adapter to accept or drop frames with an incorrect Frame Check sequence (FCS).

Parameters:
AdapterHandle Handle to the adapter.
ValidationType The type of validation the driver will perform. See the documentation of AirpcapValidationType for details.
Returns:
TRUE on success.
Note:
By default, the driver is configured in AIRPCAP_VT_ACCEPT_EVERYTHING mode.

BOOL AirpcapGetFcsValidation ( PAirpcapHandle  AdapterHandle,
PAirpcapValidationType  ValidationType 
)

Checks if the specified adapter is configured to capture frames with incorrect an incorrect Frame Check Sequence (FCS).

Parameters:
AdapterHandle Handle to the adapter.
ValidationType Pointer to a user supplied variable that will contain the type of validation the driver will perform. See the documentation of AirpcapValidationType for details.
Returns:
TRUE if the operation is succesful. FALSE otherwise.
Note:
By default, the driver is configured in AIRPCAP_VT_ACCEPT_EVERYTHING mode.

BOOL AirpcapSetDeviceKeys ( PAirpcapHandle  AdapterHandle,
PAirpcapKeysCollection  KeysCollection 
)

Sets the list of decryption keys that AirPcap is going to use with the specified device.

Parameters:
AdapterHandle Handle an open adapter instance.
KeysCollection Pointer to a PAirpcapKeysCollection structure that contains the keys to be set in the device.
Returns:
TRUE if the operation is successful. FALSE otherwise.
AirPcap is able to use a set of decryption keys to decrypt the traffic transmitted on a specific SSID. If one of the keys corresponds to the one the frame has been encrypted with, the driver will perform decryption and return the cleartext frames to the application.

This function allows to set the device-specific set of keys. These keys will be used by the specified device only, and will not be used by other airpcap devices besides the specified one.

At this time, the only supported decryption method is WEP.

The keys are applied to the packets in the same order they appear in the KeysCollection structure until the packet is correctly decrypted, therefore putting frequently used keys at the beginning of the structure improves performance.

Note:
When you change the set of keys from an open capture instance, the change will be immediately reflected on all the other capture instances on the same device.

BOOL AirpcapGetDeviceKeys ( PAirpcapHandle  AdapterHandle,
PAirpcapKeysCollection  KeysCollection,
PUINT  PKeysCollectionSize 
)

Returns the list of decryption keys that are currently associated with the specified device.

Parameters:
AdapterHandle Handle to an open adapter instance.
KeysCollection User-allocated PAirpcapKeysCollection structure that will be filled with the keys.
PKeysCollectionSize 
  • IN: pointer to a user-allocated variable that contains the length of the KeysCollection structure, in bytes.
  • OUT: amount of data moved by AirPcap in the buffer pointed by KeysBuffer, in bytes.
Returns:
TRUE if the operation is successful. If an error occurs, the return value is FALSE and KeysCollectionSize is zero. If the provided buffer is too small to contain the keys, the return value is FALSE and KeysCollectionSize contains the needed KeysCollection length, in bytes. If the device doesn't have any decryption key configured, the return value is TRUE, and KeysCollectionSize will be zero.
This function returns the device-specific set of keys. These keys are used by the specified device only, and not by other airpcap devices besides the specified one.

AirPcap is able to use a set of decryption keys to decrypt the traffic transmitted on a specific SSID. If one of the keys corresponds to the one the frame has been encrypted with, the driver will perform decryption and return the cleartext frames to the application. AirPcap supports, for every device, multiple keys at the same time.

The configured decryption keys are device-specific, therefore AirpcapGetDeviceKeys() will return a different set of keys when called on different devices.

At this time, the only supported decryption method is WEP.

BOOL AirpcapSetDriverKeys ( PAirpcapHandle  AdapterHandle,
PAirpcapKeysCollection  KeysCollection 
)

Set the global list of decryption keys that AirPcap is going to use with all the devices.

Parameters:
AdapterHandle Handle an open adapter instance.
KeysCollection Pointer to a PAirpcapKeysCollection structure that contains the keys to be set globally.
Returns:
TRUE if the operation is successful. FALSE otherwise.
The AirPcap driver is able to use a set of decryption keys to decrypt the traffic transmitted on a specific SSID. If one of the keys corresponds to the one the frame has been encrypted with, the driver will perform decryption and return the cleartext frames to the application.

This function allows to set the global set of keys. These keys will be used by all the devices plugged in the machine.

At this time, the only supported decryption method is WEP.

The keys are applied to the packets in the same order they appear in the KeysCollection structure until the packet is correctly decrypted, therefore putting frequently used keys at the beginning of the structure improves performance.

Note:
When you change the set of keys from an open capture instance, the change will be immediately reflected on all the other capture instances.

BOOL AirpcapGetDriverKeys ( PAirpcapHandle  AdapterHandle,
PAirpcapKeysCollection  KeysCollection,
PUINT  PKeysCollectionSize 
)

Returns the global list of decryption keys that AirPcap is using with all the devices.

Parameters:
AdapterHandle Handle to an open adapter instance.
KeysCollection User-allocated PAirpcapKeysCollection structure that will be filled with the keys.
PKeysCollectionSize 
  • IN: pointer to a user-allocated variable that contains the length of the KeysCollection structure, in bytes.
  • OUT: amount of data moved by AirPcap in the buffer pointed by KeysBuffer, in bytes.
Returns:
TRUE if the operation is successful. If an error occurs, the return value is FALSE and KeysCollectionSize is zero. If the provided buffer is too small to contain the keys, the return value is FALSE and KeysCollectionSize contains the needed KeysCollection length, in bytes. If no global decryption keys are configured, the return value is TRUE, and KeysCollectionSize will be zero.
This function returns the global set of keys. These keys will be used by all the devices plugged in the machine.

The AirPcap driver is able to use a set of decryption keys to decrypt the traffic transmitted on a specific SSID. If one of the keys corresponds to the one the frame has been encrypted with, the driver will perform decryption and return the cleartext frames to the application.

At this time, the only supported decryption method is WEP.

BOOL AirpcapSetDecryptionState ( PAirpcapHandle  AdapterHandle,
AirpcapDecryptionState  Enable 
)

Turns on or off the decryption of the incoming frames with the device-specific keys.

Parameters:
AdapterHandle Handle to the adapter.
Enable Either AIRPCAP_DECRYPTION_ON or AIRPCAP_DECRYPTION_OFF
Returns:
TRUE on success.
The device-specific decryption keys can be configured with the AirpcapSetDeviceKeys() function.
Note:
By default, the driver is configured with AIRPCAP_DECRYPTION_ON.

BOOL AirpcapGetDecryptionState ( PAirpcapHandle  AdapterHandle,
PAirpcapDecryptionState  PEnable 
)

Tells if this open instance is configured to perform the decryption of the incoming frames with the device-specific keys.

Parameters:
AdapterHandle Handle to the adapter.
PEnable Pointer to a user supplied variable that will contain the decryption configuration. See PAirpcapDecryptionState for details.
Returns:
TRUE if the operation is succesful. FALSE otherwise.
The device-specific decryption keys can be configured with the AirpcapSetDeviceKeys() function.
Note:
By default, the driver is configured with AIRPCAP_DECRYPTION_ON.

BOOL AirpcapSetDriverDecryptionState ( PAirpcapHandle  AdapterHandle,
AirpcapDecryptionState  Enable 
)

Turns on or off the decryption of the incoming frames with the global set of keys.

Parameters:
AdapterHandle Handle to the adapter.
Enable Either AIRPCAP_DECRYPTION_ON or AIRPCAP_DECRYPTION_OFF
Returns:
TRUE on success.
The global decryption keys can be configured with the AirpcapSetDriverKeys() function.
Note:
By default, the driver is configured with AIRPCAP_DECRYPTION_ON.

BOOL AirpcapGetDriverDecryptionState ( PAirpcapHandle  AdapterHandle,
PAirpcapDecryptionState  PEnable 
)

Tells if this open instance is configured to perform the decryption of the incoming frames with the global set of keys.

Parameters:
AdapterHandle Handle to the adapter.
PEnable Pointer to a user supplied variable that will contain the decryption configuration. See PAirpcapDecryptionState for details.
Returns:
TRUE if the operation is successful. FALSE otherwise.
The global decryption keys can be configured with the AirpcapSetDriverKeys() function.
Note:
By default, the driver is configured with AIRPCAP_DECRYPTION_ON.

BOOL AirpcapSetDeviceChannel ( PAirpcapHandle  AdapterHandle,
UINT  Channel 
)

Sets the radio channel of a device.

Parameters:
AdapterHandle Handle to the adapter.
Channel the new channel to set.
Returns:
TRUE on success.
The list of available channels can be retrieved with AirpcapGetDeviceSupportedChannels(). The default channel setting is 6.

Note:
This is a device-related function: when you change the channel from an open capture instance, the change will be immediately reflected on all the other capture instances.

BOOL AirpcapGetDeviceChannel ( PAirpcapHandle  AdapterHandle,
PUINT  PChannel 
)

Gets the radio channel of a device.

Parameters:
AdapterHandle Handle to the adapter.
PChannel Pointer to a user-supplied variable into which the function will copy the currently configured radio channel.
Returns:
TRUE on success.
The list of available channels can be retrieved with AirpcapGetDeviceSupportedChannels(). The default channel setting is 6.

Note:
This is a device-related function: when you change the channel from an open capture instance, the change will be immediately reflected on all the other capture instances.

BOOL AirpcapSetDeviceChannelEx ( PAirpcapHandle  AdapterHandle,
AirpcapChannelInfo  ChannelInfo 
)

Sets the channel of a device through its radio frequency. In case of 802.11n enabled devices, it sets the extension channel, if used.

Parameters:
AdapterHandle Handle to the adapter.
ChannelInfo The new channel information to set.
Returns:
TRUE on success.
Note:
This is a device-related function: when you change the channel from an open capture instance, the change will be immediately reflected on all the other capture instances.

BOOL AirpcapGetDeviceChannelEx ( PAirpcapHandle  AdapterHandle,
PAirpcapChannelInfo  PChannelInfo 
)

Gets the channel of a device through its radio frequency. In case of 802.11n enabled devices, it gets the extension channel, if in use.

Parameters:
AdapterHandle Handle to the adapter.
PChannelInfo Pointer to a user-supplied variable into which the function will copy the currently configured channel information.
Returns:
TRUE on success.
Note:
This is a device-related function: when you change the channel from an open capture instance, the change will be immediately reflected on all the other capture instances.

BOOL AirpcapGetDeviceSupportedChannels ( PAirpcapHandle  AdapterHandle,
PAirpcapChannelInfo ppChannelInfo,
PUINT  pNumChannelInfo 
)

Gets the list of supported channels for a given device. In case of a 802.11n capable device, information related to supported extension channels is also reported.

Every control channel is listed multiple times, one for each different supported extension channel. For example channel 6 (2437MHz) is usually listed three times:

  • Frequency 2437 Extension +1. Control channel is 6, extension channel is 10.
  • Frequency 2437 Extension 0. Control channel is 6, no extension channel is used (20MHz channel and legacy mode).
  • Frequency 2437 Extension -1. Control channel is 6, extension channel is 2.
    Parameters:
    AdapterHandle Handle to the adapter.
    ppChannelInfo Pointer to a user-supplied variable that will point to an array of supported channel. Such list must not be freed by the caller
    pNumChannelInfo Number of channels returned in the array.
    Returns:
    TRUE on success.
    Note:
    The supported channels are not listed in any specific order.

BOOL AirpcapConvertFrequencyToChannel ( UINT  Frequency,
PUINT  PChannel,
PAirpcapChannelBand  PBand 
)

Converts a given frequency to the corresponding channel.

Parameters:
Frequency Frequency of the channel, in MHz.
PChannel Pointer to a user-supplied variable that will contain the channel number on success.
PBand Pointer to a user-supplied variable that will contain the band (a or b/g) of the given channel.
Returns:
TRUE on success, i.e. the frequency corresponds to a valid a or b/g channel.

BOOL AirpcapConvertChannelToFrequency ( UINT  Channel,
PUINT  PFrequency 
)

Converts a given channel to the corresponding frequency.

Parameters:
Channel Channel number to be converted.
PFrequency Pointer to a user-supplied variable that will contain the channel frequency in MHz on success.
Returns:
TRUE on success, i.e. the given channel number exists.
Because of the overlap of channels with respect to 1-14BG and 1-14A, this function will give precidence to BG. Thus, the channels are returned as follows:
  • Channel 0: 5000MHz
  • Channels 1-14: 2412MHz - 2484MHz
  • Channels 15-239: 5005MHz - 6195MHz
  • Channels 240-255: 4920MHz - 4995MHz

BOOL AirpcapSetKernelBuffer ( PAirpcapHandle  AdapterHandle,
UINT  BufferSize 
)

Sets the size of the kernel packet buffer for this adapter.

Parameters:
AdapterHandle Handle to the adapter.
BufferSize New size, in bytes.
Returns:
TRUE on success.
Every AirPcap open instance has an associated kernel buffer, whose default size is 1 Mbyte. This function can be used to change the size of this buffer, and can be called at any time. A bigger kernel buffer size decreases the risk of dropping packets during network bursts or when the application is busy, at the cost of higher kernel memory usage.

Note:
Don't use this function unless you know what you are doing. Due to caching issues and bigger non-paged memory consumption, bigger buffer sizes can decrease the capture performace instead of improving it.

BOOL AirpcapGetKernelBufferSize ( PAirpcapHandle  AdapterHandle,
PUINT  PSizeBytes 
)

Gets the size of the kernel packet buffer for this adapter.

Parameters:
AdapterHandle Handle to the adapter.
PSizeBytes User-allocated variable that will be filled with the size of the kernel buffer.
Returns:
TRUE on success.
Every AirPcap open instance has an associated kernel buffer, whose default size is 1 Mbyte. This function can be used to get the size of this buffer.

BOOL AirpcapSetTxPower ( PAirpcapHandle  AdapterHandle,
UINT  Power 
)

Sets the power of the frames are transmitted by adapter.

Parameters:
AdapterHandle Handle to the adapter.
Power The transmit power. Setting a zero power makes the adapter select the highest possible power for the current channel.
Returns:
TRUE on success. False on failure or if the adapter doesn't support setting the transmit power.
The transmit power value is monotonically increasing with higher power levels. 1 is the minimum allowed transmit power.

Note:
The maximum transmit power on each channel is limited by FCC regulations. Therefore, the maximum transmit power changes from channel to channel. When the channel is changed with AirpcapSetDeviceChannel() or AirpcapSetDeviceChannelEx() the power is set to the maximum allowd value for that channel. You can read this value with AirpcapGetTxPower(). Not all the AirPcap adapters support setting the transmit power; you can use AirpcapGetDeviceCapabilities() to find if the current adapter supports this feature.

BOOL AirpcapGetTxPower ( PAirpcapHandle  AdapterHandle,
PUINT  PPower 
)

Returns the current transmit power level of the adapter.

Parameters:
AdapterHandle Handle to the adapter.
PPower User-allocated variable that will be filled with the size of the transmit power.
Returns:
TRUE on success. False on failure or if the adapter doesn't support getting the transmit power.
The transmit power value is monotonically increasing with higher power levels. 0 is the minimum allowed power.

Note:
The maximum transmit power on each channel is limited by FCC regulations. Therefore, the maximum transmit power changes from channel to channel. When the channel is changed with AirpcapSetDeviceChannel() or AirpcapSetDeviceChannelEx() the power is set to the maximum allowd value for that channel. Not all the AirPcap adapters support setting the transmit power; you can use AirpcapGetDeviceCapabilities() to find if the current adapter supports this feature.

BOOL AirpcapStoreCurConfigAsAdapterDefault ( PAirpcapHandle  AdapterHandle  ) 

Saves the configuration of the specified adapter in the registry, so that it becomes the default for this adapter.

Parameters:
AdapterHandle Handle to the adapter.
Returns:
TRUE on success. FALSE on failure.
Almost all the AirPcap calls that modify the configuration (AirpcapSetLinkType(), AirpcapSetFcsPresence(), AirpcapSetFcsValidation(), AirpcapSetKernelBuffer(), AirpcapSetMinToCopy()) affect only the referenced AirPcap open instance. This means that if you do another AirpcapOpen() on the same adapter, the configuration changes will not be remembered, and the new adapter handle will have default configuration settings.

Exceptions to this rule are the AirpcapSetDeviceChannel() and AirpcapSetDeviceKeys() functions: a channel change is reflected on all the open instances, and remembered until the next call to AirpcapSetDeviceChannel(), until the adapter is unplugged, or until the machine is powered off. Same thing for the configuration of the WEP keys.

AirpcapStoreCurConfigAsAdapterDefault() stores the configuration of the give open instance as the default for the adapter: all the instances opened in the future will have the same configuration that this adapter currently has. The configuration is stored in the registry, therefore it is remembered even when the adapter is unplugged or the machine is turned off. However, an adapter doesn't bring its configuration with it from machine to machine.

the configuration information saved in the registry includes the following parameters:

  • channel
  • kernel buffer size
  • mintocopy
  • link type
  • CRC presence
  • Encryption keys
  • Encryption Enabled/Disabled state

The configuration is device-specific. This means that changing the configuration of a device doesn't modify the one of the other devices that are currently used or that will be used in the future.

Note:
AirpcapStoreCurConfigAsAdapterDefault() must have exclusive access to the adapter -- it will fail if more than one AirPcap handle is opened at the same time for this device. AirpcapStoreCurConfigAsAdapterDefault() needs administrator privileges. It will fail if the calling user is not a local machine administrator.

BOOL AirpcapSetFilter ( PAirpcapHandle  AdapterHandle,
PVOID  Instructions,
UINT  Len 
)

Sets the BPF kernel filter for an adapter.

Parameters:
AdapterHandle Handle to the adapter.
Instructions pointer to the first BPF instruction in the array. Corresponds to the bf_insns in a bpf_program structure (see the WinPcap documentation at http://www.winpcap.org/devel.htm).
Len Number of instructions in the array pointed by the previous field. Corresponds to the bf_len in a a bpf_program structure (see the WinPcap documentation at http://www.winpcap.org/devel.htm).
Returns:
TRUE on success.
The AirPcap driver is able to perform kernel-level filtering using the standard BPF pseudo-machine format. You can read the WinPcap documentation at http://www.winpcap.org/devel.htm for more details on the BPF filtering mechaism.

A filter can be automatically created by using the pcap_compile() function of the WinPcap API. This function converts a human readable text expression with the tcpdump/libpcap syntax into a BPF program. If your program doesn't link wpcap, but you need to generate the code for a particular filter, you can run WinDump with the -d or -dd or -ddd flags to obtain the pseudocode.

BOOL AirpcapGetMacAddress ( PAirpcapHandle  AdapterHandle,
PAirpcapMacAddress  PMacAddress 
)

Returns the MAC address of a device.

Parameters:
AdapterHandle Handle to the adapter.
PMacAddress Pointer to a user allocated AirpcapMacAddress structure that will receive the MAC address on success.
Returns:
TRUE on success.

BOOL AirpcapSetMacAddress ( PAirpcapHandle  AdapterHandle,
PAirpcapMacAddress  PMacAddress 
)

Sets the MAC address of a device.

Parameters:
AdapterHandle Handle to the adapter.
PMacAddress Pointer to a user-initialized structure containing the MAC address.
Returns:
TRUE on success. FALSE on failure, or if the adapter doesn't support changing the address.
Using this function, the programmer can change the MAC address of the device. This is useful when disabling monitor mode with AirpcapSetDeviceMacFlags(), because the device will acknowledge the data frames sent to its MAC address.

Note:
The address change is temporary: when the device is unplugged or when the host PC is turned off, the address is reset to the original value.

BOOL AirpcapSetMinToCopy ( PAirpcapHandle  AdapterHandle,
UINT  MinToCopy 
)

Sets the mintocopy parameter for an open adapter.

Parameters:
AdapterHandle Handle to the adapter.
MinToCopy is the mintocopy size in bytes.
Returns:
TRUE on success.
When the number of bytes in the kernel buffer changes from less than mintocopy bytes to greater than or equal to mintocopy bytes, the read event is signalled (see AirpcapGetReadEvent()). A high value for mintocopy results in poor responsiveness since the driver may signal the application "long" after the arrival of the packet. And a high value results in low CPU loading by minimizing the number of user/kernel context switches. A low MinToCopy results in good responsiveness since the driver will signal the application close to the arrival time of the packet. This has higher CPU loading over the first approach.

BOOL AirpcapGetReadEvent ( PAirpcapHandle  AdapterHandle,
HANDLE *  PReadEvent 
)

Gets an event that is signalled when packets are available in the kernel buffer (see AirpcapSetMinToCopy()).

Parameters:
AdapterHandle Handle to the adapter.
PReadEvent Pointer to a user-supplied handle in which the read event will be copied.
Returns:
TRUE on success.
Note:
The event is signalled when at least mintocopy bytes are present in the kernel buffer (see AirpcapSetMinToCopy()). This event can be used by WaitForSingleObject() and WaitForMultipleObjects() to create blocking behavior when reading packets from one or more adapters (see AirpcapRead()).

BOOL AirpcapRead ( PAirpcapHandle  AdapterHandle,
PBYTE  Buffer,
UINT  BufSize,
PUINT  PReceievedBytes 
)

Fills a user-provided buffer with zero or more packets that have been captured on the referenced adapter.

Parameters:
AdapterHandle Handle to the adapter.
Buffer pointer to the buffer that will be filled with captured packets.
BufSize size of the input buffer that will contain the packets, in bytes.
PReceievedBytes Pointer to a user supplied variable that will receive the number of bytes copied by AirpcapRead. Can be smaller than BufSize.
Returns:
TRUE on success.
802.11 frames are returned by the driver in buffers. Every 802.11 frame in the buffer is preceded by a AirpcapBpfHeader structure. The suggested way to use an AirPcap adapter is through the pcap API exported by wpcap.dll. If this is not possible, the Capture_radio and Capture_no_radio examples in the AirPcap developer's pack show how to properly decode the packets in the read buffer returned by AirpcapRead().

Note:
This function is NOT blocking. Blocking behavior can be obtained using the event returned by AirpcapGetReadEvent(). See also AirpcapSetMinToCopy().

BOOL AirpcapWrite ( PAirpcapHandle  AdapterHandle,
PCHAR  TxPacket,
ULONG  PacketLen 
)

Transmits a packet.

Parameters:
AdapterHandle Handle to the adapter.
TxPacket Pointer to a buffer that contains the packet to be transmitted.
PacketLen Length of the buffer pointed by the TxPacket argument, in bytes.
Returns:
TRUE on success.
The packet will be transmitted on the channel the device is currently set. To change the device adapter, use the AirpcapSetDeviceChannel() function.

If the link type of the adapter is AIRPCAP_LT_802_11, the buffer pointed by TxPacket should contain just the 802.11 packet, without additional information. The packet will be transmitted at 1Mbps.

If the link type of the adapter is AIRPCAP_LT_802_11_PLUS_RADIO, the buffer pointed by TxPacket should contain a radiotap header followed by the 802.11 packet. AirpcapWrite will use the rate information in the radiotap header when transmitting the packet.

If the link type of the adapter is AIRPCAP_LT_802_11_PLUS_PPI, the buffer pointed by TxPacket should contain a PPI header followed by the 802.11 packet. AirpcapWrite will use the rate information in the PPI header when transmitting the packet. If the packet should be transmitted at a 802.11n rate, the packet must include a PPI 802.11n MAC+PHY Extension header, containing the rate expressed in terms of MCS, short/long guard interval (SGI/LGI) and 20MHz or 40MHz channel. When the MAC+PHY Extension header is present, the rate field in the PPI 802.11-Common header is ignored. By default on 802.11n-capable AirPcap adapters, packets are transmitted with no A-MPDU aggregation. A-MPDU aggregation is controlled by the adapter, but it's possible to give a hint to the hardware to aggregate some packets by setting the "Aggregate" and "More aggregates" flags in the PPI 802.11n MAC+PHY extension header.

BOOL AirpcapGetStats ( PAirpcapHandle  AdapterHandle,
PAirpcapStats  PStats 
)

Gets per-adapter WinPcap-compatible capture statistics.

Parameters:
AdapterHandle Handle to the adapter.
PStats pointer to a user-allocated AirpcapStats structure that will be filled with statistical information.
Returns:
TRUE on success.

BOOL AirpcapGetLedsNumber ( PAirpcapHandle  AdapterHandle,
PUINT  NumberOfLeds 
)

Gets the number of LEDs the referenced adapter has available.

Parameters:
AdapterHandle Handle to the adapter.
NumberOfLeds Number of LEDs available on this adapter.
Returns:
TRUE on success.

BOOL AirpcapTurnLedOn ( PAirpcapHandle  AdapterHandle,
UINT  LedNumber 
)

Turns on one of the adapter's LEDs.

Parameters:
AdapterHandle Handle to the adapter.
LedNumber zero-based identifier of the LED to turn on.
Returns:
TRUE on success.

BOOL AirpcapTurnLedOff ( PAirpcapHandle  AdapterHandle,
UINT  LedNumber 
)

Turns off one of the adapter's LEDs.

Parameters:
AdapterHandle Handle to the adapter.
LedNumber zero-based identifier of the LED to turn off.
Returns:
TRUE on success.

BOOL AirpcapGetDeviceTimestamp ( PAirpcapHandle  AdapterHandle,
PAirpcapDeviceTimestamp  PTimestamp 
)

Gets the current value of the device counter used to timestamp packets.

Parameters:
AdapterHandle Handle to the adapter.
PTimestamp Pointer to a caller allocated 64bit integer that will receive the device timestamp, in microseconds.
Returns:
TRUE on success.


AirPcap documentation. Copyright (c) 2006-2008 CACE Technologies, Inc. All rights reserved.