From 6ef0117870937300d348b9e1656da31c785d4811 Mon Sep 17 00:00:00 2001 From: shin Date: Sat, 29 Jan 2000 11:49:07 +0000 Subject: Sorry in this just befor code freeze commit. This is fix to usr.sbin/trpt and tcp_debug.[ch] I think of putting this after 4.0 but,,, -There was bug that when INET6 is defined, IPv4 socket is not traced by trpt. -I received request from a person who distribute a program which use tcp_debug interface and print performance statistics, that -leave comptibility with old program as much as possible -use same interface with other OSes So, I talked with itojun, and synced API with netbsd IPv6 extension. makeworld check, kernel build check(includes GENERIC) is done. But if there happen to any problem, please let me know and I soon backout this change. --- usr.sbin/trpt/trpt.c | 60 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 10 deletions(-) (limited to 'usr.sbin/trpt') diff --git a/usr.sbin/trpt/trpt.c b/usr.sbin/trpt/trpt.c index 66e51d8..9258af7 100644 --- a/usr.sbin/trpt/trpt.c +++ b/usr.sbin/trpt/trpt.c @@ -100,7 +100,7 @@ void dotrace __P((caddr_t)); void klseek __P((int, off_t, int)); int numeric __P((caddr_t *, caddr_t *)); void tcp_trace __P((short, short, struct tcpcb *, struct tcpcb *, - void *, struct tcphdr *, int)); + int, void *, struct tcphdr *, int)); static void usage __P((void)); int @@ -227,7 +227,7 @@ dotrace(tcpcb) { register struct tcp_debug *td; register int i; - int prev_debx = tcp_debx; + int prev_debx = tcp_debx, family; again: if (--tcp_debx < 0) tcp_debx = TCP_NDEBUG - 1; @@ -236,8 +236,27 @@ again: if (--tcp_debx < 0) if (tcpcb && td->td_tcb != tcpcb) continue; ntime = ntohl(td->td_time); - tcp_trace(td->td_act, td->td_ostate, td->td_tcb, &td->td_cb, - td->td_ipgen, &td->td_th, td->td_req); +#ifdef INET6 + family = td->td_family; +#else + family = AF_INET; +#endif + switch(family) { + case AF_INET: + tcp_trace(td->td_act, td->td_ostate, + (struct tcpcb *)td->td_tcb, + &td->td_cb, td->td_family, &td->td_ti.ti_i, + &td->td_ti.ti_t, td->td_req); + break; +#ifdef INET6 + case AF_INET6: + tcp_trace(td->td_act, td->td_ostate, + (struct tcpcb *)td->td_tcb, + &td->td_cb, td->td_family, &td->td_ti6.ip6, + &td->td_ti6.th, td->td_req); + break; +#endif + } if (i == tcp_debx) goto done; } @@ -246,8 +265,27 @@ again: if (--tcp_debx < 0) if (tcpcb && td->td_tcb != tcpcb) continue; ntime = ntohl(td->td_time); - tcp_trace(td->td_act, td->td_ostate, td->td_tcb, &td->td_cb, - td->td_ipgen, &td->td_th, td->td_req); +#ifdef INET6 + family = td->td_family; +#else + family = AF_INET; +#endif + switch(family) { + case AF_INET: + tcp_trace(td->td_act, td->td_ostate, + (struct tcpcb *)td->td_tcb, + &td->td_cb, td->td_family, &td->td_ti.ti_i, + &td->td_ti.ti_t, td->td_req); + break; +#ifdef INET6 + case AF_INET6: + tcp_trace(td->td_act, td->td_ostate, + (struct tcpcb *)td->td_tcb, + &td->td_cb, td->td_family, &td->td_ti6.ip6, + &td->td_ti6.th, td->td_req); + break; +#endif + } } done: if (follow) { prev_debx = tcp_debx + 1; @@ -273,9 +311,10 @@ done: if (follow) { */ /*ARGSUSED*/ void -tcp_trace(act, ostate, atp, tp, ip, th, req) +tcp_trace(act, ostate, atp, tp, family, ip, th, req) short act, ostate; struct tcpcb *atp, *tp; + int family; void *ip; struct tcphdr *th; int req; @@ -290,12 +329,13 @@ tcp_trace(act, ostate, atp, tp, ip, th, req) #endif #ifdef INET6 - switch (((struct ip *)ip)->ip_v) { - case 4: + switch (family) { + case AF_INET: nopkt = 0; + isipv6 = 0; ip4 = (struct ip *)ip; break; - case 6: + case AF_INET6: nopkt = 0; isipv6 = 1; ip6 = (struct ip6_hdr *)ip; -- cgit v1.1