td = &tcp_debug[tcp_debx++];
tcp_trace(act, ostate, tp, m, req, len)	short act, ostate;	struct tcpcb *tp;	struct mbuf *m;	int req;	int len;{#ifdef TCPDEBUG	tcp_seq seq, ack;	int flags;#endif	caddr_t headers;	struct tcp_debug *td;	struct tcpiphdr *ti;	struct tcphdr *th;#ifdef INET6	struct tcpipv6hdr *ti6 = (struct tcpipv6hdr *)ti;#endif	td = &tcp_debug[tcp_debx++];	if (tcp_debx == TCP_NDEBUG)		tcp_debx = 0;	if (m)		headers = mtod(m, caddr_t);	else		headers = NULL;	ti = (struct tcpiphdr *)headers;#ifdef INET6	ti6 = (struct tcpipv6hdr *)headers;#endif	td->td_time = iptime();	td->td_act = act;	td->td_ostate = ostate;	td->td_tcb = (caddr_t)tp;	if (tp)		td->td_cb = *tp;	else		bzero((caddr_t)&td->td_cb, sizeof (*tp));	switch (tp->pf) {#ifdef INET6	case PF_INET6:		if (ti6) {			th = &ti6->ti6_t;			td->td_ti6 = *ti6;		} else			bzero(&td->td_ti6, sizeof(struct tcpipv6hdr));		break;#endif /* INET6 */	case PF_INET:		if (ti) {			th = &ti->ti_t;			td->td_ti = *ti;		} else			bzero(&td->td_ti, sizeof(struct tcpiphdr));		break;	default:		return;	}	td->td_req = req;#ifdef TCPDEBUG	if (tcpconsdebug == 0)		return;	if (tp)		printf("%x %s:", tp, tcpstates[ostate]);	else		printf("???????? ");	printf("%s ", tanames[act]);	switch (act) {	case TA_INPUT:	case TA_OUTPUT:	case TA_DROP:		if (ti == 0)			break;		seq = th->th_seq;		ack = th->th_ack;		if (act == TA_OUTPUT) {			seq = ntohl(seq);			ack = ntohl(ack);		}		if (len)			printf("[%x..%x)", seq, seq+len);		else			printf("%x", seq);		printf("@%x, urp=%x", ack, th->th_urp);		flags = th->th_flags;		if (flags) {#ifndef lint			char *cp = "<";#define pf(f) { if (th->th_flags&TH_##f) { printf("%s%s", cp, "f"); cp = ","; } }			pf(SYN); pf(ACK); pf(FIN); pf(RST); pf(PUSH); pf(URG);#endif			printf(">");		}		break;	case TA_USER:		printf("%s", prurequests[req&0xff]);		if ((req & 0xff) == PRU_SLOWTIMO)			printf("<%s>", tcptimers[req>>8]);		break;	}	if (tp)		printf(" -> %s", tcpstates[tp->t_state]);	/* print out internal state of tp !?! */	printf("\n");	if (tp == 0)		return;	printf("\trcv_(nxt,wnd,up) (%x,%x,%x) snd_(una,nxt,max) (%x,%x,%x)\n",	    tp->rcv_nxt, tp->rcv_wnd, tp->rcv_up, tp->snd_una, tp->snd_nxt,	    tp->snd_max);	printf("\tsnd_(wl1,wl2,wnd) (%x,%x,%x)\n",	    tp->snd_wl1, tp->snd_wl2, tp->snd_wnd);#endif /* TCPDEBUG */}