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