Ethereal-dev: [ethereal-dev] Libpcap timeout patch

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Gerald Combs - Unicom Communications <gerald@xxxxxxxxxx>
Date: Fri, 4 Dec 1998 17:16:58 -0600 (CST)
  Attached is a patch for libpcap 0.4a6, written by Brian Costello, that
fixes the timeout problem with pcap-linux.c.  I wasn't able to find it on
my machine at home, but Brian was kind enough to send me another copy.
It's also available at http://ethereal.zing.org/devteam/gerald/ .

--
Gerald Combs              gerald@xxxxxxxxxx               (913) 327-5309
Mouse cleaning czar                              Rocky Mountain Internet

*** libpcap-0.4a6/pcap-linux.c	Thu Oct  2 22:39:53 1997
--- pcap-linux.c	Sun May 17 14:44:16 1998
***************
*** 29,30 ****
--- 29,31 ----
  #include <sys/time.h>
+ #include <fcntl.h>
  
***************
*** 48,49 ****
--- 49,52 ----
  static struct ifreq saved_ifr;
+ static int pcap_timeout_ms=0;
+ static int pcap_timeout_s=0;
  
***************
*** 86,87 ****
--- 89,102 ----
  	do {
+ 		fd_set set1;
+ 		struct timeval timeout;
+ 		
+ 		FD_ZERO(&set1);
+ 		FD_SET(p->fd, &set1);
+ 		
+ 		timeout.tv_usec = pcap_timeout_ms;
+ 		timeout.tv_sec = pcap_timeout_s;
+ 		
+ 		if (select(p->fd+1, &set1, NULL, NULL, &timeout) == 0)
+ 		   return(0);
+ 		
  		fromlen = sizeof(from);
***************
*** 267,268 ****
--- 282,284 ----
  	/* Leave room for link header (which is never large under linux...) */
+ 	
  	p->bufsize = ifr.ifr_mtu + 64;
***************
*** 275,276 ****
--- 291,294 ----
+ 	pcap_timeout_ms = (to_ms * 1000) % 1000000;
+ 	pcap_timeout_s = to_ms / 1000;
  	/* XXX */