2013-12-16 16:55:33 +00:00
|
|
|
---
|
|
|
|
pcap-bpf.c | 2 +-
|
|
|
|
pcap-linux.c | 22 ++++++++++++++++++++++
|
|
|
|
2 files changed, 23 insertions(+), 1 deletion(-)
|
|
|
|
|
2014-02-15 10:08:40 +00:00
|
|
|
Index: libpcap-1.5.3/pcap-bpf.c
|
2012-01-03 14:53:29 +00:00
|
|
|
===================================================================
|
2014-02-15 10:08:40 +00:00
|
|
|
--- libpcap-1.5.3.orig/pcap-bpf.c 2014-02-13 17:22:30.794295046 +0100
|
|
|
|
+++ libpcap-1.5.3/pcap-bpf.c 2014-02-13 17:22:31.667305231 +0100
|
2013-12-16 16:55:33 +00:00
|
|
|
@@ -494,7 +494,7 @@ bpf_open(pcap_t *p)
|
2007-01-04 16:25:26 +00:00
|
|
|
fd = open(device, O_RDWR);
|
|
|
|
if (fd == -1 && errno == EACCES)
|
|
|
|
fd = open(device, O_RDONLY);
|
|
|
|
- } while (fd < 0 && errno == EBUSY);
|
|
|
|
+ } while (fd < 0 && errno == EBUSY && n < 1000);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX better message for all minors used
|
2014-02-15 10:08:40 +00:00
|
|
|
Index: libpcap-1.5.3/pcap-linux.c
|
2012-01-03 14:53:29 +00:00
|
|
|
===================================================================
|
2014-02-15 10:08:40 +00:00
|
|
|
--- libpcap-1.5.3.orig/pcap-linux.c 2014-02-13 17:22:31.668305243 +0100
|
|
|
|
+++ libpcap-1.5.3/pcap-linux.c 2014-02-13 17:24:01.924357989 +0100
|
|
|
|
@@ -2476,11 +2476,33 @@ pcap_setfilter_linux_common(pcap_t *hand
|
2007-01-04 16:25:26 +00:00
|
|
|
if (can_filter_in_kernel) {
|
|
|
|
if ((err = set_kernel_filter(handle, &fcode)) == 0)
|
|
|
|
{
|
|
|
|
+ char buf[1024];
|
|
|
|
+ int oldflags;
|
|
|
|
+ int ret;
|
|
|
|
+ unsigned int received = 0, rec_len = 0;
|
|
|
|
+ socklen_t optlen = sizeof(rec_len);
|
2014-02-15 10:08:40 +00:00
|
|
|
/*
|
|
|
|
* Installation succeded - using kernel filter,
|
|
|
|
* so userland filtering not needed.
|
|
|
|
*/
|
|
|
|
handlep->filter_in_userland = 0;
|
2007-01-04 16:25:26 +00:00
|
|
|
+
|
|
|
|
+ oldflags = fcntl(handle->fd, F_GETFL, 0);
|
|
|
|
+ oldflags |= O_NONBLOCK;
|
|
|
|
+ fcntl(handle->fd, F_SETFL, oldflags);
|
|
|
|
+ getsockopt(handle->fd, SOL_SOCKET, SO_RCVBUF,
|
|
|
|
+ (char *)&rec_len, &optlen);
|
|
|
|
+
|
2014-02-15 10:08:40 +00:00
|
|
|
+ /* now read all packets received until now */
|
2007-01-04 16:25:26 +00:00
|
|
|
+ while((ret = read(handle->fd, buf, 1024)) > 0
|
|
|
|
+ && received < rec_len) {
|
|
|
|
+ received += ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(oldflags > 0) {
|
|
|
|
+ oldflags &= ~O_NONBLOCK;
|
|
|
|
+ fcntl(handle->fd, F_SETFL, oldflags);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
else if (err == -1) /* Non-fatal error */
|
|
|
|
{
|