=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/netstat/inet.c,v retrieving revision 1.106 retrieving revision 1.107 diff -c -r1.106 -r1.107 *** src/usr.bin/netstat/inet.c 2008/05/08 03:13:55 1.106 --- src/usr.bin/netstat/inet.c 2008/09/16 15:48:12 1.107 *************** *** 1,4 **** ! /* $OpenBSD: inet.c,v 1.106 2008/05/08 03:13:55 mpf Exp $ */ /* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: inet.c,v 1.107 2008/09/16 15:48:12 gollo Exp $ */ /* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */ /* *************** *** 68,73 **** --- 68,74 ---- #include #include #include + #include #include #include *************** *** 1033,1038 **** --- 1034,1070 ---- p(pfsyncs_opackets6, "\t%llu packet%s sent (IPv6)\n"); p2(pfsyncs_onomem, "\t\t%llu send failed due to mbuf memory error\n"); p2(pfsyncs_oerrors, "\t\t%llu send error\n"); + #undef p + #undef p2 + } + + /* + * Dump pflow statistics structure. + */ + void + pflow_stats(char *name) + { + struct pflowstats flowstats; + int mib[] = { CTL_NET, PF_PFLOW, NET_PFLOW_STATS }; + size_t len = sizeof(struct pflowstats); + + if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), &flowstats, &len, + NULL, 0) == -1) { + if (errno != ENOPROTOOPT) + warn(name); + return; + } + + printf("%s:\n", name); + #define p(f, m) if (flowstats.f || sflag <= 1) \ + printf(m, flowstats.f, plural(flowstats.f)) + #define p2(f, m) if (flowstats.f || sflag <= 1) \ + printf(m, flowstats.f) + + p(pflow_flows, "\t%llu flow%s sent\n"); + p(pflow_packets, "\t%llu packet%s sent\n"); + p2(pflow_onomem, "\t\t%llu send failed due to mbuf memory error\n"); + p2(pflow_oerrors, "\t\t%llu send error\n"); #undef p #undef p2 }