diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-27 01:50:37 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-27 01:50:37 +0000 |
commit | 57f7b372da8f4a0a182066821a43e3422d5d3a86 (patch) | |
tree | 0511034d11a2564cecbf2743a118a0f7266b0d5e /usr.bin/netstat/inet.c | |
parent | 69c9d9d8ef901dadbc090699751edbd20f6afed7 (diff) |
a night of cleanup, so i can read this easier
Diffstat (limited to 'usr.bin/netstat/inet.c')
-rw-r--r-- | usr.bin/netstat/inet.c | 85 |
1 files changed, 42 insertions, 43 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 462c6561600..fa83863ac06 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet.c,v 1.59 2002/05/16 14:18:34 kjc Exp $ */ +/* $OpenBSD: inet.c,v 1.60 2002/05/27 01:50:36 deraadt 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.59 2002/05/16 14:18:34 kjc Exp $"; +static char *rcsid = "$OpenBSD: inet.c,v 1.60 2002/05/27 01:50:36 deraadt Exp $"; #endif #endif /* not lint */ @@ -203,8 +203,8 @@ protopr0(off, name, af) } #ifdef INET6 if (inpcb.inp_flags & INP_IPV6) { - strcpy(namebuf, name0); - strcat(namebuf, "6"); + strlcpy(namebuf, name0, sizeof namebuf); + strlcat(namebuf, "6", sizeof namebuf); name = namebuf; } else name = name0; @@ -251,24 +251,24 @@ tcp_stats(off, name) kread(off, (char *)&tcpstat, sizeof (tcpstat)); #define p(f, m) if (tcpstat.f || sflag <= 1) \ - printf(m, tcpstat.f, plural(tcpstat.f)) + printf(m, tcpstat.f, plural(tcpstat.f)) #define p1(f, m) if (tcpstat.f || sflag <= 1) \ - printf(m, tcpstat.f) + printf(m, tcpstat.f) #define p2(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \ - printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2, plural(tcpstat.f2)) + printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2, plural(tcpstat.f2)) #define p2a(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \ - printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2) + printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2) #define p3(f, m) if (tcpstat.f || sflag <= 1) \ - printf(m, tcpstat.f, plurales(tcpstat.f)) + printf(m, tcpstat.f, plurales(tcpstat.f)) p(tcps_sndtotal, "\t%u packet%s sent\n"); p2(tcps_sndpack,tcps_sndbyte, - "\t\t%u data packet%s (%qd byte%s)\n"); + "\t\t%u data packet%s (%qd byte%s)\n"); p2(tcps_sndrexmitpack, tcps_sndrexmitbyte, - "\t\t%u data packet%s (%qd byte%s) retransmitted\n"); + "\t\t%u data packet%s (%qd byte%s) retransmitted\n"); p(tcps_sndrexmitfast, "\t\t%qd fast retransmitted packet%s\n"); p2a(tcps_sndacks, tcps_delack, - "\t\t%u ack-only packet%s (%u delayed)\n"); + "\t\t%u ack-only packet%s (%u delayed)\n"); p(tcps_sndurg, "\t\t%u URG only packet%s\n"); p(tcps_sndprobe, "\t\t%u window probe packet%s\n"); p(tcps_sndwinup, "\t\t%u window update packet%s\n"); @@ -279,16 +279,16 @@ tcp_stats(off, name) p(tcps_rcvdupack, "\t\t%u duplicate ack%s\n"); p(tcps_rcvacktoomuch, "\t\t%u ack%s for unsent data\n"); p2(tcps_rcvpack, tcps_rcvbyte, - "\t\t%u packet%s (%qu byte%s) received in-sequence\n"); + "\t\t%u packet%s (%qu byte%s) received in-sequence\n"); p2(tcps_rcvduppack, tcps_rcvdupbyte, - "\t\t%u completely duplicate packet%s (%qd byte%s)\n"); + "\t\t%u completely duplicate packet%s (%qd byte%s)\n"); p(tcps_pawsdrop, "\t\t%u old duplicate packet%s\n"); p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte, - "\t\t%u packet%s with some dup. data (%qd byte%s duped)\n"); + "\t\t%u packet%s with some dup. data (%qd byte%s duped)\n"); p2(tcps_rcvoopack, tcps_rcvoobyte, - "\t\t%u out-of-order packet%s (%qd byte%s)\n"); + "\t\t%u out-of-order packet%s (%qd byte%s)\n"); p2(tcps_rcvpackafterwin, tcps_rcvbyteafterwin, - "\t\t%u packet%s (%qd byte%s) of data after window\n"); + "\t\t%u packet%s (%qd byte%s) of data after window\n"); p(tcps_rcvwinprobe, "\t\t%u window probe%s\n"); p(tcps_rcvwinupd, "\t\t%u window update packet%s\n"); p(tcps_rcvafterclose, "\t\t%u packet%s received after close\n"); @@ -301,10 +301,10 @@ tcp_stats(off, name) p(tcps_accepts, "\t%u connection accept%s\n"); p(tcps_connects, "\t%u connection%s established (including accepts)\n"); p2(tcps_closed, tcps_drops, - "\t%u connection%s closed (including %u drop%s)\n"); + "\t%u connection%s closed (including %u drop%s)\n"); p(tcps_conndrops, "\t%u embryonic connection%s dropped\n"); p2(tcps_rttupdated, tcps_segstimed, - "\t%u segment%s updated rtt (of %u attempt%s)\n"); + "\t%u segment%s updated rtt (of %u attempt%s)\n"); p(tcps_rexmttimeo, "\t%u retransmit timeout%s\n"); p(tcps_timeoutdrop, "\t\t%u connection%s dropped by rexmit timeout\n"); p(tcps_persisttimeo, "\t%u persist timeout%s\n"); @@ -350,9 +350,10 @@ udp_stats(off, name) kread(off, (char *)&udpstat, sizeof (udpstat)); printf("%s:\n", name); #define p(f, m) if (udpstat.f || sflag <= 1) \ - printf(m, udpstat.f, plural(udpstat.f)) + printf(m, udpstat.f, plural(udpstat.f)) #define p1(f, m) if (udpstat.f || sflag <= 1) \ - printf(m, udpstat.f) + printf(m, udpstat.f) + p(udps_ipackets, "\t%lu datagram%s received\n"); p1(udps_hdrops, "\t%lu with incomplete header\n"); p1(udps_badlen, "\t%lu with bad data length field\n"); @@ -364,13 +365,10 @@ udp_stats(off, name) p(udps_noportbcast, "\t%lu broadcast/multicast datagram%s dropped due to no socket\n"); p1(udps_nosec, "\t%lu dropped due to missing IPsec protection\n"); p1(udps_fullsock, "\t%lu dropped due to full socket buffers\n"); - delivered = udpstat.udps_ipackets - - udpstat.udps_hdrops - - udpstat.udps_badlen - - udpstat.udps_badsum - - udpstat.udps_noport - - udpstat.udps_noportbcast - - udpstat.udps_fullsock; + delivered = udpstat.udps_ipackets - udpstat.udps_hdrops - + udpstat.udps_badlen - udpstat.udps_badsum - + udpstat.udps_noport - udpstat.udps_noportbcast - + udpstat.udps_fullsock; if (delivered || sflag <= 1) printf("\t%lu delivered\n", delivered); p(udps_opackets, "\t%lu datagram%s output\n"); @@ -395,9 +393,9 @@ ip_stats(off, name) printf("%s:\n", name); #define p(f, m) if (ipstat.f || sflag <= 1) \ - printf(m, ipstat.f, plural(ipstat.f)) + printf(m, ipstat.f, plural(ipstat.f)) #define p1(f, m) if (ipstat.f || sflag <= 1) \ - printf(m, ipstat.f) + printf(m, ipstat.f) p(ips_total, "\t%lu total packet%s received\n"); p(ips_badsum, "\t%lu bad header checksum%s\n"); @@ -473,7 +471,7 @@ icmp_stats(off, name) printf("%s:\n", name); #define p(f, m) if (icmpstat.f || sflag <= 1) \ - printf(m, icmpstat.f, plural(icmpstat.f)) + printf(m, icmpstat.f, plural(icmpstat.f)) p(icps_error, "\t%lu call%s to icmp_error\n"); p(icps_oldicmp, @@ -485,7 +483,7 @@ icmp_stats(off, name) first = 0; } printf("\t\t%s: %lu\n", icmpnames[i], - icmpstat.icps_outhist[i]); + icmpstat.icps_outhist[i]); } p(icps_badcode, "\t%lu message%s with bad code fields\n"); p(icps_tooshort, "\t%lu message%s < minimum length\n"); @@ -498,7 +496,7 @@ icmp_stats(off, name) first = 0; } printf("\t\t%s: %lu\n", icmpnames[i], - icmpstat.icps_inhist[i]); + icmpstat.icps_inhist[i]); } p(icps_reflect, "\t%lu message response%s generated\n"); #undef p @@ -520,9 +518,10 @@ igmp_stats(off, name) printf("%s:\n", name); #define p(f, m) if (igmpstat.f || sflag <= 1) \ - printf(m, igmpstat.f, plural(igmpstat.f)) + printf(m, igmpstat.f, plural(igmpstat.f)) #define py(f, m) if (igmpstat.f || sflag <= 1) \ - printf(m, igmpstat.f, igmpstat.f != 1 ? "ies" : "y") + printf(m, igmpstat.f, igmpstat.f != 1 ? "ies" : "y") + p(igps_rcv_total, "\t%lu message%s received\n"); p(igps_rcv_tooshort, "\t%lu message%s received with too few bytes\n"); p(igps_rcv_badsum, "\t%lu message%s received with bad checksum\n"); @@ -661,9 +660,9 @@ inetname(inp) first = 0; if (gethostname(domain, sizeof(domain)) == 0 && (cp = strchr(domain, '.'))) - (void) strcpy(domain, cp + 1); + (void) strlcpy(domain, cp + 1, sizeof domain); else - domain[0] = 0; + domain[0] = '\0'; } cp = 0; if (!nflag && inp->s_addr != INADDR_ANY) { @@ -715,9 +714,9 @@ ah_stats(off, name) printf("%s:\n", name); #define p(f, m) if (ahstat.f || sflag <= 1) \ - printf(m, ahstat.f, plural(ahstat.f)) + printf(m, ahstat.f, plural(ahstat.f)) #define p1(f, m) if (ahstat.f || sflag <= 1) \ - printf(m, ahstat.f) + printf(m, ahstat.f) p1(ahs_input, "\t%u input AH packets\n"); p1(ahs_output, "\t%u output AH packets\n"); @@ -758,7 +757,7 @@ etherip_stats(off, name) printf("%s:\n", name); #define p(f, m) if (etheripstat.f || sflag <= 1) \ - printf(m, etheripstat.f, plural(etheripstat.f)) + printf(m, etheripstat.f, plural(etheripstat.f)) p(etherip_hdrops, "\t%u packet%s shorter than header shows\n"); @@ -789,7 +788,7 @@ esp_stats(off, name) printf("%s:\n", name); #define p(f, m) if (espstat.f || sflag <= 1) \ - printf(m, espstat.f, plural(espstat.f)) + printf(m, espstat.f, plural(espstat.f)) p(esps_input, "\t%u input ESP packet%s\n"); p(esps_output, "\t%u output ESP packet%s\n"); @@ -830,7 +829,7 @@ ipip_stats(off, name) printf("%s:\n", name); #define p(f, m) if (ipipstat.f || sflag <= 1) \ - printf(m, ipipstat.f, plural(ipipstat.f)) + printf(m, ipipstat.f, plural(ipipstat.f)) p(ipips_ipackets, "\t%u total input packet%s\n"); p(ipips_opackets, "\t%u total output packet%s\n"); @@ -861,7 +860,7 @@ ipcomp_stats(off, name) printf("%s:\n", name); #define p(f, m) if (ipcompstat.f || sflag <= 1) \ - printf(m, ipcompstat.f, plural(ipcompstat.f)) + printf(m, ipcompstat.f, plural(ipcompstat.f)) p(ipcomps_input, "\t%u input IPCOMP packet%s\n"); p(ipcomps_output, "\t%u output IPCOMP packet%s\n"); |