#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);
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;
}
-/*
- * 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()/
return (n);
}
-static int
-snf_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);
-}
-
static int
snf_inject(pcap_t *p, const void *buf _U_, int size _U_)
{
p->linktype = DLT_EN10MB;
p->read_op = snf_read;
p->inject_op = snf_inject;
- p->setfilter_op = snf_setfilter;
+ p->setfilter_op = install_bpf_program;
p->setdirection_op = NULL; /* Not implemented.*/
p->set_datalink_op = snf_set_datalink;
p->getnonblock_op = snf_getnonblock;
static int TcInject(pcap_t *p, const void *buf, int size);
static int TcRead(pcap_t *p, int cnt, pcap_handler callback, u_char *user);
static int TcStats(pcap_t *p, struct pcap_stat *ps);
-static int TcSetFilter(pcap_t *p, struct bpf_program *fp);
#ifdef _WIN32
static struct pcap_stat *TcStatsEx(pcap_t *p, int *pcap_stat_size);
static int TcSetBuff(pcap_t *p, int dim);
}
p->read_op = TcRead;
- p->setfilter_op = TcSetFilter;
+ p->setfilter_op = install_bpf_program;
p->setdirection_op = NULL; /* Not implemented. */
p->set_datalink_op = TcSetDatalink;
p->getnonblock_op = TcGetNonBlock;
}
-/*
- * We filter at user level, since the kernel driver does't process the packets
- */
-static int
-TcSetFilter(pcap_t *p, struct bpf_program *fp)
-{
- if(!fp)
- {
- strncpy(p->errbuf, "setfilter: No filter specified", sizeof(p->errbuf));
- return -1;
- }
-
- /* Install a user level filter */
- if (install_bpf_program(p, fp) < 0)
- {
- return -1;
- }
-
- return 0;
-}
-
#ifdef _WIN32
static struct pcap_stat *
TcStatsEx(pcap_t *p, int *pcap_stat_size)