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
This commit is contained in:
+14
-34
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user