Skip to content

Commit

Permalink
From Gisle Vanem: enter the packet-processing loop even if no packets
Browse files Browse the repository at this point in the history
were read, so we check "p->break_loop"; that way, we can break out of
the loop even if we get no packets (because of a timeout).

Also, check "p->break_loop" before reading packets from the driver.
  • Loading branch information
yuguy committed Nov 30, 2003
1 parent 42af591 commit b7a5a71
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pcap-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.17 2003-11-20 02:02:40 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.18 2003-11-30 02:31:04 guy Exp $ (LBL)";
#endif

#include <pcap-int.h>
Expand Down Expand Up @@ -100,6 +100,18 @@ pcap_read_win32(pcap_t *p, int cnt, pcap_handler callback, u_char *user)

cc = p->cc;
if (p->cc == 0) {
/*
* Has "pcap_breakloop()" been called?
*/
if (p->break_loop) {
/*
* Yes - clear the flag that indicates that it
* has, and return -2 to indicate that we were
* told to break out of the loop.
*/
p->break_loop = 0;
return (-2);
}

/* capture the packets */
if(PacketReceivePacket(p->adapter,p->Packet,TRUE)==FALSE){
Expand All @@ -119,7 +131,7 @@ pcap_read_win32(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
*/
#define bhp ((struct bpf_hdr *)bp)
ep = bp + cc;
while (bp < ep) {
while (1) {
register int caplen, hdrlen;

/*
Expand All @@ -141,6 +153,8 @@ pcap_read_win32(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
return (n);
}
}
if (bp >= ep)
break;

caplen = bhp->bh_caplen;
hdrlen = bhp->bh_hdrlen;
Expand Down

0 comments on commit b7a5a71

Please sign in to comment.