diff options
Diffstat (limited to 'usr.bin/netstat/main.c')
-rw-r--r-- | usr.bin/netstat/main.c | 84 |
1 files changed, 72 insertions, 12 deletions
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index 230290534c0..188de0b3907 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.18 1999/10/29 03:26:40 angelos Exp $ */ +/* $OpenBSD: main.c,v 1.19 1999/12/08 12:30:17 itojun Exp $ */ /* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */ /* @@ -44,7 +44,7 @@ char copyright[] = #if 0 static char sccsid[] = "from: @(#)main.c 8.4 (Berkeley) 3/1/94"; #else -static char *rcsid = "$OpenBSD: main.c,v 1.18 1999/10/29 03:26:40 angelos Exp $"; +static char *rcsid = "$OpenBSD: main.c,v 1.19 1999/12/08 12:30:17 itojun Exp $"; #endif #endif /* not lint */ @@ -153,6 +153,24 @@ struct nlist nl[] = { { "_ddpcb"}, #define N_ETHERIPSTAT 41 { "_etheripstat"}, +#define N_IP6STAT 42 + { "_ip6stat" }, +#define N_ICMP6STAT 43 + { "_icmp6stat" }, +#define N_IPSECSTAT 44 + { "_ipsecstat" }, +#define N_IPSEC6STAT 45 + { "_ipsec6stat" }, +#define N_PIM6STAT 46 + { "_pim6stat" }, +#define N_MRT6PROTO 47 + { "_ip6_mrtproto" }, +#define N_MRT6STAT 48 + { "_mrt6stat" }, +#define N_MF6CTABLE 49 + { "_mf6ctable" }, +#define N_MIF6TABLE 50 + { "_mif6table" }, { ""}, }; @@ -186,6 +204,19 @@ struct protox { 0, 0 } }; +#ifdef INET6 +struct protox ip6protox[] = { + { -1, N_IP6STAT, 1, 0, + ip6_stats, "ip6" }, + { -1, N_ICMP6STAT, 1, 0, + icmp6_stats, "icmp6" }, + { -1, N_PIM6STAT, 1, 0, + pim6_stats, "pim6" }, + { -1, -1, 0, 0, + 0, 0 } +}; +#endif + struct protox ipxprotox[] = { { N_IPX, N_IPXSTAT, 1, ipxprotopr, ipx_stats, "ipx" }, @@ -228,7 +259,11 @@ struct protox atalkprotox[] = { 0, 0 } }; +#ifndef INET6 struct protox *protoprotox[] = { protox, ipxprotox, nsprotox, isoprotox, atalkprotox, NULL }; +#else +struct protox *protoprotox[] = { protox, ip6protox, ipxprotox, nsprotox, isoprotox, atalkprotox, NULL }; +#endif static void printproto __P((struct protox *, char *)); static void usage __P((void)); @@ -245,14 +280,14 @@ main(argc, argv) extern char *optarg; extern int optind; register struct protoent *p; - register struct protox *tp; /* for printing cblocks & stats */ + register struct protox *tp = NULL; /* for printing cblocks & stats */ int ch; char *nlistf = NULL, *memf = NULL; char buf[_POSIX2_LINE_MAX]; af = AF_UNSPEC; - while ((ch = getopt(argc, argv, "Aadf:gI:iM:mN:np:rstuvw:")) != -1) + while ((ch = getopt(argc, argv, "Aadf:gI:ilM:mN:np:rstuvw:")) != -1) switch(ch) { case 'A': Aflag = 1; @@ -266,6 +301,8 @@ main(argc, argv) case 'f': if (strcmp(optarg, "inet") == 0) af = AF_INET; + else if (strcmp(optarg, "inet6") == 0) + af = AF_INET6; else if (strcmp(optarg, "local") == 0) af = AF_LOCAL; else if (strcmp(optarg, "unix") == 0) @@ -297,6 +334,9 @@ main(argc, argv) case 'i': iflag = 1; break; + case 'l': + lflag = 1; + break; case 'M': memf = optarg; break; @@ -417,14 +457,29 @@ main(argc, argv) exit(0); } if (gflag) { - if (sflag) - mrt_stats(nl[N_MRTPROTO].n_value, - nl[N_MRTSTAT].n_value); - else - mroutepr(nl[N_MRTPROTO].n_value, - nl[N_MFCHASHTBL].n_value, - nl[N_MFCHASH].n_value, - nl[N_VIFTABLE].n_value); + if (sflag) { + if (af == AF_INET || af == AF_UNSPEC) + mrt_stats(nl[N_MRTPROTO].n_value, + nl[N_MRTSTAT].n_value); +#ifdef INET6 + if (af == AF_INET6 || af == AF_UNSPEC) + mrt6_stats(nl[N_MRT6PROTO].n_value, + nl[N_MRT6STAT].n_value); +#endif + } + else { + if (af == AF_INET || af == AF_UNSPEC) + mroutepr(nl[N_MRTPROTO].n_value, + nl[N_MFCHASHTBL].n_value, + nl[N_MFCHASH].n_value, + nl[N_VIFTABLE].n_value); +#ifdef INET6 + if (af == AF_INET6 || af == AF_UNSPEC) + mroute6pr(nl[N_MRT6PROTO].n_value, + nl[N_MF6CTABLE].n_value, + nl[N_MIF6TABLE].n_value); +#endif + } exit(0); } if (af == AF_INET || af == AF_UNSPEC) { @@ -441,6 +496,11 @@ main(argc, argv) } endprotoent(); } +#ifdef INET6 + if (af == AF_INET6 || af == AF_UNSPEC) + for (tp = ip6protox; tp->pr_name; tp++) + printproto(tp, tp->pr_name); +#endif if (af == AF_IPX || af == AF_UNSPEC) for (tp = ipxprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); |