|
|
1.1 root 1: /*
2: * Copyright (c) 1982, 1986 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution is only permitted until one year after the first shipment
6: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and
7: * binary forms are permitted provided that: (1) source distributions retain
8: * this entire copyright notice and comment, and (2) distributions including
9: * binaries display the following acknowledgement: This product includes
10: * software developed by the University of California, Berkeley and its
11: * contributors'' in the documentation or other materials provided with the
12: * distribution and in all advertising materials mentioning features or use
13: * of this software. Neither the name of the University nor the names of
14: * its contributors may be used to endorse or promote products derived from
15: * this software without specific prior written permission.
16: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
17: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19: *
20: * @(#)tcp_debug.c 7.6 (Berkeley) 6/28/90
21: */
22:
23: #ifdef TCPDEBUG
24: /* load symbolic names */
25: #define PRUREQUESTS
26: #define TCPSTATES
27: #define TCPTIMERS
28: #define TANAMES
29: #endif
30:
31: #include "param.h"
32: #include "systm.h"
33: #include "mbuf.h"
34: #include "socket.h"
35: #include "socketvar.h"
36: #include "protosw.h"
37: #include "errno.h"
38:
39: #include "../net/route.h"
40: #include "../net/if.h"
41:
42: #include "in.h"
43: #include "in_systm.h"
44: #include "ip.h"
45: #include "in_pcb.h"
46: #include "ip_var.h"
47: #include "tcp.h"
48: #include "tcp_fsm.h"
49: #include "tcp_seq.h"
50: #include "tcp_timer.h"
51: #include "tcp_var.h"
52: #include "tcpip.h"
53: #include "tcp_debug.h"
54:
55: #ifdef TCPDEBUG
56: int tcpconsdebug = 0;
57: #endif
58: /*
59: * Tcp debug routines
60: */
61: tcp_trace(act, ostate, tp, ti, req)
62: short act, ostate;
63: struct tcpcb *tp;
64: struct tcpiphdr *ti;
65: int req;
66: {
67: tcp_seq seq, ack;
68: int len, flags;
69: struct tcp_debug *td = &tcp_debug[tcp_debx++];
70:
71: if (tcp_debx == TCP_NDEBUG)
72: tcp_debx = 0;
73: td->td_time = iptime();
74: td->td_act = act;
75: td->td_ostate = ostate;
76: td->td_tcb = (caddr_t)tp;
77: if (tp)
78: td->td_cb = *tp;
79: else
80: bzero((caddr_t)&td->td_cb, sizeof (*tp));
81: if (ti)
82: td->td_ti = *ti;
83: else
84: bzero((caddr_t)&td->td_ti, sizeof (*ti));
85: td->td_req = req;
86: #ifdef TCPDEBUG
87: if (tcpconsdebug == 0)
88: return;
89: if (tp)
90: printf("%x %s:", tp, tcpstates[ostate]);
91: else
92: printf("???????? ");
93: printf("%s ", tanames[act]);
94: switch (act) {
95:
96: case TA_INPUT:
97: case TA_OUTPUT:
98: case TA_DROP:
99: if (ti == 0)
100: break;
101: seq = ti->ti_seq;
102: ack = ti->ti_ack;
103: len = ti->ti_len;
104: if (act == TA_OUTPUT) {
105: seq = ntohl(seq);
106: ack = ntohl(ack);
107: len = ntohs((u_short)len);
108: }
109: if (act == TA_OUTPUT)
110: len -= sizeof (struct tcphdr);
111: if (len)
112: printf("[%x..%x)", seq, seq+len);
113: else
114: printf("%x", seq);
115: printf("@%x, urp=%x", ack, ti->ti_urp);
116: flags = ti->ti_flags;
117: if (flags) {
118: #ifndef lint
119: char *cp = "<";
120: #define pf(f) { if (ti->ti_flags&TH_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
121: pf(SYN); pf(ACK); pf(FIN); pf(RST); pf(PUSH); pf(URG);
122: #endif
123: printf(">");
124: }
125: break;
126:
127: case TA_USER:
128: printf("%s", prurequests[req&0xff]);
129: if ((req & 0xff) == PRU_SLOWTIMO)
130: printf("<%s>", tcptimers[req>>8]);
131: break;
132: }
133: if (tp)
134: printf(" -> %s", tcpstates[tp->t_state]);
135: /* print out internal state of tp !?! */
136: printf("\n");
137: if (tp == 0)
138: return;
139: printf("\trcv_(nxt,wnd,up) (%x,%x,%x) snd_(una,nxt,max) (%x,%x,%x)\n",
140: tp->rcv_nxt, tp->rcv_wnd, tp->rcv_up, tp->snd_una, tp->snd_nxt,
141: tp->snd_max);
142: printf("\tsnd_(wl1,wl2,wnd) (%x,%x,%x)\n",
143: tp->snd_wl1, tp->snd_wl2, tp->snd_wnd);
144: #endif /* TCPDEBUG */
145: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.