diff options
author | 2017-08-12 03:21:02 +0000 | |
---|---|---|
committer | 2017-08-12 03:21:02 +0000 | |
commit | 6b9bc89db416a66279d2b3758a1f6e1f320c1be1 (patch) | |
tree | 6098ae8be4ec56cf2686b6ee8ce34bc54f37c3d0 | |
parent | Improve snps,dwc3 support. Enough to make the USB3 controller on the (diff) | |
download | wireguard-openbsd-6b9bc89db416a66279d2b3758a1f6e1f320c1be1.tar.xz wireguard-openbsd-6b9bc89db416a66279d2b3758a1f6e1f320c1be1.zip |
add option -l to show only listening sockets (for tcp)
feedback and ok awhile ago bluhm@ job@
-rw-r--r-- | usr.bin/netstat/inet.c | 13 | ||||
-rw-r--r-- | usr.bin/netstat/main.c | 6 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.1 | 8 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.h | 5 |
4 files changed, 21 insertions, 11 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 3d71dab7063..468d514a22e 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet.c,v 1.159 2017/07/27 19:59:46 florian Exp $ */ +/* $OpenBSD: inet.c,v 1.160 2017/08/12 03:21:02 benno Exp $ */ /* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */ /* @@ -294,9 +294,14 @@ netdomainpr(struct kinfo_file *kf, int proto) } /* filter listening sockets out unless -a is set */ - if (!aflag && istcp && kf->t_state <= TCPS_LISTEN) + if (!(aflag || lflag) && istcp && kf->t_state <= TCPS_LISTEN) return; - else if (!aflag && isany) + else if (!(aflag || lflag) && isany) + return; + + /* when -l is set, show only listening sockets */ + if (!aflag && lflag && istcp && + kf->t_state != TCPS_LISTEN) return; if (af != kf->so_family || type != kf->so_type) { @@ -305,6 +310,8 @@ netdomainpr(struct kinfo_file *kf, int proto) printf("Active Internet connections"); if (aflag) printf(" (including servers)"); + else if (lflag) + printf(" (only servers)"); putchar('\n'); if (Aflag) { addrlen = 18; diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index e534b166634..f2310f3dffd 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.111 2016/12/22 11:04:44 rzalamena Exp $ */ +/* $OpenBSD: main.c,v 1.112 2017/08/12 03:21:02 benno Exp $ */ /* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */ /* @@ -128,7 +128,7 @@ main(int argc, char *argv[]) tableid = getrtable(); while ((ch = getopt(argc, argv, - "AaBbc:dFf:ghI:ilM:mN:np:P:qrsT:tuvW:w:")) != -1) + "AaBbc:dFf:ghI:iLlM:mN:np:P:qrsT:tuvW:w:")) != -1) switch (ch) { case 'A': Aflag = 1; @@ -441,7 +441,7 @@ static void usage(void) { (void)fprintf(stderr, - "usage: %s [-AaBn] [-f address_family] [-M core] [-N system]\n" + "usage: %s [-AaBln] [-f address_family] [-M core] [-N system]\n" " %s [-bdFgilmnqrstu] [-f address_family] [-M core] [-N system]\n" " [-T tableid]\n" " %s [-bdhn] [-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 2347af1470e..6284f8c24fc 100644 --- a/usr.bin/netstat/netstat.1 +++ b/usr.bin/netstat/netstat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: netstat.1,v 1.80 2016/10/12 13:04:03 jca Exp $ +.\" $OpenBSD: netstat.1,v 1.81 2017/08/12 03:21:02 benno 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: October 12 2016 $ +.Dd $Mdocdate: August 12 2017 $ .Dt NETSTAT 1 .Os .Sh NAME @@ -38,7 +38,7 @@ .Nd show network status .Sh SYNOPSIS .Nm netstat -.Op Fl AaBn +.Op Fl AaBln .Op Fl f Ar address_family .Op Fl p Ar protocol .Op Fl M Ar core @@ -200,6 +200,8 @@ option) is present, show per-interface statistics on all interfaces for the specified .Ar address_family . .It Fl l +With the default display, +show only listening sockets. With the .Fl g option, display wider fields for the IPv6 multicast routing table diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index 7d117013f2f..4782b700d24 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: netstat.h,v 1.70 2016/07/20 19:57:54 bluhm Exp $ */ +/* $OpenBSD: netstat.h,v 1.71 2017/08/12 03:21:02 benno Exp $ */ /* $NetBSD: netstat.h,v 1.6 1996/05/07 02:55:05 thorpej Exp $ */ /* @@ -49,7 +49,8 @@ int Fflag; /* show routes whose gateways are in specified AF */ int gflag; /* show group (multicast) routing or stats */ int hflag; /* print human numbers */ int iflag; /* show interfaces */ -int lflag; /* show routing table with use and ref */ +int lflag; /* show only listening sockets (only servers), */ + /* with -g, show routing table with use and ref */ int mflag; /* show memory stats */ int nflag; /* show addresses numerically */ int pflag; /* show given protocol */ |