make netstat IPv6-ready.
This commit is contained in:
parent
c74aeb8363
commit
414ee1ddfb
@ -1,13 +1,15 @@
|
||||
# $NetBSD: Makefile,v 1.14 1997/05/08 21:11:44 gwr Exp $
|
||||
# $NetBSD: Makefile,v 1.15 1999/07/01 18:40:35 itojun Exp $
|
||||
# from: @(#)Makefile 8.1 (Berkeley) 6/12/93
|
||||
|
||||
PROG= netstat
|
||||
SRCS= atalk.c if.c inet.c iso.c main.c mbuf.c mroute.c ns.c route.c \
|
||||
tp_astring.c unix.c
|
||||
tp_astring.c unix.c mroute6.c
|
||||
SRCS+= inet6.c
|
||||
.PATH: ${.CURDIR}/../../sys/netiso
|
||||
BINGRP= kmem
|
||||
BINMODE=2555
|
||||
LDADD= -lkvm
|
||||
DPADD= ${LIBKVM}
|
||||
CPPFLAGS+= -DINET6 -DIPSEC
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if.c,v 1.31 1999/03/14 22:28:05 mycroft Exp $ */
|
||||
/* $NetBSD: if.c,v 1.32 1999/07/01 18:40:35 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1988, 1993
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: if.c,v 1.31 1999/03/14 22:28:05 mycroft Exp $");
|
||||
__RCSID("$NetBSD: if.c,v 1.32 1999/07/01 18:40:35 itojun Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -70,6 +70,11 @@ __RCSID("$NetBSD: if.c,v 1.31 1999/03/14 22:28:05 mycroft Exp $");
|
||||
static void sidewaysintpr __P((u_int, u_long));
|
||||
static void catchalarm __P((int));
|
||||
|
||||
#ifdef INET6
|
||||
char *netname6 __P((struct in6_addr *, struct in6_addr *));
|
||||
static char ntop_buf[INET6_ADDRSTRLEN]; /* for inet_ntop() */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Print a description of the network interfaces.
|
||||
* NOTE: ifnetaddr is the location of the kernel global "ifnet",
|
||||
@ -84,6 +89,9 @@ intpr(interval, ifnetaddr)
|
||||
union {
|
||||
struct ifaddr ifa;
|
||||
struct in_ifaddr in;
|
||||
#ifdef INET6
|
||||
struct in6_ifaddr in6;
|
||||
#endif /* INET6 */
|
||||
struct ns_ifaddr ns;
|
||||
struct iso_ifaddr iso;
|
||||
} ifaddr;
|
||||
@ -129,6 +137,9 @@ intpr(interval, ifnetaddr)
|
||||
ifaddraddr = 0;
|
||||
while (ifnetaddr || ifaddraddr) {
|
||||
struct sockaddr_in *sin;
|
||||
#ifdef INET6
|
||||
struct sockaddr_in6 *sin6;
|
||||
#endif /* INET6 */
|
||||
char *cp;
|
||||
int n, m;
|
||||
|
||||
@ -201,6 +212,18 @@ intpr(interval, ifnetaddr)
|
||||
}
|
||||
}
|
||||
break;
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
sin6 = (struct sockaddr_in6 *)sa;
|
||||
printf("%-13.13s ",
|
||||
netname6(&ifaddr.in6.ia_addr.sin6_addr,
|
||||
&ifaddr.in6.ia_prefixmask.sin6_addr));
|
||||
printf("%-17.17s ",
|
||||
(char *)inet_ntop(AF_INET6,
|
||||
&sin6->sin6_addr,
|
||||
ntop_buf, sizeof(ntop_buf)));
|
||||
break;
|
||||
#endif /*INET6*/
|
||||
#ifndef SMALL
|
||||
case AF_APPLETALK:
|
||||
printf("atalk:%-7.7s ",
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: inet.c,v 1.36 1999/04/29 03:58:27 thorpej Exp $ */
|
||||
/* $NetBSD: inet.c,v 1.37 1999/07/01 18:40:35 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1988, 1993
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: inet.c,v 1.36 1999/04/29 03:58:27 thorpej Exp $");
|
||||
__RCSID("$NetBSD: inet.c,v 1.37 1999/07/01 18:40:35 itojun Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -55,6 +55,11 @@ __RCSID("$NetBSD: inet.c,v 1.36 1999/04/29 03:58:27 thorpej Exp $");
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/in_pcb.h>
|
||||
#include <netinet/ip_icmp.h>
|
||||
|
||||
#ifdef INET6
|
||||
#include <netinet/ip6.h>
|
||||
#endif
|
||||
|
||||
#include <netinet/icmp_var.h>
|
||||
#include <netinet/igmp_var.h>
|
||||
#include <netinet/ip_var.h>
|
||||
@ -69,6 +74,9 @@ __RCSID("$NetBSD: inet.c,v 1.36 1999/04/29 03:58:27 thorpej Exp $");
|
||||
#include <netinet/tcp_debug.h>
|
||||
#include <netinet/udp.h>
|
||||
#include <netinet/udp_var.h>
|
||||
#ifdef IPSEC
|
||||
#include <netinet6/ipsec.h>
|
||||
#endif
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
@ -490,6 +498,107 @@ igmp_stats(off, name)
|
||||
#undef py
|
||||
}
|
||||
|
||||
#ifdef IPSEC
|
||||
static char *ipsec_ahnames[] = {
|
||||
"none",
|
||||
"hmac MD5",
|
||||
"hmac SHA1",
|
||||
"keyed MD5",
|
||||
"keyed SHA1",
|
||||
"null",
|
||||
};
|
||||
|
||||
static char *ipsec_espnames[] = {
|
||||
"none",
|
||||
"DES CBC",
|
||||
"3DES CBC",
|
||||
"simple",
|
||||
"blowfish CBC",
|
||||
"CAST128 CBC",
|
||||
"DES derived IV",
|
||||
};
|
||||
|
||||
/*
|
||||
* Dump IPSEC statistics structure.
|
||||
*/
|
||||
void
|
||||
ipsec_stats(off, name)
|
||||
u_long off;
|
||||
char *name;
|
||||
{
|
||||
struct ipsecstat ipsecstat;
|
||||
int first, proto;
|
||||
|
||||
if (off == 0)
|
||||
return;
|
||||
printf ("%s:\n", name);
|
||||
kread(off, (char *)&ipsecstat, sizeof (ipsecstat));
|
||||
|
||||
#define p(f, m) if (ipsecstat.f || sflag <= 1) \
|
||||
printf(m, ipsecstat.f, plural(ipsecstat.f))
|
||||
|
||||
p(in_success, "\t%lu inbound packet%s processed successfully\n");
|
||||
p(in_polvio, "\t%lu inbound packet%s violated process security "
|
||||
"policy\n");
|
||||
p(in_nosa, "\t%lu inbound packet%s with no SA available\n");
|
||||
p(in_inval, "\t%lu inbound packet%s failed processing due to EINVAL\n");
|
||||
p(in_badspi, "\t%lu inbound packet%s failed getting SPI\n");
|
||||
p(in_ahreplay, "\t%lu inbound packet%s failed on AH replay check\n");
|
||||
p(in_espreplay, "\t%lu inbound packet%s failed on ESP replay check\n");
|
||||
p(in_ahauthsucc, "\t%lu inbound packet%s considered authentic\n");
|
||||
p(in_ahauthfail, "\t%lu inbound packet%s failed on authentication\n");
|
||||
for (first = 1, proto = 0; proto < SADB_AALG_MAX; proto++) {
|
||||
if (ipsecstat.in_ahhist[proto] <= 0)
|
||||
continue;
|
||||
if (first) {
|
||||
printf("\tAH input histogram:\n");
|
||||
first = 0;
|
||||
}
|
||||
printf("\t\t%s: %lu\n", ipsec_ahnames[proto],
|
||||
ipsecstat.in_ahhist[proto]);
|
||||
}
|
||||
for (first = 1, proto = 0; proto < SADB_EALG_MAX; proto++) {
|
||||
if (ipsecstat.in_esphist[proto] <= 0)
|
||||
continue;
|
||||
if (first) {
|
||||
printf("\tESP input histogram:\n");
|
||||
first = 0;
|
||||
}
|
||||
printf("\t\t%s: %lu\n", ipsec_espnames[proto],
|
||||
ipsecstat.in_esphist[proto]);
|
||||
}
|
||||
|
||||
p(out_success, "\t%lu outbound packet%s processed successfully\n");
|
||||
p(out_polvio, "\t%lu outbound packet%s violated process security "
|
||||
"policy\n");
|
||||
p(out_nosa, "\t%lu outbound packet%s with no SA available\n");
|
||||
p(out_inval, "\t%lu outbound packet%s failed processing due to "
|
||||
"EINVAL\n");
|
||||
p(out_noroute, "\t%lu outbound packet%s with no route\n");
|
||||
for (first = 1, proto = 0; proto < SADB_AALG_MAX; proto++) {
|
||||
if (ipsecstat.out_ahhist[proto] <= 0)
|
||||
continue;
|
||||
if (first) {
|
||||
printf("\tAH output histogram:\n");
|
||||
first = 0;
|
||||
}
|
||||
printf("\t\t%s: %lu\n", ipsec_ahnames[proto],
|
||||
ipsecstat.out_ahhist[proto]);
|
||||
}
|
||||
for (first = 1, proto = 0; proto < SADB_EALG_MAX; proto++) {
|
||||
if (ipsecstat.out_esphist[proto] <= 0)
|
||||
continue;
|
||||
if (first) {
|
||||
printf("\tESP output histogram:\n");
|
||||
first = 0;
|
||||
}
|
||||
printf("\t\t%s: %lu\n", ipsec_espnames[proto],
|
||||
ipsecstat.out_esphist[proto]);
|
||||
}
|
||||
#undef p
|
||||
}
|
||||
#endif /*IPSEC*/
|
||||
|
||||
/*
|
||||
* Pretty print an Internet address (net address + port).
|
||||
* If the nflag was specified, use numbers instead of names.
|
||||
|
1131
usr.bin/netstat/inet6.c
Normal file
1131
usr.bin/netstat/inet6.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.22 1999/03/14 18:30:04 kristerw Exp $ */
|
||||
/* $NetBSD: main.c,v 1.23 1999/07/01 18:40:36 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1988, 1993
|
||||
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)main.c 8.4 (Berkeley) 3/1/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.22 1999/03/14 18:30:04 kristerw Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.23 1999/07/01 18:40:36 itojun Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -145,6 +145,36 @@ struct nlist nl[] = {
|
||||
{ "_mbpool" },
|
||||
#define N_MCLPOOL 37
|
||||
{ "_mclpool" },
|
||||
#define N_DIVPCB 38
|
||||
{ "_divcb"},
|
||||
#define N_DIVSTAT 39
|
||||
{ "_divstat"},
|
||||
#define N_IP6STAT 40
|
||||
{ "_ip6stat" },
|
||||
#define N_TCB6 41
|
||||
{ "_tcb6" },
|
||||
#define N_TCP6STAT 42
|
||||
{ "_tcp6stat" },
|
||||
#define N_UDB6 43
|
||||
{ "_udb6" },
|
||||
#define N_UDP6STAT 44
|
||||
{ "_udp6stat" },
|
||||
#define N_ICMP6STAT 45
|
||||
{ "_icmp6stat" },
|
||||
#define N_IPSECSTAT 46
|
||||
{ "_ipsecstat" },
|
||||
#define N_IPSEC6STAT 47
|
||||
{ "_ipsec6stat" },
|
||||
#define N_PIM6STAT 48
|
||||
{ "_pim6stat" },
|
||||
#define N_MRT6PROTO 49
|
||||
{ "_ip6_mrtproto" },
|
||||
#define N_MRT6STAT 50
|
||||
{ "_mrt6stat" },
|
||||
#define N_MF6CTABLE 51
|
||||
{ "_mf6ctable" },
|
||||
#define N_MIF6TABLE 52
|
||||
{ "_mif6table" },
|
||||
{ "" },
|
||||
};
|
||||
|
||||
@ -170,10 +200,40 @@ struct protox {
|
||||
icmp_stats, 0, "icmp" },
|
||||
{ -1, N_IGMPSTAT, 1, 0,
|
||||
igmp_stats, 0, "igmp" },
|
||||
#ifdef IPSEC
|
||||
{ -1, N_IPSECSTAT, 1, 0,
|
||||
ipsec_stats, 0, "ipsec" },
|
||||
#endif
|
||||
{ -1, -1, 0, 0,
|
||||
0, 0, 0 }
|
||||
};
|
||||
|
||||
#ifdef INET6
|
||||
struct protox ip6protox[] = {
|
||||
{ -1, N_IP6STAT, 1, 0,
|
||||
ip6_stats, 0, "ip6" },
|
||||
{ -1, N_ICMP6STAT, 1, 0,
|
||||
icmp6_stats, 0, "icmp6" },
|
||||
#ifdef TCP6
|
||||
{ N_TCB6, N_TCP6STAT, 1, ip6protopr,
|
||||
tcp6_stats, tcp6_dump, "tcp6" },
|
||||
#else
|
||||
{ N_TCB6, N_TCP6STAT, 1, ip6protopr,
|
||||
tcp_stats, tcp_dump, "tcp6" },
|
||||
#endif
|
||||
{ N_UDB6, N_UDP6STAT, 1, ip6protopr,
|
||||
udp6_stats, 0, "udp6" },
|
||||
#ifdef IPSEC
|
||||
{ -1, N_IPSEC6STAT, 1, 0,
|
||||
ipsec_stats, 0, "ipsec6" },
|
||||
#endif
|
||||
{ -1, N_PIM6STAT, 1, 0,
|
||||
pim6_stats, 0, "pim6" },
|
||||
{ -1, -1, 0, 0,
|
||||
0, 0, 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef SMALL
|
||||
struct protox atalkprotox[] = {
|
||||
{ N_DDPCB, N_DDPSTAT, 1, atalkprotopr,
|
||||
@ -208,6 +268,9 @@ struct protox isoprotox[] = {
|
||||
#endif
|
||||
|
||||
struct protox *protoprotox[] = { protox,
|
||||
#ifdef INET6
|
||||
ip6protox,
|
||||
#endif
|
||||
#ifndef SMALL
|
||||
atalkprotox, nsprotox, isoprotox,
|
||||
#endif
|
||||
@ -241,7 +304,7 @@ main(argc, argv)
|
||||
af = AF_UNSPEC;
|
||||
pcbaddr = 0;
|
||||
|
||||
while ((ch = getopt(argc, argv, "Aabdf:ghI:iM:mN:nP:p:rstuvw:")) != -1)
|
||||
while ((ch = getopt(argc, argv, "Aabdf:ghI:liM:mN:nP:p:rstuvw:")) != -1)
|
||||
switch(ch) {
|
||||
case 'A':
|
||||
Aflag = 1;
|
||||
@ -260,6 +323,8 @@ main(argc, argv)
|
||||
af = AF_NS;
|
||||
else if (strcmp(optarg, "inet") == 0)
|
||||
af = AF_INET;
|
||||
else if (strcmp(optarg, "inet6") == 0)
|
||||
af = AF_INET6;
|
||||
else if (strcmp(optarg, "unix") == 0
|
||||
|| strcmp(optarg, "local") == 0)
|
||||
af = AF_LOCAL;
|
||||
@ -283,6 +348,9 @@ main(argc, argv)
|
||||
case 'i':
|
||||
iflag = 1;
|
||||
break;
|
||||
case 'l':
|
||||
lflag = 1;
|
||||
break;
|
||||
case 'M':
|
||||
memf = optarg;
|
||||
break;
|
||||
@ -421,14 +489,29 @@ main(argc, argv)
|
||||
}
|
||||
#ifndef SMALL
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
@ -443,9 +526,18 @@ main(argc, argv)
|
||||
if (tp->pr_name == 0 || tp->pr_wanted == 0)
|
||||
continue;
|
||||
printproto(tp, p->p_name);
|
||||
tp->pr_wanted = 0;
|
||||
}
|
||||
endprotoent();
|
||||
for (tp = protox; tp->pr_name; tp++)
|
||||
if (tp->pr_wanted)
|
||||
printproto(tp, tp->pr_name);
|
||||
}
|
||||
#ifdef INET6
|
||||
if (af == AF_INET6 || af == AF_UNSPEC)
|
||||
for (tp = ip6protox; tp->pr_name; tp++)
|
||||
printproto(tp, tp->pr_name);
|
||||
#endif
|
||||
#ifndef SMALL
|
||||
if (af == AF_APPLETALK || af == AF_UNSPEC)
|
||||
for (tp = atalkprotox; tp->pr_name; tp++)
|
||||
|
278
usr.bin/netstat/mroute6.c
Normal file
278
usr.bin/netstat/mroute6.c
Normal file
@ -0,0 +1,278 @@
|
||||
/*
|
||||
* Copyright (C) 1998 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989 Stephen Deering
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Stephen Deering of Stanford University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)mroute.c 8.2 (Berkeley) 4/28/95
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/protosw.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#define KERNEL 1
|
||||
#include <netinet6/ip6_mroute.h>
|
||||
#undef KERNEL
|
||||
|
||||
#include <stdio.h>
|
||||
#include "netstat.h"
|
||||
|
||||
#ifdef INET6
|
||||
|
||||
#define WID_ORG (lflag ? 39 : (nflag ? 29 : 18)) /* width of origin column */
|
||||
#define WID_GRP (lflag ? 18 : (nflag ? 16 : 18)) /* width of group column */
|
||||
|
||||
void
|
||||
mroute6pr(mrpaddr, mfcaddr, mifaddr)
|
||||
u_long mrpaddr, mfcaddr, mifaddr;
|
||||
{
|
||||
u_int mrtproto;
|
||||
struct mf6c *mf6ctable[MF6CTBLSIZ], *mfcp;
|
||||
struct mif6 mif6table[MAXMIFS];
|
||||
struct mf6c mfc;
|
||||
struct rtdetq rte, *rtep;
|
||||
register struct mif6 *mifp;
|
||||
register mifi_t mifi;
|
||||
register int i;
|
||||
register int banner_printed;
|
||||
register int saved_nflag;
|
||||
mifi_t maxmif = 0;
|
||||
int waitings;
|
||||
|
||||
if (mrpaddr == 0) {
|
||||
printf("mroute6pr: symbol not in namelist\n");
|
||||
return;
|
||||
}
|
||||
|
||||
kread(mrpaddr, (char *)&mrtproto, sizeof(mrtproto));
|
||||
switch (mrtproto) {
|
||||
|
||||
case 0:
|
||||
printf("no IPv6 multicast routing compiled into this system\n");
|
||||
return;
|
||||
|
||||
case IPPROTO_PIM:
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("IPv6 multicast routing protocol %u, unknown\n",
|
||||
mrtproto);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mfcaddr == 0) {
|
||||
printf("mf6ctable: symbol not in namelist\n");
|
||||
return;
|
||||
}
|
||||
if (mifaddr == 0) {
|
||||
printf("miftable: symbol not in namelist\n");
|
||||
return;
|
||||
}
|
||||
|
||||
saved_nflag = nflag;
|
||||
nflag = 1;
|
||||
|
||||
kread(mifaddr, (char *)&mif6table, sizeof(mif6table));
|
||||
banner_printed = 0;
|
||||
for (mifi = 0, mifp = mif6table; mifi < MAXMIFS; ++mifi, ++mifp) {
|
||||
struct ifnet ifnet;
|
||||
char ifname[IFNAMSIZ];
|
||||
|
||||
if (mifp->m6_ifp == NULL)
|
||||
continue;
|
||||
|
||||
kread((u_long)mifp->m6_ifp, (char *)&ifnet, sizeof(ifnet));
|
||||
maxmif = mifi;
|
||||
if (!banner_printed) {
|
||||
printf("\nIPv6 Multicast Interface Table\n"
|
||||
" Mif Rate PhyIF "
|
||||
"Pkts-In Pkts-Out\n");
|
||||
banner_printed = 1;
|
||||
}
|
||||
|
||||
printf(" %2u %4d",
|
||||
mifi, mifp->m6_rate_limit);
|
||||
printf(" %5s", (mifp->m6_flags & MIFF_REGISTER) ?
|
||||
"reg0" : if_indextoname(ifnet.if_index, ifname));
|
||||
|
||||
printf(" %9lu %9lu\n", mifp->m6_pkt_in, mifp->m6_pkt_out);
|
||||
}
|
||||
if (!banner_printed)
|
||||
printf("\nIPv6 Multicast Interface Table is empty\n");
|
||||
|
||||
kread(mfcaddr, (char *)&mf6ctable, sizeof(mf6ctable));
|
||||
banner_printed = 0;
|
||||
for (i = 0; i < MF6CTBLSIZ; ++i) {
|
||||
mfcp = mf6ctable[i];
|
||||
while(mfcp) {
|
||||
kread((u_long)mfcp, (char *)&mfc, sizeof(mfc));
|
||||
if (!banner_printed) {
|
||||
printf ("\nIPv6 Multicast Forwarding Cache\n");
|
||||
printf(" %-*.*s %-*.*s %s",
|
||||
WID_ORG, WID_ORG, "Origin",
|
||||
WID_GRP, WID_GRP, "Group",
|
||||
" Packets Waits In-Mif Out-Mifs\n");
|
||||
banner_printed = 1;
|
||||
}
|
||||
|
||||
printf(" %-*.*s", WID_ORG, WID_ORG,
|
||||
routename6((char *)&mfc.mf6c_origin.sin6_addr));
|
||||
printf(" %-*.*s", WID_GRP, WID_GRP,
|
||||
routename6((char *)&mfc.mf6c_mcastgrp.sin6_addr));
|
||||
printf(" %9lu", mfc.mf6c_pkt_cnt);
|
||||
|
||||
for (waitings = 0, rtep = mfc.mf6c_stall; rtep; ) {
|
||||
waitings++;
|
||||
kread((u_long)rtep, (char *)&rte, sizeof(rte));
|
||||
rtep = rte.next;
|
||||
}
|
||||
printf(" %3d", waitings);
|
||||
|
||||
if (mfc.mf6c_parent == MF6C_INCOMPLETE_PARENT)
|
||||
printf(" --- ");
|
||||
else
|
||||
printf(" %3d ", mfc.mf6c_parent);
|
||||
for (mifi = 0; mifi <= MAXMIFS; mifi++) {
|
||||
if (IF_ISSET(mifi, &mfc.mf6c_ifset))
|
||||
printf(" %u", mifi);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
mfcp = mfc.mf6c_next;
|
||||
}
|
||||
}
|
||||
if (!banner_printed)
|
||||
printf("\nIPv6 Multicast Routing Table is empty\n");
|
||||
|
||||
printf("\n");
|
||||
nflag = saved_nflag;
|
||||
}
|
||||
|
||||
void
|
||||
mrt6_stats(mrpaddr, mstaddr)
|
||||
u_long mrpaddr, mstaddr;
|
||||
{
|
||||
u_int mrtproto;
|
||||
struct mrt6stat mrtstat;
|
||||
|
||||
if(mrpaddr == 0) {
|
||||
printf("mrt6_stats: symbol not in namelist\n");
|
||||
return;
|
||||
}
|
||||
|
||||
kread(mrpaddr, (char *)&mrtproto, sizeof(mrtproto));
|
||||
switch (mrtproto) {
|
||||
case 0:
|
||||
printf("no IPv6 multicast routing compiled into this system\n");
|
||||
return;
|
||||
|
||||
case IPPROTO_PIM:
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("IPv6 multicast routing protocol %u, unknown\n",
|
||||
mrtproto);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mstaddr == 0) {
|
||||
printf("mrt6_stats: symbol not in namelist\n");
|
||||
return;
|
||||
}
|
||||
|
||||
kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
|
||||
printf("multicast forwarding:\n");
|
||||
printf(" %10lu multicast forwarding cache lookup%s\n",
|
||||
mrtstat.mrt6s_mfc_lookups, plural(mrtstat.mrt6s_mfc_lookups));
|
||||
printf(" %10lu multicast forwarding cache miss%s\n",
|
||||
mrtstat.mrt6s_mfc_misses, plurales(mrtstat.mrt6s_mfc_misses));
|
||||
printf(" %10lu upcall%s to mrouted\n",
|
||||
mrtstat.mrt6s_upcalls, plural(mrtstat.mrt6s_upcalls));
|
||||
printf(" %10lu upcall queue overflow%s\n",
|
||||
mrtstat.mrt6s_upq_ovflw, plural(mrtstat.mrt6s_upq_ovflw));
|
||||
printf(" %10lu upcall%s dropped due to full socket buffer\n",
|
||||
mrtstat.mrt6s_upq_sockfull, plural(mrtstat.mrt6s_upq_sockfull));
|
||||
printf(" %10lu cache cleanup%s\n",
|
||||
mrtstat.mrt6s_cache_cleanups, plural(mrtstat.mrt6s_cache_cleanups));
|
||||
printf(" %10lu datagram%s with no route for origin\n",
|
||||
mrtstat.mrt6s_no_route, plural(mrtstat.mrt6s_no_route));
|
||||
printf(" %10lu datagram%s arrived with bad tunneling\n",
|
||||
mrtstat.mrt6s_bad_tunnel, plural(mrtstat.mrt6s_bad_tunnel));
|
||||
printf(" %10lu datagram%s could not be tunneled\n",
|
||||
mrtstat.mrt6s_cant_tunnel, plural(mrtstat.mrt6s_cant_tunnel));
|
||||
printf(" %10lu datagram%s arrived on wrong interface\n",
|
||||
mrtstat.mrt6s_wrong_if, plural(mrtstat.mrt6s_wrong_if));
|
||||
printf(" %10lu datagram%s selectively dropped\n",
|
||||
mrtstat.mrt6s_drop_sel, plural(mrtstat.mrt6s_drop_sel));
|
||||
printf(" %10lu datagram%s dropped due to queue overflow\n",
|
||||
mrtstat.mrt6s_q_overflow, plural(mrtstat.mrt6s_q_overflow));
|
||||
printf(" %10lu datagram%s dropped for being too large\n",
|
||||
mrtstat.mrt6s_pkt2large, plural(mrtstat.mrt6s_pkt2large));
|
||||
}
|
||||
#endif /*INET6*/
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: netstat.1,v 1.21 1999/03/22 18:16:40 garbled Exp $
|
||||
.\" $NetBSD: netstat.1,v 1.22 1999/07/01 18:40:36 itojun Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1983, 1990, 1992, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -309,6 +309,7 @@ The
|
||||
.Nm
|
||||
command appeared in
|
||||
.Bx 4.2 .
|
||||
IPv6 support was added by WIDE/KAME project.
|
||||
.\" .Sh FILES
|
||||
.\" .Bl -tag -width /dev/kmem -compact
|
||||
.\" .It Pa /netbsd
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: netstat.h,v 1.13 1999/02/27 17:37:25 sommerfe Exp $ */
|
||||
/* $NetBSD: netstat.h,v 1.14 1999/07/01 18:40:36 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -45,6 +45,7 @@ int dflag; /* show i/f dropped packets */
|
||||
int gflag; /* show group (multicast) routing or stats */
|
||||
#endif
|
||||
int iflag; /* show interfaces */
|
||||
int lflag; /* show routing table with use and ref */
|
||||
int mflag; /* show memory stats */
|
||||
int nflag; /* show addresses numerically */
|
||||
int Pflag; /* dump a PCB */
|
||||
@ -74,6 +75,22 @@ 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 *));
|
||||
#ifdef IPSEC
|
||||
void ipsec_stats __P((u_long, char *));
|
||||
#endif
|
||||
|
||||
#ifdef INET6
|
||||
void ip6protopr __P((u_long, char *));
|
||||
void tcp6_stats __P((u_long, char *));
|
||||
void tcp6_dump __P((u_long));
|
||||
void udp6_stats __P((u_long, char *));
|
||||
void ip6_stats __P((u_long, char *));
|
||||
void icmp6_stats __P((u_long, char *));
|
||||
void pim6_stats __P((u_long, char *));
|
||||
void mroute6pr __P((u_long, u_long, u_long));
|
||||
void mrt6_stats __P((u_long, u_long));
|
||||
char *routename6 __P((char *));
|
||||
#endif /*INET6*/
|
||||
|
||||
void mbpr(u_long, u_long, u_long, u_long, u_long);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: route.c,v 1.37 1999/04/02 20:13:40 chopps Exp $ */
|
||||
/* $NetBSD: route.c,v 1.38 1999/07/01 18:40:36 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1988, 1993
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: route.c,v 1.37 1999/04/02 20:13:40 chopps Exp $");
|
||||
__RCSID("$NetBSD: route.c,v 1.38 1999/07/01 18:40:36 itojun Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -62,6 +62,8 @@ __RCSID("$NetBSD: route.c,v 1.37 1999/04/02 20:13:40 chopps Exp $");
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
@ -110,6 +112,7 @@ static union sockaddr_union {
|
||||
struct sockaddr_dl u_dl;
|
||||
struct sockaddr_ns u_ns;
|
||||
u_short u_data[128];
|
||||
int u_dummy; /* force word-alignment */
|
||||
} pt_u;
|
||||
|
||||
int do_rtent = 0;
|
||||
@ -131,6 +134,10 @@ static void p_rtentry __P((struct rtentry *));
|
||||
static void ntreestuff __P((void));
|
||||
static u_long forgemask __P((u_long));
|
||||
static void domask __P((char *, size_t, u_long, u_long));
|
||||
#ifdef INET6
|
||||
char *netname6 __P((struct in6_addr *, struct in6_addr *));
|
||||
static char ntop_buf[INET6_ADDRSTRLEN];
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Print routing tables.
|
||||
@ -185,6 +192,11 @@ pr_family(af)
|
||||
case AF_INET:
|
||||
afname = "Internet";
|
||||
break;
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
afname = "Internet6";
|
||||
break;
|
||||
#endif
|
||||
case AF_NS:
|
||||
afname = "XNS";
|
||||
break;
|
||||
@ -208,8 +220,13 @@ pr_family(af)
|
||||
}
|
||||
|
||||
/* column widths; each followed by one space */
|
||||
#ifndef INET6
|
||||
#define WID_DST 18 /* width of destination column */
|
||||
#define WID_GW 18 /* width of gateway column */
|
||||
#else
|
||||
#define WID_DST (nflag ? 28 : 18) /* width of destination column */
|
||||
#define WID_GW (nflag ? 26 : 18) /* width of gateway column */
|
||||
#endif /* INET6 */
|
||||
|
||||
/*
|
||||
* Print header for routing table columns.
|
||||
@ -407,6 +424,23 @@ p_sockaddr(sa, mask, flags, width)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
struct in6_addr *in6 = &((struct sockaddr_in6 *)sa)->sin6_addr;
|
||||
|
||||
if (flags & RTF_HOST)
|
||||
cp = routename6((char *)in6);
|
||||
else if (mask) {
|
||||
cp = netname6(in6,
|
||||
&((struct sockaddr_in6 *)mask)->sin6_addr);
|
||||
} else
|
||||
cp = (char *)inet_ntop(AF_INET6, in6, ntop_buf,
|
||||
sizeof(ntop_buf));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef SMALL
|
||||
case AF_APPLETALK:
|
||||
case 0:
|
||||
@ -525,11 +559,13 @@ p_rtentry(rt)
|
||||
union sockaddr_union addr_un, mask_un;
|
||||
struct sockaddr *addr, *mask;
|
||||
|
||||
memset(&addr_un, 0, sizeof(addr_un));
|
||||
memset(&mask_un, 0, sizeof(mask_un));
|
||||
addr = sockcopy(kgetsa(rt_key(rt)), &addr_un);
|
||||
if (rt_mask(rt))
|
||||
mask = sockcopy(kgetsa(rt_mask(rt)), &mask_un);
|
||||
else
|
||||
mask = sockcopy(0, &mask_un);
|
||||
mask = sockcopy(NULL, &mask_un);
|
||||
p_sockaddr(addr, mask, rt->rt_flags, WID_DST);
|
||||
p_sockaddr(kgetsa(rt->rt_gateway), NULL, RTF_HOST, WID_GW);
|
||||
p_flags(rt->rt_flags, "%-6.6s ");
|
||||
@ -729,6 +765,96 @@ netname(in, mask)
|
||||
return (line);
|
||||
}
|
||||
|
||||
#ifdef INET6
|
||||
char *
|
||||
netname6(in6, mask)
|
||||
struct in6_addr *in6;
|
||||
struct in6_addr *mask;
|
||||
{
|
||||
static char line[MAXHOSTNAMELEN + 1];
|
||||
struct in6_addr net6;
|
||||
u_char *p;
|
||||
u_char *lim;
|
||||
int masklen, final = 0, illegal = 0;
|
||||
|
||||
net6 = *in6;
|
||||
net6.s6_addr32[0] &= mask->s6_addr32[0];
|
||||
net6.s6_addr32[1] &= mask->s6_addr32[1];
|
||||
net6.s6_addr32[2] &= mask->s6_addr32[2];
|
||||
net6.s6_addr32[3] &= mask->s6_addr32[3];
|
||||
|
||||
masklen = 0;
|
||||
lim = (u_char *)mask + 16;
|
||||
for (p = (u_char *)mask; p < lim; p++) {
|
||||
if (final && *p) {
|
||||
illegal++;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (*p & 0xff) {
|
||||
case 0xff:
|
||||
masklen += 8;
|
||||
break;
|
||||
case 0xfe:
|
||||
masklen += 7;
|
||||
final++;
|
||||
break;
|
||||
case 0xfc:
|
||||
masklen += 6;
|
||||
final++;
|
||||
break;
|
||||
case 0xf8:
|
||||
masklen += 5;
|
||||
final++;
|
||||
break;
|
||||
case 0xf0:
|
||||
masklen += 4;
|
||||
final++;
|
||||
break;
|
||||
case 0xe0:
|
||||
masklen += 3;
|
||||
final++;
|
||||
break;
|
||||
case 0xc0:
|
||||
masklen += 2;
|
||||
final++;
|
||||
break;
|
||||
case 0x80:
|
||||
masklen += 1;
|
||||
final++;
|
||||
break;
|
||||
case 0x00:
|
||||
final++;
|
||||
break;
|
||||
default:
|
||||
final++;
|
||||
illegal++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(in6))
|
||||
return("default");
|
||||
|
||||
if (illegal)
|
||||
fprintf(stderr, "illegal prefixlen\n");
|
||||
sprintf(line, "%s/%d", inet_ntop(AF_INET6, &net6, ntop_buf,
|
||||
sizeof(ntop_buf)),
|
||||
masklen);
|
||||
return line;
|
||||
}
|
||||
|
||||
char *
|
||||
routename6(in6)
|
||||
char *in6;
|
||||
{
|
||||
static char line[MAXHOSTNAMELEN + 1];
|
||||
sprintf(line, "%s", inet_ntop(AF_INET6, in6, ntop_buf,
|
||||
sizeof(ntop_buf)));
|
||||
return line;
|
||||
}
|
||||
#endif /*INET6*/
|
||||
|
||||
/*
|
||||
* Print routing statistics
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user