summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2001-06-11 12:39:29 +0000
committerume <ume@FreeBSD.org>2001-06-11 12:39:29 +0000
commit832f8d224926758a9ae0b23a6b45353e44fbc87a (patch)
treea79fc7ad2b97862c4a404f352f0211ad93a7b5f1 /usr.bin/netstat
parent2693854b01a52b0395a91322aa3edf926bddff38 (diff)
downloadFreeBSD-src-832f8d224926758a9ae0b23a6b45353e44fbc87a.zip
FreeBSD-src-832f8d224926758a9ae0b23a6b45353e44fbc87a.tar.gz
Sync with recent KAME.
This work was based on kame-20010528-freebsd43-snap.tgz and some critical problem after the snap was out were fixed. There are many many changes since last KAME merge. TODO: - The definitions of SADB_* in sys/net/pfkeyv2.h are still different from RFC2407/IANA assignment because of binary compatibility issue. It should be fixed under 5-CURRENT. - ip6po_m member of struct ip6_pktopts is no longer used. But, it is still there because of binary compatibility issue. It should be removed under 5-CURRENT. Reviewed by: itojun Obtained from: KAME MFC after: 3 weeks
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/inet.c1
-rw-r--r--usr.bin/netstat/inet6.c55
-rw-r--r--usr.bin/netstat/ipsec.c98
-rw-r--r--usr.bin/netstat/main.c2
-rw-r--r--usr.bin/netstat/mroute6.c1
-rw-r--r--usr.bin/netstat/netstat.h1
-rw-r--r--usr.bin/netstat/route.c11
7 files changed, 126 insertions, 43 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 185506c..aee1aed 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -552,6 +552,7 @@ ip_stats(off, name)
p(ips_ofragments, "\t%lu fragment%s created\n");
p(ips_cantfrag, "\t%lu datagram%s that can't be fragmented\n");
p(ips_nogif, "\t%lu tunneling packet%s that can't find gif\n");
+ p(ips_badaddr, "\t%lu datagram%s with bad address in header\n");
#undef p
#undef p1a
}
diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c
index 5b09706..c41ab90 100644
--- a/usr.bin/netstat/inet6.c
+++ b/usr.bin/netstat/inet6.c
@@ -47,6 +47,7 @@ static char sccsid[] = "@(#)inet6.c 8.4 (Berkeley) 4/20/94";
#include <sys/ioctl.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
+#include <sys/sysctl.h>
#include <net/route.h>
#include <net/if.h>
@@ -59,6 +60,7 @@ static char sccsid[] = "@(#)inet6.c 8.4 (Berkeley) 4/20/94";
#include <netinet6/in6_var.h>
#include <netinet6/ip6_var.h>
#include <netinet6/pim6_var.h>
+#include <netinet6/raw_ip6.h>
#include <arpa/inet.h>
#include <netdb.h>
@@ -868,6 +870,13 @@ icmp6_stats(off, name)
p(icp6s_reflect, "\t%llu message response%s generated\n");
p(icp6s_nd_toomanyopt, "\t%llu message%s with too many ND options\n");
+ p(icp6s_nd_badopt, "\t%qu message%s with bad ND options\n");
+ p(icp6s_badns, "\t%qu bad neighbor solicitation message%s\n");
+ p(icp6s_badna, "\t%qu bad neighbor advertisement message%s\n");
+ p(icp6s_badrs, "\t%qu bad router solicitation message%s\n");
+ p(icp6s_badra, "\t%qu bad router advertisement message%s\n");
+ p(icp6s_badredirect, "\t%qu bad redirect message%s\n");
+ p(icp6s_pmtuchg, "\t%llu path MTU change%s\n");
#undef p
#undef p_5
}
@@ -966,6 +975,52 @@ pim6_stats(off, name)
}
/*
+ * Dump raw ip6 statistics structure.
+ */
+void
+rip6_stats(off, name)
+ u_long off;
+ char *name;
+{
+ struct rip6stat rip6stat;
+ u_quad_t delivered;
+ int mib[4];
+ size_t l;
+
+ mib[0] = CTL_NET;
+ mib[1] = PF_INET6;
+ mib[2] = IPPROTO_IPV6;
+ mib[3] = IPV6CTL_RIP6STATS;
+ l = sizeof(rip6stat);
+ if (sysctl(mib, 4, &rip6stat, &l, NULL, 0) < 0) {
+ perror("Warning: sysctl(net.inet6.ip6.rip6stats)");
+ return;
+ }
+
+ printf("%s:\n", name);
+
+#define p(f, m) if (rip6stat.f || sflag <= 1) \
+ printf(m, (unsigned long long)rip6stat.f, plural(rip6stat.f))
+ p(rip6s_ipackets, "\t%llu message%s received\n");
+ p(rip6s_isum, "\t%llu checksum calcuration%s on inbound\n");
+ p(rip6s_badsum, "\t%llu message%s with bad checksum\n");
+ p(rip6s_nosock, "\t%llu message%s dropped due to no socket\n");
+ p(rip6s_nosockmcast,
+ "\t%llu multicast message%s dropped due to no socket\n");
+ p(rip6s_fullsock,
+ "\t%llu message%s dropped due to full socket buffers\n");
+ delivered = rip6stat.rip6s_ipackets -
+ rip6stat.rip6s_badsum -
+ rip6stat.rip6s_nosock -
+ rip6stat.rip6s_nosockmcast -
+ rip6stat.rip6s_fullsock;
+ if (delivered || sflag <= 1)
+ printf("\t%llu delivered\n", (unsigned long long)delivered);
+ p(rip6s_opackets, "\t%llu datagram%s output\n");
+#undef p
+}
+
+/*
* Pretty print an Internet address (net address + port).
* If the nflag was specified, use numbers instead of names.
*/
diff --git a/usr.bin/netstat/ipsec.c b/usr.bin/netstat/ipsec.c
index ce96488..6037d13 100644
--- a/usr.bin/netstat/ipsec.c
+++ b/usr.bin/netstat/ipsec.c
@@ -1,5 +1,6 @@
/* $FreeBSD$ */
/* $NetBSD: inet.c,v 1.35.2.1 1999/04/29 14:57:08 perry Exp $ */
+/* $KAME: ipsec.c,v 1.25 2001/03/12 09:04:39 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
@@ -63,6 +64,7 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
/*
static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
@@ -99,30 +101,52 @@ static const char rcsid[] =
#define CAST unsigned long long
#ifdef IPSEC
-static const char *ipsec_ahnames[] = {
- "none",
- "hmac MD5",
- "hmac SHA1",
- "keyed MD5",
- "keyed SHA1",
- "null",
+struct val2str {
+ int val;
+ const char *str;
};
-static const char *ipsec_espnames[] = {
- "none",
- "DES CBC",
- "3DES CBC",
- "simple",
- "blowfish CBC",
- "CAST128 CBC",
- "DES derived IV",
+static struct val2str ipsec_ahnames[] = {
+ { SADB_AALG_NONE, "none", },
+ { SADB_AALG_MD5HMAC, "hmac-md5", },
+ { SADB_AALG_SHA1HMAC, "hmac-sha1", },
+ { SADB_X_AALG_MD5, "md5", },
+ { SADB_X_AALG_SHA, "sha", },
+ { SADB_X_AALG_NULL, "null", },
+#ifdef SADB_X_AALG_SHA2_256
+ { SADB_X_AALG_SHA2_256, "hmac-sha2-256", },
+#endif
+#ifdef SADB_X_AALG_SHA2_384
+ { SADB_X_AALG_SHA2_384, "hmac-sha2-384", },
+#endif
+#ifdef SADB_X_AALG_SHA2_512
+ { SADB_X_AALG_SHA2_512, "hmac-sha2-512", },
+#endif
+ { -1, NULL },
};
-static const char *ipsec_compnames[] = {
- "none",
- "OUI",
- "deflate",
- "LZS",
+static struct val2str ipsec_espnames[] = {
+ { SADB_EALG_NONE, "none", },
+ { SADB_EALG_DESCBC, "des-cbc", },
+ { SADB_EALG_3DESCBC, "3des-cbc", },
+ { SADB_EALG_NULL, "null", },
+#ifdef SADB_X_EALG_RC5CBC
+ { SADB_X_EALG_RC5CBC, "rc5-cbc", },
+#endif
+ { SADB_X_EALG_CAST128CBC, "cast128-cbc", },
+ { SADB_X_EALG_BLOWFISHCBC, "blowfish-cbc", },
+#ifdef SADB_X_EALG_RIJNDAELCBC
+ { SADB_X_EALG_RIJNDAELCBC, "rijndael-cbc", },
+#endif
+ { -1, NULL },
+};
+
+static struct val2str ipsec_compnames[] = {
+ { SADB_X_CALG_NONE, "none", },
+ { SADB_X_CALG_OUI, "oui", },
+ { SADB_X_CALG_DEFLATE, "deflate", },
+ { SADB_X_CALG_LZS, "lzs", },
+ { -1, NULL },
};
static const char *pfkey_msgtypenames[] = {
@@ -137,8 +161,8 @@ static struct ipsecstat ipsecstat;
static void print_ipsecstats __P((void));
static const char *pfkey_msgtype_names __P((int));
-static void ipsec_hist __P((const u_quad_t *, size_t, const char **, size_t,
- const char *));
+static void ipsec_hist __P((const u_quad_t *, size_t, const struct val2str *,
+ size_t, const char *));
/*
* Dump IPSEC statistics structure.
@@ -147,26 +171,31 @@ static void
ipsec_hist(hist, histmax, name, namemax, title)
const u_quad_t *hist;
size_t histmax;
- const char **name;
+ const struct val2str *name;
size_t namemax;
const char *title;
{
int first;
size_t proto;
+ const struct val2str *p;
- for (first = 1, proto = 0; proto < histmax; proto++) {
+ first = 1;
+ for (proto = 0; proto < histmax; proto++) {
if (hist[proto] <= 0)
continue;
if (first) {
printf("\t%s histogram:\n", title);
first = 0;
}
- if (proto < namemax && name[proto]) {
- printf("\t\t%s: " LLU "\n", name[proto],
- (CAST)hist[proto]);
+ for (p = name; p && p->str; p++) {
+ if (p->val == proto)
+ break;
+ }
+ if (p && p->str) {
+ printf("\t\t%s: " LLU "\n", p->str, (CAST)hist[proto]);
} else {
printf("\t\t#%ld: " LLU "\n", (long)proto,
- (CAST)hist[proto]);
+ (CAST)hist[proto]);
}
}
}
@@ -221,19 +250,6 @@ ipsec_stats(off, name)
print_ipsecstats();
}
-#if defined(__bsdi__) && _BSDI_VERSION >= 199802 /* bsdi4 only */
-void
-ipsec_stats0(name)
- char *name;
-{
- printf("%s:\n", name);
-
- skread(name, &ipsecstat_info);
-
- print_ipsecstats();
-}
-#endif
-
static const char *
pfkey_msgtype_names(x)
int x;
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index 7a11793..3aab72b 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -199,6 +199,8 @@ struct protox ip6protox[] = {
pim6_stats, NULL, "pim6", 0 },
#endif
{ -1, -1, 1, 0,
+ rip6_stats, NULL, "rip6", 0 },
+ { -1, -1, 1, 0,
bdg_stats, NULL, "bdg", 1 /* bridging... */ },
{ -1, -1, 0, 0,
0, NULL, 0, 0 }
diff --git a/usr.bin/netstat/mroute6.c b/usr.bin/netstat/mroute6.c
index 7e38a05..3441445 100644
--- a/usr.bin/netstat/mroute6.c
+++ b/usr.bin/netstat/mroute6.c
@@ -76,6 +76,7 @@
#include <net/if.h>
#include <net/if_var.h>
+#include <net/route.h>
#include <netinet/in.h>
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h
index ef297d5..012ca9b 100644
--- a/usr.bin/netstat/netstat.h
+++ b/usr.bin/netstat/netstat.h
@@ -79,6 +79,7 @@ void ip6_ifstats __P((char *));
void icmp6_stats __P((u_long, char *));
void icmp6_ifstats __P((char *));
void pim6_stats __P((u_long, char *));
+void rip6_stats __P((u_long, char *));
void mroute6pr __P((u_long, u_long));
void mrt6_stats __P((u_long));
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index db7f190..72b48ec 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -608,8 +608,15 @@ p_rtentry(rt)
p_sockaddr(kgetsa(rt->rt_gateway), NULL, RTF_HOST,
WID_GW(addr.u_sa.sa_family));
p_flags(rt->rt_flags, "%-6.6s ");
- if (addr.u_sa.sa_family == AF_INET || lflag)
- printf("%6ld %8ld ", rt->rt_refcnt, rt->rt_use);
+ if (addr.u_sa.sa_family == AF_INET || lflag) {
+ printf("%6ld %8ld", rt->rt_refcnt, rt->rt_use);
+ if (lflag) {
+ if (rt->rt_rmx.rmx_mtu != 0)
+ printf("%6lu ", rt->rt_rmx.rmx_mtu);
+ else
+ printf("%6s ", "");
+ }
+ }
if (rt->rt_ifp) {
if (rt->rt_ifp != lastif) {
kget(rt->rt_ifp, ifnet);
OpenPOWER on IntegriCloud