Implement the ``-f address_family'' filter for -i.

Prodded by:	Igor Podlesny <poige@morning.ru>
This commit is contained in:
ru 2001-09-11 17:14:33 +00:00
parent ad39f94bd0
commit a955db2e6b
3 changed files with 14 additions and 3 deletions

View File

@ -251,7 +251,6 @@ intpr(int interval, u_long ifnetaddr, void (*pfunc)(char *))
*cp = '\0';
ifaddraddr = (u_long)TAILQ_FIRST(&ifnet.if_addrhead);
}
printf("%-5.5s %-5lu ", name, ifnet.if_mtu);
ifaddrfound = ifaddraddr;
/*
@ -269,6 +268,7 @@ intpr(int interval, u_long ifnetaddr, void (*pfunc)(char *))
drops = ifnet.if_snd.ifq_drops;
if (ifaddraddr == 0) {
printf("%-5.5s %-5lu ", name, ifnet.if_mtu);
printf("%-13.13s ", "none");
printf("%-15.15s ", "none");
} else {
@ -280,6 +280,12 @@ intpr(int interval, u_long ifnetaddr, void (*pfunc)(char *))
cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) +
CP(&ifaddr);
sa = (struct sockaddr *)cp;
if (af != AF_UNSPEC && sa->sa_family != af) {
ifaddraddr =
(u_long)TAILQ_NEXT(&ifaddr.ifa, ifa_link);
continue;
}
printf("%-5.5s %-5lu ", name, ifnet.if_mtu);
switch (sa->sa_family) {
case AF_UNSPEC:
printf("%-13.13s ", "none");

View File

@ -393,6 +393,8 @@ main(argc, argv)
else if (strcmp(optarg, "iso") == 0)
af = AF_ISO;
#endif
else if (strcmp(optarg, "link") == 0)
af = AF_LINK;
else {
errx(1, "%s: unknown address family", optarg);
}
@ -754,7 +756,8 @@ usage(void)
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
"usage: netstat [-AaLnSW] [-f protocol_family | -p protocol]\n"
" [-M core] [-N system]",
" netstat -i | -I interface [-abdnt] [-M core] [-N system]",
" netstat -i | -I interface [-abdnt] [-f address_family]\n"
" [-M core] [-N system]",
" netstat -w wait [-I interface] [-d] [-M core] [-N system]",
" netstat -s [-s] [-z] [-f protocol_family | -p protocol] [-M core]",
" netstat -i | -I interface -s [-f protocol_family | -p protocol]\n"

View File

@ -90,6 +90,7 @@ but show ports symbolically.
.Nm
.Fl i | I Ar interface
.Op Fl abdnt
.Op Fl f Ar address_family
.Op Fl M Ar core
.Op Fl N Ar system
.Ek
@ -109,7 +110,7 @@ is also present, multicast addresses currently in use are shown
for each Ethernet interface and for each IP interface address.
Multicast addresses are shown on separate lines following the interface
address with which they are associated.
It
If
.Fl b
is also present, show the number of bytes in and out.
If
@ -286,6 +287,7 @@ The following address families and protocols are recognized:
.\".It Cm iso Pq Dv AF_ISO
.\".Cm clnp , cltp , esis , tp
.It Cm unix Pq Dv AF_UNIX
.It Cm link Pq Dv AF_LINK
.El
.Pp
The program will complain if