summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2001-02-07 11:43:56 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2001-02-07 11:43:56 +0000
commitab68204e67acf8f6cd003849586aeaa58289360f (patch)
tree87b1cb0f893deffd42f895d53965d05f091332f0 /usr.bin
parentb23bfb5222ff0818eb8adf909ff2d781c2ade312 (diff)
by default, don't bark on inbound ND messages, as outsider may be able to
fill up /var with bogus packets. setting net.inet6.icmp6.nd6_debug will re-enable kernel messages on invalid ND packet and other occasions. improve icmp6 stats.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/netstat/inet6.c319
1 files changed, 174 insertions, 145 deletions
diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c
index 34d425484f0..596632d1276 100644
--- a/usr.bin/netstat/inet6.c
+++ b/usr.bin/netstat/inet6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet6.c,v 1.13 2000/12/11 17:53:29 itojun Exp $ */
+/* $OpenBSD: inet6.c,v 1.14 2001/02/07 11:43:50 itojun Exp $ */
/* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */
/*
* Copyright (c) 1983, 1988, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)inet.c 8.4 (Berkeley) 4/20/94";
#else
-/*__RCSID("$OpenBSD: inet6.c,v 1.13 2000/12/11 17:53:29 itojun Exp $");*/
+/*__RCSID("$OpenBSD: inet6.c,v 1.14 2001/02/07 11:43:50 itojun Exp $");*/
/*__RCSID("KAME Id: inet6.c,v 1.10 2000/02/09 10:49:31 itojun Exp");*/
#endif
#endif /* not lint */
@@ -351,6 +351,8 @@ ip6_stats(off, name)
{
struct ip6stat ip6stat;
int first, i;
+ struct protoent *ep;
+ const char *n;
if (off == 0)
return;
@@ -359,44 +361,55 @@ ip6_stats(off, name)
printf("%s:\n", name);
#define p(f, m) if (ip6stat.f || sflag <= 1) \
- printf(m, ip6stat.f, plural(ip6stat.f))
+ printf(m, (unsigned long long)ip6stat.f, plural(ip6stat.f))
#define p1(f, m) if (ip6stat.f || sflag <= 1) \
- printf(m, ip6stat.f)
+ printf(m, (unsigned long long)ip6stat.f)
- p(ip6s_total, "\t%qu total packet%s received\n");
- p1(ip6s_toosmall, "\t%qu with size smaller than minimum\n");
- p1(ip6s_tooshort, "\t%qu with data size < data length\n");
- p1(ip6s_badoptions, "\t%qu with bad options\n");
- p1(ip6s_badvers, "\t%qu with incorrect version number\n");
- p(ip6s_fragments, "\t%qu fragment%s received\n");
- p(ip6s_fragdropped, "\t%qu fragment%s dropped (dup or out of space)\n");
- p(ip6s_fragtimeout, "\t%qu fragment%s dropped after timeout\n");
- p(ip6s_fragoverflow, "\t%qu fragment%s that exceeded limit\n");
- p(ip6s_reassembled, "\t%qu packet%s reassembled ok\n");
- p(ip6s_delivered, "\t%qu packet%s for this host\n");
- p(ip6s_forward, "\t%qu packet%s forwarded\n");
- p(ip6s_cantforward, "\t%qu packet%s not forwardable\n");
- p(ip6s_redirectsent, "\t%qu redirect%s sent\n");
- p(ip6s_localout, "\t%qu packet%s sent from this host\n");
- p(ip6s_rawout, "\t%qu packet%s sent with fabricated ip header\n");
- p(ip6s_odropped, "\t%qu output packet%s dropped due to no bufs, etc.\n");
- p(ip6s_noroute, "\t%qu output packet%s discarded due to no route\n");
- p(ip6s_fragmented, "\t%qu output datagram%s fragmented\n");
- p(ip6s_ofragments, "\t%qu fragment%s created\n");
- p(ip6s_cantfrag, "\t%qu datagram%s that can't be fragmented\n");
- p(ip6s_badscope, "\t%qu packet%s that violated scope rules\n");
- p(ip6s_notmember, "\t%qu multicast packet%s which we don't join\n");
+ p(ip6s_total, "\t%llu total packet%s received\n");
+ p1(ip6s_toosmall, "\t%llu with size smaller than minimum\n");
+ p1(ip6s_tooshort, "\t%llu with data size < data length\n");
+ p1(ip6s_badoptions, "\t%llu with bad options\n");
+ p1(ip6s_badvers, "\t%llu with incorrect version number\n");
+ p(ip6s_fragments, "\t%llu fragment%s received\n");
+ p(ip6s_fragdropped,
+ "\t%llu fragment%s dropped (dup or out of space)\n");
+ p(ip6s_fragtimeout, "\t%llu fragment%s dropped after timeout\n");
+ p(ip6s_fragoverflow, "\t%llu fragment%s that exceeded limit\n");
+ p(ip6s_reassembled, "\t%llu packet%s reassembled ok\n");
+ p(ip6s_delivered, "\t%llu packet%s for this host\n");
+ p(ip6s_forward, "\t%llu packet%s forwarded\n");
+ p(ip6s_cantforward, "\t%llu packet%s not forwardable\n");
+ p(ip6s_redirectsent, "\t%llu redirect%s sent\n");
+ p(ip6s_localout, "\t%llu packet%s sent from this host\n");
+ p(ip6s_rawout, "\t%llu packet%s sent with fabricated ip header\n");
+ p(ip6s_odropped,
+ "\t%llu output packet%s dropped due to no bufs, etc.\n");
+ p(ip6s_noroute, "\t%llu output packet%s discarded due to no route\n");
+ p(ip6s_fragmented, "\t%llu output datagram%s fragmented\n");
+ p(ip6s_ofragments, "\t%llu fragment%s created\n");
+ p(ip6s_cantfrag, "\t%llu datagram%s that can't be fragmented\n");
+ p(ip6s_badscope, "\t%llu packet%s that violated scope rules\n");
+ p(ip6s_notmember, "\t%llu multicast packet%s which we don't join\n");
for (first = 1, i = 0; i < 256; i++)
if (ip6stat.ip6s_nxthist[i] != 0) {
if (first) {
printf("\tInput packet histogram:\n");
first = 0;
}
- printf("\t\t%s: %qu\n", ip6nh[i],
- ip6stat.ip6s_nxthist[i]);
+ n = NULL;
+ if (ip6nh[i])
+ n = ip6nh[i];
+ else if ((ep = getprotobynumber(i)) != NULL)
+ n = ep->p_name;
+ if (n)
+ printf("\t\t%s: %llu\n", n,
+ (unsigned long long)ip6stat.ip6s_nxthist[i]);
+ else
+ printf("\t\t#%d: %llu\n", i,
+ (unsigned long long)ip6stat.ip6s_nxthist[i]);
}
printf("\tMbuf statistics:\n");
- p(ip6s_m1, "\t\t%qu one mbuf%s\n");
+ p(ip6s_m1, "\t\t%llu one mbuf%s\n");
for (first = 1, i = 0; i < 32; i++) {
char ifbuf[IFNAMSIZ];
if (ip6stat.ip6s_m2m[i] != 0) {
@@ -404,40 +417,42 @@ ip6_stats(off, name)
printf("\t\ttwo or more mbuf:\n");
first = 0;
}
- printf("\t\t\t%s = %qu\n",
+ printf("\t\t\t%s = %llu\n",
if_indextoname(i, ifbuf),
- ip6stat.ip6s_m2m[i]);
+ (unsigned long long)ip6stat.ip6s_m2m[i]);
}
}
- p(ip6s_mext1, "\t\t%qu one ext mbuf%s\n");
- p(ip6s_mext2m, "\t\t%qu two or more ext mbuf%s\n");
- p(ip6s_exthdrtoolong, "\t%qu packet%s whose headers are not continuous\n");
- p(ip6s_nogif, "\t%qu tunneling packet%s that can't find gif\n");
- p(ip6s_toomanyhdr, "\t%qu packet%s discarded due to too many headers\n");
+ p(ip6s_mext1, "\t\t%llu one ext mbuf%s\n");
+ p(ip6s_mext2m, "\t\t%llu two or more ext mbuf%s\n");
+ p(ip6s_exthdrtoolong,
+ "\t%llu packet%s whose headers are not continuous\n");
+ p(ip6s_nogif, "\t%llu tunneling packet%s that can't find gif\n");
+ p(ip6s_toomanyhdr,
+ "\t%llu packet%s discarded due to too many headers\n");
/* for debugging source address selection */
#define PRINT_SCOPESTAT(s,i) do {\
switch(i) { /* XXX hardcoding in each case */\
case 1:\
- p(s, "\t\t%qu node-local%s\n");\
+ p(s, "\t\t%llu node-local%s\n");\
break;\
case 2:\
- p(s,"\t\t%qu link-local%s\n");\
+ p(s, "\t\t%llu link-local%s\n");\
break;\
case 5:\
- p(s,"\t\t%qu site-local%s\n");\
+ p(s, "\t\t%llu site-local%s\n");\
break;\
case 14:\
- p(s,"\t\t%qu global%s\n");\
+ p(s, "\t\t%llu global%s\n");\
break;\
default:\
- printf("\t\t%qu addresses scope=%x\n",\
- ip6stat.s, i);\
+ printf("\t\t%llu addresses scope=%x\n",\
+ (unsigned long long)ip6stat.s, i);\
}\
} while(0);
p(ip6s_sources_none,
- "\t%qu failure%s of source address selection\n");
+ "\t%llu failure%s of source address selection\n");
for (first = 1, i = 0; i < 16; i++) {
if (ip6stat.ip6s_sources_sameif[i]) {
if (first) {
@@ -500,9 +515,10 @@ ip6_ifstats(ifname)
struct in6_ifreq ifr;
int s;
#define p(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \
- printf(m, ifr.ifr_ifru.ifru_stat.f, plural(ifr.ifr_ifru.ifru_stat.f))
+ printf(m, (unsigned long long)ifr.ifr_ifru.ifru_stat.f, \
+ plural(ifr.ifr_ifru.ifru_stat.f))
#define p_5(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \
- printf(m, ip6stat.f)
+ printf(m, (unsigned long long)ip6stat.f)
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
perror("Warning: socket(AF_INET6)");
@@ -517,27 +533,28 @@ ip6_ifstats(ifname)
goto end;
}
- p(ifs6_in_receive, "\t%qu total input datagram%s\n");
- p(ifs6_in_hdrerr, "\t%qu datagram%s with invalid header received\n");
- p(ifs6_in_toobig, "\t%qu datagram%s exceeded MTU received\n");
- p(ifs6_in_noroute, "\t%qu datagram%s with no route received\n");
- p(ifs6_in_addrerr, "\t%qu datagram%s with invalid dst received\n");
- p(ifs6_in_protounknown, "\t%qu datagram%s with unknown proto received\n");
- p(ifs6_in_discard, "\t%qu input datagram%s discarded\n");
+ p(ifs6_in_receive, "\t%llu total input datagram%s\n");
+ p(ifs6_in_hdrerr, "\t%llu datagram%s with invalid header received\n");
+ p(ifs6_in_toobig, "\t%llu datagram%s exceeded MTU received\n");
+ p(ifs6_in_noroute, "\t%llu datagram%s with no route received\n");
+ p(ifs6_in_addrerr, "\t%llu datagram%s with invalid dst received\n");
+ p(ifs6_in_truncated, "\t%llu truncated datagram%s received\n");
+ p(ifs6_in_protounknown, "\t%llu datagram%s with unknown proto received\n");
+ p(ifs6_in_discard, "\t%llu input datagram%s discarded\n");
p(ifs6_in_deliver,
- "\t%qu datagram%s delivered to an upper layer protocol\n");
- p(ifs6_out_forward, "\t%qu datagram%s forwarded to this interface\n");
+ "\t%llu datagram%s delivered to an upper layer protocol\n");
+ p(ifs6_out_forward, "\t%llu datagram%s forwarded to this interface\n");
p(ifs6_out_request,
- "\t%qu datagram%s sent from an upper layer protocol\n");
- p(ifs6_out_discard, "\t%qu total discarded output datagram%s\n");
- p(ifs6_out_fragok, "\t%qu output datagram%s fragmented\n");
- p(ifs6_out_fragfail, "\t%qu output datagram%s failed on fragment\n");
- p(ifs6_out_fragcreat, "\t%qu output datagram%s succeeded on fragment\n");
- p(ifs6_reass_reqd, "\t%qu incoming datagram%s fragmented\n");
- p(ifs6_reass_ok, "\t%qu datagram%s reassembled\n");
- p(ifs6_reass_fail, "\t%qu datagram%s failed on reassembling\n");
- p(ifs6_in_mcast, "\t%qu multicast datagram%s received\n");
- p(ifs6_out_mcast, "\t%qu multicast datagram%s sent\n");
+ "\t%llu datagram%s sent from an upper layer protocol\n");
+ p(ifs6_out_discard, "\t%llu total discarded output datagram%s\n");
+ p(ifs6_out_fragok, "\t%llu output datagram%s fragmented\n");
+ p(ifs6_out_fragfail, "\t%llu output datagram%s failed on fragment\n");
+ p(ifs6_out_fragcreat, "\t%llu output datagram%s succeeded on fragment\n");
+ p(ifs6_reass_reqd, "\t%llu incoming datagram%s fragmented\n");
+ p(ifs6_reass_ok, "\t%llu datagram%s reassembled\n");
+ p(ifs6_reass_fail, "\t%llu datagram%s failed on reassembling\n");
+ p(ifs6_in_mcast, "\t%llu multicast datagram%s received\n");
+ p(ifs6_out_mcast, "\t%llu multicast datagram%s sent\n");
end:
close(s);
@@ -822,57 +839,63 @@ icmp6_stats(off, name)
printf("%s:\n", name);
#define p(f, m) if (icmp6stat.f || sflag <= 1) \
- printf(m, icmp6stat.f, plural(icmp6stat.f))
+ printf(m, (unsigned long long)icmp6stat.f, plural(icmp6stat.f))
#define p_5(f, m) if (icmp6stat.f || sflag <= 1) \
- printf(m, icmp6stat.f)
+ printf(m, (unsigned long long)icmp6stat.f)
- p(icp6s_error, "\t%qu call%s to icmp6_error\n");
+ p(icp6s_error, "\t%llu call%s to icmp6_error\n");
p(icp6s_canterror,
- "\t%qu error%s not generated because old message was icmp6 or so\n");
+ "\t%llu error%s not generated because old message was icmp6 or so\n");
p(icp6s_toofreq,
- "\t%qu error%s not generated because of rate limitation\n");
+ "\t%llu error%s not generated because of rate limitation\n");
for (first = 1, i = 0; i < 256; i++)
if (icmp6stat.icp6s_outhist[i] != 0) {
if (first) {
printf("\tOutput packet histogram:\n");
first = 0;
}
- printf("\t\t%s: %qu\n", icmp6names[i],
- icmp6stat.icp6s_outhist[i]);
+ printf("\t\t%s: %llu\n", icmp6names[i],
+ (unsigned long long)icmp6stat.icp6s_outhist[i]);
}
- p(icp6s_badcode, "\t%qu message%s with bad code fields\n");
- p(icp6s_tooshort, "\t%qu message%s < minimum length\n");
- p(icp6s_checksum, "\t%qu bad checksum%s\n");
- p(icp6s_badlen, "\t%qu message%s with bad length\n");
+ p(icp6s_badcode, "\t%llu message%s with bad code fields\n");
+ p(icp6s_tooshort, "\t%llu message%s < minimum length\n");
+ p(icp6s_checksum, "\t%llu bad checksum%s\n");
+ p(icp6s_badlen, "\t%llu message%s with bad length\n");
for (first = 1, i = 0; i < ICMP6_MAXTYPE; i++)
if (icmp6stat.icp6s_inhist[i] != 0) {
if (first) {
printf("\tInput packet histogram:\n");
first = 0;
}
- printf("\t\t%s: %qu\n", icmp6names[i],
- icmp6stat.icp6s_inhist[i]);
+ printf("\t\t%s: %llu\n", icmp6names[i],
+ (unsigned long long)icmp6stat.icp6s_inhist[i]);
}
printf("\tHistogram of error messages to be generated:\n");
- p_5(icp6s_odst_unreach_noroute, "\t\t%qu no route\n");
- p_5(icp6s_odst_unreach_admin, "\t\t%qu administratively prohibited\n");
- p_5(icp6s_odst_unreach_beyondscope, "\t\t%qu beyond scope\n");
- p_5(icp6s_odst_unreach_addr, "\t\t%qu address unreachable\n");
- p_5(icp6s_odst_unreach_noport, "\t\t%qu port unreachable\n");
- p_5(icp6s_opacket_too_big, "\t\t%qu packet too big\n");
- p_5(icp6s_otime_exceed_transit, "\t\t%qu time exceed transit\n");
- p_5(icp6s_otime_exceed_reassembly, "\t\t%qu time exceed reassembly\n");
- p_5(icp6s_oparamprob_header, "\t\t%qu erroneous header field\n");
- p_5(icp6s_oparamprob_nextheader, "\t\t%qu unrecognized next header\n");
- p_5(icp6s_oparamprob_option, "\t\t%qu unrecognized option\n");
- p_5(icp6s_oredirect, "\t\t%qu redirect\n");
- p_5(icp6s_ounknown, "\t\t%qu unknown\n");
+ p_5(icp6s_odst_unreach_noroute, "\t\t%llu no route\n");
+ p_5(icp6s_odst_unreach_admin, "\t\t%llu administratively prohibited\n");
+ p_5(icp6s_odst_unreach_beyondscope, "\t\t%llu beyond scope\n");
+ p_5(icp6s_odst_unreach_addr, "\t\t%llu address unreachable\n");
+ p_5(icp6s_odst_unreach_noport, "\t\t%llu port unreachable\n");
+ p_5(icp6s_opacket_too_big, "\t\t%llu packet too big\n");
+ p_5(icp6s_otime_exceed_transit, "\t\t%llu time exceed transit\n");
+ p_5(icp6s_otime_exceed_reassembly, "\t\t%llu time exceed reassembly\n");
+ p_5(icp6s_oparamprob_header, "\t\t%llu erroneous header field\n");
+ p_5(icp6s_oparamprob_nextheader, "\t\t%llu unrecognized next header\n");
+ p_5(icp6s_oparamprob_option, "\t\t%llu unrecognized option\n");
+ p_5(icp6s_oredirect, "\t\t%llu redirect\n");
+ p_5(icp6s_ounknown, "\t\t%llu unknown\n");
- p(icp6s_reflect, "\t%qu message response%s generated\n");
- p(icp6s_nd_toomanyopt, "\t%qu message%s with too many ND options\n");
+ 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%llu message%s with bad ND options\n");
+ p(icp6s_badns, "\t%llu bad neighbor solicitation message%s\n");
+ p(icp6s_badna, "\t%llu bad neighbor advertisement message%s\n");
+ p(icp6s_badrs, "\t%llu bad router solicitation message%s\n");
+ p(icp6s_badra, "\t%llu bad router advertisement message%s\n");
+ p(icp6s_badredirect, "\t%llu bad redirect message%s\n");
p(icp6s_pmtuchg, "\t%llu path MTU change%s\n");
-#undef p_5
#undef p
+#undef p_5
}
/*
@@ -885,7 +908,8 @@ icmp6_ifstats(ifname)
struct in6_ifreq ifr;
int s;
#define p(f, m) if (ifr.ifr_ifru.ifru_icmp6stat.f || sflag <= 1) \
- printf(m, (u_quad_t)ifr.ifr_ifru.ifru_icmp6stat.f, plural(ifr.ifr_ifru.ifru_icmp6stat.f))
+ printf(m, (unsigned long long)ifr.ifr_ifru.ifru_icmp6stat.f, \
+ plural(ifr.ifr_ifru.ifru_icmp6stat.f))
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
perror("Warning: socket(AF_INET6)");
@@ -900,41 +924,41 @@ icmp6_ifstats(ifname)
goto end;
}
- p(ifs6_in_msg, "\t%qu total input message%s\n");
- p(ifs6_in_error, "\t%qu total input error message%s\n");
- p(ifs6_in_dstunreach, "\t%qu input destination unreachable error%s\n");
- p(ifs6_in_adminprohib, "\t%qu input administratively prohibited error%s\n");
- p(ifs6_in_timeexceed, "\t%qu input time exceeded error%s\n");
- p(ifs6_in_paramprob, "\t%qu input parameter problem error%s\n");
- p(ifs6_in_pkttoobig, "\t%qu input packet too big error%s\n");
- p(ifs6_in_echo, "\t%qu input echo request%s\n");
- p(ifs6_in_echoreply, "\t%qu input echo reply%s\n");
- p(ifs6_in_routersolicit, "\t%qu input router solicitation%s\n");
- p(ifs6_in_routeradvert, "\t%qu input router advertisement%s\n");
- p(ifs6_in_neighborsolicit, "\t%qu input neighbor solicitation%s\n");
- p(ifs6_in_neighboradvert, "\t%qu input neighbor advertisement%s\n");
- p(ifs6_in_redirect, "\t%qu input redirect%s\n");
- p(ifs6_in_mldquery, "\t%qu input MLD query%s\n");
- p(ifs6_in_mldreport, "\t%qu input MLD report%s\n");
- p(ifs6_in_mlddone, "\t%qu input MLD done%s\n");
+ p(ifs6_in_msg, "\t%llu total input message%s\n");
+ p(ifs6_in_error, "\t%llu total input error message%s\n");
+ p(ifs6_in_dstunreach, "\t%llu input destination unreachable error%s\n");
+ p(ifs6_in_adminprohib, "\t%llu input administratively prohibited error%s\n");
+ p(ifs6_in_timeexceed, "\t%llu input time exceeded error%s\n");
+ p(ifs6_in_paramprob, "\t%llu input parameter problem error%s\n");
+ p(ifs6_in_pkttoobig, "\t%llu input packet too big error%s\n");
+ p(ifs6_in_echo, "\t%llu input echo request%s\n");
+ p(ifs6_in_echoreply, "\t%llu input echo reply%s\n");
+ p(ifs6_in_routersolicit, "\t%llu input router solicitation%s\n");
+ p(ifs6_in_routeradvert, "\t%llu input router advertisement%s\n");
+ p(ifs6_in_neighborsolicit, "\t%llu input neighbor solicitation%s\n");
+ p(ifs6_in_neighboradvert, "\t%llu input neighbor advertisement%s\n");
+ p(ifs6_in_redirect, "\t%llu input redirect%s\n");
+ p(ifs6_in_mldquery, "\t%llu input MLD query%s\n");
+ p(ifs6_in_mldreport, "\t%llu input MLD report%s\n");
+ p(ifs6_in_mlddone, "\t%llu input MLD done%s\n");
- p(ifs6_out_msg, "\t%qu total output message%s\n");
- p(ifs6_out_error, "\t%qu total output error message%s\n");
- p(ifs6_out_dstunreach, "\t%qu output destination unreachable error%s\n");
- p(ifs6_out_adminprohib, "\t%qu output administratively prohibited error%s\n");
- p(ifs6_out_timeexceed, "\t%qu output time exceeded error%s\n");
- p(ifs6_out_paramprob, "\t%qu output parameter problem error%s\n");
- p(ifs6_out_pkttoobig, "\t%qu output packet too big error%s\n");
- p(ifs6_out_echo, "\t%qu output echo request%s\n");
- p(ifs6_out_echoreply, "\t%qu output echo reply%s\n");
- p(ifs6_out_routersolicit, "\t%qu output router solicitation%s\n");
- p(ifs6_out_routeradvert, "\t%qu output router advertisement%s\n");
- p(ifs6_out_neighborsolicit, "\t%qu output neighbor solicitation%s\n");
- p(ifs6_out_neighboradvert, "\t%qu output neighbor advertisement%s\n");
- p(ifs6_out_redirect, "\t%qu output redirect%s\n");
- p(ifs6_out_mldquery, "\t%qu output MLD query%s\n");
- p(ifs6_out_mldreport, "\t%qu output MLD report%s\n");
- p(ifs6_out_mlddone, "\t%qu output MLD done%s\n");
+ p(ifs6_out_msg, "\t%llu total output message%s\n");
+ p(ifs6_out_error, "\t%llu total output error message%s\n");
+ p(ifs6_out_dstunreach, "\t%llu output destination unreachable error%s\n");
+ p(ifs6_out_adminprohib, "\t%llu output administratively prohibited error%s\n");
+ p(ifs6_out_timeexceed, "\t%llu output time exceeded error%s\n");
+ p(ifs6_out_paramprob, "\t%llu output parameter problem error%s\n");
+ p(ifs6_out_pkttoobig, "\t%llu output packet too big error%s\n");
+ p(ifs6_out_echo, "\t%llu output echo request%s\n");
+ p(ifs6_out_echoreply, "\t%llu output echo reply%s\n");
+ p(ifs6_out_routersolicit, "\t%llu output router solicitation%s\n");
+ p(ifs6_out_routeradvert, "\t%llu output router advertisement%s\n");
+ p(ifs6_out_neighborsolicit, "\t%llu output neighbor solicitation%s\n");
+ p(ifs6_out_neighboradvert, "\t%llu output neighbor advertisement%s\n");
+ p(ifs6_out_redirect, "\t%llu output redirect%s\n");
+ p(ifs6_out_mldquery, "\t%llu output MLD query%s\n");
+ p(ifs6_out_mldreport, "\t%llu output MLD report%s\n");
+ p(ifs6_out_mlddone, "\t%llu output MLD done%s\n");
end:
close(s);
@@ -957,14 +981,14 @@ pim6_stats(off, name)
printf("%s:\n", name);
#define p(f, m) if (pim6stat.f || sflag <= 1) \
- printf(m, pim6stat.f, plural(pim6stat.f))
- p(pim6s_rcv_total, "\t%qu message%s received\n");
- p(pim6s_rcv_tooshort, "\t%qu message%s received with too few bytes\n");
- p(pim6s_rcv_badsum, "\t%qu message%s received with bad checksum\n");
- p(pim6s_rcv_badversion, "\t%qu message%s received with bad version\n");
- p(pim6s_rcv_registers, "\t%qu register%s received\n");
- p(pim6s_rcv_badregisters, "\t%qu bad register%s received\n");
- p(pim6s_snd_registers, "\t%qu register%s sent\n");
+ printf(m, (unsigned long long)pim6stat.f, plural(pim6stat.f))
+ p(pim6s_rcv_total, "\t%llu message%s received\n");
+ p(pim6s_rcv_tooshort, "\t%llu message%s received with too few bytes\n");
+ p(pim6s_rcv_badsum, "\t%llu message%s received with bad checksum\n");
+ p(pim6s_rcv_badversion, "\t%llu message%s received with bad version\n");
+ p(pim6s_rcv_registers, "\t%llu register%s received\n");
+ p(pim6s_rcv_badregisters, "\t%llu bad register%s received\n");
+ p(pim6s_snd_registers, "\t%llu register%s sent\n");
#undef p
}
@@ -980,19 +1004,22 @@ inet6print(in6, port, proto)
char *proto;
{
#define GETSERVBYPORT6(port, proto, ret)\
-{\
+do {\
if (strcmp((proto), "tcp6") == 0)\
(ret) = getservbyport((int)(port), "tcp");\
else if (strcmp((proto), "udp6") == 0)\
(ret) = getservbyport((int)(port), "udp");\
else\
(ret) = getservbyport((int)(port), (proto));\
-};
+} while (0)
struct servent *sp = 0;
char line[80], *cp;
int width;
- sprintf(line, "%.*s.", (Aflag && !nflag) ? 12 : 16, inet6name(in6));
+ width = Aflag ? 12 : 16;
+ if (vflag && width < strlen(inet6name(in6)))
+ width = strlen(inet6name(in6));
+ sprintf(line, "%.*s.", width, inet6name(in6));
cp = index(line, '\0');
if (!nflag && port)
GETSERVBYPORT6(port, proto, sp);
@@ -1001,6 +1028,8 @@ inet6print(in6, port, proto)
else
sprintf(cp, "%d", ntohs((u_short)port));
width = Aflag ? 18 : 22;
+ if (vflag && width < strlen(line))
+ width = strlen(line);
printf(" %-*.*s", width, width, line);
}
@@ -1015,11 +1044,11 @@ inet6name(in6p)
struct in6_addr *in6p;
{
register char *cp;
- static char line[50];
+ static char line[NI_MAXHOST];
struct hostent *hp;
static char domain[MAXHOSTNAMELEN + 1];
static int first = 1;
- static char hbuf[NI_MAXHOST];
+ char hbuf[NI_MAXHOST];
struct sockaddr_in6 sin6;
#ifdef NI_WITHSCOPEID
const int niflag = NI_NUMERICHOST | NI_WITHSCOPEID;
@@ -1046,9 +1075,9 @@ inet6name(in6p)
}
}
if (IN6_IS_ADDR_UNSPECIFIED(in6p))
- strcpy(line, "*");
+ strlcpy(line, "*", sizeof(line));
else if (cp)
- strcpy(line, cp);
+ strlcpy(line, cp, sizeof(line));
else {
memset(&sin6, 0, sizeof(sin6));
sin6.sin6_len = sizeof(sin6);
@@ -1065,7 +1094,7 @@ inet6name(in6p)
if (getnameinfo((struct sockaddr *)&sin6, sin6.sin6_len,
hbuf, sizeof(hbuf), NULL, 0, niflag) != 0)
strcpy(hbuf, "?");
- strncpy(line, hbuf, sizeof(line));
+ strlcpy(line, hbuf, sizeof(line));
}
return (line);
}