summaryrefslogtreecommitdiff
path: root/usr.bin/netstat/inet.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-06-29 20:18:05 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-06-29 20:18:05 +0000
commit0b1d6d59b408bc7e5d443a930eb2b59b35d58883 (patch)
treebfe0d518b2e7a81324edf27b82ef502cc14cffc8 /usr.bin/netstat/inet.c
parentc326c9da542ea064bd243d71b785da7f5667a058 (diff)
Mostly clean -Wall + 64bit issues.
Diffstat (limited to 'usr.bin/netstat/inet.c')
-rw-r--r--usr.bin/netstat/inet.c206
1 files changed, 103 insertions, 103 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 9af1ffa9def..90cd595e61a 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet.c,v 1.15 1997/06/25 07:56:18 provos Exp $ */
+/* $OpenBSD: inet.c,v 1.16 1997/06/29 20:17:59 millert 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.15 1997/06/25 07:56:18 provos Exp $";
+static char *rcsid = "$OpenBSD: inet.c,v 1.16 1997/06/29 20:17:59 millert Exp $";
#endif
#endif /* not lint */
@@ -149,10 +149,10 @@ protopr(off, name)
}
if (Aflag)
if (istcp)
- printf("%8x ", inpcb.inp_ppcb);
+ printf("%8p ", inpcb.inp_ppcb);
else
- printf("%8x ", prev);
- printf("%-5.5s %6d %6d ", name, sockb.so_rcv.sb_cc,
+ printf("%8p ", prev);
+ printf("%-5.5s %6ld %6ld ", name, sockb.so_rcv.sb_cc,
sockb.so_snd.sb_cc);
inetprint(&inpcb.inp_laddr, (int)inpcb.inp_lport, name, 1);
inetprint(&inpcb.inp_faddr, (int)inpcb.inp_fport, name, 0);
@@ -188,55 +188,55 @@ tcp_stats(off, name)
#define p3(f, m) if (tcpstat.f || sflag <= 1) \
printf(m, tcpstat.f, plurales(tcpstat.f))
- p(tcps_sndtotal, "\t%d packet%s sent\n");
+ p(tcps_sndtotal, "\t%ld packet%s sent\n");
p2(tcps_sndpack,tcps_sndbyte,
- "\t\t%d data packet%s (%qd byte%s)\n");
+ "\t\t%ld data packet%s (%qd byte%s)\n");
p2(tcps_sndrexmitpack, tcps_sndrexmitbyte,
- "\t\t%d data packet%s (%qd byte%s) retransmitted\n");
+ "\t\t%ld data packet%s (%qd byte%s) retransmitted\n");
p2(tcps_sndacks, tcps_delack,
- "\t\t%d ack-only packet%s (%d delayed)\n");
- p(tcps_sndurg, "\t\t%d URG only packet%s\n");
- p(tcps_sndprobe, "\t\t%d window probe packet%s\n");
- p(tcps_sndwinup, "\t\t%d window update packet%s\n");
- p(tcps_sndctrl, "\t\t%d control packet%s\n");
- p(tcps_rcvtotal, "\t%d packet%s received\n");
- p2(tcps_rcvackpack, tcps_rcvackbyte, "\t\t%d ack%s (for %qd byte%s)\n");
- p(tcps_rcvdupack, "\t\t%d duplicate ack%s\n");
- p(tcps_rcvacktoomuch, "\t\t%d ack%s for unsent data\n");
+ "\t\t%ld ack-only packet%s (%ld delayed)\n");
+ p(tcps_sndurg, "\t\t%ld URG only packet%s\n");
+ p(tcps_sndprobe, "\t\t%ld window probe packet%s\n");
+ p(tcps_sndwinup, "\t\t%ld window update packet%s\n");
+ p(tcps_sndctrl, "\t\t%ld control packet%s\n");
+ p(tcps_rcvtotal, "\t%ld packet%s received\n");
+ p2(tcps_rcvackpack, tcps_rcvackbyte, "\t\t%ld ack%s (for %qd byte%s)\n");
+ p(tcps_rcvdupack, "\t\t%ld duplicate ack%s\n");
+ p(tcps_rcvacktoomuch, "\t\t%ld ack%s for unsent data\n");
p2(tcps_rcvpack, tcps_rcvbyte,
- "\t\t%d packet%s (%qd byte%s) received in-sequence\n");
+ "\t\t%ld packet%s (%qd byte%s) received in-sequence\n");
p2(tcps_rcvduppack, tcps_rcvdupbyte,
- "\t\t%d completely duplicate packet%s (%qd byte%s)\n");
- p(tcps_pawsdrop, "\t\t%d old duplicate packet%s\n");
+ "\t\t%ld completely duplicate packet%s (%qd byte%s)\n");
+ p(tcps_pawsdrop, "\t\t%ld old duplicate packet%s\n");
p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte,
- "\t\t%d packet%s with some dup. data (%qd byte%s duped)\n");
+ "\t\t%ld packet%s with some dup. data (%qd byte%s duped)\n");
p2(tcps_rcvoopack, tcps_rcvoobyte,
- "\t\t%d out-of-order packet%s (%qd byte%s)\n");
+ "\t\t%ld out-of-order packet%s (%qd byte%s)\n");
p2(tcps_rcvpackafterwin, tcps_rcvbyteafterwin,
- "\t\t%d packet%s (%qd byte%s) of data after window\n");
- p(tcps_rcvwinprobe, "\t\t%d window probe%s\n");
- p(tcps_rcvwinupd, "\t\t%d window update packet%s\n");
- p(tcps_rcvafterclose, "\t\t%d packet%s received after close\n");
- p(tcps_rcvbadsum, "\t\t%d discarded for bad checksum%s\n");
- p(tcps_rcvbadoff, "\t\t%d discarded for bad header offset field%s\n");
- p(tcps_rcvshort, "\t\t%d discarded because packet too short\n");
- p(tcps_connattempt, "\t%d connection request%s\n");
- p(tcps_accepts, "\t%d connection accept%s\n");
- p(tcps_connects, "\t%d connection%s established (including accepts)\n");
+ "\t\t%ld packet%s (%qd byte%s) of data after window\n");
+ p(tcps_rcvwinprobe, "\t\t%ld window probe%s\n");
+ p(tcps_rcvwinupd, "\t\t%ld window update packet%s\n");
+ p(tcps_rcvafterclose, "\t\t%ld packet%s received after close\n");
+ p(tcps_rcvbadsum, "\t\t%ld discarded for bad checksum%s\n");
+ p(tcps_rcvbadoff, "\t\t%ld discarded for bad header offset field%s\n");
+ p(tcps_rcvshort, "\t\t%ld discarded because packet too short\n");
+ p(tcps_connattempt, "\t%ld connection request%s\n");
+ p(tcps_accepts, "\t%ld connection accept%s\n");
+ p(tcps_connects, "\t%ld connection%s established (including accepts)\n");
p2(tcps_closed, tcps_drops,
- "\t%d connection%s closed (including %d drop%s)\n");
- p(tcps_conndrops, "\t%d embryonic connection%s dropped\n");
+ "\t%ld connection%s closed (including %ld drop%s)\n");
+ p(tcps_conndrops, "\t%ld embryonic connection%s dropped\n");
p2(tcps_rttupdated, tcps_segstimed,
- "\t%d segment%s updated rtt (of %d attempt%s)\n");
- p(tcps_rexmttimeo, "\t%d retransmit timeout%s\n");
- p(tcps_timeoutdrop, "\t\t%d connection%s dropped by rexmit timeout\n");
- p(tcps_persisttimeo, "\t%d persist timeout%s\n");
- p(tcps_keeptimeo, "\t%d keepalive timeout%s\n");
- p(tcps_keepprobe, "\t\t%d keepalive probe%s sent\n");
- p(tcps_keepdrops, "\t\t%d connection%s dropped by keepalive\n");
- p(tcps_predack, "\t%d correct ACK header prediction%s\n");
- p(tcps_preddat, "\t%d correct data packet header prediction%s\n");
- p3(tcps_pcbhashmiss, "\t%d PCB cache miss%s\n");
+ "\t%ld segment%s updated rtt (of %ld attempt%s)\n");
+ p(tcps_rexmttimeo, "\t%ld retransmit timeout%s\n");
+ p(tcps_timeoutdrop, "\t\t%ld connection%s dropped by rexmit timeout\n");
+ p(tcps_persisttimeo, "\t%ld persist timeout%s\n");
+ p(tcps_keeptimeo, "\t%ld keepalive timeout%s\n");
+ p(tcps_keepprobe, "\t\t%ld keepalive probe%s sent\n");
+ p(tcps_keepdrops, "\t\t%ld connection%s dropped by keepalive\n");
+ p(tcps_predack, "\t%ld correct ACK header prediction%s\n");
+ p(tcps_preddat, "\t%ld correct data packet header prediction%s\n");
+ p3(tcps_pcbhashmiss, "\t%ld PCB cache miss%s\n");
#undef p
#undef p2
#undef p3
@@ -259,13 +259,13 @@ udp_stats(off, name)
printf("%s:\n", name);
#define p(f, m) if (udpstat.f || sflag <= 1) \
printf(m, udpstat.f, plural(udpstat.f))
- p(udps_ipackets, "\t%u datagram%s received\n");
- p(udps_hdrops, "\t%u with incomplete header\n");
- p(udps_badlen, "\t%u with bad data length field\n");
- p(udps_badsum, "\t%u with bad checksum\n");
- p(udps_noport, "\t%u dropped due to no socket\n");
- p(udps_noportbcast, "\t%u broadcast/multicast datagram%s dropped due to no socket\n");
- p(udps_fullsock, "\t%u dropped due to full socket buffers\n");
+ p(udps_ipackets, "\t%lu datagram%s received\n");
+ p(udps_hdrops, "\t%lu with incomplete header\n");
+ p(udps_badlen, "\t%lu with bad data length field\n");
+ p(udps_badsum, "\t%lu with bad checksum\n");
+ p(udps_noport, "\t%lu dropped due to no socket\n");
+ p(udps_noportbcast, "\t%lu broadcast/multicast datagram%s dropped due to no socket\n");
+ p(udps_fullsock, "\t%lu dropped due to full socket buffers\n");
delivered = udpstat.udps_ipackets -
udpstat.udps_hdrops -
udpstat.udps_badlen -
@@ -274,8 +274,8 @@ udp_stats(off, name)
udpstat.udps_noportbcast -
udpstat.udps_fullsock;
if (delivered || sflag <= 1)
- printf("\t%u delivered\n", delivered);
- p(udps_opackets, "\t%u datagram%s output\n");
+ printf("\t%lu delivered\n", delivered);
+ p(udps_opackets, "\t%lu datagram%s output\n");
#undef p
}
@@ -297,31 +297,31 @@ ip_stats(off, name)
#define p(f, m) if (ipstat.f || sflag <= 1) \
printf(m, ipstat.f, plural(ipstat.f))
- p(ips_total, "\t%u total packet%s received\n");
- p(ips_badsum, "\t%u bad header checksum%s\n");
- p(ips_toosmall, "\t%u with size smaller than minimum\n");
- p(ips_tooshort, "\t%u with data size < data length\n");
- p(ips_badhlen, "\t%u with header length < data size\n");
- p(ips_badlen, "\t%u with data length < header length\n");
- p(ips_badoptions, "\t%u with bad options\n");
- p(ips_badvers, "\t%u with incorrect version number\n");
- p(ips_fragments, "\t%u fragment%s received\n");
- p(ips_fragdropped, "\t%u fragment%s dropped (dup or out of space)\n");
- p(ips_badfrags, "\t%u malformed fragment%s dropped\n");
- p(ips_fragtimeout, "\t%u fragment%s dropped after timeout\n");
- p(ips_reassembled, "\t%u packet%s reassembled ok\n");
- p(ips_delivered, "\t%u packet%s for this host\n");
- p(ips_noproto, "\t%u packet%s for unknown/unsupported protocol\n");
- p(ips_forward, "\t%u packet%s forwarded\n");
- p(ips_cantforward, "\t%u packet%s not forwardable\n");
- p(ips_redirectsent, "\t%u redirect%s sent\n");
- p(ips_localout, "\t%u packet%s sent from this host\n");
- p(ips_rawout, "\t%u packet%s sent with fabricated ip header\n");
- p(ips_odropped, "\t%u output packet%s dropped due to no bufs, etc.\n");
- p(ips_noroute, "\t%u output packet%s discarded due to no route\n");
- p(ips_fragmented, "\t%u output datagram%s fragmented\n");
- p(ips_ofragments, "\t%u fragment%s created\n");
- p(ips_cantfrag, "\t%u datagram%s that can't be fragmented\n");
+ p(ips_total, "\t%lu total packet%s received\n");
+ p(ips_badsum, "\t%lu bad header checksum%s\n");
+ p(ips_toosmall, "\t%lu with size smaller than minimum\n");
+ p(ips_tooshort, "\t%lu with data size < data length\n");
+ p(ips_badhlen, "\t%lu with header length < data size\n");
+ p(ips_badlen, "\t%lu with data length < header length\n");
+ p(ips_badoptions, "\t%lu with bad options\n");
+ p(ips_badvers, "\t%lu with incorrect version number\n");
+ p(ips_fragments, "\t%lu fragment%s received\n");
+ p(ips_fragdropped, "\t%lu fragment%s dropped (dup or out of space)\n");
+ p(ips_badfrags, "\t%lu malformed fragment%s dropped\n");
+ p(ips_fragtimeout, "\t%lu fragment%s dropped after timeout\n");
+ p(ips_reassembled, "\t%lu packet%s reassembled ok\n");
+ p(ips_delivered, "\t%lu packet%s for this host\n");
+ p(ips_noproto, "\t%lu packet%s for unknown/unsupported protocol\n");
+ p(ips_forward, "\t%lu packet%s forwarded\n");
+ p(ips_cantforward, "\t%lu packet%s not forwardable\n");
+ p(ips_redirectsent, "\t%lu redirect%s sent\n");
+ p(ips_localout, "\t%lu packet%s sent from this host\n");
+ p(ips_rawout, "\t%lu packet%s sent with fabricated ip header\n");
+ p(ips_odropped, "\t%lu output packet%s dropped due to no bufs, etc.\n");
+ p(ips_noroute, "\t%lu output packet%s discarded due to no route\n");
+ p(ips_fragmented, "\t%lu output datagram%s fragmented\n");
+ p(ips_ofragments, "\t%lu fragment%s created\n");
+ p(ips_cantfrag, "\t%lu datagram%s that can't be fragmented\n");
#undef p
}
@@ -366,32 +366,32 @@ icmp_stats(off, name)
#define p(f, m) if (icmpstat.f || sflag <= 1) \
printf(m, icmpstat.f, plural(icmpstat.f))
- p(icps_error, "\t%u call%s to icmp_error\n");
+ p(icps_error, "\t%lu call%s to icmp_error\n");
p(icps_oldicmp,
- "\t%u error%s not generated 'cuz old message was icmp\n");
+ "\t%lu error%s not generated 'cuz old message was icmp\n");
for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
if (icmpstat.icps_outhist[i] != 0) {
if (first) {
printf("\tOutput histogram:\n");
first = 0;
}
- printf("\t\t%s: %u\n", icmpnames[i],
+ printf("\t\t%s: %lu\n", icmpnames[i],
icmpstat.icps_outhist[i]);
}
- p(icps_badcode, "\t%u message%s with bad code fields\n");
- p(icps_tooshort, "\t%u message%s < minimum length\n");
- p(icps_checksum, "\t%u bad checksum%s\n");
- p(icps_badlen, "\t%u message%s with bad length\n");
+ p(icps_badcode, "\t%lu message%s with bad code fields\n");
+ p(icps_tooshort, "\t%lu message%s < minimum length\n");
+ p(icps_checksum, "\t%lu bad checksum%s\n");
+ p(icps_badlen, "\t%lu message%s with bad length\n");
for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
if (icmpstat.icps_inhist[i] != 0) {
if (first) {
printf("\tInput histogram:\n");
first = 0;
}
- printf("\t\t%s: %u\n", icmpnames[i],
+ printf("\t\t%s: %lu\n", icmpnames[i],
icmpstat.icps_inhist[i]);
}
- p(icps_reflect, "\t%u message response%s generated\n");
+ p(icps_reflect, "\t%lu message response%s generated\n");
#undef p
}
@@ -414,28 +414,28 @@ igmp_stats(off, name)
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")
- p(igps_rcv_total, "\t%u message%s received\n");
- p(igps_rcv_tooshort, "\t%u message%s received with too few bytes\n");
- p(igps_rcv_badsum, "\t%u message%s received with bad checksum\n");
- py(igps_rcv_queries, "\t%u membership quer%s received\n");
- py(igps_rcv_badqueries, "\t%u membership quer%s received with invalid field(s)\n");
- p(igps_rcv_reports, "\t%u membership report%s received\n");
- p(igps_rcv_badreports, "\t%u membership report%s received with invalid field(s)\n");
- p(igps_rcv_ourreports, "\t%u membership report%s received for groups to which we belong\n");
- p(igps_snd_reports, "\t%u membership report%s sent\n");
+ 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");
+ py(igps_rcv_queries, "\t%lu membership quer%s received\n");
+ py(igps_rcv_badqueries, "\t%lu membership quer%s received with invalid field(s)\n");
+ p(igps_rcv_reports, "\t%lu membership report%s received\n");
+ p(igps_rcv_badreports, "\t%lu membership report%s received with invalid field(s)\n");
+ p(igps_rcv_ourreports, "\t%lu membership report%s received for groups to which we belong\n");
+ p(igps_snd_reports, "\t%lu membership report%s sent\n");
#undef p
#undef py
}
struct rpcnams {
struct rpcnams *next;
- int port;
+ in_port_t port;
char *rpcname;
};
char *
getrpcportnam(port)
- int port;
+ in_port_t port;
{
struct sockaddr_in server_addr;
register struct hostent *hp;
@@ -482,7 +482,7 @@ getrpcportnam(port)
if (rpc)
n->rpcname = strdup(rpc->r_name);
else {
- sprintf(num, "%d", head->pml_map.pm_prog);
+ sprintf(num, "%ld", head->pml_map.pm_prog);
n->rpcname = strdup(num);
}
}
@@ -502,7 +502,7 @@ getrpcportnam(port)
void
inetprint(in, port, proto, local)
register struct in_addr *in;
- int port;
+ in_port_t port;
char *proto;
int local;
{
@@ -516,10 +516,10 @@ inetprint(in, port, proto, local)
sp = getservbyport((int)port, proto);
if (sp || port == 0)
sprintf(cp, "%.8s", sp ? sp->s_name : "*");
- else if (local && !nflag && (nam = getrpcportnam(ntohs((u_short)port))))
- sprintf(cp, "%d[%.8s]", ntohs((u_short)port), nam);
+ else if (local && !nflag && (nam = getrpcportnam(ntohs(port))))
+ sprintf(cp, "%d[%.8s]", ntohs(port), nam);
else
- sprintf(cp, "%d", ntohs((u_short)port));
+ sprintf(cp, "%d", ntohs(port));
width = Aflag ? 18 : 22;
printf(" %-*.*s", width, width, line);
}