=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/netstat/inet6.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- src/usr.bin/netstat/inet6.c 2009/07/17 14:21:37 1.39 +++ src/usr.bin/netstat/inet6.c 2009/11/05 20:50:14 1.40 @@ -1,4 +1,4 @@ -/* $OpenBSD: inet6.c,v 1.39 2009/07/17 14:21:37 tedu Exp $ */ +/* $OpenBSD: inet6.c,v 1.40 2009/11/05 20:50:14 michele Exp $ */ /* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */ /* * Copyright (c) 1983, 1988, 1993 @@ -51,6 +51,7 @@ #include #include #include +#include #include #if 0 @@ -1028,6 +1029,37 @@ printf("\t%llu delivered\n", (unsigned long long)delivered); p(rip6s_opackets, "\t%llu datagram%s output\n"); #undef p +} + +/* + * Dump divert6 statistics structure. + */ +void +div6_stats(char *name) +{ + struct div6stat div6stat; + int mib[] = { CTL_NET, AF_INET6, IPPROTO_DIVERT, DIVERT6CTL_STATS }; + size_t len = sizeof(div6stat); + + if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), + &div6stat, &len, NULL, 0) == -1) { + if (errno != ENOPROTOOPT) + warn(name); + return; + } + + printf("%s:\n", name); +#define p(f, m) if (div6stat.f || sflag <= 1) \ + printf(m, div6stat.f, plural(div6stat.f)) +#define p1(f, m) if (div6stat.f || sflag <= 1) \ + printf(m, div6stat.f) + p(divs_ipackets, "\t%lu total packet%s received\n"); + p1(divs_noport, "\t%lu dropped due to no socket\n"); + p1(divs_fullsock, "\t%lu dropped due to full socket buffers\n"); + p(divs_opackets, "\t%lu packet%s output\n"); + p1(divs_errors, "\t%lu errors\n"); +#undef p +#undef p1 } /*