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