From 3f85c66ac78a19340612b9349baf1c4072566ab0 Mon Sep 17 00:00:00 2001 From: angelos Date: Fri, 21 Feb 1997 09:09:50 +0000 Subject: [PATCH] netstat now understands SIPP-AH/SIPP-ESP (IPsec) and ENCAP protocols. --- usr.bin/netstat/inet.c | 94 ++++++++++++++++++++++++++++++++++++++- usr.bin/netstat/main.c | 16 ++++++- usr.bin/netstat/netstat.h | 5 ++- 3 files changed, 110 insertions(+), 5 deletions(-) diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 1788a1198b7..5eea0e6d4d6 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet.c,v 1.9 1997/02/21 02:46:49 deraadt Exp $ */ +/* $OpenBSD: inet.c,v 1.10 1997/02/21 09:09:50 angelos Exp $ */ /* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94"; #else -static char *rcsid = "$OpenBSD: inet.c,v 1.9 1997/02/21 02:46:49 deraadt Exp $"; +static char *rcsid = "$OpenBSD: inet.c,v 1.10 1997/02/21 09:09:50 angelos Exp $"; #endif #endif /* not lint */ @@ -68,6 +68,9 @@ static char *rcsid = "$OpenBSD: inet.c,v 1.9 1997/02/21 02:46:49 deraadt Exp $"; #include #include #include +#include +#include +#include #include #include @@ -576,3 +579,90 @@ inetname(inp) } return (line); } + +/* + * Dump AH statistics structure. + */ +void +ah_stats(off, name) + u_long off; + char *name; +{ + struct ahstat ahstat; + + if (off == 0) + return; + kread(off, (char *)&ahstat, sizeof (ahstat)); + printf("%s:\n", name); + +#define p(f, m) if (ahstat.f || sflag <= 1) \ + printf(m, ahstat.f, plural(ahstat.f)) + + p(ahs_hdrops, "\t%u packet%s shorter than header shows\n"); + p(ahs_notdb, "\t%u packet%s for which no TDB was found\n"); + p(ahs_badkcr, "\t%u input packet%s that failed to be processed\n"); + p(ahs_badauth, "\t%u packet%s that failed verification received\n"); + p(ahs_noxform, "\t%u packet%s for which no XFORM was set in TDB received\n"); + p(ahs_qfull, "\t%u packet%s were dropeed due to full output queue\n"); + p(ahs_wrap, "\t%u packet%s where counter wrapping was detected\n"); + p(ahs_replay, "\t%u possibly replayed packet%s received\n"); + p(ahs_badauthl, "\t%u packet%s with bad authenticator length received\n"); +#undef p +} + +/* + * Dump ESP statistics structure. + */ +void +esp_stats(off, name) + u_long off; + char *name; +{ + struct espstat espstat; + + if (off == 0) + return; + kread(off, (char *)&espstat, sizeof (espstat)); + printf("%s:\n", name); + +#define p(f, m) if (espstat.f || sflag <= 1) \ + printf(m, espstat.f, plural(espstat.f)) + + p(esps_hdrops, "\t%u packet%s shorter than header shows\n"); + p(esps_notdb, "\t%u packet%s for which no TDB was found\n"); + p(esps_badkcr, "\t%u input packet%s that failed to be processed\n"); + p(esps_badauth, "\t%u packet%s that failed verification received\n"); + p(esps_noxform, "\t%u packet%s for which no XFORM was set in TDB received\n"); + p(esps_qfull, "\t%u packet%s were dropeed due to full output queue\n"); + p(esps_wrap, "\t%u packet%s where counter wrapping was detected\n"); + p(esps_replay, "\t%u possibly replayed packet%s received\n"); + p(esps_badilen, "\t%u packet%s with payload not a multiple of 8 received\n"); + +#undef p +} + +/* + * Dump ESP statistics structure. + */ +void +ip4_stats(off, name) + u_long off; + char *name; +{ + struct ip4stat ip4stat; + + if (off == 0) + return; + kread(off, (char *)&ip4stat, sizeof (ip4stat)); + printf("%s:\n", name); + +#define p(f, m) if (ip4stat.f || sflag <= 1) \ + printf(m, ip4stat.f, plural(ip4stat.f)) + + p(ip4s_ipackets, "\t%u total input packet%s\n"); + p(ip4s_hdrops, "\t%u packet%s shorter than header shows\n"); + p(ip4s_notip4, "\t%u packet%s with internal header not IPv4 received\n"); + p(ip4s_qfull, "\t%u packet%s were dropeed due to full output queue\n"); + +#undef p +} diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index 5a866fd8aa1..d09ab2547b5 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.7 1997/02/01 17:31:19 kstailey Exp $ */ +/* $OpenBSD: main.c,v 1.8 1997/02/21 09:09:52 angelos 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.7 1997/02/01 17:31:19 kstailey Exp $"; +static char *rcsid = "$OpenBSD: main.c,v 1.8 1997/02/21 09:09:52 angelos Exp $"; #endif #endif /* not lint */ @@ -141,6 +141,12 @@ struct nlist nl[] = { { "_spx_istat"}, #define N_IPXERR 35 { "_ipx_errstat"}, +#define N_AHSTAT 36 + { "_ahstat"}, +#define N_ESPSTAT 37 + { "_espstat"}, +#define N_IP4STAT 38 + { "_ip4stat"}, "", }; @@ -162,6 +168,12 @@ struct protox { icmp_stats, "icmp" }, { -1, N_IGMPSTAT, 1, 0, igmp_stats, "igmp" }, + { -1, N_AHSTAT, 1, 0, + ah_stats, "sipp-ah" }, + { -1, N_ESPSTAT, 1, 0, + esp_stats, "sipp-esp" }, + { -1, N_IP4STAT, 1, 0, + ip4_stats, "encap" }, { -1, -1, 0, 0, 0, 0 } }; diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index 7d494f98cf2..3feb7ac98d3 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: netstat.h,v 1.4 1996/08/16 09:29:34 mickey Exp $ */ +/* $OpenBSD: netstat.h,v 1.5 1997/02/21 09:09:53 angelos Exp $ */ /* $NetBSD: netstat.h,v 1.6 1996/05/07 02:55:05 thorpej Exp $ */ /* @@ -69,6 +69,9 @@ void udp_stats __P((u_long, char *)); void ip_stats __P((u_long, char *)); void icmp_stats __P((u_long, char *)); void igmp_stats __P((u_long, char *)); +void ah_stats __P((u_long, char *)); +void esp_stats __P((u_long, char *)); +void ip4_stats __P((u_long, char *)); void protopr __P((u_long, char *)); void mbpr(u_long); -- 2.20.1