aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2005-02-25 13:13:11 +0000
committerRobert Watson <rwatson@FreeBSD.org>2005-02-25 13:13:11 +0000
commit3db07840b9a9b19fafe9a431fb72ddce1a10665f (patch)
treecb25946d03d04c534fcd5eb9505de06a04a4b8a4 /usr.bin/netstat
parent31b5d2d884ebb4421536a5fe60df806d32ba82d8 (diff)
Merge ipx.c:1.21-1.23 from HEAD to RELENG_5:
date: 2004/12/31 00:32:50; author: rwatson; state: Exp; lines: +23 -3 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. date: 2004/12/31 12:04:21; author: rwatson; state: Exp; lines: +14 -34 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 date: 2005/01/02 19:26:06; author: rwatson; state: Exp; lines: +5 -11 Revise use of queue(9) macros for netipx when used from userspace: LIST_FOREACH() is difficult to use correctly, so don't try to.
Notes
svn path=/stable/5/; revision=142455
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/ipx.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/usr.bin/netstat/ipx.c b/usr.bin/netstat/ipx.c
index b4f294007436..04ba023ee399 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,13 +69,8 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include "netstat.h"
-struct ipxpcb ipxpcb;
-struct spxpcb spxpcb;
-struct socket sockb;
-
static char *ipx_prpr (struct ipx_addr *);
-static int first = 1;
extern char *tcpstates[];
/*
@@ -87,27 +83,26 @@ 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 *ipxp;
+ struct ipxpcb ipxpcb;
+ struct spxpcb spxpcb;
+ struct socket sockb;
+ static int first = 1;
int isspx;
if (off == 0)
return;
+
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)
- return;
- for (;ipxpcb.ipxp_next != (struct ipxpcb *)off; prev = next) {
+ kread(off, (char *)&cb, sizeof (struct ipxpcbhead));
+ ipxp = LIST_FIRST(&cb);
+ while (ipxp != NULL) {
u_long ppcb;
- next = ipxpcb.ipxp_next;
- kread((u_long)next, (char *)&ipxpcb, sizeof (ipxpcb));
- if (ipxpcb.ipxp_prev != prev) {
- printf("???\n");
- break;
- }
+ kread((u_long)ipxp, (char *)&ipxpcb, sizeof (ipxpcb));
+ ipxp = LIST_NEXT(&ipxpcb, ipxp_list);
+
if (!aflag && ipx_nullhost(ipxpcb.ipxp_faddr) ) {
continue;
}
@@ -147,7 +142,6 @@ ipxprotopr(u_long off, const char *name, int af1 __unused)
printf(" %s", tcpstates[spxpcb.s_state]);
}
putchar('\n');
- prev = next;
}
}