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