summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2007-02-26 22:24:14 +0000
committerjkim <jkim@FreeBSD.org>2007-02-26 22:24:14 +0000
commit2bd7382fdc16aa04088cebb691546535c56c484b (patch)
tree8efb23bc3668968e694845b80771f494e428f138 /usr.bin/netstat
parentfdcdf27f8008b78cf159fbc5e87092ebded35ab3 (diff)
downloadFreeBSD-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 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/bpf.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/netstat/bpf.c b/usr.bin/netstat/bpf.c
index f5cda6a..90fa623d 100644
--- a/usr.bin/netstat/bpf.c
+++ b/usr.bin/netstat/bpf.c
@@ -34,6 +34,7 @@
#include <net/if.h>
#include <net/if_var.h>
+#include <net/bpf.h>
#include <net/bpfdesc.h>
#include <arpa/inet.h>
@@ -76,7 +77,9 @@ bpf_flags(struct xbpf_d *bd, char *flagbuf)
*flagbuf++ = bd->bd_promisc ? 'p' : '-';
*flagbuf++ = bd->bd_immediate ? 'i' : '-';
*flagbuf++ = bd->bd_hdrcmplt ? '-' : 'f';
- *flagbuf++ = bd->bd_seesent ? 's' : '-';
+ *flagbuf++ = (bd->bd_direction == BPF_D_IN) ? '-' :
+ ((bd->bd_direction == BPF_D_OUT) ? 'o' : 's');
+ *flagbuf++ = bd->bd_feedback ? 'b' : '-';
*flagbuf++ = bd->bd_async ? 'a' : '-';
*flagbuf++ = bd->bd_locked ? 'l' : '-';
*flagbuf++ = '\0';
@@ -107,7 +110,7 @@ bpf_stats(char *ifname)
free(bd);
return;
}
- printf("%5s %6s %6s %9s %9s %9s %5s %5s %s\n",
+ printf("%5s %6s %7s %9s %9s %9s %5s %5s %s\n",
"Pid", "Netif", "Flags", "Recv", "Drop", "Match", "Sblen",
"Hblen", "Command");
for (d = &bd[0]; d < &bd[size / sizeof(*d)]; d++) {
@@ -115,7 +118,7 @@ bpf_stats(char *ifname)
continue;
bpf_flags(d, flagbuf);
pname = bpf_pidname(d->bd_pid);
- printf("%5d %6s %6s %9lu %9lu %9lu %5d %5d %s\n",
+ printf("%5d %6s %7s %9lu %9lu %9lu %5d %5d %s\n",
d->bd_pid, d->bd_ifname, flagbuf,
d->bd_rcount, d->bd_dcount, d->bd_fcount,
d->bd_slen, d->bd_hlen, pname);
OpenPOWER on IntegriCloud