diff options
author | jkim <jkim@FreeBSD.org> | 2007-02-26 22:24:14 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2007-02-26 22:24:14 +0000 |
commit | 2bd7382fdc16aa04088cebb691546535c56c484b (patch) | |
tree | 8efb23bc3668968e694845b80771f494e428f138 /contrib/libpcap | |
parent | fdcdf27f8008b78cf159fbc5e87092ebded35ab3 (diff) | |
download | FreeBSD-src-2bd7382fdc16aa04088cebb691546535c56c484b.zip FreeBSD-src-2bd7382fdc16aa04088cebb691546535c56c484b.tar.gz |
Add three new ioctl(2) commands for bpf(4).
- BIOCGDIRECTION and BIOCSDIRECTION get or set the setting determining
whether incoming, outgoing, or all packets on the interface should be
returned by BPF. Set to BPF_D_IN to see only incoming packets on the
interface. Set to BPF_D_INOUT to see packets originating locally and
remotely on the interface. Set to BPF_D_OUT to see only outgoing
packets on the interface. This setting is initialized to BPF_D_INOUT
by default. BIOCGSEESENT and BIOCSSEESENT are obsoleted by these but
kept for backward compatibility.
- BIOCFEEDBACK sets packet feedback mode. This allows injected packets
to be fed back as input to the interface when output via the interface is
successful. When BPF_D_INOUT direction is set, injected outgoing packet
is not returned by BPF to avoid duplication. This flag is initialized to
zero by default.
Note that libpcap has been modified to support BPF_D_OUT direction for
pcap_setdirection(3) and PCAP_D_OUT direction is functional now.
Reviewed by: rwatson
Diffstat (limited to 'contrib/libpcap')
-rw-r--r-- | contrib/libpcap/pcap-bpf.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/contrib/libpcap/pcap-bpf.c b/contrib/libpcap/pcap-bpf.c index 863827f..e8492d3 100644 --- a/contrib/libpcap/pcap-bpf.c +++ b/contrib/libpcap/pcap-bpf.c @@ -1093,9 +1093,22 @@ pcap_setfilter_bpf(pcap_t *p, struct bpf_program *fp) static int pcap_setdirection_bpf(pcap_t *p, pcap_direction_t d) { -#ifdef BIOCSSEESENT +#if defined(BIOCSDIRECTION) + u_int direction; + + direction = (d == PCAP_D_IN) ? BPF_D_IN : + ((d == PCAP_D_OUT) ? BPF_D_OUT : BPF_D_INOUT); + if (ioctl(p->fd, BIOCSDIRECTION, &direction) == -1) { + (void) snprintf(p->errbuf, sizeof(p->errbuf), + "Cannot set direction to %s: %s", + (d == PCAP_D_IN) ? "PCAP_D_IN" : + ((d == PCAP_D_OUT) ? "PCAP_D_OUT" : "PCAP_D_INOUT"), + strerror(errno)); + return (-1); + } + return (0); +#elif defined(BIOCSSEESENT) u_int seesent; -#endif /* * We don't support PCAP_D_OUT. @@ -1105,7 +1118,7 @@ pcap_setdirection_bpf(pcap_t *p, pcap_direction_t d) "Setting direction to PCAP_D_OUT is not supported on BPF"); return -1; } -#ifdef BIOCSSEESENT + seesent = (d == PCAP_D_INOUT); if (ioctl(p->fd, BIOCSSEESENT, &seesent) == -1) { (void) snprintf(p->errbuf, sizeof(p->errbuf), |