Annotation of src/usr.bin/netstat/inet.c, Revision 1.114
1.114 ! bluhm 1: /* $OpenBSD: inet.c,v 1.113 2010/06/29 03:09:29 blambert Exp $ */
1.1 deraadt 2: /* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */
3:
4: /*
5: * Copyright (c) 1983, 1988, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
1.65 millert 16: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 17: * may be used to endorse or promote products derived from this software
18: * without specific prior written permission.
19: *
20: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30: * SUCH DAMAGE.
31: */
32:
33: #include <sys/param.h>
34: #include <sys/queue.h>
35: #include <sys/socket.h>
36: #include <sys/socketvar.h>
37: #include <sys/mbuf.h>
1.114 ! bluhm 38: #include <sys/domain.h>
1.1 deraadt 39: #include <sys/protosw.h>
1.102 reyk 40: #include <sys/sysctl.h>
1.1 deraadt 41:
42: #include <net/route.h>
43: #include <netinet/in.h>
44: #include <netinet/in_systm.h>
45: #include <netinet/ip.h>
46: #include <netinet/in_pcb.h>
47: #include <netinet/ip_icmp.h>
48: #include <netinet/icmp_var.h>
49: #include <netinet/igmp_var.h>
50: #include <netinet/ip_var.h>
1.90 mcbride 51: #include <netinet/pim_var.h>
1.1 deraadt 52: #include <netinet/tcp.h>
53: #include <netinet/tcpip.h>
54: #include <netinet/tcp_seq.h>
55: #define TCPSTATES
56: #include <netinet/tcp_fsm.h>
57: #include <netinet/tcp_timer.h>
58: #include <netinet/tcp_var.h>
59: #include <netinet/tcp_debug.h>
60: #include <netinet/udp.h>
61: #include <netinet/udp_var.h>
1.30 angelos 62: #include <netinet/ip_ipsp.h>
1.10 angelos 63: #include <netinet/ip_ah.h>
64: #include <netinet/ip_esp.h>
1.45 angelos 65: #include <netinet/ip_ipip.h>
1.52 angelos 66: #include <netinet/ip_ipcomp.h>
1.34 angelos 67: #include <netinet/ip_ether.h>
1.69 mcbride 68: #include <netinet/ip_carp.h>
1.111 michele 69: #include <netinet/ip_divert.h>
1.75 mcbride 70: #include <net/if.h>
71: #include <net/pfvar.h>
72: #include <net/if_pfsync.h>
1.107 gollo 73: #include <net/if_pflow.h>
1.1 deraadt 74:
1.103 deraadt 75: #include <rpc/rpc.h>
76: #include <rpc/pmap_prot.h>
77: #include <rpc/pmap_clnt.h>
78:
1.1 deraadt 79: #include <arpa/inet.h>
1.110 chl 80: #include <err.h>
1.18 millert 81: #include <limits.h>
1.1 deraadt 82: #include <netdb.h>
83: #include <stdio.h>
84: #include <string.h>
85: #include <unistd.h>
1.14 dgregor 86: #include <stdlib.h>
1.103 deraadt 87: #include <errno.h>
1.1 deraadt 88: #include "netstat.h"
89:
90: struct inpcb inpcb;
91: struct tcpcb tcpcb;
92: struct socket sockb;
93:
1.56 millert 94: char *inetname(struct in_addr *);
1.63 deraadt 95: void inetprint(struct in_addr *, in_port_t, char *, int);
1.56 millert 96: char *inet6name(struct in6_addr *);
1.108 deraadt 97: void inet6print(struct in6_addr *, int, char *);
1.114 ! bluhm 98: void sockbuf_dump(struct sockbuf *, const char *);
! 99: void protosw_dump(u_long, u_long);
! 100: void domain_dump(u_long, u_long, short);
! 101: void inpcb_dump(u_long, short, int);
! 102: void tcpcb_dump(u_long);
1.1 deraadt 103:
104: /*
105: * Print a summary of connections related to an Internet
106: * protocol. For TCP, also give state of connection.
107: * Listening processes (aflag) are suppressed unless the
108: * -a (all) flag is specified.
109: */
110: void
1.114 ! bluhm 111: protopr(u_long off, char *name, int af, u_long pcbaddr)
1.48 itojun 112: {
1.1 deraadt 113: struct inpcbtable table;
1.54 mpech 114: struct inpcb *head, *next, *prev;
1.1 deraadt 115: struct inpcb inpcb;
1.105 sthen 116: int istcp, israw, isany;
1.54 mpech 117: int first = 1;
1.38 itojun 118: char *name0;
119: char namebuf[20];
1.1 deraadt 120:
1.38 itojun 121: name0 = name;
1.1 deraadt 122: if (off == 0)
123: return;
124: istcp = strcmp(name, "tcp") == 0;
1.72 markus 125: israw = strncmp(name, "ip", 2) == 0;
1.93 jaredy 126: kread(off, &table, sizeof table);
1.1 deraadt 127: prev = head =
1.99 otto 128: (struct inpcb *)&CIRCLEQ_FIRST(&((struct inpcbtable *)off)->inpt_queue);
129: next = CIRCLEQ_FIRST(&table.inpt_queue);
1.1 deraadt 130:
131: while (next != head) {
1.93 jaredy 132: kread((u_long)next, &inpcb, sizeof inpcb);
1.99 otto 133: if (CIRCLEQ_PREV(&inpcb, inp_queue) != prev) {
1.1 deraadt 134: printf("???\n");
135: break;
136: }
137: prev = next;
1.99 otto 138: next = CIRCLEQ_NEXT(&inpcb, inp_queue);
1.48 itojun 139:
140: switch (af) {
141: case AF_INET:
142: if ((inpcb.inp_flags & INP_IPV6) != 0)
143: continue;
1.105 sthen 144: isany = inet_lnaof(inpcb.inp_faddr) == INADDR_ANY;
1.48 itojun 145: break;
146: case AF_INET6:
147: if ((inpcb.inp_flags & INP_IPV6) == 0)
148: continue;
1.105 sthen 149: isany = IN6_IS_ADDR_UNSPECIFIED(&inpcb.inp_faddr6);
1.48 itojun 150: break;
151: default:
1.105 sthen 152: isany = 0;
1.48 itojun 153: break;
154: }
1.1 deraadt 155:
1.114 ! bluhm 156: if (Pflag) {
! 157: if (istcp && pcbaddr == (u_long)inpcb.inp_ppcb) {
! 158: if (vflag)
! 159: socket_dump((u_long)inpcb.inp_socket);
! 160: else
! 161: tcpcb_dump(pcbaddr);
! 162: } else if (pcbaddr == (u_long)prev) {
! 163: if (vflag)
! 164: socket_dump((u_long)inpcb.inp_socket);
! 165: else
! 166: inpcb_dump(pcbaddr, 0, af);
! 167: }
! 168: continue;
! 169: }
! 170:
1.93 jaredy 171: kread((u_long)inpcb.inp_socket, &sockb, sizeof (sockb));
1.1 deraadt 172: if (istcp) {
1.93 jaredy 173: kread((u_long)inpcb.inp_ppcb, &tcpcb, sizeof (tcpcb));
1.105 sthen 174: if (!aflag && tcpcb.t_state <= TCPS_LISTEN)
175: continue;
176: } else if (!aflag && isany)
177: continue;
1.1 deraadt 178: if (first) {
179: printf("Active Internet connections");
180: if (aflag)
181: printf(" (including servers)");
182: putchar('\n');
183: if (Aflag)
1.112 michele 184: printf("%-*.*s %-7.7s %-6.6s %-6.6s %-18.18s %-18.18s %s\n",
1.18 millert 185: PLEN, PLEN, "PCB", "Proto", "Recv-Q",
1.29 deraadt 186: "Send-Q", "Local Address",
187: "Foreign Address", "(state)");
1.18 millert 188: else
1.112 michele 189: printf("%-7.7s %-6.6s %-6.6s %-22.22s %-22.22s %s\n",
1.18 millert 190: "Proto", "Recv-Q", "Send-Q",
191: "Local Address", "Foreign Address",
192: "(state)");
1.1 deraadt 193: first = 0;
194: }
1.38 itojun 195: if (Aflag) {
1.1 deraadt 196: if (istcp)
1.18 millert 197: printf("%*p ", PLEN, inpcb.inp_ppcb);
1.1 deraadt 198: else
1.18 millert 199: printf("%*p ", PLEN, prev);
1.38 itojun 200: }
1.72 markus 201: if (inpcb.inp_flags & INP_IPV6 && !israw) {
1.60 deraadt 202: strlcpy(namebuf, name0, sizeof namebuf);
203: strlcat(namebuf, "6", sizeof namebuf);
1.38 itojun 204: name = namebuf;
205: } else
206: name = name0;
1.112 michele 207: printf("%-7.7s %6ld %6ld ", name, sockb.so_rcv.sb_cc,
1.63 deraadt 208: sockb.so_snd.sb_cc);
1.38 itojun 209: if (inpcb.inp_flags & INP_IPV6) {
210: inet6print(&inpcb.inp_laddr6, (int)inpcb.inp_lport,
1.108 deraadt 211: name);
1.38 itojun 212: inet6print(&inpcb.inp_faddr6, (int)inpcb.inp_fport,
1.108 deraadt 213: name);
1.103 deraadt 214: } else {
1.38 itojun 215: inetprint(&inpcb.inp_laddr, (int)inpcb.inp_lport,
1.63 deraadt 216: name, 1);
1.38 itojun 217: inetprint(&inpcb.inp_faddr, (int)inpcb.inp_fport,
1.63 deraadt 218: name, 0);
1.38 itojun 219: }
1.1 deraadt 220: if (istcp) {
221: if (tcpcb.t_state < 0 || tcpcb.t_state >= TCP_NSTATES)
222: printf(" %d", tcpcb.t_state);
223: else
224: printf(" %s", tcpstates[tcpcb.t_state]);
1.72 markus 225: } else if (israw) {
226: u_int8_t proto;
1.103 deraadt 227:
1.72 markus 228: if (inpcb.inp_flags & INP_IPV6)
229: proto = inpcb.inp_ipv6.ip6_nxt;
230: else
231: proto = inpcb.inp_ip.ip_p;
1.88 otto 232: printf(" %u", proto);
1.1 deraadt 233: }
234: putchar('\n');
235: }
236: }
237:
238: /*
239: * Dump TCP statistics structure.
240: */
241: void
1.103 deraadt 242: tcp_stats(char *name)
1.1 deraadt 243: {
244: struct tcpstat tcpstat;
1.102 reyk 245: int mib[] = { CTL_NET, AF_INET, IPPROTO_TCP, TCPCTL_STATS };
1.103 deraadt 246: size_t len = sizeof(tcpstat);
1.1 deraadt 247:
1.102 reyk 248: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
249: &tcpstat, &len, NULL, 0) == -1) {
1.103 deraadt 250: if (errno != ENOPROTOOPT)
251: warn(name);
1.102 reyk 252: return;
253: }
254:
1.63 deraadt 255: printf("%s:\n", name);
1.1 deraadt 256: #define p(f, m) if (tcpstat.f || sflag <= 1) \
1.60 deraadt 257: printf(m, tcpstat.f, plural(tcpstat.f))
1.38 itojun 258: #define p1(f, m) if (tcpstat.f || sflag <= 1) \
1.60 deraadt 259: printf(m, tcpstat.f)
1.1 deraadt 260: #define p2(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \
1.60 deraadt 261: printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2, plural(tcpstat.f2))
1.38 itojun 262: #define p2a(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \
1.60 deraadt 263: printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2)
1.1 deraadt 264: #define p3(f, m) if (tcpstat.f || sflag <= 1) \
1.60 deraadt 265: printf(m, tcpstat.f, plurales(tcpstat.f))
1.1 deraadt 266:
1.38 itojun 267: p(tcps_sndtotal, "\t%u packet%s sent\n");
1.1 deraadt 268: p2(tcps_sndpack,tcps_sndbyte,
1.60 deraadt 269: "\t\t%u data packet%s (%qd byte%s)\n");
1.1 deraadt 270: p2(tcps_sndrexmitpack, tcps_sndrexmitbyte,
1.60 deraadt 271: "\t\t%u data packet%s (%qd byte%s) retransmitted\n");
1.26 provos 272: p(tcps_sndrexmitfast, "\t\t%qd fast retransmitted packet%s\n");
1.38 itojun 273: p2a(tcps_sndacks, tcps_delack,
1.60 deraadt 274: "\t\t%u ack-only packet%s (%u delayed)\n");
1.38 itojun 275: p(tcps_sndurg, "\t\t%u URG only packet%s\n");
276: p(tcps_sndprobe, "\t\t%u window probe packet%s\n");
277: p(tcps_sndwinup, "\t\t%u window update packet%s\n");
278: p(tcps_sndctrl, "\t\t%u control packet%s\n");
1.50 angelos 279: p(tcps_outhwcsum, "\t\t%u packet%s hardware-checksummed\n");
1.38 itojun 280: p(tcps_rcvtotal, "\t%u packet%s received\n");
281: p2(tcps_rcvackpack, tcps_rcvackbyte, "\t\t%u ack%s (for %qd byte%s)\n");
282: p(tcps_rcvdupack, "\t\t%u duplicate ack%s\n");
283: p(tcps_rcvacktoomuch, "\t\t%u ack%s for unsent data\n");
1.85 markus 284: p(tcps_rcvacktooold, "\t\t%u ack%s for old data\n");
1.1 deraadt 285: p2(tcps_rcvpack, tcps_rcvbyte,
1.60 deraadt 286: "\t\t%u packet%s (%qu byte%s) received in-sequence\n");
1.1 deraadt 287: p2(tcps_rcvduppack, tcps_rcvdupbyte,
1.60 deraadt 288: "\t\t%u completely duplicate packet%s (%qd byte%s)\n");
1.38 itojun 289: p(tcps_pawsdrop, "\t\t%u old duplicate packet%s\n");
1.1 deraadt 290: p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte,
1.62 jsyn 291: "\t\t%u packet%s with some duplicate data (%qd byte%s duplicated)\n");
1.1 deraadt 292: p2(tcps_rcvoopack, tcps_rcvoobyte,
1.60 deraadt 293: "\t\t%u out-of-order packet%s (%qd byte%s)\n");
1.1 deraadt 294: p2(tcps_rcvpackafterwin, tcps_rcvbyteafterwin,
1.60 deraadt 295: "\t\t%u packet%s (%qd byte%s) of data after window\n");
1.38 itojun 296: p(tcps_rcvwinprobe, "\t\t%u window probe%s\n");
297: p(tcps_rcvwinupd, "\t\t%u window update packet%s\n");
298: p(tcps_rcvafterclose, "\t\t%u packet%s received after close\n");
299: p(tcps_rcvbadsum, "\t\t%u discarded for bad checksum%s\n");
300: p(tcps_rcvbadoff, "\t\t%u discarded for bad header offset field%s\n");
301: p1(tcps_rcvshort, "\t\t%u discarded because packet too short\n");
1.58 miod 302: p1(tcps_rcvnosec, "\t\t%u discarded for missing IPsec protection\n");
1.82 markus 303: p1(tcps_rcvmemdrop, "\t\t%u discarded due to memory shortage\n");
1.50 angelos 304: p(tcps_inhwcsum, "\t\t%u packet%s hardware-checksummed\n");
1.80 markus 305: p(tcps_rcvbadsig, "\t\t%u bad/missing md5 checksum%s\n");
306: p(tcps_rcvgoodsig, "\t\t%qd good md5 checksum%s\n");
1.38 itojun 307: p(tcps_connattempt, "\t%u connection request%s\n");
308: p(tcps_accepts, "\t%u connection accept%s\n");
309: p(tcps_connects, "\t%u connection%s established (including accepts)\n");
1.1 deraadt 310: p2(tcps_closed, tcps_drops,
1.60 deraadt 311: "\t%u connection%s closed (including %u drop%s)\n");
1.83 markus 312: p(tcps_conndrained, "\t%qd connection%s drained\n");
1.38 itojun 313: p(tcps_conndrops, "\t%u embryonic connection%s dropped\n");
1.1 deraadt 314: p2(tcps_rttupdated, tcps_segstimed,
1.60 deraadt 315: "\t%u segment%s updated rtt (of %u attempt%s)\n");
1.38 itojun 316: p(tcps_rexmttimeo, "\t%u retransmit timeout%s\n");
317: p(tcps_timeoutdrop, "\t\t%u connection%s dropped by rexmit timeout\n");
318: p(tcps_persisttimeo, "\t%u persist timeout%s\n");
319: p(tcps_keeptimeo, "\t%u keepalive timeout%s\n");
320: p(tcps_keepprobe, "\t\t%u keepalive probe%s sent\n");
321: p(tcps_keepdrops, "\t\t%u connection%s dropped by keepalive\n");
322: p(tcps_predack, "\t%u correct ACK header prediction%s\n");
323: p(tcps_preddat, "\t%u correct data packet header prediction%s\n");
324: p3(tcps_pcbhashmiss, "\t%u PCB cache miss%s\n");
1.59 kjc 325:
326: p(tcps_ecn_accepts, "\t%u ECN connection%s accepted\n");
327: p(tcps_ecn_rcvece, "\t\t%u ECE packet%s received\n");
328: p(tcps_ecn_rcvcwr, "\t\t%u CWR packet%s received\n");
329: p(tcps_ecn_rcvce, "\t\t%u CE packet%s received\n");
330: p(tcps_ecn_sndect, "\t\t%u ECT packet%s sent\n");
331: p(tcps_ecn_sndece, "\t\t%u ECE packet%s sent\n");
332: p(tcps_ecn_sndcwr, "\t\t%u CWR packet%s sent\n");
333: p1(tcps_cwr_frecovery, "\t\t\tcwr by fastrecovery: %u\n");
334: p1(tcps_cwr_timeout, "\t\t\tcwr by timeout: %u\n");
335: p1(tcps_cwr_ecn, "\t\t\tcwr by ecn: %u\n");
1.78 markus 336:
337: p(tcps_badsyn, "\t%u bad connection attempt%s\n");
338: p1(tcps_sc_added, "\t%qd SYN cache entries added\n");
339: p(tcps_sc_collisions, "\t\t%qd hash collision%s\n");
340: p1(tcps_sc_completed, "\t\t%qd completed\n");
341: p1(tcps_sc_aborted, "\t\t%qd aborted (no space to build PCB)\n");
342: p1(tcps_sc_timed_out, "\t\t%qd timed out\n");
343: p1(tcps_sc_overflowed, "\t\t%qd dropped due to overflow\n");
344: p1(tcps_sc_bucketoverflow, "\t\t%qd dropped due to bucket overflow\n");
345: p1(tcps_sc_reset, "\t\t%qd dropped due to RST\n");
346: p1(tcps_sc_unreach, "\t\t%qd dropped due to ICMP unreachable\n");
347: p(tcps_sc_retransmitted, "\t%qd SYN,ACK%s retransmitted\n");
348: p(tcps_sc_dupesyn, "\t%qd duplicate SYN%s received for entries "
349: "already in the cache\n");
350: p(tcps_sc_dropped, "\t%qd SYN%s dropped (no route or no space)\n");
1.95 markus 351:
352: p(tcps_sack_recovery_episode, "\t%qd SACK recovery episode%s\n");
353: p(tcps_sack_rexmits,
354: "\t\t%qd segment rexmit%s in SACK recovery episodes\n");
355: p(tcps_sack_rexmit_bytes,
356: "\t\t%qd byte rexmit%s in SACK recovery episodes\n");
357: p(tcps_sack_rcv_opts,
358: "\t%qd SACK option%s received\n");
359: p(tcps_sack_snd_opts, "\t%qd SACK option%s sent\n");
1.59 kjc 360:
1.1 deraadt 361: #undef p
1.38 itojun 362: #undef p1
1.1 deraadt 363: #undef p2
1.38 itojun 364: #undef p2a
1.1 deraadt 365: #undef p3
366: }
367:
368: /*
369: * Dump UDP statistics structure.
370: */
371: void
1.103 deraadt 372: udp_stats(char *name)
1.1 deraadt 373: {
374: struct udpstat udpstat;
375: u_long delivered;
1.102 reyk 376: int mib[] = { CTL_NET, AF_INET, IPPROTO_UDP, UDPCTL_STATS };
1.103 deraadt 377: size_t len = sizeof(udpstat);
1.1 deraadt 378:
1.102 reyk 379: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
380: &udpstat, &len, NULL, 0) == -1) {
1.103 deraadt 381: if (errno != ENOPROTOOPT)
382: warn(name);
1.102 reyk 383: return;
384: }
385:
1.1 deraadt 386: printf("%s:\n", name);
387: #define p(f, m) if (udpstat.f || sflag <= 1) \
1.60 deraadt 388: printf(m, udpstat.f, plural(udpstat.f))
1.38 itojun 389: #define p1(f, m) if (udpstat.f || sflag <= 1) \
1.60 deraadt 390: printf(m, udpstat.f)
391:
1.16 millert 392: p(udps_ipackets, "\t%lu datagram%s received\n");
1.38 itojun 393: p1(udps_hdrops, "\t%lu with incomplete header\n");
394: p1(udps_badlen, "\t%lu with bad data length field\n");
395: p1(udps_badsum, "\t%lu with bad checksum\n");
396: p1(udps_nosum, "\t%lu with no checksum\n");
1.50 angelos 397: p(udps_inhwcsum, "\t%lu input packet%s hardware-checksummed\n");
398: p(udps_outhwcsum, "\t%lu output packet%s hardware-checksummed\n");
1.38 itojun 399: p1(udps_noport, "\t%lu dropped due to no socket\n");
1.16 millert 400: p(udps_noportbcast, "\t%lu broadcast/multicast datagram%s dropped due to no socket\n");
1.58 miod 401: p1(udps_nosec, "\t%lu dropped due to missing IPsec protection\n");
1.38 itojun 402: p1(udps_fullsock, "\t%lu dropped due to full socket buffers\n");
1.60 deraadt 403: delivered = udpstat.udps_ipackets - udpstat.udps_hdrops -
404: udpstat.udps_badlen - udpstat.udps_badsum -
405: udpstat.udps_noport - udpstat.udps_noportbcast -
406: udpstat.udps_fullsock;
1.1 deraadt 407: if (delivered || sflag <= 1)
1.16 millert 408: printf("\t%lu delivered\n", delivered);
409: p(udps_opackets, "\t%lu datagram%s output\n");
1.38 itojun 410: p1(udps_pcbhashmiss, "\t%lu missed PCB cache\n");
1.1 deraadt 411: #undef p
1.38 itojun 412: #undef p1
1.1 deraadt 413: }
414:
415: /*
416: * Dump IP statistics structure.
417: */
418: void
1.103 deraadt 419: ip_stats(char *name)
1.1 deraadt 420: {
421: struct ipstat ipstat;
1.102 reyk 422: int mib[] = { CTL_NET, AF_INET, IPPROTO_IP, IPCTL_STATS };
1.109 mbalmer 423: size_t len = sizeof(ipstat);
1.1 deraadt 424:
1.102 reyk 425: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
426: &ipstat, &len, NULL, 0) == -1) {
1.103 deraadt 427: if (errno != ENOPROTOOPT)
428: warn(name);
1.102 reyk 429: return;
430: }
431:
1.1 deraadt 432: printf("%s:\n", name);
433: #define p(f, m) if (ipstat.f || sflag <= 1) \
1.60 deraadt 434: printf(m, ipstat.f, plural(ipstat.f))
1.38 itojun 435: #define p1(f, m) if (ipstat.f || sflag <= 1) \
1.60 deraadt 436: printf(m, ipstat.f)
1.1 deraadt 437:
1.16 millert 438: p(ips_total, "\t%lu total packet%s received\n");
439: p(ips_badsum, "\t%lu bad header checksum%s\n");
1.38 itojun 440: p1(ips_toosmall, "\t%lu with size smaller than minimum\n");
441: p1(ips_tooshort, "\t%lu with data size < data length\n");
442: p1(ips_badhlen, "\t%lu with header length < data size\n");
443: p1(ips_badlen, "\t%lu with data length < header length\n");
444: p1(ips_badoptions, "\t%lu with bad options\n");
445: p1(ips_badvers, "\t%lu with incorrect version number\n");
1.16 millert 446: p(ips_fragments, "\t%lu fragment%s received\n");
1.62 jsyn 447: p(ips_fragdropped, "\t%lu fragment%s dropped (duplicates or out of space)\n");
1.16 millert 448: p(ips_badfrags, "\t%lu malformed fragment%s dropped\n");
449: p(ips_fragtimeout, "\t%lu fragment%s dropped after timeout\n");
450: p(ips_reassembled, "\t%lu packet%s reassembled ok\n");
451: p(ips_delivered, "\t%lu packet%s for this host\n");
452: p(ips_noproto, "\t%lu packet%s for unknown/unsupported protocol\n");
453: p(ips_forward, "\t%lu packet%s forwarded\n");
454: p(ips_cantforward, "\t%lu packet%s not forwardable\n");
455: p(ips_redirectsent, "\t%lu redirect%s sent\n");
456: p(ips_localout, "\t%lu packet%s sent from this host\n");
457: p(ips_rawout, "\t%lu packet%s sent with fabricated ip header\n");
458: p(ips_odropped, "\t%lu output packet%s dropped due to no bufs, etc.\n");
459: p(ips_noroute, "\t%lu output packet%s discarded due to no route\n");
460: p(ips_fragmented, "\t%lu output datagram%s fragmented\n");
461: p(ips_ofragments, "\t%lu fragment%s created\n");
462: p(ips_cantfrag, "\t%lu datagram%s that can't be fragmented\n");
1.38 itojun 463: p1(ips_rcvmemdrop, "\t%lu fragment floods\n");
1.42 itojun 464: p(ips_toolong, "\t%lu packet%s with ip length > max ip packet size\n");
465: p(ips_nogif, "\t%lu tunneling packet%s that can't find gif\n");
1.49 itojun 466: p(ips_badaddr, "\t%lu datagram%s with bad address in header\n");
1.50 angelos 467: p(ips_inhwcsum, "\t%lu input datagram%s checksum-processed by hardware\n");
468: p(ips_outhwcsum, "\t%lu output datagram%s checksum-processed by hardware\n");
1.97 mpf 469: p(ips_notmember, "\t%lu multicast packet%s which we don't join\n");
1.111 michele 470: #undef p
471: #undef p1
472: }
473:
474: /*
475: * Dump DIVERT statistics structure.
476: */
477: void
478: div_stats(char *name)
479: {
480: struct divstat divstat;
481: int mib[] = { CTL_NET, AF_INET, IPPROTO_DIVERT, DIVERTCTL_STATS };
482: size_t len = sizeof(divstat);
483:
484: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
485: &divstat, &len, NULL, 0) == -1) {
486: if (errno != ENOPROTOOPT)
487: warn(name);
488: return;
489: }
490:
491: printf("%s:\n", name);
492: #define p(f, m) if (divstat.f || sflag <= 1) \
493: printf(m, divstat.f, plural(divstat.f))
494: #define p1(f, m) if (divstat.f || sflag <= 1) \
495: printf(m, divstat.f)
496: p(divs_ipackets, "\t%lu total packet%s received\n");
497: p1(divs_noport, "\t%lu dropped due to no socket\n");
498: p1(divs_fullsock, "\t%lu dropped due to full socket buffers\n");
499: p(divs_opackets, "\t%lu packet%s output\n");
500: p1(divs_errors, "\t%lu errors\n");
1.1 deraadt 501: #undef p
1.38 itojun 502: #undef p1
1.1 deraadt 503: }
504:
1.68 tedu 505: static char *icmpnames[ICMP_MAXTYPE + 1] = {
1.1 deraadt 506: "echo reply",
507: "#1",
508: "#2",
509: "destination unreachable",
510: "source quench",
511: "routing redirect",
512: "#6",
513: "#7",
514: "echo",
1.9 deraadt 515: "router advertisement",
516: "router solicitation",
1.1 deraadt 517: "time exceeded",
518: "parameter problem",
519: "time stamp",
520: "time stamp reply",
521: "information request",
522: "information request reply",
523: "address mask request",
524: "address mask reply",
1.68 tedu 525: "#19",
526: "#20",
527: "#21",
528: "#22",
529: "#23",
530: "#24",
531: "#25",
532: "#26",
533: "#27",
534: "#28",
535: "#29",
536: "traceroute",
537: "data conversion error",
538: "mobile host redirect",
539: "IPv6 where-are-you",
540: "IPv6 i-am-here",
541: "mobile registration request",
542: "mobile registration reply",
543: "#37",
544: "#38",
545: "SKIP",
546: "Photuris",
1.1 deraadt 547: };
548:
549: /*
550: * Dump ICMP statistics.
551: */
552: void
1.103 deraadt 553: icmp_stats(char *name)
1.1 deraadt 554: {
555: struct icmpstat icmpstat;
1.54 mpech 556: int i, first;
1.102 reyk 557: int mib[] = { CTL_NET, AF_INET, IPPROTO_ICMP, ICMPCTL_STATS };
1.103 deraadt 558: size_t len = sizeof(icmpstat);
1.102 reyk 559:
560: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
561: &icmpstat, &len, NULL, 0) == -1) {
1.103 deraadt 562: if (errno != ENOPROTOOPT)
563: warn(name);
1.102 reyk 564: return;
565: }
566:
1.1 deraadt 567: printf("%s:\n", name);
568: #define p(f, m) if (icmpstat.f || sflag <= 1) \
1.60 deraadt 569: printf(m, icmpstat.f, plural(icmpstat.f))
1.1 deraadt 570:
1.16 millert 571: p(icps_error, "\t%lu call%s to icmp_error\n");
1.1 deraadt 572: p(icps_oldicmp,
1.61 aaron 573: "\t%lu error%s not generated because old message was icmp\n");
1.1 deraadt 574: for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
575: if (icmpstat.icps_outhist[i] != 0) {
576: if (first) {
1.43 itojun 577: printf("\tOutput packet histogram:\n");
1.1 deraadt 578: first = 0;
579: }
1.68 tedu 580: if (icmpnames[i])
581: printf("\t\t%s:", icmpnames[i]);
582: else
583: printf("\t\t#%d:", i);
584: printf(" %lu\n", icmpstat.icps_outhist[i]);
1.1 deraadt 585: }
1.16 millert 586: p(icps_badcode, "\t%lu message%s with bad code fields\n");
587: p(icps_tooshort, "\t%lu message%s < minimum length\n");
588: p(icps_checksum, "\t%lu bad checksum%s\n");
589: p(icps_badlen, "\t%lu message%s with bad length\n");
1.1 deraadt 590: for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
591: if (icmpstat.icps_inhist[i] != 0) {
592: if (first) {
1.43 itojun 593: printf("\tInput packet histogram:\n");
1.1 deraadt 594: first = 0;
595: }
1.68 tedu 596: if (icmpnames[i])
597: printf("\t\t%s:", icmpnames[i]);
598: else
599: printf("\t\t#%d:", i);
600: printf(" %lu\n", icmpstat.icps_inhist[i]);
1.1 deraadt 601: }
1.16 millert 602: p(icps_reflect, "\t%lu message response%s generated\n");
1.1 deraadt 603: #undef p
604: }
605:
606: /*
607: * Dump IGMP statistics structure.
608: */
609: void
1.103 deraadt 610: igmp_stats(char *name)
1.1 deraadt 611: {
612: struct igmpstat igmpstat;
1.103 deraadt 613: int mib[] = { CTL_NET, AF_INET, IPPROTO_IGMP, IGMPCTL_STATS };
614: size_t len = sizeof(igmpstat);
1.1 deraadt 615:
1.103 deraadt 616: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
617: &igmpstat, &len, NULL, 0) == -1) {
618: if (errno != ENOPROTOOPT)
619: warn(name);
1.1 deraadt 620: return;
1.103 deraadt 621: }
622:
1.1 deraadt 623: printf("%s:\n", name);
624: #define p(f, m) if (igmpstat.f || sflag <= 1) \
1.60 deraadt 625: printf(m, igmpstat.f, plural(igmpstat.f))
1.1 deraadt 626: #define py(f, m) if (igmpstat.f || sflag <= 1) \
1.60 deraadt 627: printf(m, igmpstat.f, igmpstat.f != 1 ? "ies" : "y")
628:
1.16 millert 629: p(igps_rcv_total, "\t%lu message%s received\n");
1.55 mickey 630: p(igps_rcv_tooshort, "\t%lu message%s received with too few bytes\n");
631: p(igps_rcv_badsum, "\t%lu message%s received with bad checksum\n");
632: py(igps_rcv_queries, "\t%lu membership quer%s received\n");
633: py(igps_rcv_badqueries, "\t%lu membership quer%s received with invalid field(s)\n");
634: p(igps_rcv_reports, "\t%lu membership report%s received\n");
635: p(igps_rcv_badreports, "\t%lu membership report%s received with invalid field(s)\n");
636: p(igps_rcv_ourreports, "\t%lu membership report%s received for groups to which we belong\n");
637: p(igps_snd_reports, "\t%lu membership report%s sent\n");
1.90 mcbride 638: #undef p
639: #undef py
640: }
641:
642: /*
643: * Dump PIM statistics structure.
644: */
645: void
1.103 deraadt 646: pim_stats(char *name)
1.90 mcbride 647: {
648: struct pimstat pimstat;
1.103 deraadt 649: int mib[] = { CTL_NET, AF_INET, IPPROTO_PIM, PIMCTL_STATS };
650: size_t len = sizeof(pimstat);
1.90 mcbride 651:
1.103 deraadt 652: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
653: &pimstat, &len, NULL, 0) == -1) {
654: if (errno != ENOPROTOOPT)
655: warn(name);
1.90 mcbride 656: return;
657: }
658:
659: printf("%s:\n", name);
660: #define p(f, m) if (pimstat.f || sflag <= 1) \
661: printf(m, pimstat.f, plural(pimstat.f))
662: #define py(f, m) if (pimstat.f || sflag <= 1) \
663: printf(m, pimstat.f, pimstat.f != 1 ? "ies" : "y")
664:
665: p(pims_rcv_total_msgs, "\t%llu message%s received\n");
666: p(pims_rcv_total_bytes, "\t%llu byte%s received\n");
667: p(pims_rcv_tooshort, "\t%llu message%s received with too few bytes\n");
668: p(pims_rcv_badsum, "\t%llu message%s received with bad checksum\n");
669: p(pims_rcv_badversion, "\t%llu message%s received with bad version\n");
670: p(pims_rcv_registers_msgs, "\t%llu data register message%s received\n");
671: p(pims_rcv_registers_bytes, "\t%llu data register byte%s received\n");
672: p(pims_rcv_registers_wrongiif, "\t%llu data register message%s received on wrong iif\n");
673: p(pims_rcv_badregisters, "\t%llu bad register%s received\n");
674: p(pims_snd_registers_msgs, "\t%llu data register message%s sent\n");
675: p(pims_snd_registers_bytes, "\t%llu data register byte%s sent\n");
1.1 deraadt 676: #undef p
677: #undef py
678: }
679:
1.5 deraadt 680: struct rpcnams {
681: struct rpcnams *next;
1.16 millert 682: in_port_t port;
1.21 deraadt 683: int proto;
1.5 deraadt 684: char *rpcname;
685: };
686:
1.66 deraadt 687: static char *
1.63 deraadt 688: getrpcportnam(in_port_t port, int proto)
1.5 deraadt 689: {
690: struct sockaddr_in server_addr;
1.54 mpech 691: struct hostent *hp;
1.5 deraadt 692: static struct pmaplist *head;
693: int socket = RPC_ANYSOCK;
694: struct timeval minutetimeout;
1.54 mpech 695: CLIENT *client;
1.5 deraadt 696: struct rpcent *rpc;
697: static int first;
698: static struct rpcnams *rpcn;
699: struct rpcnams *n;
1.23 deraadt 700: char num[20];
1.55 mickey 701:
1.5 deraadt 702: if (first == 0) {
703: first = 1;
1.93 jaredy 704: memset(&server_addr, 0, sizeof server_addr);
1.5 deraadt 705: server_addr.sin_family = AF_INET;
706: if ((hp = gethostbyname("localhost")) != NULL)
1.7 deraadt 707: memmove((caddr_t)&server_addr.sin_addr, hp->h_addr,
1.5 deraadt 708: hp->h_length);
709: else
710: (void) inet_aton("0.0.0.0", &server_addr.sin_addr);
711:
712: minutetimeout.tv_sec = 60;
713: minutetimeout.tv_usec = 0;
714: server_addr.sin_port = htons(PMAPPORT);
715: if ((client = clnttcp_create(&server_addr, PMAPPROG,
1.7 deraadt 716: PMAPVERS, &socket, 50, 500)) == NULL)
717: return (NULL);
1.5 deraadt 718: if (clnt_call(client, PMAPPROC_DUMP, xdr_void, NULL,
1.8 deraadt 719: xdr_pmaplist, &head, minutetimeout) != RPC_SUCCESS) {
1.7 deraadt 720: clnt_destroy(client);
721: return (NULL);
1.5 deraadt 722: }
723: for (; head != NULL; head = head->pml_next) {
724: n = (struct rpcnams *)malloc(sizeof(struct rpcnams));
725: if (n == NULL)
726: continue;
727: n->next = rpcn;
728: rpcn = n;
729: n->port = head->pml_map.pm_port;
1.21 deraadt 730: n->proto = head->pml_map.pm_prot;
1.5 deraadt 731:
732: rpc = getrpcbynumber(head->pml_map.pm_prog);
733: if (rpc)
734: n->rpcname = strdup(rpc->r_name);
735: else {
1.23 deraadt 736: snprintf(num, sizeof num, "%ld",
737: head->pml_map.pm_prog);
1.5 deraadt 738: n->rpcname = strdup(num);
739: }
740: }
741: clnt_destroy(client);
742: }
743:
744: for (n = rpcn; n; n = n->next)
1.21 deraadt 745: if (n->port == port && n->proto == proto)
1.5 deraadt 746: return (n->rpcname);
747: return (NULL);
748: }
749:
1.1 deraadt 750: /*
751: * Pretty print an Internet address (net address + port).
752: * If the nflag was specified, use numbers instead of names.
753: */
754: void
1.63 deraadt 755: inetprint(struct in_addr *in, in_port_t port, char *proto, int local)
1.1 deraadt 756: {
757: struct servent *sp = 0;
1.5 deraadt 758: char line[80], *cp, *nam;
1.1 deraadt 759: int width;
760:
1.23 deraadt 761: snprintf(line, sizeof line, "%.*s.", (Aflag && !nflag) ? 12 : 16,
762: inetname(in));
1.4 millert 763: cp = strchr(line, '\0');
1.1 deraadt 764: if (!nflag && port)
765: sp = getservbyport((int)port, proto);
766: if (sp || port == 0)
1.23 deraadt 767: snprintf(cp, line + sizeof line - cp, "%.8s",
768: sp ? sp->s_name : "*");
1.21 deraadt 769: else if (local && !nflag && (nam = getrpcportnam(ntohs(port),
770: (strcmp(proto, "tcp") == 0 ? IPPROTO_TCP : IPPROTO_UDP))))
1.23 deraadt 771: snprintf(cp, line + sizeof line - cp, "%d[%.8s]",
772: ntohs(port), nam);
1.1 deraadt 773: else
1.23 deraadt 774: snprintf(cp, line + sizeof line - cp, "%d", ntohs(port));
1.1 deraadt 775: width = Aflag ? 18 : 22;
776: printf(" %-*.*s", width, width, line);
777: }
778:
779: /*
780: * Construct an Internet address representation.
781: * If the nflag has been supplied, give
782: * numeric value, otherwise try for symbolic name.
783: */
784: char *
1.63 deraadt 785: inetname(struct in_addr *inp)
1.1 deraadt 786: {
1.54 mpech 787: char *cp;
1.1 deraadt 788: static char line[50];
789: struct hostent *hp;
790: struct netent *np;
1.57 mpech 791: static char domain[MAXHOSTNAMELEN];
1.1 deraadt 792: static int first = 1;
793:
794: if (first && !nflag) {
795: first = 0;
1.57 mpech 796: if (gethostname(domain, sizeof(domain)) == 0 &&
1.4 millert 797: (cp = strchr(domain, '.')))
1.60 deraadt 798: (void) strlcpy(domain, cp + 1, sizeof domain);
1.1 deraadt 799: else
1.60 deraadt 800: domain[0] = '\0';
1.1 deraadt 801: }
1.84 deraadt 802: cp = NULL;
1.1 deraadt 803: if (!nflag && inp->s_addr != INADDR_ANY) {
804: int net = inet_netof(*inp);
805: int lna = inet_lnaof(*inp);
806:
807: if (lna == INADDR_ANY) {
808: np = getnetbyaddr(net, AF_INET);
809: if (np)
810: cp = np->n_name;
811: }
1.84 deraadt 812: if (cp == NULL) {
1.1 deraadt 813: hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET);
814: if (hp) {
1.4 millert 815: if ((cp = strchr(hp->h_name, '.')) &&
1.1 deraadt 816: !strcmp(cp + 1, domain))
1.84 deraadt 817: *cp = '\0';
1.1 deraadt 818: cp = hp->h_name;
819: }
820: }
821: }
822: if (inp->s_addr == INADDR_ANY)
1.23 deraadt 823: snprintf(line, sizeof line, "*");
1.1 deraadt 824: else if (cp)
1.23 deraadt 825: snprintf(line, sizeof line, "%s", cp);
1.1 deraadt 826: else {
827: inp->s_addr = ntohl(inp->s_addr);
828: #define C(x) ((x) & 0xff)
1.23 deraadt 829: snprintf(line, sizeof line, "%u.%u.%u.%u",
830: C(inp->s_addr >> 24), C(inp->s_addr >> 16),
831: C(inp->s_addr >> 8), C(inp->s_addr));
1.1 deraadt 832: }
833: return (line);
1.10 angelos 834: }
835:
836: /*
837: * Dump AH statistics structure.
838: */
839: void
1.103 deraadt 840: ah_stats(char *name)
1.10 angelos 841: {
1.55 mickey 842: struct ahstat ahstat;
1.103 deraadt 843: int mib[] = { CTL_NET, AF_INET, IPPROTO_AH, AHCTL_STATS };
844: size_t len = sizeof(ahstat);
1.10 angelos 845:
1.103 deraadt 846: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
847: &ahstat, &len, NULL, 0) == -1) {
848: if (errno != ENOPROTOOPT)
849: warn(name);
1.55 mickey 850: return;
1.103 deraadt 851: }
852:
1.55 mickey 853: printf("%s:\n", name);
1.10 angelos 854: #define p(f, m) if (ahstat.f || sflag <= 1) \
1.60 deraadt 855: printf(m, ahstat.f, plural(ahstat.f))
1.38 itojun 856: #define p1(f, m) if (ahstat.f || sflag <= 1) \
1.60 deraadt 857: printf(m, ahstat.f)
1.10 angelos 858:
1.38 itojun 859: p1(ahs_input, "\t%u input AH packets\n");
860: p1(ahs_output, "\t%u output AH packets\n");
1.55 mickey 861: p(ahs_nopf, "\t%u packet%s from unsupported protocol families\n");
862: p(ahs_hdrops, "\t%u packet%s shorter than header shows\n");
863: p(ahs_pdrops, "\t%u packet%s dropped due to policy\n");
864: p(ahs_notdb, "\t%u packet%s for which no TDB was found\n");
865: p(ahs_badkcr, "\t%u input packet%s that failed to be processed\n");
866: p(ahs_badauth, "\t%u packet%s that failed verification received\n");
867: p(ahs_noxform, "\t%u packet%s for which no XFORM was set in TDB received\n");
868: p(ahs_qfull, "\t%u packet%s were dropped due to full output queue\n");
869: p(ahs_wrap, "\t%u packet%s where counter wrapping was detected\n");
870: p(ahs_replay, "\t%u possibly replayed packet%s received\n");
871: p(ahs_badauthl, "\t%u packet%s with bad authenticator length received\n");
1.62 jsyn 872: p(ahs_invalid, "\t%u packet%s attempted to use an invalid TDB\n");
1.25 niklas 873: p(ahs_toobig, "\t%u packet%s got larger than max IP packet size\n");
1.46 angelos 874: p(ahs_crypto, "\t%u packet%s that failed crypto processing\n");
1.20 angelos 875: p(ahs_ibytes, "\t%qu input byte%s\n");
876: p(ahs_obytes, "\t%qu output byte%s\n");
877:
1.34 angelos 878: #undef p
1.38 itojun 879: #undef p1
1.34 angelos 880: }
881:
882: /*
883: * Dump etherip statistics structure.
884: */
885: void
1.103 deraadt 886: etherip_stats(char *name)
1.34 angelos 887: {
1.55 mickey 888: struct etheripstat etheripstat;
1.103 deraadt 889: int mib[] = { CTL_NET, AF_INET, IPPROTO_ETHERIP, ETHERIPCTL_STATS };
890: size_t len = sizeof(etheripstat);
1.34 angelos 891:
1.103 deraadt 892: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
893: ðeripstat, &len, NULL, 0) == -1) {
894: if (errno != ENOPROTOOPT)
895: warn(name);
1.55 mickey 896: return;
1.103 deraadt 897: }
898:
1.55 mickey 899: printf("%s:\n", name);
1.34 angelos 900: #define p(f, m) if (etheripstat.f || sflag <= 1) \
1.60 deraadt 901: printf(m, etheripstat.f, plural(etheripstat.f))
1.34 angelos 902:
1.53 brian 903: p(etherip_hdrops, "\t%u packet%s shorter than header shows\n");
904: p(etherip_qfull, "\t%u packet%s were dropped due to full output queue\n");
1.34 angelos 905: p(etherip_noifdrops, "\t%u packet%s were dropped because of no interface/bridge information\n");
1.53 brian 906: p(etherip_pdrops, "\t%u packet%s dropped due to policy\n");
907: p(etherip_adrops, "\t%u packet%s dropped for other reasons\n");
908: p(etherip_ipackets, "\t%u input ethernet-in-IP packet%s\n");
909: p(etherip_opackets, "\t%u output ethernet-in-IP packet%s\n");
1.34 angelos 910: p(etherip_ibytes, "\t%qu input byte%s\n");
911: p(etherip_obytes, "\t%qu output byte%s\n");
1.10 angelos 912: #undef p
913: }
914:
915: /*
916: * Dump ESP statistics structure.
917: */
918: void
1.103 deraadt 919: esp_stats(char *name)
1.10 angelos 920: {
1.55 mickey 921: struct espstat espstat;
1.103 deraadt 922: int mib[] = { CTL_NET, AF_INET, IPPROTO_ESP, ESPCTL_STATS };
923: size_t len = sizeof(espstat);
1.10 angelos 924:
1.103 deraadt 925: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
926: &espstat, &len, NULL, 0) == -1) {
927: if (errno != ENOPROTOOPT)
928: warn(name);
1.55 mickey 929: return;
1.103 deraadt 930: }
931:
1.55 mickey 932: printf("%s:\n", name);
1.10 angelos 933: #define p(f, m) if (espstat.f || sflag <= 1) \
1.60 deraadt 934: printf(m, espstat.f, plural(espstat.f))
1.10 angelos 935:
1.38 itojun 936: p(esps_input, "\t%u input ESP packet%s\n");
937: p(esps_output, "\t%u output ESP packet%s\n");
1.55 mickey 938: p(esps_nopf, "\t%u packet%s from unsupported protocol families\n");
939: p(esps_hdrops, "\t%u packet%s shorter than header shows\n");
940: p(esps_pdrops, "\t%u packet%s dropped due to policy\n");
941: p(esps_notdb, "\t%u packet%s for which no TDB was found\n");
942: p(esps_badkcr, "\t%u input packet%s that failed to be processed\n");
943: p(esps_badenc, "\t%u packet%s with bad encryption received\n");
944: p(esps_badauth, "\t%u packet%s that failed verification received\n");
945: p(esps_noxform, "\t%u packet%s for which no XFORM was set in TDB received\n");
946: p(esps_qfull, "\t%u packet%s were dropped due to full output queue\n");
947: p(esps_wrap, "\t%u packet%s where counter wrapping was detected\n");
948: p(esps_replay, "\t%u possibly replayed packet%s received\n");
949: p(esps_badilen, "\t%u packet%s with bad payload size or padding received\n");
1.62 jsyn 950: p(esps_invalid, "\t%u packet%s attempted to use an invalid TDB\n");
1.25 niklas 951: p(esps_toobig, "\t%u packet%s got larger than max IP packet size\n");
1.46 angelos 952: p(esps_crypto, "\t%u packet%s that failed crypto processing\n");
1.74 markus 953: p(esps_udpencin, "\t%u input UDP encapsulated ESP packet%s\n");
954: p(esps_udpencout, "\t%u output UDP encapsulated ESP packet%s\n");
955: p(esps_udpinval, "\t%u UDP packet%s for non-encapsulating TDB received\n");
1.20 angelos 956: p(esps_ibytes, "\t%qu input byte%s\n");
957: p(esps_obytes, "\t%qu output byte%s\n");
1.10 angelos 958:
959: #undef p
960: }
961:
962: /*
1.67 deraadt 963: * Dump IP-in-IP statistics structure.
1.10 angelos 964: */
965: void
1.103 deraadt 966: ipip_stats(char *name)
1.10 angelos 967: {
1.55 mickey 968: struct ipipstat ipipstat;
1.103 deraadt 969: int mib[] = { CTL_NET, AF_INET, IPPROTO_IPIP, IPIPCTL_STATS };
970: size_t len = sizeof(ipipstat);
1.10 angelos 971:
1.103 deraadt 972: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
973: &ipipstat, &len, NULL, 0) == -1) {
974: if (errno != ENOPROTOOPT)
975: warn(name);
1.55 mickey 976: return;
1.103 deraadt 977: }
978:
1.55 mickey 979: printf("%s:\n", name);
1.45 angelos 980: #define p(f, m) if (ipipstat.f || sflag <= 1) \
1.60 deraadt 981: printf(m, ipipstat.f, plural(ipipstat.f))
1.10 angelos 982:
1.55 mickey 983: p(ipips_ipackets, "\t%u total input packet%s\n");
984: p(ipips_opackets, "\t%u total output packet%s\n");
985: p(ipips_hdrops, "\t%u packet%s shorter than header shows\n");
986: p(ipips_pdrops, "\t%u packet%s dropped due to policy\n");
987: p(ipips_spoof, "\t%u packet%s with possibly spoofed local addresses\n");
988: p(ipips_qfull, "\t%u packet%s were dropped due to full output queue\n");
1.45 angelos 989: p(ipips_ibytes, "\t%qu input byte%s\n");
990: p(ipips_obytes, "\t%qu output byte%s\n");
1.63 deraadt 991: p(ipips_family, "\t%u protocol family mismatche%s\n");
992: p(ipips_unspec, "\t%u attempt%s to use tunnel with unspecified endpoint(s)\n");
1.69 mcbride 993: #undef p
994: }
995:
1.84 deraadt 996: /*
1.69 mcbride 997: * Dump CARP statistics structure.
998: */
999: void
1.103 deraadt 1000: carp_stats(char *name)
1.69 mcbride 1001: {
1002: struct carpstats carpstat;
1.103 deraadt 1003: int mib[] = { CTL_NET, AF_INET, IPPROTO_CARP, CARPCTL_STATS };
1004: size_t len = sizeof(carpstat);
1.69 mcbride 1005:
1.103 deraadt 1006: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
1007: &carpstat, &len, NULL, 0) == -1) {
1008: if (errno != ENOPROTOOPT)
1009: warn(name);
1.69 mcbride 1010: return;
1.103 deraadt 1011: }
1012:
1.69 mcbride 1013: printf("%s:\n", name);
1014: #define p(f, m) if (carpstat.f || sflag <= 1) \
1015: printf(m, carpstat.f, plural(carpstat.f))
1016: #define p2(f, m) if (carpstat.f || sflag <= 1) \
1017: printf(m, carpstat.f)
1018:
1.87 mcbride 1019: p(carps_ipackets, "\t%llu packet%s received (IPv4)\n");
1020: p(carps_ipackets6, "\t%llu packet%s received (IPv6)\n");
1021: p(carps_badif, "\t\t%llu packet%s discarded for bad interface\n");
1.89 mcbride 1022: p(carps_badttl, "\t\t%llu packet%s discarded for wrong TTL\n");
1.87 mcbride 1023: p(carps_hdrops, "\t\t%llu packet%s shorter than header\n");
1024: p(carps_badsum, "\t\t%llu discarded for bad checksum%s\n");
1025: p(carps_badver, "\t\t%llu discarded packet%s with a bad version\n");
1026: p2(carps_badlen, "\t\t%llu discarded because packet too short\n");
1027: p2(carps_badauth, "\t\t%llu discarded for bad authentication\n");
1.106 mpf 1028: p2(carps_badvhid, "\t\t%llu discarded for unknown vhid\n");
1.87 mcbride 1029: p2(carps_badaddrs, "\t\t%llu discarded because of a bad address list\n");
1030: p(carps_opackets, "\t%llu packet%s sent (IPv4)\n");
1031: p(carps_opackets6, "\t%llu packet%s sent (IPv6)\n");
1.89 mcbride 1032: p2(carps_onomem, "\t\t%llu send failed due to mbuf memory error\n");
1.101 joel 1033: p(carps_preempt, "\t%llu transition%s to master\n");
1.51 jjbg 1034: #undef p
1.70 mcbride 1035: #undef p2
1.51 jjbg 1036: }
1037:
1.94 deraadt 1038: /*
1.75 mcbride 1039: * Dump pfsync statistics structure.
1040: */
1041: void
1.103 deraadt 1042: pfsync_stats(char *name)
1.75 mcbride 1043: {
1044: struct pfsyncstats pfsyncstat;
1.103 deraadt 1045: int mib[] = { CTL_NET, AF_INET, IPPROTO_PFSYNC, PFSYNCCTL_STATS };
1046: size_t len = sizeof(pfsyncstat);
1.75 mcbride 1047:
1.103 deraadt 1048: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
1049: &pfsyncstat, &len, NULL, 0) == -1) {
1050: if (errno != ENOPROTOOPT)
1051: warn(name);
1.75 mcbride 1052: return;
1.103 deraadt 1053: }
1054:
1.75 mcbride 1055: printf("%s:\n", name);
1056: #define p(f, m) if (pfsyncstat.f || sflag <= 1) \
1057: printf(m, pfsyncstat.f, plural(pfsyncstat.f))
1058: #define p2(f, m) if (pfsyncstat.f || sflag <= 1) \
1059: printf(m, pfsyncstat.f)
1060:
1.86 mcbride 1061: p(pfsyncs_ipackets, "\t%llu packet%s received (IPv4)\n");
1062: p(pfsyncs_ipackets6, "\t%llu packet%s received (IPv6)\n");
1063: p(pfsyncs_badif, "\t\t%llu packet%s discarded for bad interface\n");
1064: p(pfsyncs_badttl, "\t\t%llu packet%s discarded for bad ttl\n");
1065: p(pfsyncs_hdrops, "\t\t%llu packet%s shorter than header\n");
1066: p(pfsyncs_badver, "\t\t%llu packet%s discarded for bad version\n");
1067: p(pfsyncs_badauth, "\t\t%llu packet%s discarded for bad HMAC\n");
1068: p(pfsyncs_badact,"\t\t%llu packet%s discarded for bad action\n");
1069: p(pfsyncs_badlen, "\t\t%llu packet%s discarded for short packet\n");
1070: p(pfsyncs_badval, "\t\t%llu state%s discarded for bad values\n");
1071: p(pfsyncs_stale, "\t\t%llu stale state%s\n");
1072: p(pfsyncs_badstate, "\t\t%llu failed state lookup/insert%s\n");
1073: p(pfsyncs_opackets, "\t%llu packet%s sent (IPv4)\n");
1074: p(pfsyncs_opackets6, "\t%llu packet%s sent (IPv6)\n");
1075: p2(pfsyncs_onomem, "\t\t%llu send failed due to mbuf memory error\n");
1076: p2(pfsyncs_oerrors, "\t\t%llu send error\n");
1.107 gollo 1077: #undef p
1078: #undef p2
1079: }
1080:
1081: /*
1082: * Dump pflow statistics structure.
1083: */
1084: void
1085: pflow_stats(char *name)
1086: {
1087: struct pflowstats flowstats;
1088: int mib[] = { CTL_NET, PF_PFLOW, NET_PFLOW_STATS };
1089: size_t len = sizeof(struct pflowstats);
1090:
1091: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), &flowstats, &len,
1092: NULL, 0) == -1) {
1093: if (errno != ENOPROTOOPT)
1094: warn(name);
1095: return;
1096: }
1097:
1098: printf("%s:\n", name);
1099: #define p(f, m) if (flowstats.f || sflag <= 1) \
1100: printf(m, flowstats.f, plural(flowstats.f))
1101: #define p2(f, m) if (flowstats.f || sflag <= 1) \
1102: printf(m, flowstats.f)
1103:
1104: p(pflow_flows, "\t%llu flow%s sent\n");
1105: p(pflow_packets, "\t%llu packet%s sent\n");
1106: p2(pflow_onomem, "\t\t%llu send failed due to mbuf memory error\n");
1107: p2(pflow_oerrors, "\t\t%llu send error\n");
1.75 mcbride 1108: #undef p
1109: #undef p2
1110: }
1111:
1.51 jjbg 1112: /*
1113: * Dump IPCOMP statistics structure.
1114: */
1115: void
1.103 deraadt 1116: ipcomp_stats(char *name)
1.51 jjbg 1117: {
1118: struct ipcompstat ipcompstat;
1.103 deraadt 1119: int mib[] = { CTL_NET, AF_INET, IPPROTO_IPCOMP, IPCOMPCTL_STATS };
1120: size_t len = sizeof(ipcompstat);
1.51 jjbg 1121:
1.103 deraadt 1122: if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
1123: &ipcompstat, &len, NULL, 0) == -1) {
1124: if (errno != ENOPROTOOPT)
1125: warn(name);
1.51 jjbg 1126: return;
1.103 deraadt 1127: }
1128:
1.51 jjbg 1129: printf("%s:\n", name);
1130: #define p(f, m) if (ipcompstat.f || sflag <= 1) \
1.60 deraadt 1131: printf(m, ipcompstat.f, plural(ipcompstat.f))
1.51 jjbg 1132:
1133: p(ipcomps_input, "\t%u input IPCOMP packet%s\n");
1134: p(ipcomps_output, "\t%u output IPCOMP packet%s\n");
1135: p(ipcomps_nopf, "\t%u packet%s from unsupported protocol families\n");
1136: p(ipcomps_hdrops, "\t%u packet%s shorter than header shows\n");
1137: p(ipcomps_pdrops, "\t%u packet%s dropped due to policy\n");
1138: p(ipcomps_notdb, "\t%u packet%s for which no TDB was found\n");
1139: p(ipcomps_badkcr, "\t%u input packet%s that failed to be processed\n");
1.55 mickey 1140: p(ipcomps_noxform, "\t%u packet%s for which no XFORM was set in TDB received\n");
1.51 jjbg 1141: p(ipcomps_qfull, "\t%u packet%s were dropped due to full output queue\n");
1142: p(ipcomps_wrap, "\t%u packet%s where counter wrapping was detected\n");
1.62 jsyn 1143: p(ipcomps_invalid, "\t%u packet%s attempted to use an invalid TDB\n");
1.51 jjbg 1144: p(ipcomps_toobig, "\t%u packet%s got larger than max IP packet size\n");
1145: p(ipcomps_crypto, "\t%u packet%s that failed (de)compression processing\n");
1.64 jason 1146: p(ipcomps_minlen, "\t%u packet%s less than minimum compression length\n");
1.51 jjbg 1147: p(ipcomps_ibytes, "\t%qu input byte%s\n");
1148: p(ipcomps_obytes, "\t%qu output byte%s\n");
1149:
1.10 angelos 1150: #undef p
1.1 deraadt 1151: }
1.96 markus 1152:
1153: /*
1.114 ! bluhm 1154: * Dump the contents of a socket structure
! 1155: */
! 1156: void
! 1157: socket_dump(u_long off)
! 1158: {
! 1159: struct socket so;
! 1160:
! 1161: if (off == 0)
! 1162: return;
! 1163: kread(off, &so, sizeof(so));
! 1164:
! 1165: #define p(fmt, v, sep) printf(#v " " fmt sep, so.v);
! 1166: printf("socket %#lx\n ", off);
! 1167: p("%#0.4x", so_type, "\n ");
! 1168: p("%#0.4x", so_options, "\n ");
! 1169: p("%d", so_linger, "\n ");
! 1170: p("%#0.4x", so_state, "\n ");
! 1171: p("%p", so_pcb, ", ");
! 1172: p("%p", so_proto, ", ");
! 1173: p("%p", so_head, "\n ");
! 1174: p("%d", so_q0len, ", ");
! 1175: p("%d", so_qlen, ", ");
! 1176: p("%d", so_qlimit, "\n ");
! 1177: p("%d", so_timeo, "\n ");
! 1178: p("%u", so_error, "\n ");
! 1179: p("%d", so_pgid, ", ");
! 1180: p("%u", so_siguid, ", ");
! 1181: p("%u", so_sigeuid, "\n ");
! 1182: p("%lu", so_oobmark, "\n ");
! 1183: sockbuf_dump(&so.so_rcv, "so_rcv");
! 1184: sockbuf_dump(&so.so_snd, "so_snd");
! 1185: p("%u", so_euid, ", ");
! 1186: p("%u", so_ruid, ", ");
! 1187: p("%u", so_egid, ", ");
! 1188: p("%u", so_rgid, "\n ");
! 1189: p("%d", so_cpid, "\n");
! 1190: #undef p
! 1191:
! 1192: if (!vflag)
! 1193: return;
! 1194: protosw_dump((u_long)so.so_proto, (u_long)so.so_pcb);
! 1195: }
! 1196:
! 1197: /*
! 1198: * Dump the contents of a socket buffer
! 1199: */
! 1200: void
! 1201: sockbuf_dump(struct sockbuf *sb, const char *name)
! 1202: {
! 1203: #define p(fmt, v, sep) printf(#v " " fmt sep, sb->v);
! 1204: printf("%s ", name);
! 1205: p("%lu", sb_cc, ", ");
! 1206: p("%lu", sb_datacc, ", ");
! 1207: p("%lu", sb_hiwat, ", ");
! 1208: p("%lu", sb_wat, "\n ");
! 1209: printf("%s ", name);
! 1210: p("%lu", sb_mbcnt, ", ");
! 1211: p("%lu", sb_mbmax, ", ");
! 1212: p("%ld", sb_lowat, "\n ");
! 1213: printf("%s ", name);
! 1214: p("%#0.4x", sb_flags, ", ");
! 1215: p("%u", sb_timeo, "\n ");
! 1216: #undef p
! 1217: }
! 1218:
! 1219: /*
! 1220: * Dump the contents of a protosw structure
! 1221: */
! 1222: void
! 1223: protosw_dump(u_long off, u_long pcb)
! 1224: {
! 1225: struct protosw proto;
! 1226:
! 1227: if (off == 0)
! 1228: return;
! 1229: kread(off, &proto, sizeof(proto));
! 1230:
! 1231: #define p(fmt, v, sep) printf(#v " " fmt sep, proto.v);
! 1232: printf("protosw %#lx\n ", off);
! 1233: p("%#0.4x", pr_type, "\n ");
! 1234: p("%p", pr_domain, "\n ");
! 1235: p("%d", pr_protocol, "\n ");
! 1236: p("%#0.4x", pr_flags, "\n");
! 1237: #undef p
! 1238:
! 1239: domain_dump((u_long)proto.pr_domain, pcb, proto.pr_protocol);
! 1240: }
! 1241:
! 1242: /*
! 1243: * Dump the contents of a domain structure
! 1244: */
! 1245: void
! 1246: domain_dump(u_long off, u_long pcb, short protocol)
! 1247: {
! 1248: struct domain dom;
! 1249: char name[256];
! 1250:
! 1251: if (off == 0)
! 1252: return;
! 1253: kread(off, &dom, sizeof(dom));
! 1254: kread((u_long)dom.dom_name, name, sizeof(name));
! 1255:
! 1256: #define p(fmt, v, sep) printf(#v " " fmt sep, dom.v);
! 1257: printf("domain %#lx\n ", off);
! 1258: p("%d", dom_family, "\n ");
! 1259: printf("dom_name %.*s\n", sizeof(name), name);
! 1260: #undef p
! 1261:
! 1262: switch (dom.dom_family) {
! 1263: case AF_INET:
! 1264: case AF_INET6:
! 1265: inpcb_dump(pcb, protocol, dom.dom_family);
! 1266: break;
! 1267: case AF_UNIX:
! 1268: unpcb_dump(pcb);
! 1269: break;
! 1270: }
! 1271: }
! 1272:
! 1273: /*
! 1274: * Dump the contents of a internet PCB
! 1275: */
! 1276: void
! 1277: inpcb_dump(u_long off, short protocol, int af)
! 1278: {
! 1279: struct inpcb inp;
! 1280: char faddr[256], laddr[256];
! 1281:
! 1282: if (off == 0)
! 1283: return;
! 1284: kread(off, &inp, sizeof(inp));
! 1285: switch (af) {
! 1286: case AF_INET:
! 1287: inet_ntop(af, &inp.inp_faddr, faddr, sizeof(faddr));
! 1288: inet_ntop(af, &inp.inp_laddr, laddr, sizeof(laddr));
! 1289: break;
! 1290: case AF_INET6:
! 1291: inet_ntop(af, &inp.inp_faddr6, faddr, sizeof(faddr));
! 1292: inet_ntop(af, &inp.inp_laddr6, laddr, sizeof(laddr));
! 1293: break;
! 1294: default:
! 1295: faddr[0] = laddr[0] = '\0';
! 1296: }
! 1297:
! 1298: #define p(fmt, v, sep) printf(#v " " fmt sep, inp.v);
! 1299: printf("inpcb %#lx\n ", off);
! 1300: p("%p", inp_table, "\n ");
! 1301: printf("inp_faddru %s, inp_laddru %s\n ", faddr, laddr);
! 1302: HTONS(inp.inp_fport);
! 1303: HTONS(inp.inp_lport);
! 1304: p("%u", inp_fport, ", ");
! 1305: p("%u", inp_lport, "\n ");
! 1306: p("%p", inp_socket, ", ");
! 1307: p("%p", inp_ppcb, "\n ");
! 1308: p("%#0.8x", inp_flags, "\n ");
! 1309: p("%d", inp_hops, "\n ");
! 1310: p("%u", inp_seclevel[0], ", ");
! 1311: p("%u", inp_seclevel[1], ", ");
! 1312: p("%u", inp_seclevel[2], ", ");
! 1313: p("%u", inp_seclevel[3], "\n ");
! 1314: p("%#x", inp_secrequire, ", ");
! 1315: p("%#x", inp_secresult, "\n ");
! 1316: p("%u", inp_ip_minttl, "\n ");
! 1317: p("%p", inp_tdb_in, ", ");
! 1318: p("%p", inp_tdb_out, ", ");
! 1319: p("%p", inp_ipo, "\n ");
! 1320: p("%p", inp_ipsec_remotecred, ", ");
! 1321: p("%p", inp_ipsec_remoteauth, "\n ");
! 1322: p("%d", in6p_cksum, "\n ");
! 1323: p("%p", inp_icmp6filt, "\n ");
! 1324: p("%p", inp_pf_sk, "\n ");
! 1325: p("%u", inp_rtableid, "\n ");
! 1326: p("%d", inp_pipex, "\n");
! 1327: #undef p
! 1328:
! 1329: switch (protocol) {
! 1330: case IPPROTO_TCP:
! 1331: tcpcb_dump((u_long)inp.inp_ppcb);
! 1332: break;
! 1333: }
! 1334: }
! 1335:
! 1336: /*
! 1337: * Dump the contents of a TCP PCB
1.96 markus 1338: */
1339: void
1.114 ! bluhm 1340: tcpcb_dump(u_long off)
1.96 markus 1341: {
1342: struct tcpcb tcpcb;
1343:
1344: if (off == 0)
1345: return;
1346: kread(off, (char *)&tcpcb, sizeof (tcpcb));
1347:
1348: #define p(fmt, v, sep) printf(#v " " fmt sep, tcpcb.v);
1.114 ! bluhm 1349: printf("tcpcb %#lx\n ", off);
! 1350: p("%p", t_inpcb, "\n ");
1.96 markus 1351: p("%d", t_state, "");
1.114 ! bluhm 1352: if (tcpcb.t_state >= 0 && tcpcb.t_state < TCP_NSTATES)
1.96 markus 1353: printf(" (%s)", tcpstates[tcpcb.t_state]);
1.114 ! bluhm 1354: printf("\n ");
1.96 markus 1355: p("%d", t_rxtshift, ", ");
1356: p("%d", t_rxtcur, ", ");
1.114 ! bluhm 1357: p("%d", t_dupacks, "\n ");
1.96 markus 1358: p("%u", t_maxseg, ", ");
1359: p("%u", t_maxopd, ", ");
1.114 ! bluhm 1360: p("%u", t_peermss, "\n ");
1.96 markus 1361: p("0x%x", t_flags, ", ");
1.114 ! bluhm 1362: p("%u", t_force, "\n ");
! 1363: p("%u", iss, "\n ");
1.96 markus 1364: p("%u", snd_una, ", ");
1365: p("%u", snd_nxt, ", ");
1.114 ! bluhm 1366: p("%u", snd_up, "\n ");
1.96 markus 1367: p("%u", snd_wl1, ", ");
1368: p("%u", snd_wl2, ", ");
1.114 ! bluhm 1369: p("%lu", snd_wnd, "\n ");
1.96 markus 1370: p("%d", sack_enable, ", ");
1371: p("%d", snd_numholes, ", ");
1372: p("%u", snd_fack, ", ");
1.114 ! bluhm 1373: p("%lu",snd_awnd, "\n ");
1.96 markus 1374: p("%u", retran_data, ", ");
1.114 ! bluhm 1375: p("%u", snd_last, "\n ");
! 1376: p("%u", irs, "\n ");
1.96 markus 1377: p("%u", rcv_nxt, ", ");
1378: p("%u", rcv_up, ", ");
1.114 ! bluhm 1379: p("%lu", rcv_wnd, "\n ");
! 1380: p("%u", rcv_lastsack, "\n ");
! 1381: p("%d", rcv_numsacks, "\n ");
1.96 markus 1382: p("%u", rcv_adv, ", ");
1.114 ! bluhm 1383: p("%u", snd_max, "\n ");
1.96 markus 1384: p("%lu", snd_cwnd, ", ");
1385: p("%lu", snd_ssthresh, ", ");
1.114 ! bluhm 1386: p("%lu", max_sndwnd, "\n ");
1.96 markus 1387: p("%u", t_rcvtime, ", ");
1388: p("%u", t_rtttime, ", ");
1.114 ! bluhm 1389: p("%u", t_rtseq, "\n ");
1.96 markus 1390: p("%u", t_srtt, ", ");
1391: p("%u", t_rttvar, ", ");
1.114 ! bluhm 1392: p("%u", t_rttmin, "\n ");
1.96 markus 1393: p("%u", t_oobflags, ", ");
1.114 ! bluhm 1394: p("%u", t_iobc, "\n ");
! 1395: p("%u", t_softerror, "\n ");
1.96 markus 1396: p("%u", snd_scale, ", ");
1397: p("%u", rcv_scale, ", ");
1398: p("%u", request_r_scale, ", ");
1.114 ! bluhm 1399: p("%u", requested_s_scale, "\n ");
1.96 markus 1400: p("%u", ts_recent, ", ");
1.114 ! bluhm 1401: p("%u", ts_recent_age, "\n ");
! 1402: p("%u", last_ack_sent, "\n ");
1.98 markus 1403: HTONS(tcpcb.t_pmtud_ip_len);
1404: HTONS(tcpcb.t_pmtud_nextmtu);
1405: p("%u", t_pmtud_mss_acked, ", ");
1.114 ! bluhm 1406: p("%u", t_pmtud_mtu_sent, "\n ");
1.98 markus 1407: p("%u", t_pmtud_nextmtu, ", ");
1408: p("%u", t_pmtud_ip_len, ", ");
1.114 ! bluhm 1409: p("%u", t_pmtud_ip_hl, "\n ");
! 1410: p("%u", t_pmtud_th_seq, "\n ");
1.96 markus 1411: p("%u", pf, "\n");
1412: #undef p
1.98 markus 1413: }