Date: Tue, 28 Jul 2009 23:59:14 GMT From: Gabor Pali <pgj@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 166708 for review Message-ID: <200907282359.n6SNxEnV056995@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=166708 Change 166708 by pgj@petymeg-current on 2009/07/28 23:58:34 Use libnetstat(3) for DDP statistics in netstat(1). Affected files ... .. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/atalk.c#3 edit .. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#18 edit .. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#26 edit Differences ... ==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/atalk.c#3 (text+ko) ==== @@ -58,6 +58,7 @@ #include <stdint.h> #include <stdio.h> #include <string.h> +#include <netstat.h> #include "extern.h" struct ddpcb ddpcb; @@ -260,30 +261,26 @@ } } -#define ANY(x,y,z) if (x || sflag <= 1) \ - printf("\t%lu %s%s%s\n",x,y,plural(x),z) - /* * Dump DDP statistics structure. */ void -ddp_stats(u_long off __unused, const char *name, int af1 __unused, - int proto __unused) +ddp_stats(const struct stat_type *sttp) { - struct ddpstat ddpstat; + const struct ddp_stat *s; - if (off == 0) - return; - kread(off, (char *)&ddpstat, sizeof (ddpstat)); - printf("%s:\n", name); - ANY(ddpstat.ddps_short, "packet", " with short headers "); - ANY(ddpstat.ddps_long, "packet", " with long headers "); - ANY(ddpstat.ddps_nosum, "packet", " with no checksum "); - ANY(ddpstat.ddps_tooshort, "packet", " too short "); - ANY(ddpstat.ddps_badsum, "packet", " with bad checksum "); - ANY(ddpstat.ddps_toosmall, "packet", " with not enough data "); - ANY(ddpstat.ddps_forward, "packet", " forwarded "); - ANY(ddpstat.ddps_encap, "packet", " encapsulated "); - ANY(ddpstat.ddps_cantforward, "packet", " rcvd for unreachable dest "); - ANY(ddpstat.ddps_nosockspace, "packet", " dropped due to no socket space "); + s = netstat_get_ddpstats(sttp); +#define ANY(x,y,z) if (netstat_ddps_get_##x(s) || sflag <= 1) \ + printf("\t%ju %s%s%s\n",netstat_ddps_get_##x(s),y,\ + plural(netstat_ddps_get_##x(s)),z) + ANY(short, "packet", " with short headers "); + ANY(long, "packet", " with long headers "); + ANY(nosum, "packet", " with no checksum "); + ANY(tooshort, "packet", " too short "); + ANY(badsum, "packet", " with bad checksum "); + ANY(toosmall, "packet", " with not enough data "); + ANY(forward, "packet", " forwarded "); + ANY(encap, "packet", " encapsulated "); + ANY(cantforward, "packet", " rcvd for unreachable dest "); + ANY(nosockspace, "packet", " dropped due to no socket space "); } ==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#18 (text+ko) ==== @@ -148,7 +148,7 @@ void nserr_stats(u_long, const char *, int, int); void atalkprotopr(u_long, const char *, int, int); -void ddp_stats(u_long, const char *, int, int); +void ddp_stats(const struct stat_type *); #ifdef NETGRAPH void netgraphprotopr(u_long, const char *, int, int); ==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#26 (text+ko) ==== @@ -93,45 +93,43 @@ { .n_name = "_ipxstat"}, #define N_SPXSTAT 7 { .n_name = "_spx_istat"}, -#define N_DDPSTAT 8 - { .n_name = "_ddpstat"}, -#define N_DDPCB 9 +#define N_DDPCB 8 { .n_name = "_ddpcb"}, -#define N_NGSOCKS 10 +#define N_NGSOCKS 9 { .n_name = "_ngsocklist"}, -#define N_IP6STAT 11 +#define N_IP6STAT 10 { .n_name = "_ip6stat" }, -#define N_ICMP6STAT 12 +#define N_ICMP6STAT 11 { .n_name = "_icmp6stat" }, -#define N_IPSECSTAT 13 +#define N_IPSECSTAT 12 { .n_name = "_ipsec4stat" }, -#define N_IPSEC6STAT 14 +#define N_IPSEC6STAT 13 { .n_name = "_ipsec6stat" }, -#define N_PIM6STAT 15 +#define N_PIM6STAT 14 { .n_name = "_pim6stat" }, -#define N_MRT6STAT 16 +#define N_MRT6STAT 15 { .n_name = "_mrt6stat" }, -#define N_MF6CTABLE 17 +#define N_MF6CTABLE 16 { .n_name = "_mf6ctable" }, -#define N_MIF6TABLE 18 +#define N_MIF6TABLE 17 { .n_name = "_mif6table" }, -#define N_PFKEYSTAT 19 +#define N_PFKEYSTAT 18 { .n_name = "_pfkeystat" }, -#define N_RTTRASH 20 +#define N_RTTRASH 19 { .n_name = "_rttrash" }, -#define N_PFSYNCSTAT 21 +#define N_PFSYNCSTAT 20 { .n_name = "_pfsyncstats" }, -#define N_AHSTAT 22 +#define N_AHSTAT 21 { .n_name = "_ahstat" }, -#define N_ESPSTAT 23 +#define N_ESPSTAT 22 { .n_name = "_espstat" }, -#define N_IPCOMPSTAT 24 +#define N_IPCOMPSTAT 23 { .n_name = "_ipcompstat" }, -#define N_RIP6STAT 25 +#define N_RIP6STAT 24 { .n_name = "_rip6stat" }, -#define N_SCTPSTAT 26 +#define N_SCTPSTAT 25 { .n_name = "_sctpstat" }, -#define N_MFCTABLESIZE 27 +#define N_MFCTABLESIZE 26 { .n_name = "_mfctablesize" }, { .n_name = NULL }, }; @@ -222,8 +220,8 @@ #endif struct protox atalkprotox[] = { - { N_DDPCB, N_DDPSTAT, 1, atalkprotopr, NULL, stat_MAX, - ddp_stats, NULL, "ddp", 0, 0 }, + { N_DDPCB, 0, 1, atalkprotopr, ddp_stats, stat_DDP, + NULL, NULL, "ddp", 0, 0 }, { -1, -1, 0, NULL, NULL, stat_MAX, NULL, NULL, NULL, 0, 0 } };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907282359.n6SNxEnV056995>
