xref: /csrg-svn/sys/netiso/tp_trace.c (revision 49268)
1*49268Sbostic /*-
2*49268Sbostic  * Copyright (c) 1991 The Regents of the University of California.
3*49268Sbostic  * All rights reserved.
4*49268Sbostic  *
5*49268Sbostic  * %sccs.include.redist.c%
6*49268Sbostic  *
7*49268Sbostic  *	@(#)tp_trace.c	7.4 (Berkeley) 05/06/91
8*49268Sbostic  */
9*49268Sbostic 
1036417Ssklower /***********************************************************
1136417Ssklower 		Copyright IBM Corporation 1987
1236417Ssklower 
1336417Ssklower                       All Rights Reserved
1436417Ssklower 
1536417Ssklower Permission to use, copy, modify, and distribute this software and its
1636417Ssklower documentation for any purpose and without fee is hereby granted,
1736417Ssklower provided that the above copyright notice appear in all copies and that
1836417Ssklower both that copyright notice and this permission notice appear in
1936417Ssklower supporting documentation, and that the name of IBM not be
2036417Ssklower used in advertising or publicity pertaining to distribution of the
2136417Ssklower software without specific, written prior permission.
2236417Ssklower 
2336417Ssklower IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
2436417Ssklower ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
2536417Ssklower IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
2636417Ssklower ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
2736417Ssklower WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
2836417Ssklower ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
2936417Ssklower SOFTWARE.
3036417Ssklower 
3136417Ssklower ******************************************************************/
3236417Ssklower 
3336417Ssklower /*
3436417Ssklower  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
3536417Ssklower  */
3636417Ssklower /*
3736417Ssklower  * ARGO TP
3836417Ssklower  *
3936417Ssklower  * $Header: tp_trace.c,v 5.3 88/11/18 17:29:14 nhall Exp $
4036417Ssklower  * $Source: /usr/argo/sys/netiso/RCS/tp_trace.c,v $
4136417Ssklower  *
4236417Ssklower  * The whole protocol trace module.
4336417Ssklower  * We keep a circular buffer of trace structures, which are big
4436417Ssklower  * unions of different structures we might want to see.
4536417Ssklower  * Unfortunately this gets too big pretty easily. Pcbs were removed
4636417Ssklower  * from the tracing when the kernel got too big to boot.
4736417Ssklower  */
4836417Ssklower 
4936417Ssklower #define TP_TRACEFILE
5036417Ssklower 
5136417Ssklower #include "param.h"
5236417Ssklower #include "systm.h"
5336417Ssklower #include "mbuf.h"
5436417Ssklower #include "socket.h"
5536417Ssklower #include "types.h"
5636417Ssklower #include "time.h"
5736417Ssklower 
5837469Ssklower #include "tp_param.h"
5937469Ssklower #include "tp_timer.h"
6037469Ssklower #include "tp_stat.h"
6137469Ssklower #include "tp_param.h"
6237469Ssklower #include "tp_ip.h"
6337469Ssklower #include "tp_pcb.h"
6437469Ssklower #include "tp_tpdu.h"
6537469Ssklower #include "argo_debug.h"
6637469Ssklower #include "tp_trace.h"
6736417Ssklower 
6836417Ssklower #ifdef TPPT
6936417Ssklower static tp_seq = 0;
7036417Ssklower u_char tp_traceflags[128];
7136417Ssklower 
7236417Ssklower /*
7336417Ssklower  * The argument tpcb is the obvious.
7436417Ssklower  * event here is just the type of trace event - TPPTmisc, etc.
7536417Ssklower  * The rest of the arguments have different uses depending
7636417Ssklower  * on the type of trace event.
7736417Ssklower  */
7836417Ssklower /*ARGSUSED*/
7936417Ssklower /*VARARGS*/
8036417Ssklower 
8136417Ssklower void
8236417Ssklower tpTrace(tpcb, event, arg, src, len, arg4, arg5)
8336417Ssklower 	struct tp_pcb	*tpcb;
8436417Ssklower 	u_int 			event, arg;
8536417Ssklower 	u_int	 		src;
8636417Ssklower 	u_int	 		len;
8736417Ssklower 	u_int	 		arg4;
8836417Ssklower 	u_int	 		arg5;
8936417Ssklower {
9036417Ssklower 	register struct tp_Trace *tp;
9136417Ssklower 
9236417Ssklower 	tp = &tp_Trace[tp_Tracen++];
9336417Ssklower 	tp_Tracen %= TPTRACEN;
9436417Ssklower 
9536417Ssklower 	tp->tpt_event = event;
9636417Ssklower 	tp->tpt_tseq = tp_seq++;
9736417Ssklower 	tp->tpt_arg = arg;
9836417Ssklower 	if(tpcb)
9936417Ssklower 		tp->tpt_arg2 = tpcb->tp_lref;
10036417Ssklower 	bcopy( (caddr_t)&time, (caddr_t)&tp->tpt_time, sizeof(struct timeval) );
10136417Ssklower 
10236417Ssklower 	switch(event) {
10336417Ssklower 
10436417Ssklower 	case TPPTertpdu:
10536417Ssklower 		bcopy((caddr_t)src, (caddr_t)&tp->tpt_ertpdu,
10637469Ssklower 			(unsigned)MIN((int)len, sizeof(struct tp_Trace)));
10736417Ssklower 		break;
10836417Ssklower 
10936417Ssklower 	case TPPTusrreq:
11036417Ssklower 	case TPPTmisc:
11136417Ssklower 
11236417Ssklower 		/* arg is a string */
11336417Ssklower 		bcopy((caddr_t)arg, (caddr_t)tp->tpt_str,
11437469Ssklower 			(unsigned)MIN(1+strlen((caddr_t) arg), TPTRACE_STRLEN));
11536417Ssklower 		tp->tpt_m2 = src;
11636417Ssklower 		tp->tpt_m3 = len;
11736417Ssklower 		tp->tpt_m4 = arg4;
11836417Ssklower 		tp->tpt_m1 = arg5;
11936417Ssklower 		break;
12036417Ssklower 
12136417Ssklower 	case TPPTgotXack:
12236417Ssklower 	case TPPTXack:
12336417Ssklower 	case TPPTsendack:
12436417Ssklower 	case TPPTgotack:
12536417Ssklower 	case TPPTack:
12636417Ssklower 	case TPPTindicate:
12736417Ssklower 	default:
12836417Ssklower 	case TPPTdriver:
12936417Ssklower 		tp->tpt_m2 = arg;
13036417Ssklower 		tp->tpt_m3 = src;
13136417Ssklower 		tp->tpt_m4 = len;
13236417Ssklower 		tp->tpt_m5 = arg4;
13336417Ssklower 		tp->tpt_m1 = arg5;
13436417Ssklower 		break;
13536417Ssklower 	case TPPTparam:
13636417Ssklower 		bcopy((caddr_t)src, (caddr_t)&tp->tpt_param, sizeof(struct tp_param));
13736417Ssklower 		break;
13836417Ssklower 	case TPPTref:
13936417Ssklower 		bcopy((caddr_t)src, (caddr_t)&tp->tpt_ref, sizeof(struct tp_ref));
14036417Ssklower 		break;
14136417Ssklower 
14236417Ssklower 	case TPPTtpduin:
14336417Ssklower 	case TPPTtpduout:
14436417Ssklower 		tp->tpt_arg2 = arg4;
14537469Ssklower 		bcopy((caddr_t)src, (caddr_t)&tp->tpt_tpdu,
14637469Ssklower 		      (unsigned)MIN((int)len, sizeof(struct tp_Trace)));
14736417Ssklower 		break;
14836417Ssklower 	}
14936417Ssklower }
15036417Ssklower #endif TPPT
151