summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2011-03-15 13:10:32 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2011-03-15 13:10:32 +0000
commit14140ba333d1f37745c00caf55b042a7d8182ef4 (patch)
treec9c057a8cde79c9aabefdb92105501928f3fb307 /usr.bin
parent7df9027b84c46b50471d8d278e77424d5f90ce79 (diff)
Add a -B flag to netstat which displays buffer sizes for TCP sockets.
With feedback from bluhm@ ok bluhm@ sthen@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/netstat/inet.c34
-rw-r--r--usr.bin/netstat/main.c10
-rw-r--r--usr.bin/netstat/netstat.111
-rw-r--r--usr.bin/netstat/netstat.h3
4 files changed, 38 insertions, 20 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 41d47c82de3..c5019bf697d 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet.c,v 1.115 2011/03/02 21:51:14 bluhm Exp $ */
+/* $OpenBSD: inet.c,v 1.116 2011/03/15 13:10:31 jsing Exp $ */
/* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */
/*
@@ -114,6 +114,7 @@ protopr(u_long off, char *name, int af, u_long pcbaddr)
struct inpcb *head, *next, *prev;
struct inpcb inpcb;
int istcp, israw, isany;
+ int addrlen = 22;
int first = 1;
char *name0;
char namebuf[20];
@@ -180,16 +181,18 @@ protopr(u_long off, char *name, int af, u_long pcbaddr)
if (aflag)
printf(" (including servers)");
putchar('\n');
- if (Aflag)
- printf("%-*.*s %-7.7s %-6.6s %-6.6s %-18.18s %-18.18s %s\n",
- PLEN, PLEN, "PCB", "Proto", "Recv-Q",
- "Send-Q", "Local Address",
- "Foreign Address", "(state)");
- else
- printf("%-7.7s %-6.6s %-6.6s %-22.22s %-22.22s %s\n",
- "Proto", "Recv-Q", "Send-Q",
- "Local Address", "Foreign Address",
- "(state)");
+ if (Aflag) {
+ addrlen = 18;
+ printf("%-*.*s ", PLEN, PLEN, "PCB");
+ }
+ printf("%-7.7s %-6.6s %-6.6s ",
+ "Proto", "Recv-Q", "Send-Q");
+ if (Bflag && istcp)
+ printf("%-6.6s %-6.6s %-6.6s ",
+ "Recv-W", "Send-W", "Cgst-W");
+ printf(" %-*.*s %-*.*s %s\n",
+ addrlen, addrlen, "Local Address",
+ addrlen, addrlen, "Foreign Address", "(state)");
first = 0;
}
if (Aflag) {
@@ -204,8 +207,13 @@ protopr(u_long off, char *name, int af, u_long pcbaddr)
name = namebuf;
} else
name = name0;
- printf("%-7.7s %6ld %6ld ", name, sockb.so_rcv.sb_cc,
- sockb.so_snd.sb_cc);
+ printf("%-7.7s %6lu %6lu ",
+ name, sockb.so_rcv.sb_cc, sockb.so_snd.sb_cc);
+ if (Bflag && istcp)
+ printf("%6lu %6lu %6lu ", tcpcb.rcv_wnd, tcpcb.snd_wnd,
+ (tcpcb.t_state == TCPS_ESTABLISHED) ?
+ tcpcb.snd_cwnd : 0);
+
if (inpcb.inp_flags & INP_IPV6) {
inet6print(&inpcb.inp_laddr6, (int)inpcb.inp_lport,
name);
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index 5f3fd0059e5..c1e65e4988a 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.87 2010/10/30 23:06:05 bluhm Exp $ */
+/* $OpenBSD: main.c,v 1.88 2011/03/15 13:10:31 jsing Exp $ */
/* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */
/*
@@ -169,7 +169,8 @@ main(int argc, char *argv[])
af = AF_UNSPEC;
- while ((ch = getopt(argc, argv, "Aabc:dFf:gI:ilM:mN:np:P:qrsT:tuvW:w:")) != -1)
+ while ((ch = getopt(argc, argv,
+ "AaBbc:dFf:gI:ilM:mN:np:P:qrsT:tuvW:w:")) != -1)
switch (ch) {
case 'A':
Aflag = 1;
@@ -177,6 +178,9 @@ main(int argc, char *argv[])
case 'a':
aflag = 1;
break;
+ case 'B':
+ Bflag = 1;
+ break;
case 'b':
bflag = 1;
break;
@@ -527,7 +531,7 @@ static void
usage(void)
{
(void)fprintf(stderr,
- "usage: %s [-Aan] [-f address_family] [-M core] [-N system]\n"
+ "usage: %s [-AaBn] [-f address_family] [-M core] [-N system]\n"
" %s [-bdFgilmnqrstu] [-f address_family] [-M core] [-N system]\n"
" [-T tableid]\n"
" %s [-bdn] [-c count] [-I interface] [-M core] [-N system] [-w wait]\n"
diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1
index 740020eb76e..3154be634a8 100644
--- a/usr.bin/netstat/netstat.1
+++ b/usr.bin/netstat/netstat.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: netstat.1,v 1.62 2011/03/05 18:34:12 schwarze Exp $
+.\" $OpenBSD: netstat.1,v 1.63 2011/03/15 13:10:31 jsing Exp $
.\" $NetBSD: netstat.1,v 1.11 1995/10/03 21:42:43 thorpej Exp $
.\"
.\" Copyright (c) 1983, 1990, 1992, 1993
@@ -30,7 +30,7 @@
.\"
.\" from: @(#)netstat.1 8.8 (Berkeley) 4/18/94
.\"
-.Dd $Mdocdate: March 5 2011 $
+.Dd $Mdocdate: March 15 2011 $
.Dt NETSTAT 1
.Os
.Sh NAME
@@ -38,7 +38,7 @@
.Nd show network status
.Sh SYNOPSIS
.Nm netstat
-.Op Fl Aan
+.Op Fl AaBn
.Op Fl f Ar address_family
.Op Fl p Ar protocol
.Op Fl M Ar core
@@ -119,6 +119,11 @@ With the interface display (options
or
.Fl i ) ,
show multicast addresses.
+.It Fl B
+With the default display,
+show buffer sizes for TCP sockets.
+This includes the send window size, receive window size and congestion
+window size.
.It Fl b
With the interface display (options
.Fl I
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h
index 3de27669ecc..80ebf53e5b3 100644
--- a/usr.bin/netstat/netstat.h
+++ b/usr.bin/netstat/netstat.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: netstat.h,v 1.58 2010/10/30 23:06:05 bluhm Exp $ */
+/* $OpenBSD: netstat.h,v 1.59 2011/03/15 13:10:31 jsing Exp $ */
/* $NetBSD: netstat.h,v 1.6 1996/05/07 02:55:05 thorpej Exp $ */
/*
@@ -39,6 +39,7 @@
int Aflag; /* show addresses of protocol control block */
int aflag; /* show all sockets (including servers) */
+int Bflag; /* show TCP send and receive buffer sizes */
int bflag; /* show bytes instead of packets */
int dflag; /* show i/f dropped packets */
int Fflag; /* show routes whose gateways are in specified AF */