Subject: bin/1555: usr.bin/systat/netstat.c doesn't compile
To: None <gnats-bugs@gnats.netbsd.org>
From: None <sommerfeld@orchard.medford.ma.us>
List: netbsd-bugs
Date: 10/01/1995 22:22:54
>Number:         1555
>Category:       bin
>Synopsis:       usr.bin/systat/netstat.c doesn't compile
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct  2 15:50:02 1995
>Last-Modified:
>Originator:     Bill Sommerfeld
>Organization:
	
>Release:        950927
>Environment:
	
System: NetBSD orchard.medford.ma.us 1.0A NetBSD 1.0A (ORCHARD) #2: Mon Sep 25 23:26:59 EDT 1995 sommerfe@orchard.medford.ma.us:/u1/jsys/sys/arch/i386/compile/ORCHARD i386


>Description:
	usr.bin/systat/netstat.c doesn't compile
>How-To-Repeat:
	cd /usr/src/usr.bin/systat; make

>Fix:
	(code cribbed from usr.bin/netstat/inet.c)

*** netstat.c	1994/07/21 13:31:03	1.1
--- netstat.c	1995/10/01 22:19:42
***************
*** 136,145 ****
  }
  
  static struct nlist namelist[] = {
! #define	X_TCB	0
! 	{ "_tcb" },
! #define	X_UDB	1
! 	{ "_udb" },
  	{ "" },
  };
  
--- 136,145 ----
  }
  
  static struct nlist namelist[] = {
! #define	X_TCBTABLE	0
! 	{ "_tcbtable" },
! #define	X_UDBTABLE	1
! 	{ "_udbtable" },
  	{ "" },
  };
  
***************
*** 150,156 ****
  		nlisterr(namelist);
  		return(0);
  	}
! 	if (namelist[X_TCB].n_value == 0) {
  		error("No symbols in namelist");
  		return(0);
  	}
--- 150,156 ----
  		nlisterr(namelist);
  		return(0);
  	}
! 	if (namelist[X_TCBTABLE].n_value == 0) {
  		error("No symbols in namelist");
  		return(0);
  	}
***************
*** 162,168 ****
  void
  fetchnetstat()
  {
! 	register struct inpcb *prev, *next;
  	register struct netinfo *p;
  	struct inpcb inpcb;
  	struct socket sockb;
--- 162,169 ----
  void
  fetchnetstat()
  {
! 	struct inpcbtable table;
! 	register struct inpcb *head, *prev, *next;
  	register struct netinfo *p;
  	struct inpcb inpcb;
  	struct socket sockb;
***************
*** 170,185 ****
  	void *off;
  	int istcp;
  
! 	if (namelist[X_TCB].n_value == 0)
  		return;
  	for (p = netcb.ni_forw; p != (struct netinfo *)&netcb; p = p->ni_forw)
  		p->ni_seen = 0;
  	if (protos&TCP) {
! 		off = NPTR(X_TCB); 
  		istcp = 1;
  	}
  	else if (protos&UDP) {
! 		off = NPTR(X_UDB); 
  		istcp = 0;
  	}
  	else {
--- 171,186 ----
  	void *off;
  	int istcp;
  
! 	if (namelist[X_TCBTABLE].n_value == 0)
  		return;
  	for (p = netcb.ni_forw; p != (struct netinfo *)&netcb; p = p->ni_forw)
  		p->ni_seen = 0;
  	if (protos&TCP) {
! 		off = NPTR(X_TCBTABLE); 
  		istcp = 1;
  	}
  	else if (protos&UDP) {
! 		off = NPTR(X_UDBTABLE); 
  		istcp = 0;
  	}
  	else {
***************
*** 187,204 ****
  		return;
  	}
  again:
! 	KREAD(off, &inpcb, sizeof (struct inpcb));
! 	prev = off;
! 	for (; inpcb.inp_next != off; prev = next) {
! 		next = inpcb.inp_next;
  		KREAD(next, &inpcb, sizeof (inpcb));
! 		if (inpcb.inp_prev != prev) {
  			p = netcb.ni_forw;
  			for (; p != (struct netinfo *)&netcb; p = p->ni_forw)
  				p->ni_seen = 1;
  			error("Kernel state in transition");
  			return;
  		}
  		if (!aflag && inet_lnaof(inpcb.inp_laddr) == INADDR_ANY)
  			continue;
  		if (nhosts && !checkhost(&inpcb))
--- 188,209 ----
  		return;
  	}
  again:
! 	KREAD(off, &table, sizeof(table));
! 	prev = head = 
! 		(struct inpcb *)&((struct inpcbtable *)off)->inpt_queue.cqh_first;
! 	next = table.inpt_queue.cqh_first;
! 	while (next != head) {
  		KREAD(next, &inpcb, sizeof (inpcb));
! 		if (inpcb.inp_queue.cqe_prev != prev) {
  			p = netcb.ni_forw;
  			for (; p != (struct netinfo *)&netcb; p = p->ni_forw)
  				p->ni_seen = 1;
  			error("Kernel state in transition");
  			return;
  		}
+ 		prev = next;
+ 		next = inpcb.inp_queue.cqe_next;
+ 
  		if (!aflag && inet_lnaof(inpcb.inp_laddr) == INADDR_ANY)
  			continue;
  		if (nhosts && !checkhost(&inpcb))
***************
*** 214,220 ****
  	}
  	if (istcp && (protos&UDP)) {
  		istcp = 0;
! 		off = NPTR(X_UDB);
  		goto again;
  	}
  }
--- 219,225 ----
  	}
  	if (istcp && (protos&UDP)) {
  		istcp = 0;
! 		off = NPTR(X_UDBTABLE);
  		goto again;
  	}
  }
***************
*** 280,286 ****
  void
  labelnetstat()
  {
! 	if (namelist[X_TCB].n_type == 0)
  		return;
  	wmove(wnd, 0, 0); wclrtobot(wnd);
  	mvwaddstr(wnd, 0, LADDR, "Local Address");
--- 285,291 ----
  void
  labelnetstat()
  {
! 	if (namelist[X_TCBTABLE].n_type == 0)
  		return;
  	wmove(wnd, 0, 0); wclrtobot(wnd);
  	mvwaddstr(wnd, 0, LADDR, "Local Address");
>Audit-Trail:
>Unformatted: