From e1d1aaa012c9d5a1a1ab782daafff83fbba24197 Mon Sep 17 00:00:00 2001 From: rwatson Date: Fri, 31 Dec 2004 00:32:50 +0000 Subject: Update netstat(1) for recent conversion of netipx to queue(9) from home-brew linked lists. Read in the ipxpcb_list structure first in order to find the first pcb pointer. Then follow the chain as before, only the termination condition is a NULL next pointer rather than a next pointer equal to the original offset. --- usr.bin/netstat/ipx.c | 26 +++++++++++++++++++++++--- usr.bin/netstat/main.c | 2 +- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'usr.bin/netstat') diff --git a/usr.bin/netstat/ipx.c b/usr.bin/netstat/ipx.c index b4f2940..2d4aad0 100644 --- a/usr.bin/netstat/ipx.c +++ b/usr.bin/netstat/ipx.c @@ -1,4 +1,5 @@ /* + * Copyright (c) 2004, Robert N. M. Watson * Copyright (c) 1983, 1988, 1993 * The Regents of the University of California. All rights reserved. * @@ -68,6 +69,8 @@ __FBSDID("$FreeBSD$"); #include #include "netstat.h" +struct ipxpcbhead ipxpcb_list; +int ipxpcb_list_read; struct ipxpcb ipxpcb; struct spxpcb spxpcb; struct socket sockb; @@ -93,21 +96,38 @@ ipxprotopr(u_long off, const char *name, int af1 __unused) 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 (ipxpcb.ipxp_next == (struct ipxpcb *)off) + if (LIST_NEXT(&ipxpcb, ipxp_list) == NULL) return; - for (;ipxpcb.ipxp_next != (struct ipxpcb *)off; prev = next) { + for (;LIST_NEXT(&ipxpcb, ipxp_list) != NULL; prev = next) { u_long ppcb; - next = ipxpcb.ipxp_next; + next = LIST_NEXT(&ipxpcb, ipxp_list); 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) { printf("???\n"); break; } +#endif if (!aflag && ipx_nullhost(ipxpcb.ipxp_faddr) ) { continue; } diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index 13d52d6..e5cd2fd 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -83,7 +83,7 @@ static struct nlist nl[] = { #define N_VIFTABLE 5 { "_viftable" }, #define N_IPX 6 - { "_ipxpcb"}, + { "_ipxpcb_list"}, #define N_IPXSTAT 7 { "_ipxstat"}, #define N_SPXSTAT 8 -- cgit v1.1