diff options
Diffstat (limited to 'pcap-bpf.c')
| -rw-r--r-- | pcap-bpf.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/pcap-bpf.c b/pcap-bpf.c index b9e84e65f634..49bb273d0a4d 100644 --- a/pcap-bpf.c +++ b/pcap-bpf.c @@ -73,16 +73,6 @@ static const char usbus_prefix[] = "usbus"; #include <net/bpf.h> #define _AIX -/* - * If both BIOCROTZBUF and BPF_BUFMODE_ZBUF are defined, we have - * zero-copy BPF. - */ -#if defined(BIOCROTZBUF) && defined(BPF_BUFMODE_ZBUF) - #define HAVE_ZEROCOPY_BPF - #include <sys/mman.h> - #include <machine/atomic.h> -#endif - #include <net/if_types.h> /* for IFT_ values */ #include <sys/sysconfig.h> #include <sys/device.h> @@ -126,6 +116,16 @@ static int bpf_load(char *errbuf); # include <net/if_media.h> #endif +/* + * If both BIOCROTZBUF and BPF_BUFMODE_ZBUF are defined, we have + * zero-copy BPF. + */ +#if defined(BIOCROTZBUF) && defined(BPF_BUFMODE_ZBUF) + #define HAVE_ZEROCOPY_BPF + #include <sys/mman.h> + #include <machine/atomic.h> +#endif + #include "pcap-int.h" #ifdef HAVE_OS_PROTO_H @@ -290,7 +290,7 @@ pcap_setnonblock_bpf(pcap_t *p, int nonblock) * buffer filled for a fresh BPF session. */ static int -pcap_next_zbuf_shm(pcap_t *p, int *cc) +pcap_next_zbuf_shm(pcap_t *p, ssize_t *cc) { struct pcap_bpf *pb = p->priv; struct bpf_zbuf_header *bzh; @@ -328,7 +328,7 @@ pcap_next_zbuf_shm(pcap_t *p, int *cc) * work. */ static int -pcap_next_zbuf(pcap_t *p, int *cc) +pcap_next_zbuf(pcap_t *p, ssize_t *cc) { struct pcap_bpf *pb = p->priv; struct bpf_zbuf bz; @@ -336,7 +336,7 @@ pcap_next_zbuf(pcap_t *p, int *cc) struct timespec cur; fd_set r_set; int data, r; - int expire, tmout; + long expire, tmout; #define TSTOMILLI(ts) (((ts)->tv_sec * 1000) + ((ts)->tv_nsec / 1000000)) /* @@ -2182,7 +2182,7 @@ pcap_activate_bpf(pcap_t *p) status = PCAP_ERROR; goto bad; } - status = bpf_bind(fd, p->opt.device, ifnamsiz, p->errbuf); + status = bpf_bind(fd, p->opt.device, p->errbuf); if (status != BPF_BIND_SUCCEEDED) { if (status == BPF_BIND_BUFFER_TOO_BIG) { /* @@ -3682,11 +3682,19 @@ pcap_set_datalink_bpf(pcap_t *p _U_, int dlt _U_) /* * Platform-specific information. */ +#if defined(HAVE_ZEROCOPY_BPF) && defined(PCAP_SUPPORT_NETMAP) + #define ADDITIONAL_INFO_STRING "with zerocopy and netmap support" +#elif defined(HAVE_ZEROCOPY_BPF) + #define ADDITIONAL_INFO_STRING "with zerocopy support" +#elif defined(PCAP_SUPPORT_NETMAP) + #define ADDITIONAL_INFO_STRING "with netmap support" +#endif + const char * pcap_lib_version(void) { -#ifdef HAVE_ZEROCOPY_BPF - return (PCAP_VERSION_STRING " (with zerocopy support)"); +#ifdef ADDITIONAL_INFO_STRING + return (PCAP_VERSION_STRING_WITH_ADDITIONAL_INFO(ADDITIONAL_INFO_STRING)); #else return (PCAP_VERSION_STRING); #endif |
