Rather than selectively zeroing fields in the tcp_debug structure

throughout tcp_trace(), zero the entire structure up front.

Minor style fixes.
This commit is contained in:
Robert Watson 2007-05-07 14:05:23 +00:00
parent 6db851a281
commit 9df79d84c1

View File

@ -108,85 +108,58 @@ tcp_trace(short act, short ostate, struct tcpcb *tp, void *ipgen,
mtx_lock(&tcp_debug_mtx);
td = &tcp_debug[tcp_debx++];
if (tcp_debx == TCP_NDEBUG)
tcp_debx = 0;
bzero(td, sizeof(*td));
#ifdef INET6
isipv6 = (ipgen != NULL && ((struct ip *)ipgen)->ip_v == 6) ? 1 : 0;
#endif /* INET6 */
td->td_family =
#ifdef INET6
(isipv6 != 0) ? AF_INET6 :
(isipv6 != 0) ? AF_INET6 :
#endif
AF_INET;
if (tcp_debx == TCP_NDEBUG)
tcp_debx = 0;
AF_INET;
td->td_time = iptime();
td->td_act = act;
td->td_ostate = ostate;
td->td_tcb = (caddr_t)tp;
if (tp)
if (tp != NULL)
td->td_cb = *tp;
else
bzero((caddr_t)&td->td_cb, sizeof (*tp));
if (ipgen) {
if (ipgen != NULL) {
switch (td->td_family) {
case AF_INET:
bcopy((caddr_t)ipgen, (caddr_t)&td->td_ti.ti_i,
sizeof(td->td_ti.ti_i));
bzero((caddr_t)td->td_ip6buf, sizeof(td->td_ip6buf));
bcopy(ipgen, &td->td_ti.ti_i, sizeof(td->td_ti.ti_i));
break;
#ifdef INET6
case AF_INET6:
bcopy((caddr_t)ipgen, (caddr_t)td->td_ip6buf,
sizeof(td->td_ip6buf));
bzero((caddr_t)&td->td_ti.ti_i,
sizeof(td->td_ti.ti_i));
bcopy(ipgen, td->td_ip6buf, sizeof(td->td_ip6buf));
break;
#endif
default:
bzero((caddr_t)td->td_ip6buf, sizeof(td->td_ip6buf));
bzero((caddr_t)&td->td_ti.ti_i,
sizeof(td->td_ti.ti_i));
break;
}
} else {
bzero((caddr_t)&td->td_ti.ti_i, sizeof(td->td_ti.ti_i));
bzero((caddr_t)td->td_ip6buf, sizeof(td->td_ip6buf));
}
if (th) {
if (th != NULL) {
switch (td->td_family) {
case AF_INET:
td->td_ti.ti_t = *th;
bzero((caddr_t)&td->td_ti6.th, sizeof(td->td_ti6.th));
break;
#ifdef INET6
case AF_INET6:
td->td_ti6.th = *th;
bzero((caddr_t)&td->td_ti.ti_t,
sizeof(td->td_ti.ti_t));
break;
#endif
default:
bzero((caddr_t)&td->td_ti.ti_t,
sizeof(td->td_ti.ti_t));
bzero((caddr_t)&td->td_ti6.th, sizeof(td->td_ti6.th));
break;
}
} else {
bzero((caddr_t)&td->td_ti.ti_t, sizeof(td->td_ti.ti_t));
bzero((caddr_t)&td->td_ti6.th, sizeof(td->td_ti6.th));
}
td->td_req = req;
mtx_unlock(&tcp_debug_mtx);
#ifdef TCPDEBUG
if (tcpconsdebug == 0)
return;
if (tp)
if (tp != NULL)
printf("%p %s:", tp, tcpstates[ostate]);
else
printf("???????? ");
printf("%s ", tanames[act]);
switch (act) {
case TA_INPUT:
case TA_OUTPUT:
case TA_DROP:
@ -196,9 +169,9 @@ tcp_trace(short act, short ostate, struct tcpcb *tp, void *ipgen,
ack = th->th_ack;
len =
#ifdef INET6
isipv6 ? ((struct ip6_hdr *)ipgen)->ip6_plen :
isipv6 ? ((struct ip6_hdr *)ipgen)->ip6_plen :
#endif
((struct ip *)ipgen)->ip_len;
((struct ip *)ipgen)->ip_len;
if (act == TA_OUTPUT) {
seq = ntohl(seq);
ack = ntohl(ack);
@ -231,11 +204,11 @@ tcp_trace(short act, short ostate, struct tcpcb *tp, void *ipgen,
printf("<%s>", tcptimers[req>>8]);
break;
}
if (tp)
if (tp != NULL)
printf(" -> %s", tcpstates[tp->t_state]);
/* print out internal state of tp !?! */
printf("\n");
if (tp == 0)
if (tp == NULL)
return;
printf(
"\trcv_(nxt,wnd,up) (%lx,%lx,%lx) snd_(una,nxt,max) (%lx,%lx,%lx)\n",