Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.1
nmap
nmap-4.00-libpcap-filter.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File nmap-4.00-libpcap-filter.diff of Package nmap
--- libpcap/pcap-bpf.c +++ libpcap/pcap-bpf.c @@ -558,7 +558,7 @@ 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 --- libpcap/pcap-linux.c +++ libpcap/pcap-linux.c @@ -100,6 +100,7 @@ #include <netinet/in.h> #include <linux/if_ether.h> #include <net/if_arp.h> +#include <sys/poll.h> /* * If PF_PACKET is defined, we can use {SOCK_RAW,SOCK_DGRAM}/PF_PACKET @@ -966,8 +967,30 @@ 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); /* Installation succeded - using kernel filter. */ handle->md.use_bpf = 1; + + 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); + + /* now read all packets received until now */ + 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 */ {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor