dect
/
libpcap
Archived
13
0
Fork 0

Fixed a bug in pcap_open_live(). The return value of PacketSetHwFilter was

not checked. This was the culprit of WinPcap failing to capture on wireless
adapters when in promiscuous mode. Most of the wireless adapters drivers
do not support the promiscuous hardware, and fail the HW filter OID request.
This failure was not detected by pcap_open_live(), and resulted in no packets
being captured as no hw filter was actually set at the driver level (no hw filter
means "reject all").
This commit is contained in:
gianluca 2007-02-19 18:33:37 +00:00
parent 27d074264e
commit 9e9f5dde21
1 changed files with 20 additions and 5 deletions

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)
* Copyright (c) 2005 - 2006 CACE Technologies, Davis (California)
* Copyright (c) 2005 - 2007 CACE Technologies, Davis (California)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.25.2.5 2006-08-09 19:18:41 gianluca Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.25.2.6 2007-02-19 18:33:37 gianluca Exp $ (LBL)";
#endif
#include <pcap-int.h>
@ -500,9 +500,24 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
break;
}
/* Set promisquous mode */
if (promisc) PacketSetHwFilter(p->adapter,NDIS_PACKET_TYPE_PROMISCUOUS);
else PacketSetHwFilter(p->adapter,NDIS_PACKET_TYPE_ALL_LOCAL);
/* Set promiscuous mode */
if (promisc)
{
if (PacketSetHwFilter(p->adapter,NDIS_PACKET_TYPE_PROMISCUOUS) == FALSE)
{
snprintf(ebuf, PCAP_ERRBUF_SIZE, "failed to set hardware filter to promiscuous mode");
goto bad;
}
}
else
{
if (PacketSetHwFilter(p->adapter,NDIS_PACKET_TYPE_ALL_LOCAL) == FALSE)
{
snprintf(ebuf, PCAP_ERRBUF_SIZE, "failed to set hardware filter to non-promiscuous mode");
goto bad;
}
}
/* Set the buffer size */
p->bufsize = PcapBufSize;