1 /* $OpenBSD: inet.c,v 1.99 2005/10/17 19:09:36 otto Exp $ */ 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. 16 * 3. Neither the name of the University nor the names of its contributors 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 #ifndef lint 34 #if 0 35 static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94"; 36 #else 37 static const char *rcsid = "$OpenBSD: inet.c,v 1.99 2005/10/17 19:09:36 otto Exp $"; 38 #endif 39 #endif /* not lint */ 40 41 #include <sys/param.h> 42 #include <sys/queue.h> 43 #include <sys/socket.h> 44 #include <sys/socketvar.h> 45 #include <sys/mbuf.h> 46 #include <sys/protosw.h> 47 48 #include <net/route.h> 49 #include <netinet/in.h> 50 #include <netinet/in_systm.h> 51 #include <netinet/ip.h> 52 #include <netinet/in_pcb.h> 53 #include <netinet/ip_icmp.h> 54 #include <netinet/icmp_var.h> 55 #include <netinet/igmp_var.h> 56 #include <netinet/ip_var.h> 57 #include <netinet/pim_var.h> 58 #include <netinet/tcp.h> 59 #include <netinet/tcpip.h> 60 #include <netinet/tcp_seq.h> 61 #define TCPSTATES 62 #include <netinet/tcp_fsm.h> 63 #include <netinet/tcp_timer.h> 64 #include <netinet/tcp_var.h> 65 #include <netinet/tcp_debug.h> 66 #include <netinet/udp.h> 67 #include <netinet/udp_var.h> 68 #include <netinet/ip_ipsp.h> 69 #include <netinet/ip_ah.h> 70 #include <netinet/ip_esp.h> 71 #include <netinet/ip_ipip.h> 72 #include <netinet/ip_ipcomp.h> 73 #include <netinet/ip_ether.h> 74 #include <netinet/ip_carp.h> 75 #include <net/if.h> 76 #include <net/pfvar.h> 77 #include <net/if_pfsync.h> 78 79 #include <arpa/inet.h> 80 #include <limits.h> 81 #include <netdb.h> 82 #include <stdio.h> 83 #include <string.h> 84 #include <unistd.h> 85 #include <stdlib.h> 86 #include "netstat.h" 87 88 #include <rpc/rpc.h> 89 #include <rpc/pmap_prot.h> 90 #include <rpc/pmap_clnt.h> 91 92 struct inpcb inpcb; 93 struct tcpcb tcpcb; 94 struct socket sockb; 95 96 static void protopr0(u_long, char *, int); 97 98 char *inetname(struct in_addr *); 99 void inetprint(struct in_addr *, in_port_t, char *, int); 100 #ifdef INET6 101 char *inet6name(struct in6_addr *); 102 void inet6print(struct in6_addr *, int, char *, int); 103 #endif 104 105 /* 106 * Print a summary of connections related to an Internet 107 * protocol. For TCP, also give state of connection. 108 * Listening processes (aflag) are suppressed unless the 109 * -a (all) flag is specified. 110 */ 111 void 112 protopr(u_long off, char *name) 113 { 114 protopr0(off, name, AF_INET); 115 } 116 117 #ifdef INET6 118 void 119 ip6protopr(u_long off, char *name) 120 { 121 protopr0(off, name, AF_INET6); 122 } 123 #endif 124 125 static void 126 protopr0(u_long off, char *name, int af) 127 { 128 struct inpcbtable table; 129 struct inpcb *head, *next, *prev; 130 struct inpcb inpcb; 131 int istcp, israw; 132 int first = 1; 133 char *name0; 134 char namebuf[20]; 135 136 name0 = name; 137 if (off == 0) 138 return; 139 istcp = strcmp(name, "tcp") == 0; 140 israw = strncmp(name, "ip", 2) == 0; 141 kread(off, &table, sizeof table); 142 prev = head = 143 (struct inpcb *)&CIRCLEQ_FIRST(&((struct inpcbtable *)off)->inpt_queue); 144 next = CIRCLEQ_FIRST(&table.inpt_queue); 145 146 while (next != head) { 147 kread((u_long)next, &inpcb, sizeof inpcb); 148 if (CIRCLEQ_PREV(&inpcb, inp_queue) != prev) { 149 printf("???\n"); 150 break; 151 } 152 prev = next; 153 next = CIRCLEQ_NEXT(&inpcb, inp_queue); 154 155 switch (af) { 156 case AF_INET: 157 if ((inpcb.inp_flags & INP_IPV6) != 0) 158 continue; 159 break; 160 case AF_INET6: 161 if ((inpcb.inp_flags & INP_IPV6) == 0) 162 continue; 163 break; 164 default: 165 break; 166 } 167 168 if (!aflag && 169 inet_lnaof(inpcb.inp_laddr) == INADDR_ANY) 170 continue; 171 kread((u_long)inpcb.inp_socket, &sockb, sizeof (sockb)); 172 if (istcp) { 173 kread((u_long)inpcb.inp_ppcb, &tcpcb, sizeof (tcpcb)); 174 } 175 if (first) { 176 printf("Active Internet connections"); 177 if (aflag) 178 printf(" (including servers)"); 179 putchar('\n'); 180 if (Aflag) 181 printf("%-*.*s %-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n", 182 PLEN, PLEN, "PCB", "Proto", "Recv-Q", 183 "Send-Q", "Local Address", 184 "Foreign Address", "(state)"); 185 else 186 printf("%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n", 187 "Proto", "Recv-Q", "Send-Q", 188 "Local Address", "Foreign Address", 189 "(state)"); 190 first = 0; 191 } 192 if (Aflag) { 193 if (istcp) 194 printf("%*p ", PLEN, inpcb.inp_ppcb); 195 else 196 printf("%*p ", PLEN, prev); 197 } 198 #ifdef INET6 199 if (inpcb.inp_flags & INP_IPV6 && !israw) { 200 strlcpy(namebuf, name0, sizeof namebuf); 201 strlcat(namebuf, "6", sizeof namebuf); 202 name = namebuf; 203 } else 204 name = name0; 205 #endif 206 printf("%-5.5s %6ld %6ld ", name, sockb.so_rcv.sb_cc, 207 sockb.so_snd.sb_cc); 208 #ifdef INET6 209 if (inpcb.inp_flags & INP_IPV6) { 210 inet6print(&inpcb.inp_laddr6, (int)inpcb.inp_lport, 211 name, 1); 212 inet6print(&inpcb.inp_faddr6, (int)inpcb.inp_fport, 213 name, 0); 214 } else 215 #endif 216 { 217 inetprint(&inpcb.inp_laddr, (int)inpcb.inp_lport, 218 name, 1); 219 inetprint(&inpcb.inp_faddr, (int)inpcb.inp_fport, 220 name, 0); 221 } 222 if (istcp) { 223 if (tcpcb.t_state < 0 || tcpcb.t_state >= TCP_NSTATES) 224 printf(" %d", tcpcb.t_state); 225 else 226 printf(" %s", tcpstates[tcpcb.t_state]); 227 } else if (israw) { 228 u_int8_t proto; 229 #ifdef INET6 230 if (inpcb.inp_flags & INP_IPV6) 231 proto = inpcb.inp_ipv6.ip6_nxt; 232 else 233 #endif 234 proto = inpcb.inp_ip.ip_p; 235 printf(" %u", proto); 236 } 237 putchar('\n'); 238 } 239 } 240 241 /* 242 * Dump TCP statistics structure. 243 */ 244 void 245 tcp_stats(u_long off, char *name) 246 { 247 struct tcpstat tcpstat; 248 249 if (off == 0) 250 return; 251 printf("%s:\n", name); 252 kread(off, &tcpstat, sizeof (tcpstat)); 253 254 #define p(f, m) if (tcpstat.f || sflag <= 1) \ 255 printf(m, tcpstat.f, plural(tcpstat.f)) 256 #define p1(f, m) if (tcpstat.f || sflag <= 1) \ 257 printf(m, tcpstat.f) 258 #define p2(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \ 259 printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2, plural(tcpstat.f2)) 260 #define p2a(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \ 261 printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2) 262 #define p3(f, m) if (tcpstat.f || sflag <= 1) \ 263 printf(m, tcpstat.f, plurales(tcpstat.f)) 264 265 p(tcps_sndtotal, "\t%u packet%s sent\n"); 266 p2(tcps_sndpack,tcps_sndbyte, 267 "\t\t%u data packet%s (%qd byte%s)\n"); 268 p2(tcps_sndrexmitpack, tcps_sndrexmitbyte, 269 "\t\t%u data packet%s (%qd byte%s) retransmitted\n"); 270 p(tcps_sndrexmitfast, "\t\t%qd fast retransmitted packet%s\n"); 271 p2a(tcps_sndacks, tcps_delack, 272 "\t\t%u ack-only packet%s (%u delayed)\n"); 273 p(tcps_sndurg, "\t\t%u URG only packet%s\n"); 274 p(tcps_sndprobe, "\t\t%u window probe packet%s\n"); 275 p(tcps_sndwinup, "\t\t%u window update packet%s\n"); 276 p(tcps_sndctrl, "\t\t%u control packet%s\n"); 277 p(tcps_outhwcsum, "\t\t%u packet%s hardware-checksummed\n"); 278 p(tcps_rcvtotal, "\t%u packet%s received\n"); 279 p2(tcps_rcvackpack, tcps_rcvackbyte, "\t\t%u ack%s (for %qd byte%s)\n"); 280 p(tcps_rcvdupack, "\t\t%u duplicate ack%s\n"); 281 p(tcps_rcvacktoomuch, "\t\t%u ack%s for unsent data\n"); 282 p(tcps_rcvacktooold, "\t\t%u ack%s for old data\n"); 283 p2(tcps_rcvpack, tcps_rcvbyte, 284 "\t\t%u packet%s (%qu byte%s) received in-sequence\n"); 285 p2(tcps_rcvduppack, tcps_rcvdupbyte, 286 "\t\t%u completely duplicate packet%s (%qd byte%s)\n"); 287 p(tcps_pawsdrop, "\t\t%u old duplicate packet%s\n"); 288 p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte, 289 "\t\t%u packet%s with some duplicate data (%qd byte%s duplicated)\n"); 290 p2(tcps_rcvoopack, tcps_rcvoobyte, 291 "\t\t%u out-of-order packet%s (%qd byte%s)\n"); 292 p2(tcps_rcvpackafterwin, tcps_rcvbyteafterwin, 293 "\t\t%u packet%s (%qd byte%s) of data after window\n"); 294 p(tcps_rcvwinprobe, "\t\t%u window probe%s\n"); 295 p(tcps_rcvwinupd, "\t\t%u window update packet%s\n"); 296 p(tcps_rcvafterclose, "\t\t%u packet%s received after close\n"); 297 p(tcps_rcvbadsum, "\t\t%u discarded for bad checksum%s\n"); 298 p(tcps_rcvbadoff, "\t\t%u discarded for bad header offset field%s\n"); 299 p1(tcps_rcvshort, "\t\t%u discarded because packet too short\n"); 300 p1(tcps_rcvnosec, "\t\t%u discarded for missing IPsec protection\n"); 301 p1(tcps_rcvmemdrop, "\t\t%u discarded due to memory shortage\n"); 302 p(tcps_inhwcsum, "\t\t%u packet%s hardware-checksummed\n"); 303 p(tcps_rcvbadsig, "\t\t%u bad/missing md5 checksum%s\n"); 304 p(tcps_rcvgoodsig, "\t\t%qd good md5 checksum%s\n"); 305 p(tcps_connattempt, "\t%u connection request%s\n"); 306 p(tcps_accepts, "\t%u connection accept%s\n"); 307 p(tcps_connects, "\t%u connection%s established (including accepts)\n"); 308 p2(tcps_closed, tcps_drops, 309 "\t%u connection%s closed (including %u drop%s)\n"); 310 p(tcps_conndrained, "\t%qd connection%s drained\n"); 311 p(tcps_conndrops, "\t%u embryonic connection%s dropped\n"); 312 p2(tcps_rttupdated, tcps_segstimed, 313 "\t%u segment%s updated rtt (of %u attempt%s)\n"); 314 p(tcps_rexmttimeo, "\t%u retransmit timeout%s\n"); 315 p(tcps_timeoutdrop, "\t\t%u connection%s dropped by rexmit timeout\n"); 316 p(tcps_persisttimeo, "\t%u persist timeout%s\n"); 317 p(tcps_keeptimeo, "\t%u keepalive timeout%s\n"); 318 p(tcps_keepprobe, "\t\t%u keepalive probe%s sent\n"); 319 p(tcps_keepdrops, "\t\t%u connection%s dropped by keepalive\n"); 320 p(tcps_predack, "\t%u correct ACK header prediction%s\n"); 321 p(tcps_preddat, "\t%u correct data packet header prediction%s\n"); 322 p3(tcps_pcbhashmiss, "\t%u PCB cache miss%s\n"); 323 324 p(tcps_ecn_accepts, "\t%u ECN connection%s accepted\n"); 325 p(tcps_ecn_rcvece, "\t\t%u ECE packet%s received\n"); 326 p(tcps_ecn_rcvcwr, "\t\t%u CWR packet%s received\n"); 327 p(tcps_ecn_rcvce, "\t\t%u CE packet%s received\n"); 328 p(tcps_ecn_sndect, "\t\t%u ECT packet%s sent\n"); 329 p(tcps_ecn_sndece, "\t\t%u ECE packet%s sent\n"); 330 p(tcps_ecn_sndcwr, "\t\t%u CWR packet%s sent\n"); 331 p1(tcps_cwr_frecovery, "\t\t\tcwr by fastrecovery: %u\n"); 332 p1(tcps_cwr_timeout, "\t\t\tcwr by timeout: %u\n"); 333 p1(tcps_cwr_ecn, "\t\t\tcwr by ecn: %u\n"); 334 335 p(tcps_badsyn, "\t%u bad connection attempt%s\n"); 336 p1(tcps_sc_added, "\t%qd SYN cache entries added\n"); 337 p(tcps_sc_collisions, "\t\t%qd hash collision%s\n"); 338 p1(tcps_sc_completed, "\t\t%qd completed\n"); 339 p1(tcps_sc_aborted, "\t\t%qd aborted (no space to build PCB)\n"); 340 p1(tcps_sc_timed_out, "\t\t%qd timed out\n"); 341 p1(tcps_sc_overflowed, "\t\t%qd dropped due to overflow\n"); 342 p1(tcps_sc_bucketoverflow, "\t\t%qd dropped due to bucket overflow\n"); 343 p1(tcps_sc_reset, "\t\t%qd dropped due to RST\n"); 344 p1(tcps_sc_unreach, "\t\t%qd dropped due to ICMP unreachable\n"); 345 p(tcps_sc_retransmitted, "\t%qd SYN,ACK%s retransmitted\n"); 346 p(tcps_sc_dupesyn, "\t%qd duplicate SYN%s received for entries " 347 "already in the cache\n"); 348 p(tcps_sc_dropped, "\t%qd SYN%s dropped (no route or no space)\n"); 349 350 p(tcps_sack_recovery_episode, "\t%qd SACK recovery episode%s\n"); 351 p(tcps_sack_rexmits, 352 "\t\t%qd segment rexmit%s in SACK recovery episodes\n"); 353 p(tcps_sack_rexmit_bytes, 354 "\t\t%qd byte rexmit%s in SACK recovery episodes\n"); 355 p(tcps_sack_rcv_opts, 356 "\t%qd SACK option%s received\n"); 357 p(tcps_sack_snd_opts, "\t%qd SACK option%s sent\n"); 358 359 #undef p 360 #undef p1 361 #undef p2 362 #undef p2a 363 #undef p3 364 } 365 366 /* 367 * Dump UDP statistics structure. 368 */ 369 void 370 udp_stats(u_long off, char *name) 371 { 372 struct udpstat udpstat; 373 u_long delivered; 374 375 if (off == 0) 376 return; 377 kread(off, &udpstat, sizeof (udpstat)); 378 printf("%s:\n", name); 379 #define p(f, m) if (udpstat.f || sflag <= 1) \ 380 printf(m, udpstat.f, plural(udpstat.f)) 381 #define p1(f, m) if (udpstat.f || sflag <= 1) \ 382 printf(m, udpstat.f) 383 384 p(udps_ipackets, "\t%lu datagram%s received\n"); 385 p1(udps_hdrops, "\t%lu with incomplete header\n"); 386 p1(udps_badlen, "\t%lu with bad data length field\n"); 387 p1(udps_badsum, "\t%lu with bad checksum\n"); 388 p1(udps_nosum, "\t%lu with no checksum\n"); 389 p(udps_inhwcsum, "\t%lu input packet%s hardware-checksummed\n"); 390 p(udps_outhwcsum, "\t%lu output packet%s hardware-checksummed\n"); 391 p1(udps_noport, "\t%lu dropped due to no socket\n"); 392 p(udps_noportbcast, "\t%lu broadcast/multicast datagram%s dropped due to no socket\n"); 393 p1(udps_nosec, "\t%lu dropped due to missing IPsec protection\n"); 394 p1(udps_fullsock, "\t%lu dropped due to full socket buffers\n"); 395 delivered = udpstat.udps_ipackets - udpstat.udps_hdrops - 396 udpstat.udps_badlen - udpstat.udps_badsum - 397 udpstat.udps_noport - udpstat.udps_noportbcast - 398 udpstat.udps_fullsock; 399 if (delivered || sflag <= 1) 400 printf("\t%lu delivered\n", delivered); 401 p(udps_opackets, "\t%lu datagram%s output\n"); 402 p1(udps_pcbhashmiss, "\t%lu missed PCB cache\n"); 403 #undef p 404 #undef p1 405 } 406 407 /* 408 * Dump IP statistics structure. 409 */ 410 void 411 ip_stats(u_long off, char *name) 412 { 413 struct ipstat ipstat; 414 415 if (off == 0) 416 return; 417 kread(off, &ipstat, sizeof (ipstat)); 418 printf("%s:\n", name); 419 420 #define p(f, m) if (ipstat.f || sflag <= 1) \ 421 printf(m, ipstat.f, plural(ipstat.f)) 422 #define p1(f, m) if (ipstat.f || sflag <= 1) \ 423 printf(m, ipstat.f) 424 425 p(ips_total, "\t%lu total packet%s received\n"); 426 p(ips_badsum, "\t%lu bad header checksum%s\n"); 427 p1(ips_toosmall, "\t%lu with size smaller than minimum\n"); 428 p1(ips_tooshort, "\t%lu with data size < data length\n"); 429 p1(ips_badhlen, "\t%lu with header length < data size\n"); 430 p1(ips_badlen, "\t%lu with data length < header length\n"); 431 p1(ips_badoptions, "\t%lu with bad options\n"); 432 p1(ips_badvers, "\t%lu with incorrect version number\n"); 433 p(ips_fragments, "\t%lu fragment%s received\n"); 434 p(ips_fragdropped, "\t%lu fragment%s dropped (duplicates or out of space)\n"); 435 p(ips_badfrags, "\t%lu malformed fragment%s dropped\n"); 436 p(ips_fragtimeout, "\t%lu fragment%s dropped after timeout\n"); 437 p(ips_reassembled, "\t%lu packet%s reassembled ok\n"); 438 p(ips_delivered, "\t%lu packet%s for this host\n"); 439 p(ips_noproto, "\t%lu packet%s for unknown/unsupported protocol\n"); 440 p(ips_forward, "\t%lu packet%s forwarded\n"); 441 p(ips_cantforward, "\t%lu packet%s not forwardable\n"); 442 p(ips_redirectsent, "\t%lu redirect%s sent\n"); 443 p(ips_localout, "\t%lu packet%s sent from this host\n"); 444 p(ips_rawout, "\t%lu packet%s sent with fabricated ip header\n"); 445 p(ips_odropped, "\t%lu output packet%s dropped due to no bufs, etc.\n"); 446 p(ips_noroute, "\t%lu output packet%s discarded due to no route\n"); 447 p(ips_fragmented, "\t%lu output datagram%s fragmented\n"); 448 p(ips_ofragments, "\t%lu fragment%s created\n"); 449 p(ips_cantfrag, "\t%lu datagram%s that can't be fragmented\n"); 450 p1(ips_rcvmemdrop, "\t%lu fragment floods\n"); 451 p(ips_toolong, "\t%lu packet%s with ip length > max ip packet size\n"); 452 p(ips_nogif, "\t%lu tunneling packet%s that can't find gif\n"); 453 p(ips_badaddr, "\t%lu datagram%s with bad address in header\n"); 454 p(ips_inhwcsum, "\t%lu input datagram%s checksum-processed by hardware\n"); 455 p(ips_outhwcsum, "\t%lu output datagram%s checksum-processed by hardware\n"); 456 p(ips_notmember, "\t%lu multicast packet%s which we don't join\n"); 457 #undef p 458 #undef p1 459 } 460 461 static char *icmpnames[ICMP_MAXTYPE + 1] = { 462 "echo reply", 463 "#1", 464 "#2", 465 "destination unreachable", 466 "source quench", 467 "routing redirect", 468 "#6", 469 "#7", 470 "echo", 471 "router advertisement", 472 "router solicitation", 473 "time exceeded", 474 "parameter problem", 475 "time stamp", 476 "time stamp reply", 477 "information request", 478 "information request reply", 479 "address mask request", 480 "address mask reply", 481 "#19", 482 "#20", 483 "#21", 484 "#22", 485 "#23", 486 "#24", 487 "#25", 488 "#26", 489 "#27", 490 "#28", 491 "#29", 492 "traceroute", 493 "data conversion error", 494 "mobile host redirect", 495 "IPv6 where-are-you", 496 "IPv6 i-am-here", 497 "mobile registration request", 498 "mobile registration reply", 499 "#37", 500 "#38", 501 "SKIP", 502 "Photuris", 503 }; 504 505 /* 506 * Dump ICMP statistics. 507 */ 508 void 509 icmp_stats(u_long off, char *name) 510 { 511 struct icmpstat icmpstat; 512 int i, first; 513 514 if (off == 0) 515 return; 516 kread(off, &icmpstat, sizeof (icmpstat)); 517 printf("%s:\n", name); 518 519 #define p(f, m) if (icmpstat.f || sflag <= 1) \ 520 printf(m, icmpstat.f, plural(icmpstat.f)) 521 522 p(icps_error, "\t%lu call%s to icmp_error\n"); 523 p(icps_oldicmp, 524 "\t%lu error%s not generated because old message was icmp\n"); 525 for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++) 526 if (icmpstat.icps_outhist[i] != 0) { 527 if (first) { 528 printf("\tOutput packet histogram:\n"); 529 first = 0; 530 } 531 if (icmpnames[i]) 532 printf("\t\t%s:", icmpnames[i]); 533 else 534 printf("\t\t#%d:", i); 535 printf(" %lu\n", icmpstat.icps_outhist[i]); 536 } 537 p(icps_badcode, "\t%lu message%s with bad code fields\n"); 538 p(icps_tooshort, "\t%lu message%s < minimum length\n"); 539 p(icps_checksum, "\t%lu bad checksum%s\n"); 540 p(icps_badlen, "\t%lu message%s with bad length\n"); 541 for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++) 542 if (icmpstat.icps_inhist[i] != 0) { 543 if (first) { 544 printf("\tInput packet histogram:\n"); 545 first = 0; 546 } 547 if (icmpnames[i]) 548 printf("\t\t%s:", icmpnames[i]); 549 else 550 printf("\t\t#%d:", i); 551 printf(" %lu\n", icmpstat.icps_inhist[i]); 552 } 553 p(icps_reflect, "\t%lu message response%s generated\n"); 554 #undef p 555 } 556 557 /* 558 * Dump IGMP statistics structure. 559 */ 560 void 561 igmp_stats(u_long off, char *name) 562 { 563 struct igmpstat igmpstat; 564 565 if (off == 0) 566 return; 567 kread(off, &igmpstat, sizeof (igmpstat)); 568 printf("%s:\n", name); 569 570 #define p(f, m) if (igmpstat.f || sflag <= 1) \ 571 printf(m, igmpstat.f, plural(igmpstat.f)) 572 #define py(f, m) if (igmpstat.f || sflag <= 1) \ 573 printf(m, igmpstat.f, igmpstat.f != 1 ? "ies" : "y") 574 575 p(igps_rcv_total, "\t%lu message%s received\n"); 576 p(igps_rcv_tooshort, "\t%lu message%s received with too few bytes\n"); 577 p(igps_rcv_badsum, "\t%lu message%s received with bad checksum\n"); 578 py(igps_rcv_queries, "\t%lu membership quer%s received\n"); 579 py(igps_rcv_badqueries, "\t%lu membership quer%s received with invalid field(s)\n"); 580 p(igps_rcv_reports, "\t%lu membership report%s received\n"); 581 p(igps_rcv_badreports, "\t%lu membership report%s received with invalid field(s)\n"); 582 p(igps_rcv_ourreports, "\t%lu membership report%s received for groups to which we belong\n"); 583 p(igps_snd_reports, "\t%lu membership report%s sent\n"); 584 #undef p 585 #undef py 586 } 587 588 /* 589 * Dump PIM statistics structure. 590 */ 591 void 592 pim_stats(u_long off, char *name) 593 { 594 struct pimstat pimstat; 595 596 if (off == 0) 597 return; 598 if (kread(off, &pimstat, sizeof (pimstat)) != 0) { 599 /* XXX: PIM is probably not enabled in the kernel */ 600 return; 601 } 602 603 printf("%s:\n", name); 604 605 #define p(f, m) if (pimstat.f || sflag <= 1) \ 606 printf(m, pimstat.f, plural(pimstat.f)) 607 #define py(f, m) if (pimstat.f || sflag <= 1) \ 608 printf(m, pimstat.f, pimstat.f != 1 ? "ies" : "y") 609 610 p(pims_rcv_total_msgs, "\t%llu message%s received\n"); 611 p(pims_rcv_total_bytes, "\t%llu byte%s received\n"); 612 p(pims_rcv_tooshort, "\t%llu message%s received with too few bytes\n"); 613 p(pims_rcv_badsum, "\t%llu message%s received with bad checksum\n"); 614 p(pims_rcv_badversion, "\t%llu message%s received with bad version\n"); 615 p(pims_rcv_registers_msgs, "\t%llu data register message%s received\n"); 616 p(pims_rcv_registers_bytes, "\t%llu data register byte%s received\n"); 617 p(pims_rcv_registers_wrongiif, "\t%llu data register message%s received on wrong iif\n"); 618 p(pims_rcv_badregisters, "\t%llu bad register%s received\n"); 619 p(pims_snd_registers_msgs, "\t%llu data register message%s sent\n"); 620 p(pims_snd_registers_bytes, "\t%llu data register byte%s sent\n"); 621 #undef p 622 #undef py 623 } 624 625 struct rpcnams { 626 struct rpcnams *next; 627 in_port_t port; 628 int proto; 629 char *rpcname; 630 }; 631 632 static char * 633 getrpcportnam(in_port_t port, int proto) 634 { 635 struct sockaddr_in server_addr; 636 struct hostent *hp; 637 static struct pmaplist *head; 638 int socket = RPC_ANYSOCK; 639 struct timeval minutetimeout; 640 CLIENT *client; 641 struct rpcent *rpc; 642 static int first; 643 static struct rpcnams *rpcn; 644 struct rpcnams *n; 645 char num[20]; 646 647 if (first == 0) { 648 first = 1; 649 memset(&server_addr, 0, sizeof server_addr); 650 server_addr.sin_family = AF_INET; 651 if ((hp = gethostbyname("localhost")) != NULL) 652 memmove((caddr_t)&server_addr.sin_addr, hp->h_addr, 653 hp->h_length); 654 else 655 (void) inet_aton("0.0.0.0", &server_addr.sin_addr); 656 657 minutetimeout.tv_sec = 60; 658 minutetimeout.tv_usec = 0; 659 server_addr.sin_port = htons(PMAPPORT); 660 if ((client = clnttcp_create(&server_addr, PMAPPROG, 661 PMAPVERS, &socket, 50, 500)) == NULL) 662 return (NULL); 663 if (clnt_call(client, PMAPPROC_DUMP, xdr_void, NULL, 664 xdr_pmaplist, &head, minutetimeout) != RPC_SUCCESS) { 665 clnt_destroy(client); 666 return (NULL); 667 } 668 for (; head != NULL; head = head->pml_next) { 669 n = (struct rpcnams *)malloc(sizeof(struct rpcnams)); 670 if (n == NULL) 671 continue; 672 n->next = rpcn; 673 rpcn = n; 674 n->port = head->pml_map.pm_port; 675 n->proto = head->pml_map.pm_prot; 676 677 rpc = getrpcbynumber(head->pml_map.pm_prog); 678 if (rpc) 679 n->rpcname = strdup(rpc->r_name); 680 else { 681 snprintf(num, sizeof num, "%ld", 682 head->pml_map.pm_prog); 683 n->rpcname = strdup(num); 684 } 685 } 686 clnt_destroy(client); 687 } 688 689 for (n = rpcn; n; n = n->next) 690 if (n->port == port && n->proto == proto) 691 return (n->rpcname); 692 return (NULL); 693 } 694 695 /* 696 * Pretty print an Internet address (net address + port). 697 * If the nflag was specified, use numbers instead of names. 698 */ 699 void 700 inetprint(struct in_addr *in, in_port_t port, char *proto, int local) 701 { 702 struct servent *sp = 0; 703 char line[80], *cp, *nam; 704 int width; 705 706 snprintf(line, sizeof line, "%.*s.", (Aflag && !nflag) ? 12 : 16, 707 inetname(in)); 708 cp = strchr(line, '\0'); 709 if (!nflag && port) 710 sp = getservbyport((int)port, proto); 711 if (sp || port == 0) 712 snprintf(cp, line + sizeof line - cp, "%.8s", 713 sp ? sp->s_name : "*"); 714 else if (local && !nflag && (nam = getrpcportnam(ntohs(port), 715 (strcmp(proto, "tcp") == 0 ? IPPROTO_TCP : IPPROTO_UDP)))) 716 snprintf(cp, line + sizeof line - cp, "%d[%.8s]", 717 ntohs(port), nam); 718 else 719 snprintf(cp, line + sizeof line - cp, "%d", ntohs(port)); 720 width = Aflag ? 18 : 22; 721 printf(" %-*.*s", width, width, line); 722 } 723 724 /* 725 * Construct an Internet address representation. 726 * If the nflag has been supplied, give 727 * numeric value, otherwise try for symbolic name. 728 */ 729 char * 730 inetname(struct in_addr *inp) 731 { 732 char *cp; 733 static char line[50]; 734 struct hostent *hp; 735 struct netent *np; 736 static char domain[MAXHOSTNAMELEN]; 737 static int first = 1; 738 739 if (first && !nflag) { 740 first = 0; 741 if (gethostname(domain, sizeof(domain)) == 0 && 742 (cp = strchr(domain, '.'))) 743 (void) strlcpy(domain, cp + 1, sizeof domain); 744 else 745 domain[0] = '\0'; 746 } 747 cp = NULL; 748 if (!nflag && inp->s_addr != INADDR_ANY) { 749 int net = inet_netof(*inp); 750 int lna = inet_lnaof(*inp); 751 752 if (lna == INADDR_ANY) { 753 np = getnetbyaddr(net, AF_INET); 754 if (np) 755 cp = np->n_name; 756 } 757 if (cp == NULL) { 758 hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET); 759 if (hp) { 760 if ((cp = strchr(hp->h_name, '.')) && 761 !strcmp(cp + 1, domain)) 762 *cp = '\0'; 763 cp = hp->h_name; 764 } 765 } 766 } 767 if (inp->s_addr == INADDR_ANY) 768 snprintf(line, sizeof line, "*"); 769 else if (cp) 770 snprintf(line, sizeof line, "%s", cp); 771 else { 772 inp->s_addr = ntohl(inp->s_addr); 773 #define C(x) ((x) & 0xff) 774 snprintf(line, sizeof line, "%u.%u.%u.%u", 775 C(inp->s_addr >> 24), C(inp->s_addr >> 16), 776 C(inp->s_addr >> 8), C(inp->s_addr)); 777 } 778 return (line); 779 } 780 781 /* 782 * Dump AH statistics structure. 783 */ 784 void 785 ah_stats(u_long off, char *name) 786 { 787 struct ahstat ahstat; 788 789 if (off == 0) 790 return; 791 kread(off, &ahstat, sizeof (ahstat)); 792 printf("%s:\n", name); 793 794 #define p(f, m) if (ahstat.f || sflag <= 1) \ 795 printf(m, ahstat.f, plural(ahstat.f)) 796 #define p1(f, m) if (ahstat.f || sflag <= 1) \ 797 printf(m, ahstat.f) 798 799 p1(ahs_input, "\t%u input AH packets\n"); 800 p1(ahs_output, "\t%u output AH packets\n"); 801 p(ahs_nopf, "\t%u packet%s from unsupported protocol families\n"); 802 p(ahs_hdrops, "\t%u packet%s shorter than header shows\n"); 803 p(ahs_pdrops, "\t%u packet%s dropped due to policy\n"); 804 p(ahs_notdb, "\t%u packet%s for which no TDB was found\n"); 805 p(ahs_badkcr, "\t%u input packet%s that failed to be processed\n"); 806 p(ahs_badauth, "\t%u packet%s that failed verification received\n"); 807 p(ahs_noxform, "\t%u packet%s for which no XFORM was set in TDB received\n"); 808 p(ahs_qfull, "\t%u packet%s were dropped due to full output queue\n"); 809 p(ahs_wrap, "\t%u packet%s where counter wrapping was detected\n"); 810 p(ahs_replay, "\t%u possibly replayed packet%s received\n"); 811 p(ahs_badauthl, "\t%u packet%s with bad authenticator length received\n"); 812 p(ahs_invalid, "\t%u packet%s attempted to use an invalid TDB\n"); 813 p(ahs_toobig, "\t%u packet%s got larger than max IP packet size\n"); 814 p(ahs_crypto, "\t%u packet%s that failed crypto processing\n"); 815 p(ahs_ibytes, "\t%qu input byte%s\n"); 816 p(ahs_obytes, "\t%qu output byte%s\n"); 817 818 #undef p 819 #undef p1 820 } 821 822 /* 823 * Dump etherip statistics structure. 824 */ 825 void 826 etherip_stats(u_long off, char *name) 827 { 828 struct etheripstat etheripstat; 829 830 if (off == 0) 831 return; 832 kread(off, ðeripstat, sizeof (etheripstat)); 833 printf("%s:\n", name); 834 835 #define p(f, m) if (etheripstat.f || sflag <= 1) \ 836 printf(m, etheripstat.f, plural(etheripstat.f)) 837 838 p(etherip_hdrops, "\t%u packet%s shorter than header shows\n"); 839 p(etherip_qfull, "\t%u packet%s were dropped due to full output queue\n"); 840 p(etherip_noifdrops, "\t%u packet%s were dropped because of no interface/bridge information\n"); 841 p(etherip_pdrops, "\t%u packet%s dropped due to policy\n"); 842 p(etherip_adrops, "\t%u packet%s dropped for other reasons\n"); 843 p(etherip_ipackets, "\t%u input ethernet-in-IP packet%s\n"); 844 p(etherip_opackets, "\t%u output ethernet-in-IP packet%s\n"); 845 p(etherip_ibytes, "\t%qu input byte%s\n"); 846 p(etherip_obytes, "\t%qu output byte%s\n"); 847 #undef p 848 } 849 850 /* 851 * Dump ESP statistics structure. 852 */ 853 void 854 esp_stats(u_long off, char *name) 855 { 856 struct espstat espstat; 857 858 if (off == 0) 859 return; 860 kread(off, &espstat, sizeof (espstat)); 861 printf("%s:\n", name); 862 863 #define p(f, m) if (espstat.f || sflag <= 1) \ 864 printf(m, espstat.f, plural(espstat.f)) 865 866 p(esps_input, "\t%u input ESP packet%s\n"); 867 p(esps_output, "\t%u output ESP packet%s\n"); 868 p(esps_nopf, "\t%u packet%s from unsupported protocol families\n"); 869 p(esps_hdrops, "\t%u packet%s shorter than header shows\n"); 870 p(esps_pdrops, "\t%u packet%s dropped due to policy\n"); 871 p(esps_notdb, "\t%u packet%s for which no TDB was found\n"); 872 p(esps_badkcr, "\t%u input packet%s that failed to be processed\n"); 873 p(esps_badenc, "\t%u packet%s with bad encryption received\n"); 874 p(esps_badauth, "\t%u packet%s that failed verification received\n"); 875 p(esps_noxform, "\t%u packet%s for which no XFORM was set in TDB received\n"); 876 p(esps_qfull, "\t%u packet%s were dropped due to full output queue\n"); 877 p(esps_wrap, "\t%u packet%s where counter wrapping was detected\n"); 878 p(esps_replay, "\t%u possibly replayed packet%s received\n"); 879 p(esps_badilen, "\t%u packet%s with bad payload size or padding received\n"); 880 p(esps_invalid, "\t%u packet%s attempted to use an invalid TDB\n"); 881 p(esps_toobig, "\t%u packet%s got larger than max IP packet size\n"); 882 p(esps_crypto, "\t%u packet%s that failed crypto processing\n"); 883 p(esps_udpencin, "\t%u input UDP encapsulated ESP packet%s\n"); 884 p(esps_udpencout, "\t%u output UDP encapsulated ESP packet%s\n"); 885 p(esps_udpinval, "\t%u UDP packet%s for non-encapsulating TDB received\n"); 886 p(esps_ibytes, "\t%qu input byte%s\n"); 887 p(esps_obytes, "\t%qu output byte%s\n"); 888 889 #undef p 890 } 891 892 /* 893 * Dump IP-in-IP statistics structure. 894 */ 895 void 896 ipip_stats(u_long off, char *name) 897 { 898 struct ipipstat ipipstat; 899 900 if (off == 0) 901 return; 902 kread(off, &ipipstat, sizeof (ipipstat)); 903 printf("%s:\n", name); 904 905 #define p(f, m) if (ipipstat.f || sflag <= 1) \ 906 printf(m, ipipstat.f, plural(ipipstat.f)) 907 908 p(ipips_ipackets, "\t%u total input packet%s\n"); 909 p(ipips_opackets, "\t%u total output packet%s\n"); 910 p(ipips_hdrops, "\t%u packet%s shorter than header shows\n"); 911 p(ipips_pdrops, "\t%u packet%s dropped due to policy\n"); 912 p(ipips_spoof, "\t%u packet%s with possibly spoofed local addresses\n"); 913 p(ipips_qfull, "\t%u packet%s were dropped due to full output queue\n"); 914 p(ipips_ibytes, "\t%qu input byte%s\n"); 915 p(ipips_obytes, "\t%qu output byte%s\n"); 916 p(ipips_family, "\t%u protocol family mismatche%s\n"); 917 p(ipips_unspec, "\t%u attempt%s to use tunnel with unspecified endpoint(s)\n"); 918 #undef p 919 } 920 921 /* 922 * Dump CARP statistics structure. 923 */ 924 void 925 carp_stats(u_long off, char *name) 926 { 927 struct carpstats carpstat; 928 929 if (off == 0) 930 return; 931 kread(off, &carpstat, sizeof(carpstat)); 932 printf("%s:\n", name); 933 934 #define p(f, m) if (carpstat.f || sflag <= 1) \ 935 printf(m, carpstat.f, plural(carpstat.f)) 936 #define p2(f, m) if (carpstat.f || sflag <= 1) \ 937 printf(m, carpstat.f) 938 939 p(carps_ipackets, "\t%llu packet%s received (IPv4)\n"); 940 p(carps_ipackets6, "\t%llu packet%s received (IPv6)\n"); 941 p(carps_badif, "\t\t%llu packet%s discarded for bad interface\n"); 942 p(carps_badttl, "\t\t%llu packet%s discarded for wrong TTL\n"); 943 p(carps_hdrops, "\t\t%llu packet%s shorter than header\n"); 944 p(carps_badsum, "\t\t%llu discarded for bad checksum%s\n"); 945 p(carps_badver, "\t\t%llu discarded packet%s with a bad version\n"); 946 p2(carps_badlen, "\t\t%llu discarded because packet too short\n"); 947 p2(carps_badauth, "\t\t%llu discarded for bad authentication\n"); 948 p2(carps_badvhid, "\t\t%llu discarded for bad vhid\n"); 949 p2(carps_badaddrs, "\t\t%llu discarded because of a bad address list\n"); 950 p(carps_opackets, "\t%llu packet%s sent (IPv4)\n"); 951 p(carps_opackets6, "\t%llu packet%s sent (IPv6)\n"); 952 p2(carps_onomem, "\t\t%llu send failed due to mbuf memory error\n"); 953 #undef p 954 #undef p2 955 } 956 957 /* 958 * Dump pfsync statistics structure. 959 */ 960 void 961 pfsync_stats(u_long off, char *name) 962 { 963 struct pfsyncstats pfsyncstat; 964 965 if (off == 0) 966 return; 967 kread(off, &pfsyncstat, sizeof(pfsyncstat)); 968 printf("%s:\n", name); 969 970 #define p(f, m) if (pfsyncstat.f || sflag <= 1) \ 971 printf(m, pfsyncstat.f, plural(pfsyncstat.f)) 972 #define p2(f, m) if (pfsyncstat.f || sflag <= 1) \ 973 printf(m, pfsyncstat.f) 974 975 p(pfsyncs_ipackets, "\t%llu packet%s received (IPv4)\n"); 976 p(pfsyncs_ipackets6, "\t%llu packet%s received (IPv6)\n"); 977 p(pfsyncs_badif, "\t\t%llu packet%s discarded for bad interface\n"); 978 p(pfsyncs_badttl, "\t\t%llu packet%s discarded for bad ttl\n"); 979 p(pfsyncs_hdrops, "\t\t%llu packet%s shorter than header\n"); 980 p(pfsyncs_badver, "\t\t%llu packet%s discarded for bad version\n"); 981 p(pfsyncs_badauth, "\t\t%llu packet%s discarded for bad HMAC\n"); 982 p(pfsyncs_badact,"\t\t%llu packet%s discarded for bad action\n"); 983 p(pfsyncs_badlen, "\t\t%llu packet%s discarded for short packet\n"); 984 p(pfsyncs_badval, "\t\t%llu state%s discarded for bad values\n"); 985 p(pfsyncs_stale, "\t\t%llu stale state%s\n"); 986 p(pfsyncs_badstate, "\t\t%llu failed state lookup/insert%s\n"); 987 p(pfsyncs_opackets, "\t%llu packet%s sent (IPv4)\n"); 988 p(pfsyncs_opackets6, "\t%llu packet%s sent (IPv6)\n"); 989 p2(pfsyncs_onomem, "\t\t%llu send failed due to mbuf memory error\n"); 990 p2(pfsyncs_oerrors, "\t\t%llu send error\n"); 991 #undef p 992 #undef p2 993 } 994 995 /* 996 * Dump IPCOMP statistics structure. 997 */ 998 void 999 ipcomp_stats(u_long off, char *name) 1000 { 1001 struct ipcompstat ipcompstat; 1002 1003 if (off == 0) 1004 return; 1005 kread(off, &ipcompstat, sizeof (ipcompstat)); 1006 printf("%s:\n", name); 1007 1008 #define p(f, m) if (ipcompstat.f || sflag <= 1) \ 1009 printf(m, ipcompstat.f, plural(ipcompstat.f)) 1010 1011 p(ipcomps_input, "\t%u input IPCOMP packet%s\n"); 1012 p(ipcomps_output, "\t%u output IPCOMP packet%s\n"); 1013 p(ipcomps_nopf, "\t%u packet%s from unsupported protocol families\n"); 1014 p(ipcomps_hdrops, "\t%u packet%s shorter than header shows\n"); 1015 p(ipcomps_pdrops, "\t%u packet%s dropped due to policy\n"); 1016 p(ipcomps_notdb, "\t%u packet%s for which no TDB was found\n"); 1017 p(ipcomps_badkcr, "\t%u input packet%s that failed to be processed\n"); 1018 p(ipcomps_noxform, "\t%u packet%s for which no XFORM was set in TDB received\n"); 1019 p(ipcomps_qfull, "\t%u packet%s were dropped due to full output queue\n"); 1020 p(ipcomps_wrap, "\t%u packet%s where counter wrapping was detected\n"); 1021 p(ipcomps_invalid, "\t%u packet%s attempted to use an invalid TDB\n"); 1022 p(ipcomps_toobig, "\t%u packet%s got larger than max IP packet size\n"); 1023 p(ipcomps_crypto, "\t%u packet%s that failed (de)compression processing\n"); 1024 p(ipcomps_minlen, "\t%u packet%s less than minimum compression length\n"); 1025 p(ipcomps_ibytes, "\t%qu input byte%s\n"); 1026 p(ipcomps_obytes, "\t%qu output byte%s\n"); 1027 1028 #undef p 1029 } 1030 1031 /* 1032 * Dump the contents of a TCPCB 1033 */ 1034 void 1035 tcp_dump(u_long off) 1036 { 1037 struct tcpcb tcpcb; 1038 1039 if (off == 0) 1040 return; 1041 kread(off, (char *)&tcpcb, sizeof (tcpcb)); 1042 1043 #define p(fmt, v, sep) printf(#v " " fmt sep, tcpcb.v); 1044 printf("pcb %p, ", off); 1045 p("%p", t_inpcb, "\n"); 1046 p("%d", t_state, ""); 1047 if (tcpcb.t_state >= 0 && tcpcb.t_state < TCP_NSTATES) 1048 printf(" (%s)", tcpstates[tcpcb.t_state]); 1049 printf("\n"); 1050 p("%d", t_rxtshift, ", "); 1051 p("%d", t_rxtcur, ", "); 1052 p("%d", t_dupacks, "\n"); 1053 p("%u", t_maxseg, ", "); 1054 p("%u", t_maxopd, ", "); 1055 p("%u", t_peermss, "\n"); 1056 p("0x%x", t_flags, ", "); 1057 p("%u", t_force, "\n"); 1058 p("%u", iss, "\n"); 1059 p("%u", snd_una, ", "); 1060 p("%u", snd_nxt, ", "); 1061 p("%u", snd_up, "\n"); 1062 p("%u", snd_wl1, ", "); 1063 p("%u", snd_wl2, ", "); 1064 p("%lu", snd_wnd, "\n"); 1065 p("%d", sack_enable, ", "); 1066 p("%d", snd_numholes, ", "); 1067 p("%u", snd_fack, ", "); 1068 p("%lu",snd_awnd, "\n"); 1069 p("%u", retran_data, ", "); 1070 p("%u", snd_last, "\n"); 1071 p("%u", irs, "\n"); 1072 p("%u", rcv_nxt, ", "); 1073 p("%u", rcv_up, ", "); 1074 p("%lu", rcv_wnd, "\n"); 1075 p("%u", rcv_lastsack, "\n"); 1076 p("%d", rcv_numsacks, "\n"); 1077 p("%u", rcv_adv, ", "); 1078 p("%u", snd_max, "\n"); 1079 p("%lu", snd_cwnd, ", "); 1080 p("%lu", snd_ssthresh, ", "); 1081 p("%lu", max_sndwnd, "\n"); 1082 p("%u", t_rcvtime, ", "); 1083 p("%u", t_rtttime, ", "); 1084 p("%u", t_rtseq, "\n"); 1085 p("%u", t_srtt, ", "); 1086 p("%u", t_rttvar, ", "); 1087 p("%u", t_rttmin, "\n"); 1088 p("%u", t_oobflags, ", "); 1089 p("%u", t_iobc, "\n"); 1090 p("%u", t_softerror, "\n"); 1091 p("%u", snd_scale, ", "); 1092 p("%u", rcv_scale, ", "); 1093 p("%u", request_r_scale, ", "); 1094 p("%u", requested_s_scale, "\n"); 1095 p("%u", ts_recent, ", "); 1096 p("%u", ts_recent_age, "\n"); 1097 p("%u", last_ack_sent, "\n"); 1098 HTONS(tcpcb.t_pmtud_ip_len); 1099 HTONS(tcpcb.t_pmtud_nextmtu); 1100 p("%u", t_pmtud_mss_acked, ", "); 1101 p("%u", t_pmtud_mtu_sent, "\n"); 1102 p("%u", t_pmtud_nextmtu, ", "); 1103 p("%u", t_pmtud_ip_len, ", "); 1104 p("%u", t_pmtud_ip_hl, "\n"); 1105 p("%u", t_pmtud_th_seq, "\n"); 1106 p("%u", pf, "\n"); 1107 #undef p 1108 } 1109