inet.c (175077) | inet.c (179027) |
---|---|
1/*- 2 * Copyright (c) 1983, 1988, 1993, 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 24 unchanged lines hidden (view full) --- 33 34#if 0 35#ifndef lint 36static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95"; 37#endif /* not lint */ 38#endif 39 40#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1983, 1988, 1993, 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 24 unchanged lines hidden (view full) --- 33 34#if 0 35#ifndef lint 36static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95"; 37#endif /* not lint */ 38#endif 39 40#include <sys/cdefs.h> |
41__FBSDID("$FreeBSD: head/usr.bin/netstat/inet.c 175077 2008-01-04 03:09:28Z obrien $"); | 41__FBSDID("$FreeBSD: head/usr.bin/netstat/inet.c 179027 2008-05-15 20:18:44Z gnn $"); |
42 43#include <sys/param.h> 44#include <sys/queue.h> 45#include <sys/domain.h> 46#include <sys/socket.h> 47#include <sys/socketvar.h> 48#include <sys/sysctl.h> 49#include <sys/protosw.h> --- 87 unchanged lines hidden (view full) --- 137 * nested structures that aren't used to avoid extra work. 138 */ 139static void 140sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb) 141{ 142 xsb->sb_cc = sb->sb_cc; 143 xsb->sb_hiwat = sb->sb_hiwat; 144 xsb->sb_mbcnt = sb->sb_mbcnt; | 42 43#include <sys/param.h> 44#include <sys/queue.h> 45#include <sys/domain.h> 46#include <sys/socket.h> 47#include <sys/socketvar.h> 48#include <sys/sysctl.h> 49#include <sys/protosw.h> --- 87 unchanged lines hidden (view full) --- 137 * nested structures that aren't used to avoid extra work. 138 */ 139static void 140sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb) 141{ 142 xsb->sb_cc = sb->sb_cc; 143 xsb->sb_hiwat = sb->sb_hiwat; 144 xsb->sb_mbcnt = sb->sb_mbcnt; |
145 xsb->sb_mcnt = sb->sb_mcnt; 146 xsb->sb_ccnt = sb->sb_ccnt; |
|
145 xsb->sb_mbmax = sb->sb_mbmax; 146 xsb->sb_lowat = sb->sb_lowat; 147 xsb->sb_flags = sb->sb_flags; 148 xsb->sb_timeo = sb->sb_timeo; 149} 150 151int 152sotoxsocket(struct socket *so, struct xsocket *xso) --- 247 unchanged lines hidden (view full) --- 400 printf( 401 "Current listen queue sizes (qlen/incqlen/maxqlen)"); 402 putchar('\n'); 403 if (Aflag) 404 printf("%-8.8s ", "Tcpcb"); 405 if (Lflag) 406 printf("%-5.5s %-14.14s %-22.22s\n", 407 "Proto", "Listen", "Local Address"); | 147 xsb->sb_mbmax = sb->sb_mbmax; 148 xsb->sb_lowat = sb->sb_lowat; 149 xsb->sb_flags = sb->sb_flags; 150 xsb->sb_timeo = sb->sb_timeo; 151} 152 153int 154sotoxsocket(struct socket *so, struct xsocket *xso) --- 247 unchanged lines hidden (view full) --- 402 printf( 403 "Current listen queue sizes (qlen/incqlen/maxqlen)"); 404 putchar('\n'); 405 if (Aflag) 406 printf("%-8.8s ", "Tcpcb"); 407 if (Lflag) 408 printf("%-5.5s %-14.14s %-22.22s\n", 409 "Proto", "Listen", "Local Address"); |
410 printf((Aflag && !Wflag) ? 411 "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s" : 412 "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s", 413 "Proto", "Recv-Q", "Send-Q", 414 "Local Address", "Foreign Address"); 415 if (xflag) 416 printf("%-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %s\n", 417 "R-MBUF", "S-MBUF", "R-CLUS", "S-CLUS", 418 "R-HIWA", "S-HIWA", "R-LOWA", "S-LOWA", 419 "R-BCNT", "S-BCNT", "R-BMAX", "S-BMAX", 420 "(state)"); |
|
408 else | 421 else |
409 printf((Aflag && !Wflag) ? 410 "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n" : 411 "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n", 412 "Proto", "Recv-Q", "Send-Q", 413 "Local Address", "Foreign Address", 414 "(state)"); | 422 printf("(state)\n"); |
415 first = 0; 416 } 417 if (Lflag && so->so_qlimit == 0) 418 continue; 419 if (Aflag) { 420 if (istcp) 421 printf("%8lx ", (u_long)inp->inp_ppcb); 422 else --- 10 unchanged lines hidden (view full) --- 433 printf("%-3.3s%-2.2s ", name, vchar); 434 if (Lflag) { 435 char buf1[15]; 436 437 snprintf(buf1, 15, "%d/%d/%d", so->so_qlen, 438 so->so_incqlen, so->so_qlimit); 439 printf("%-14.14s ", buf1); 440 } else { | 423 first = 0; 424 } 425 if (Lflag && so->so_qlimit == 0) 426 continue; 427 if (Aflag) { 428 if (istcp) 429 printf("%8lx ", (u_long)inp->inp_ppcb); 430 else --- 10 unchanged lines hidden (view full) --- 441 printf("%-3.3s%-2.2s ", name, vchar); 442 if (Lflag) { 443 char buf1[15]; 444 445 snprintf(buf1, 15, "%d/%d/%d", so->so_qlen, 446 so->so_incqlen, so->so_qlimit); 447 printf("%-14.14s ", buf1); 448 } else { |
441 printf("%6u %6u ", so->so_rcv.sb_cc, so->so_snd.sb_cc); | 449 printf("%6u %6u ", 450 so->so_rcv.sb_cc, so->so_snd.sb_cc); |
442 } 443 if (numeric_port) { 444 if (inp->inp_vflag & INP_IPV4) { 445 inetprint(&inp->inp_laddr, (int)inp->inp_lport, 446 name, 1); 447 if (!Lflag) 448 inetprint(&inp->inp_faddr, 449 (int)inp->inp_fport, name, 1); --- 39 unchanged lines hidden (view full) --- 489 (int)inp->inp_lport, name, 0); 490 if (!Lflag) 491 inet6print(&inp->in6p_faddr, 492 (int)inp->inp_fport, name, 493 inp->inp_lport != inp->inp_fport); 494 } /* else nothing printed now */ 495#endif /* INET6 */ 496 } | 451 } 452 if (numeric_port) { 453 if (inp->inp_vflag & INP_IPV4) { 454 inetprint(&inp->inp_laddr, (int)inp->inp_lport, 455 name, 1); 456 if (!Lflag) 457 inetprint(&inp->inp_faddr, 458 (int)inp->inp_fport, name, 1); --- 39 unchanged lines hidden (view full) --- 498 (int)inp->inp_lport, name, 0); 499 if (!Lflag) 500 inet6print(&inp->in6p_faddr, 501 (int)inp->inp_fport, name, 502 inp->inp_lport != inp->inp_fport); 503 } /* else nothing printed now */ 504#endif /* INET6 */ 505 } |
506 if (xflag) { 507 if (Lflag) 508 printf("%21s %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u ", 509 " ", 510 so->so_rcv.sb_mcnt, so->so_snd.sb_mcnt, 511 so->so_rcv.sb_ccnt, so->so_snd.sb_ccnt, 512 so->so_rcv.sb_hiwat, so->so_snd.sb_hiwat, 513 so->so_rcv.sb_lowat, so->so_snd.sb_lowat, 514 so->so_rcv.sb_mbcnt, so->so_snd.sb_mbcnt, 515 so->so_rcv.sb_mbmax, so->so_snd.sb_mbmax); 516 else 517 printf("%6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u ", 518 so->so_rcv.sb_mcnt, so->so_snd.sb_mcnt, 519 so->so_rcv.sb_ccnt, so->so_snd.sb_ccnt, 520 so->so_rcv.sb_hiwat, so->so_snd.sb_hiwat, 521 so->so_rcv.sb_lowat, so->so_snd.sb_lowat, 522 so->so_rcv.sb_mbcnt, so->so_snd.sb_mbcnt, 523 so->so_rcv.sb_mbmax, so->so_snd.sb_mbmax); 524 } |
|
497 if (istcp && !Lflag) { 498 if (tp->t_state < 0 || tp->t_state >= TCP_NSTATES) 499 printf("%d", tp->t_state); | 525 if (istcp && !Lflag) { 526 if (tp->t_state < 0 || tp->t_state >= TCP_NSTATES) 527 printf("%d", tp->t_state); |
500 else { | 528 else { |
501 printf("%s", tcpstates[tp->t_state]); 502#if defined(TF_NEEDSYN) && defined(TF_NEEDFIN) 503 /* Show T/TCP `hidden state' */ 504 if (tp->t_flags & (TF_NEEDSYN|TF_NEEDFIN)) 505 putchar('*'); 506#endif /* defined(TF_NEEDSYN) && defined(TF_NEEDFIN) */ 507 } | 529 printf("%s", tcpstates[tp->t_state]); 530#if defined(TF_NEEDSYN) && defined(TF_NEEDFIN) 531 /* Show T/TCP `hidden state' */ 532 if (tp->t_flags & (TF_NEEDSYN|TF_NEEDFIN)) 533 putchar('*'); 534#endif /* defined(TF_NEEDSYN) && defined(TF_NEEDFIN) */ 535 } |
508 } | 536 } |
509 putchar('\n'); 510 } 511 if (xig != oxig && xig->xig_gen != oxig->xig_gen) { 512 if (oxig->xig_count > xig->xig_count) { 513 printf("Some %s sockets may have been deleted.\n", 514 name); 515 } else if (oxig->xig_count < xig->xig_count) { 516 printf("Some %s sockets may have been created.\n", --- 609 unchanged lines hidden --- | 537 putchar('\n'); 538 } 539 if (xig != oxig && xig->xig_gen != oxig->xig_gen) { 540 if (oxig->xig_count > xig->xig_count) { 541 printf("Some %s sockets may have been deleted.\n", 542 name); 543 } else if (oxig->xig_count < xig->xig_count) { 544 printf("Some %s sockets may have been created.\n", --- 609 unchanged lines hidden --- |