diff options
author | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-03-23 10:59:39 +0000 |
---|---|---|
committer | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-03-23 10:59:39 +0000 |
commit | edd87366d1551484f814b94284ee7fb76006efe4 (patch) | |
tree | 46c2cc7f6be23600f55977ee1d2940cc9a914797 /usr.bin | |
parent | 696c8c67a67a94a7911da5fa4ad29e9cd7dae7b0 (diff) |
Add a new flag -F to netstat restricting route display in conjuction
with -r to routes in the same address family as the destination.
ok henning@, claudio@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/netstat/main.c | 9 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.1 | 7 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.h | 3 | ||||
-rw-r--r-- | usr.bin/netstat/show.c | 7 |
4 files changed, 18 insertions, 8 deletions
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index aa0b3c92ccc..7cabddfd857 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.63 2006/08/29 21:51:13 claudio Exp $ */ +/* $OpenBSD: main.c,v 1.64 2007/03/23 10:59:38 pyr Exp $ */ /* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */ /* @@ -40,7 +40,7 @@ char copyright[] = #if 0 static char sccsid[] = "from: @(#)main.c 8.4 (Berkeley) 3/1/94"; #else -static char *rcsid = "$OpenBSD: main.c,v 1.63 2006/08/29 21:51:13 claudio Exp $"; +static char *rcsid = "$OpenBSD: main.c,v 1.64 2007/03/23 10:59:38 pyr Exp $"; #endif #endif /* not lint */ @@ -267,7 +267,7 @@ main(int argc, char *argv[]) af = AF_UNSPEC; - while ((ch = getopt(argc, argv, "Aabdf:gI:ilM:mN:np:P:qrstuvW:w:")) != -1) + while ((ch = getopt(argc, argv, "AabdFf:gI:ilM:mN:np:P:qrstuvW:w:")) != -1) switch (ch) { case 'A': Aflag = 1; @@ -281,6 +281,9 @@ main(int argc, char *argv[]) case 'd': dflag = 1; break; + case 'F': + Fflag = 1; + break; case 'f': if (strcmp(optarg, "inet") == 0) af = AF_INET; diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1 index 12d4d4d887f..bb23f9599a5 100644 --- a/usr.bin/netstat/netstat.1 +++ b/usr.bin/netstat/netstat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: netstat.1,v 1.47 2005/09/06 23:28:23 jmc Exp $ +.\" $OpenBSD: netstat.1,v 1.48 2007/03/23 10:59:38 pyr Exp $ .\" $NetBSD: netstat.1,v 1.11 1995/10/03 21:42:43 thorpej Exp $ .\" .\" Copyright (c) 1983, 1990, 1992, 1993 @@ -43,7 +43,7 @@ .Op Fl M Ar core .Op Fl N Ar system .Nm netstat -.Op Fl bdgilmnqrstu +.Op Fl bdFgilmnqrstu .Op Fl f Ar address_family .Op Fl M Ar core .Op Fl N Ar system @@ -124,6 +124,9 @@ or or an interval (option .Fl w ) , show the number of dropped packets. +.It Fl F +When showing routes, only show routes whose gateway are in the +same address family as the destination. .It Fl f Ar address_family Limit statistics or address control block reports to those of the specified diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index 2b724ff6e48..52fc6591be2 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: netstat.h,v 1.39 2006/08/29 21:51:13 claudio Exp $ */ +/* $OpenBSD: netstat.h,v 1.40 2007/03/23 10:59:38 pyr Exp $ */ /* $NetBSD: netstat.h,v 1.6 1996/05/07 02:55:05 thorpej Exp $ */ /* @@ -41,6 +41,7 @@ int Aflag; /* show addresses of protocol control block */ int aflag; /* show all sockets (including servers) */ int bflag; /* show bytes instead of packets */ int dflag; /* show i/f dropped packets */ +int Fflag; /* show routes whose gateways are in specified AF */ int gflag; /* show group (multicast) routing or stats */ int iflag; /* show interfaces */ int lflag; /* show routing table with use and ref */ diff --git a/usr.bin/netstat/show.c b/usr.bin/netstat/show.c index 0cf2c03ac24..3ff059bd036 100644 --- a/usr.bin/netstat/show.c +++ b/usr.bin/netstat/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.4 2006/12/29 10:09:09 claudio Exp $ */ +/* $OpenBSD: show.c,v 1.5 2007/03/23 10:59:38 pyr Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -246,12 +246,15 @@ p_rtentry(struct rt_msghdr *rtm) if (sa->sa_family == AF_KEY) return; + get_rtaddrs(rtm->rtm_addrs, sa, rti_info); + if (Fflag && rti_info[RTAX_GATEWAY]->sa_family != sa->sa_family) { + return; + } if (old_af != sa->sa_family) { old_af = sa->sa_family; pr_family(sa->sa_family); pr_rthdr(sa->sa_family, 0); } - get_rtaddrs(rtm->rtm_addrs, sa, rti_info); mask = rti_info[RTAX_NETMASK]; if ((sa = rti_info[RTAX_DST]) == NULL) |