OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [tcpip/] [current/] [src/] [sys/] [netinet/] [tcp_debug.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      sys/netinet/tcp_debug.c
4
//
5
//     
6
//
7
//==========================================================================
8
// ####BSDALTCOPYRIGHTBEGIN####                                             
9
// -------------------------------------------                              
10
// Portions of this software may have been derived from OpenBSD             
11
// or other sources, and if so are covered by the appropriate copyright     
12
// and license included herein.                                             
13
// -------------------------------------------                              
14
// ####BSDALTCOPYRIGHTEND####                                               
15
//==========================================================================
16
//#####DESCRIPTIONBEGIN####
17
//
18
// Author(s):    gthomas
19
// Contributors: gthomas
20
// Date:         2000-01-10
21
// Purpose:      
22
// Description:  
23
//              
24
//
25
//####DESCRIPTIONEND####
26
//
27
//==========================================================================
28
 
29
 
30
/*      $OpenBSD: tcp_debug.c,v 1.6 1999/12/08 06:50:20 itojun Exp $    */
31
/*      $NetBSD: tcp_debug.c,v 1.10 1996/02/13 23:43:36 christos Exp $  */
32
 
33
/*
34
 * Copyright (c) 1982, 1986, 1993
35
 *      The Regents of the University of California.  All rights reserved.
36
 *
37
 * Redistribution and use in source and binary forms, with or without
38
 * modification, are permitted provided that the following conditions
39
 * are met:
40
 * 1. Redistributions of source code must retain the above copyright
41
 *    notice, this list of conditions and the following disclaimer.
42
 * 2. Redistributions in binary form must reproduce the above copyright
43
 *    notice, this list of conditions and the following disclaimer in the
44
 *    documentation and/or other materials provided with the distribution.
45
 * 3. All advertising materials mentioning features or use of this software
46
 *    must display the following acknowledgement:
47
 *      This product includes software developed by the University of
48
 *      California, Berkeley and its contributors.
49
 * 4. Neither the name of the University nor the names of its contributors
50
 *    may be used to endorse or promote products derived from this software
51
 *    without specific prior written permission.
52
 *
53
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63
 * SUCH DAMAGE.
64
 *
65
 *      @(#)tcp_debug.c 8.1 (Berkeley) 6/10/93
66
 */
67
 
68
/*
69
%%% portions-copyright-nrl-95
70
Portions of this software are Copyright 1995-1998 by Randall Atkinson,
71
Ronald Lee, Daniel McDonald, Bao Phan, and Chris Winters. All Rights
72
Reserved. All rights under this copyright have been assigned to the US
73
Naval Research Laboratory (NRL). The NRL Copyright Notice and License
74
Agreement Version 1.1 (January 17, 1995) applies to these portions of the
75
software.
76
You should have received a copy of the license with this software. If you
77
didn't get a copy, you may request one from <license@ipv6.nrl.navy.mil>.
78
*/
79
 
80
#ifdef TCPDEBUG
81
/* load symbolic names */
82
#define PRUREQUESTS
83
#define TCPSTATES
84
#define TCPTIMERS
85
#define TANAMES
86
 
87
#include <sys/param.h>
88
#ifndef __ECOS
89
#include <sys/systm.h>
90
#endif
91
#include <sys/mbuf.h>
92
#include <sys/socket.h>
93
#include <sys/socketvar.h>
94
#include <sys/protosw.h>
95
#include <sys/errno.h>
96
 
97
#include <net/route.h>
98
#include <net/if.h>
99
 
100
#include <netinet/in.h>
101
#include <netinet/in_systm.h>
102
#include <netinet/ip.h>
103
#include <netinet/in_pcb.h>
104
#include <netinet/ip_var.h>
105
#include <netinet/tcp.h>
106
#include <netinet/tcp_fsm.h>
107
#include <netinet/tcp_seq.h>
108
#include <netinet/tcp_timer.h>
109
#include <netinet/tcp_var.h>
110
#include <netinet/tcpip.h>
111
#include <netinet/tcp_debug.h>
112
 
113
#ifdef INET6
114
#ifndef INET
115
#include <netinet/in.h>
116
#endif
117
#include <netinet6/ip6.h>
118
#endif /* INET6 */
119
 
120
#ifdef TCPDEBUG
121
int     tcpconsdebug = 1;
122
#endif
123
/*
124
 * Tcp debug routines
125
 */
126
void
127
tcp_trace(act, ostate, tp, headers, req, len)
128
        short act, ostate;
129
        struct tcpcb *tp;
130
        caddr_t headers;
131
        int req;
132
        int len;
133
{
134
#ifdef TCPDEBUG
135
        tcp_seq seq, ack;
136
        int flags;
137
#endif
138
        struct tcp_debug *td = &tcp_debug[tcp_debx++];
139
        struct tcpiphdr *ti = (struct tcpiphdr *)headers;
140
#ifdef INET6
141
        struct tcphdr *th;
142
        struct tcpipv6hdr *ti6 = (struct tcpipv6hdr *)ti;
143
#endif
144
 
145
        if (tcp_debx == TCP_NDEBUG)
146
                tcp_debx = 0;
147
        td->td_time = iptime();
148
        td->td_act = act;
149
        td->td_ostate = ostate;
150
        td->td_tcb = (caddr_t)tp;
151
        if (tp)
152
                td->td_cb = *tp;
153
        else
154
                bzero((caddr_t)&td->td_cb, sizeof (*tp));
155
#ifdef INET6
156
        if (tp->pf == PF_INET6) {
157
                if (ti) {
158
                        th = &ti6->ti6_t;
159
                        td->td_ti6 = *ti6;
160
                } else {
161
                        bzero(&td->td_ti6, sizeof(struct tcpipv6hdr));
162
                }
163
        } else {
164
                if (ti) {
165
                        th = &ti->ti_t;
166
                        td->td_ti = *ti;
167
                } else {
168
                        bzero(&td->td_ti, sizeof(struct tcpiphdr));
169
                }
170
        }
171
#else /* INET6 */
172
        if (ti)
173
                td->td_ti = *ti;
174
        else
175
                bzero((caddr_t)&td->td_ti, sizeof (*ti));
176
#endif /* INET6 */
177
 
178
        td->td_req = req;
179
#ifdef TCPDEBUG
180
        if (tcpconsdebug == 0)
181
                return;
182
        if (tp)
183
                printf("%x %s:", tp, tcpstates[ostate]);
184
        else
185
                printf("???????? ");
186
        printf("%s ", tanames[act]);
187
        switch (act) {
188
 
189
        case TA_INPUT:
190
        case TA_OUTPUT:
191
        case TA_DROP:
192
                if (ti == 0)
193
                        break;
194
                seq = th->th_seq;
195
                ack = th->th_ack;
196
                if (act == TA_OUTPUT) {
197
                        seq = ntohl(seq);
198
                        ack = ntohl(ack);
199
                }
200
                if (len)
201
                        printf("[%x..%x)", seq, seq+len);
202
                else
203
                        printf("%x", seq);
204
                printf("@%x, urp=%x", ack, th->th_urp);
205
                flags = th->th_flags;
206
                if (flags) {
207
#ifndef lint
208
                        char *cp = "<";
209
#define pf(f) { if (th->th_flags&TH_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
210
                        pf(SYN); pf(ACK); pf(FIN); pf(RST); pf(PUSH); pf(URG);
211
#endif
212
                        printf(">");
213
                }
214
                break;
215
 
216
        case TA_USER:
217
                printf("%s", prurequests[req&0xff]);
218
                if ((req & 0xff) == PRU_SLOWTIMO)
219
                        printf("<%s>", tcptimers[req>>8]);
220
                break;
221
        }
222
        if (tp)
223
                printf(" -> %s", tcpstates[tp->t_state]);
224
        /* print out internal state of tp !?! */
225
        printf("\n");
226
        if (tp == 0)
227
                return;
228
        printf("\trcv_(nxt,wnd,up) (%x,%x,%x) snd_(una,nxt,max) (%x,%x,%x)\n",
229
            tp->rcv_nxt, tp->rcv_wnd, tp->rcv_up, tp->snd_una, tp->snd_nxt,
230
            tp->snd_max);
231
        printf("\tsnd_(wl1,wl2,wnd) (%x,%x,%x)\n",
232
            tp->snd_wl1, tp->snd_wl2, tp->snd_wnd);
233
#endif /* TCPDEBUG */
234
}
235
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.