diff options
Diffstat (limited to 'pcap-septel.c')
| -rw-r--r-- | pcap-septel.c | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/pcap-septel.c b/pcap-septel.c index 24cb47bb3962..6d1d904742cc 100644 --- a/pcap-septel.c +++ b/pcap-septel.c @@ -17,7 +17,6 @@ #include "pcap-int.h" -#include <ctype.h> #include <netinet/in.h> #include <sys/mman.h> #include <sys/socket.h> @@ -32,7 +31,6 @@ #include "pcap-septel.h" -static int septel_setfilter(pcap_t *p, struct bpf_program *fp); static int septel_stats(pcap_t *p, struct pcap_stat *ps); static int septel_getnonblock(pcap_t *p); static int septel_setnonblock(pcap_t *p, int nonblock); @@ -47,7 +45,7 @@ struct pcap_septel { /* * Read at most max_packets from the capture queue and call the callback * for each of them. Returns the number of packets handled, -1 if an - * error occured, or -2 if we were told to break out of the loop. + * error occurred, or -2 if we were told to break out of the loop. */ static int septel_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) { @@ -95,7 +93,7 @@ loop: h = GCT_grab(id); m = (MSG*)h; - /* a couter is added here to avoid an infinite loop + /* a counter is added here to avoid an infinite loop * that will cause our capture program GUI to freeze while waiting * for a packet*/ counter++ ; @@ -107,7 +105,7 @@ loop: t = h->type ; - /* catch only messages with type = 0xcf00 or 0x8f01 corrsponding to ss7 messages*/ + /* catch only messages with type = 0xcf00 or 0x8f01 corresponding to ss7 messages*/ /* XXX = why not use API_MSG_TX_REQ for 0xcf00 and API_MSG_RX_IND * for 0x8f01? */ if ((t != 0xcf00) && (t != 0x8f01)) { @@ -126,7 +124,7 @@ loop: caplen = packet_len; } /* Run the packet filter if there is one. */ - if ((p->fcode.bf_insns == NULL) || bpf_filter(p->fcode.bf_insns, dp, packet_len, caplen)) { + if ((p->fcode.bf_insns == NULL) || pcap_filter(p->fcode.bf_insns, dp, packet_len, caplen)) { /* get a time stamp , consisting of : @@ -171,7 +169,7 @@ loop: static int -septel_inject(pcap_t *handle, const void *buf _U_, size_t size _U_) +septel_inject(pcap_t *handle, const void *buf _U_, int size _U_) { pcap_strlcpy(handle->errbuf, "Sending packets isn't supported on Septel cards", PCAP_ERRBUF_SIZE); @@ -209,7 +207,7 @@ static pcap_t *septel_activate(pcap_t* handle) { handle->read_op = septel_read; handle->inject_op = septel_inject; - handle->setfilter_op = septel_setfilter; + handle->setfilter_op = install_bpf_program; handle->set_datalink_op = NULL; /* can't change data link type */ handle->getnonblock_op = septel_getnonblock; handle->setnonblock_op = septel_setnonblock; @@ -235,7 +233,7 @@ pcap_t *septel_create(const char *device, char *ebuf, int *is_ours) { /* OK, it's probably ours. */ *is_ours = 1; - p = pcap_create_common(ebuf, sizeof (struct pcap_septel)); + p = PCAP_CREATE_COMMON(ebuf, struct pcap_septel); if (p == NULL) return NULL; @@ -276,28 +274,6 @@ septel_findalldevs(pcap_if_list_t *devlistp, char *errbuf) /* - * Installs the given bpf filter program in the given pcap structure. There is - * no attempt to store the filter in kernel memory as that is not supported - * with Septel cards. - */ -static int septel_setfilter(pcap_t *p, struct bpf_program *fp) { - if (!p) - return -1; - if (!fp) { - strncpy(p->errbuf, "setfilter: No filter specified", - sizeof(p->errbuf)); - return -1; - } - - /* Make our private copy of the filter */ - - if (install_bpf_program(p, fp) < 0) - return -1; - - return (0); -} - -/* * We don't support non-blocking mode. I'm not sure what we'd * do to support it and, given that we don't support select()/ * poll()/epoll_wait()/kevent() etc., it probably doesn't @@ -338,7 +314,7 @@ pcap_platform_finddevs(pcap_if_list_t *devlistp, char *errbuf) pcap_t * pcap_create_interface(const char *device, char *errbuf) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, + snprintf(errbuf, PCAP_ERRBUF_SIZE, "This version of libpcap only supports Septel cards"); return (NULL); } |
