149268Sbostic /*- 249268Sbostic * Copyright (c) 1991 The Regents of the University of California. 349268Sbostic * All rights reserved. 449268Sbostic * 549268Sbostic * %sccs.include.redist.c% 649268Sbostic * 7*56533Sbostic * @(#)tp_trace.c 7.5 (Berkeley) 10/11/92 849268Sbostic */ 949268Sbostic 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 51*56533Sbostic #include <sys/param.h> 52*56533Sbostic #include <sys/systm.h> 53*56533Sbostic #include <sys/mbuf.h> 54*56533Sbostic #include <sys/socket.h> 55*56533Sbostic #include <sys/time.h> 5636417Ssklower 57*56533Sbostic #include <netiso/tp_param.h> 58*56533Sbostic #include <netiso/tp_timer.h> 59*56533Sbostic #include <netiso/tp_stat.h> 60*56533Sbostic #include <netiso/tp_param.h> 61*56533Sbostic #include <netiso/tp_ip.h> 62*56533Sbostic #include <netiso/tp_pcb.h> 63*56533Sbostic #include <netiso/tp_tpdu.h> 64*56533Sbostic #include <netiso/argo_debug.h> 65*56533Sbostic #include <netiso/tp_trace.h> 6636417Ssklower 6736417Ssklower #ifdef TPPT 6836417Ssklower static tp_seq = 0; 6936417Ssklower u_char tp_traceflags[128]; 7036417Ssklower 7136417Ssklower /* 7236417Ssklower * The argument tpcb is the obvious. 7336417Ssklower * event here is just the type of trace event - TPPTmisc, etc. 7436417Ssklower * The rest of the arguments have different uses depending 7536417Ssklower * on the type of trace event. 7636417Ssklower */ 7736417Ssklower /*ARGSUSED*/ 7836417Ssklower /*VARARGS*/ 7936417Ssklower 8036417Ssklower void 8136417Ssklower tpTrace(tpcb, event, arg, src, len, arg4, arg5) 8236417Ssklower struct tp_pcb *tpcb; 8336417Ssklower u_int event, arg; 8436417Ssklower u_int src; 8536417Ssklower u_int len; 8636417Ssklower u_int arg4; 8736417Ssklower u_int arg5; 8836417Ssklower { 8936417Ssklower register struct tp_Trace *tp; 9036417Ssklower 9136417Ssklower tp = &tp_Trace[tp_Tracen++]; 9236417Ssklower tp_Tracen %= TPTRACEN; 9336417Ssklower 9436417Ssklower tp->tpt_event = event; 9536417Ssklower tp->tpt_tseq = tp_seq++; 9636417Ssklower tp->tpt_arg = arg; 9736417Ssklower if(tpcb) 9836417Ssklower tp->tpt_arg2 = tpcb->tp_lref; 9936417Ssklower bcopy( (caddr_t)&time, (caddr_t)&tp->tpt_time, sizeof(struct timeval) ); 10036417Ssklower 10136417Ssklower switch(event) { 10236417Ssklower 10336417Ssklower case TPPTertpdu: 10436417Ssklower bcopy((caddr_t)src, (caddr_t)&tp->tpt_ertpdu, 10537469Ssklower (unsigned)MIN((int)len, sizeof(struct tp_Trace))); 10636417Ssklower break; 10736417Ssklower 10836417Ssklower case TPPTusrreq: 10936417Ssklower case TPPTmisc: 11036417Ssklower 11136417Ssklower /* arg is a string */ 11236417Ssklower bcopy((caddr_t)arg, (caddr_t)tp->tpt_str, 11337469Ssklower (unsigned)MIN(1+strlen((caddr_t) arg), TPTRACE_STRLEN)); 11436417Ssklower tp->tpt_m2 = src; 11536417Ssklower tp->tpt_m3 = len; 11636417Ssklower tp->tpt_m4 = arg4; 11736417Ssklower tp->tpt_m1 = arg5; 11836417Ssklower break; 11936417Ssklower 12036417Ssklower case TPPTgotXack: 12136417Ssklower case TPPTXack: 12236417Ssklower case TPPTsendack: 12336417Ssklower case TPPTgotack: 12436417Ssklower case TPPTack: 12536417Ssklower case TPPTindicate: 12636417Ssklower default: 12736417Ssklower case TPPTdriver: 12836417Ssklower tp->tpt_m2 = arg; 12936417Ssklower tp->tpt_m3 = src; 13036417Ssklower tp->tpt_m4 = len; 13136417Ssklower tp->tpt_m5 = arg4; 13236417Ssklower tp->tpt_m1 = arg5; 13336417Ssklower break; 13436417Ssklower case TPPTparam: 13536417Ssklower bcopy((caddr_t)src, (caddr_t)&tp->tpt_param, sizeof(struct tp_param)); 13636417Ssklower break; 13736417Ssklower case TPPTref: 13836417Ssklower bcopy((caddr_t)src, (caddr_t)&tp->tpt_ref, sizeof(struct tp_ref)); 13936417Ssklower break; 14036417Ssklower 14136417Ssklower case TPPTtpduin: 14236417Ssklower case TPPTtpduout: 14336417Ssklower tp->tpt_arg2 = arg4; 14437469Ssklower bcopy((caddr_t)src, (caddr_t)&tp->tpt_tpdu, 14537469Ssklower (unsigned)MIN((int)len, sizeof(struct tp_Trace))); 14636417Ssklower break; 14736417Ssklower } 14836417Ssklower } 14936417Ssklower #endif TPPT 150