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