bpf.c (7b95a1ebbd9aafe9f196a75d95c7b06eaee999a1) bpf.c (04f7f23bf80d5f3675e1efd0893730d7b16ba725)
1/*-
2 * Copyright (c) 2005 Christian S.J. Peron
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 69 unchanged lines hidden (view full) ---

78 *flagbuf++ = bd->bd_hdrcmplt ? '-' : 'f';
79 *flagbuf++ = bd->bd_seesent ? 's' : '-';
80 *flagbuf++ = bd->bd_async ? 'a' : '-';
81 *flagbuf++ = bd->bd_locked ? 'l' : '-';
82 *flagbuf++ = '\0';
83}
84
85void
1/*-
2 * Copyright (c) 2005 Christian S.J. Peron
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 69 unchanged lines hidden (view full) ---

78 *flagbuf++ = bd->bd_hdrcmplt ? '-' : 'f';
79 *flagbuf++ = bd->bd_seesent ? 's' : '-';
80 *flagbuf++ = bd->bd_async ? 'a' : '-';
81 *flagbuf++ = bd->bd_locked ? 'l' : '-';
82 *flagbuf++ = '\0';
83}
84
85void
86bpf_stats(char *interface)
86bpf_stats(char *ifname)
87{
88 struct xbpf_d *d, *bd;
89 char *pname, flagbuf[12];
90 size_t size;
91
92 if (sysctlbyname("net.bpf.stats", NULL, &size,
93 NULL, 0) < 0) {
94 warn("net.bpf.stats");

--- 11 unchanged lines hidden (view full) ---

106 warn("net.bpf.stats");
107 free(bd);
108 return;
109 }
110 printf("%5s %6s %6s %9s %9s %9s %5s %5s %s\n",
111 "Pid", "Netif", "Flags", "Recv", "Drop", "Match", "Sblen",
112 "Hblen", "Command");
113 for (d = &bd[0]; d < &bd[size / sizeof(*d)]; d++) {
87{
88 struct xbpf_d *d, *bd;
89 char *pname, flagbuf[12];
90 size_t size;
91
92 if (sysctlbyname("net.bpf.stats", NULL, &size,
93 NULL, 0) < 0) {
94 warn("net.bpf.stats");

--- 11 unchanged lines hidden (view full) ---

106 warn("net.bpf.stats");
107 free(bd);
108 return;
109 }
110 printf("%5s %6s %6s %9s %9s %9s %5s %5s %s\n",
111 "Pid", "Netif", "Flags", "Recv", "Drop", "Match", "Sblen",
112 "Hblen", "Command");
113 for (d = &bd[0]; d < &bd[size / sizeof(*d)]; d++) {
114 if (interface && strcmp(interface, d->bd_ifname) != 0)
114 if (ifname && strcmp(ifname, d->bd_ifname) != 0)
115 continue;
116 bpf_flags(d, flagbuf);
117 pname = bpf_pidname(d->bd_pid);
118 printf("%5d %6s %6s %9lu %9lu %9lu %5d %5d %s\n",
119 d->bd_pid, d->bd_ifname, flagbuf,
120 d->bd_rcount, d->bd_dcount, d->bd_fcount,
121 d->bd_slen, d->bd_hlen, pname);
122 free(pname);
123 }
124 free(bd);
125}
115 continue;
116 bpf_flags(d, flagbuf);
117 pname = bpf_pidname(d->bd_pid);
118 printf("%5d %6s %6s %9lu %9lu %9lu %5d %5d %s\n",
119 d->bd_pid, d->bd_ifname, flagbuf,
120 d->bd_rcount, d->bd_dcount, d->bd_fcount,
121 d->bd_slen, d->bd_hlen, pname);
122 free(pname);
123 }
124 free(bd);
125}