xref: /csrg-svn/sys/netiso/tp_trace.c (revision 36417)
1 /***********************************************************
2 		Copyright IBM Corporation 1987
3 
4                       All Rights Reserved
5 
6 Permission to use, copy, modify, and distribute this software and its
7 documentation for any purpose and without fee is hereby granted,
8 provided that the above copyright notice appear in all copies and that
9 both that copyright notice and this permission notice appear in
10 supporting documentation, and that the name of IBM not be
11 used in advertising or publicity pertaining to distribution of the
12 software without specific, written prior permission.
13 
14 IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16 IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20 SOFTWARE.
21 
22 ******************************************************************/
23 
24 /*
25  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
26  */
27 /*
28  * ARGO TP
29  *
30  * $Header: tp_trace.c,v 5.3 88/11/18 17:29:14 nhall Exp $
31  * $Source: /usr/argo/sys/netiso/RCS/tp_trace.c,v $
32  *
33  * The whole protocol trace module.
34  * We keep a circular buffer of trace structures, which are big
35  * unions of different structures we might want to see.
36  * Unfortunately this gets too big pretty easily. Pcbs were removed
37  * from the tracing when the kernel got too big to boot.
38  */
39 
40 #ifndef lint
41 static char *rcsid = "$Header: tp_trace.c,v 5.3 88/11/18 17:29:14 nhall Exp $";
42 #endif lint
43 
44 #define TP_TRACEFILE
45 
46 #include "param.h"
47 #include "systm.h"
48 #include "mbuf.h"
49 #include "socket.h"
50 #include "types.h"
51 #include "time.h"
52 
53 #include "../netiso/tp_param.h"
54 #include "../netiso/tp_timer.h"
55 #include "../netiso/tp_stat.h"
56 #include "../netiso/tp_param.h"
57 #include "../netiso/tp_ip.h"
58 #include "../netiso/tp_pcb.h"
59 #include "../netiso/tp_tpdu.h"
60 #include "../netiso/argo_debug.h"
61 #include "../netiso/tp_trace.h"
62 
63 #ifdef TPPT
64 static tp_seq = 0;
65 u_char tp_traceflags[128];
66 
67 /*
68  * The argument tpcb is the obvious.
69  * event here is just the type of trace event - TPPTmisc, etc.
70  * The rest of the arguments have different uses depending
71  * on the type of trace event.
72  */
73 /*ARGSUSED*/
74 /*VARARGS*/
75 
76 void
77 tpTrace(tpcb, event, arg, src, len, arg4, arg5)
78 	struct tp_pcb	*tpcb;
79 	u_int 			event, arg;
80 	u_int	 		src;
81 	u_int	 		len;
82 	u_int	 		arg4;
83 	u_int	 		arg5;
84 {
85 	register struct tp_Trace *tp;
86 
87 	tp = &tp_Trace[tp_Tracen++];
88 	tp_Tracen %= TPTRACEN;
89 
90 	tp->tpt_event = event;
91 	tp->tpt_tseq = tp_seq++;
92 	tp->tpt_arg = arg;
93 	if(tpcb)
94 		tp->tpt_arg2 = tpcb->tp_lref;
95 	bcopy( (caddr_t)&time, (caddr_t)&tp->tpt_time, sizeof(struct timeval) );
96 
97 	switch(event) {
98 
99 	case TPPTertpdu:
100 		bcopy((caddr_t)src, (caddr_t)&tp->tpt_ertpdu,
101 			MIN((int)len, sizeof(struct tp_Trace)));
102 		break;
103 
104 	case TPPTusrreq:
105 	case TPPTmisc:
106 
107 		/* arg is a string */
108 		bcopy((caddr_t)arg, (caddr_t)tp->tpt_str,
109 			MIN(1+strlen((caddr_t) arg), TPTRACE_STRLEN));
110 		tp->tpt_m2 = src;
111 		tp->tpt_m3 = len;
112 		tp->tpt_m4 = arg4;
113 		tp->tpt_m1 = arg5;
114 		break;
115 
116 	case TPPTgotXack:
117 	case TPPTXack:
118 	case TPPTsendack:
119 	case TPPTgotack:
120 	case TPPTack:
121 	case TPPTindicate:
122 	default:
123 	case TPPTdriver:
124 		tp->tpt_m2 = arg;
125 		tp->tpt_m3 = src;
126 		tp->tpt_m4 = len;
127 		tp->tpt_m5 = arg4;
128 		tp->tpt_m1 = arg5;
129 		break;
130 	case TPPTparam:
131 		bcopy((caddr_t)src, (caddr_t)&tp->tpt_param, sizeof(struct tp_param));
132 		break;
133 	case TPPTref:
134 		bcopy((caddr_t)src, (caddr_t)&tp->tpt_ref, sizeof(struct tp_ref));
135 		break;
136 
137 	case TPPTtpduin:
138 	case TPPTtpduout:
139 		tp->tpt_arg2 = arg4;
140 		bcopy((caddr_t)src, (caddr_t)&tp->tpt_tpdu, MIN((int)len,
141 			sizeof(struct tp_Trace)));
142 		break;
143 	}
144 }
145 #endif TPPT
146