diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-12-31 12:04:21 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-12-31 12:04:21 +0000 |
commit | deba9fc9d088775104b25276ea681ab1f93e24ad (patch) | |
tree | cd600255612d2246f98986796eeed52c860b6f74 /usr.bin | |
parent | 942a2a4682bee4d2e700bf7314d7623b2d76b04d (diff) | |
download | FreeBSD-src-deba9fc9d088775104b25276ea681ab1f93e24ad.zip FreeBSD-src-deba9fc9d088775104b25276ea681ab1f93e24ad.tar.gz |
Apply a simplifying patch submitted by rik to the IPX support in
netstat(1):
- Make previously unnecessarily global variables local.
- Use LIST_FOREACH() in preference to manual iteration.
- Restore a sanity check through slightly incestuous use of queue macro
knowledge.
Submitted by: rik
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/netstat/ipx.c | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/usr.bin/netstat/ipx.c b/usr.bin/netstat/ipx.c index 2d4aad0..d067b9e 100644 --- a/usr.bin/netstat/ipx.c +++ b/usr.bin/netstat/ipx.c @@ -69,15 +69,8 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include "netstat.h" -struct ipxpcbhead ipxpcb_list; -int ipxpcb_list_read; -struct ipxpcb ipxpcb; -struct spxpcb spxpcb; -struct socket sockb; - static char *ipx_prpr (struct ipx_addr *); -static int first = 1; extern char *tcpstates[]; /* @@ -90,44 +83,32 @@ extern char *tcpstates[]; void ipxprotopr(u_long off, const char *name, int af1 __unused) { - struct ipxpcb cb; - struct ipxpcb *prev, *next; + struct ipxpcbhead cb; + struct ipxpcb *prev, *ipxp, *next; + struct ipxpcb ipxpcb; + struct spxpcb spxpcb; + struct socket sockb; + static int first = 1; int isspx; if (off == 0) return; - /* - * First time around, read in the pcb list header. After that, we - * walk sequential pcbs. - */ - if (ipxpcb_list_read == 0) { - kread(off, (char *)&ipxpcb_list, sizeof(ipxpcb_list)); - off = (u_long)LIST_FIRST(&ipxpcb_list); - ipxpcb_list_read = 1; - } - isspx = strcmp(name, "spx") == 0; - kread(off, (char *)&cb, sizeof (struct ipxpcb)); - ipxpcb = cb; - prev = (struct ipxpcb *)off; - if (LIST_NEXT(&ipxpcb, ipxp_list) == NULL) - return; - for (;LIST_NEXT(&ipxpcb, ipxp_list) != NULL; prev = next) { + kread(off, (char *)&cb, sizeof (struct ipxpcbhead)); + next = LIST_FIRST (&cb); + LIST_FOREACH(ipxp, &cb, ipxp_list) { u_long ppcb; - next = LIST_NEXT(&ipxpcb, ipxp_list); + prev = next; + next = ipxp; kread((u_long)next, (char *)&ipxpcb, sizeof (ipxpcb)); -#if 0 - /* - * queue(9) macros do not give us a prev pointer, so skip - * sanity check for now. - */ - if (ipxpcb.ipxp_prev != prev) { + + if (*ipxpcb.ipxp_list.le_prev != prev) { printf("???\n"); break; } -#endif + if (!aflag && ipx_nullhost(ipxpcb.ipxp_faddr) ) { continue; } @@ -167,7 +148,6 @@ ipxprotopr(u_long off, const char *name, int af1 __unused) printf(" %s", tcpstates[spxpcb.s_state]); } putchar('\n'); - prev = next; } } |