diff options
| author | Josef Karthauser <joe@FreeBSD.org> | 2000-10-19 23:15:54 +0000 |
|---|---|---|
| committer | Josef Karthauser <joe@FreeBSD.org> | 2000-10-19 23:15:54 +0000 |
| commit | 5da9f8fa978ae925af826ba78653757d2c84c9c1 (patch) | |
| tree | 9f0fe3f2362be5fa75a25ca05077a78bfe2418f0 /usr.bin/netstat | |
| parent | 7ae6b1ebd284680b965c4ce38b7d3923cd7196fe (diff) | |
Notes
Diffstat (limited to 'usr.bin/netstat')
| -rw-r--r-- | usr.bin/netstat/if.c | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index fb3750e49b3f..392fd5fd0c29 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -152,6 +152,15 @@ intpr(interval, ifnetaddr, pfunc) u_long ifaddraddr; u_long ifaddrfound; u_long ifnetfound; + u_long opackets; + u_long ipackets; + u_long obytes; + u_long ibytes; + u_long oerrors; + u_long ierrors; + u_long collisions; + short timer; + int drops; struct sockaddr *sa = NULL; char name[32], tname[16]; @@ -217,6 +226,21 @@ intpr(interval, ifnetaddr, pfunc) } printf("%-5.5s %-5lu ", name, ifnet.if_mtu); ifaddrfound = ifaddraddr; + + /* + * Get the interface stats. These may get + * overriden below on a per-interface basis. + */ + opackets = ifnet.if_opackets; + ipackets = ifnet.if_ipackets; + obytes = ifnet.if_obytes; + ibytes = ifnet.if_ibytes; + oerrors = ifnet.if_oerrors; + ierrors = ifnet.if_ierrors; + collisions = ifnet.if_collisions; + timer = ifnet.if_timer; + drops = ifnet.if_snd.ifq_drops; + if (ifaddraddr == 0) { printf("%-13.13s ", "none"); printf("%-15.15s ", "none"); @@ -327,21 +351,35 @@ intpr(interval, ifnetaddr, pfunc) putchar(' '); break; } + + /* + * Fixup the statistics for interfaces that + * update stats for their network addresses + */ + if (sa->sa_family == AF_INET || + sa->sa_family == AF_INET6) { + opackets = ifaddr.in.ia_ifa.if_opackets; + ipackets = ifaddr.in.ia_ifa.if_ipackets; + obytes = ifaddr.in.ia_ifa.if_obytes; + ibytes = ifaddr.in.ia_ifa.if_ibytes; + oerrors = ierrors = 0; + collisions = timer = drops = 0; + } + ifaddraddr = (u_long)ifaddr.ifa.ifa_link.tqe_next; } - printf("%8lu %5lu ", - ifnet.if_ipackets, ifnet.if_ierrors); + + printf("%8lu %5lu ", ipackets, ierrors); if (bflag) - printf("%10lu ", ifnet.if_ibytes); - printf("%8lu %5lu ", - ifnet.if_opackets, ifnet.if_oerrors); + printf("%10lu ", ibytes); + printf("%8lu %5lu ", opackets, oerrors); if (bflag) - printf("%10lu ", ifnet.if_obytes); - printf("%5lu", ifnet.if_collisions); + printf("%10lu ", obytes); + printf("%5lu", collisions); if (tflag) - printf(" %3d", ifnet.if_timer); + printf(" %3d", timer); if (dflag) - printf(" %3d", ifnet.if_snd.ifq_drops); + printf(" %3d", drops); putchar('\n'); if (aflag && ifaddrfound) { /* |
