Skip to content

Commit

Permalink
Added PacketIsMonitorModeSupported() function to Packet.dll and made …
Browse files Browse the repository at this point in the history
…wpcap.dll call it.
  • Loading branch information
hsluoyz committed May 17, 2016
1 parent f5a3917 commit fd683e0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions Common/Packet32.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ extern "C"
BOOLEAN PacketSetBuff(LPADAPTER AdapterObject, int dim);
BOOLEAN PacketGetNetType(LPADAPTER AdapterObject, NetType* type);
BOOLEAN PacketIsLoopbackAdapter(LPADAPTER AdapterObject);
BOOLEAN PacketIsMonitorModeSupported(LPADAPTER AdapterObject);
LPADAPTER PacketOpenAdapter(PCHAR AdapterName);
BOOLEAN PacketSendPacket(LPADAPTER AdapterObject, LPPACKET pPacket, BOOLEAN Sync);
INT PacketSendPackets(LPADAPTER AdapterObject, PVOID PacketBuff, ULONG Size, BOOLEAN Sync);
Expand Down
1 change: 1 addition & 0 deletions packetWin7/Dll/Packet.def
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ EXPORTS
PacketGetStatsEx
PacketGetNetType
PacketIsLoopbackAdapter
PacketIsMonitorModeSupported
PacketSetReadTimeout
PacketSetMode
PacketSetNumWrites
Expand Down
43 changes: 43 additions & 0 deletions packetWin7/Dll/Packet32.c
Original file line number Diff line number Diff line change
Expand Up @@ -4652,6 +4652,49 @@ BOOLEAN PacketIsLoopbackAdapter(LPADAPTER AdapterObject)
return ret;
}

/*!
\brief Returns whether a wireless adapter supports monitor mode.
\param AdapterObject The adapter on which information is needed.
\return TRUE if yes, FALSE if no.
*/
BOOLEAN PacketIsMonitorModeSupported(LPADAPTER AdapterObject)
{
BOOLEAN Status;
ULONG IoCtlBufferLength = (sizeof(PACKET_OID_DATA) + sizeof(DOT11_OPERATION_MODE_CAPABILITY) - 1);
PPACKET_OID_DATA OidData;
DOT11_OPERATION_MODE_CAPABILITY ModeCapability;

TRACE_ENTER("PacketIsMonitorModeSupported");

OidData = GlobalAllocPtr(GMEM_MOVEABLE | GMEM_ZEROINIT, IoCtlBufferLength);
if (OidData == NULL) {
TRACE_PRINT("PacketIsMonitorModeSupported failed");
TRACE_EXIT("PacketIsMonitorModeSupported");
return FALSE;
}
//get the mode capability
OidData->Oid = OID_DOT11_OPERATION_MODE_CAPABILITY;
OidData->Length = sizeof(DOT11_OPERATION_MODE_CAPABILITY);
Status = PacketRequest(AdapterObject, FALSE, OidData);
if (Status == TRUE)
{
ModeCapability = *((DOT11_OPERATION_MODE_CAPABILITY*)OidData->Data);
if ((ModeCapability.uOpModeCapability & DOT11_OPERATION_MODE_NETWORK_MONITOR) == DOT11_OPERATION_MODE_NETWORK_MONITOR)
{
Status = TRUE;
}
else
{
Status = FALSE;
}
}

GlobalFreePtr(OidData);

TRACE_EXIT("PacketIsMonitorModeSupported");
return Status;
}

/*!
\brief Returns the AirPcap handler associated with an adapter. This handler can be used to change
the wireless-related settings of the CACE Technologies AirPcap wireless capture adapters.
Expand Down
4 changes: 2 additions & 2 deletions wpcap/libpcap/pcap-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,9 +825,9 @@ pcap_activate_win32(pcap_t *p)
* Check if rfmon mode is supported on the pcap_t for Windows systems.
*/
static int
pcap_can_set_rfmon_win32(pcap_t *p _U_)
pcap_can_set_rfmon_win32(pcap_t *p)
{
return (0);
return PacketIsMonitorModeSupported(p->adapter);
}

pcap_t *
Expand Down

0 comments on commit fd683e0

Please sign in to comment.