1 /* 2 * Copyright (c) 1983 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This file includes significant work done at Cornell University by 6 * Bill Nesheim. That work included by permission. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)trace.h 5.6 (Berkeley) 06/01/90 11 */ 12 13 /* 14 * Xerox Routing Information Protocol. 15 */ 16 17 /* 18 * Trace record format. 19 */ 20 struct iftrace { 21 time_t ift_stamp; /* time stamp */ 22 struct sockaddr ift_who; /* from/to */ 23 char *ift_packet; /* pointer to packet */ 24 short ift_size; /* size of packet */ 25 short ift_metric; /* metric */ 26 }; 27 28 /* 29 * Per interface packet tracing buffers. An incoming and 30 * outgoing circular buffer of packets is maintained, per 31 * interface, for debugging. Buffers are dumped whenever 32 * an interface is marked down. 33 */ 34 struct ifdebug { 35 struct iftrace *ifd_records; /* array of trace records */ 36 struct iftrace *ifd_front; /* next empty trace record */ 37 int ifd_count; /* number of unprinted records */ 38 struct interface *ifd_if; /* for locating stuff */ 39 }; 40 41 /* 42 * Packet tracing stuff. 43 */ 44 int tracepackets; /* watch packets as they go by */ 45 int tracing; /* on/off */ 46 FILE *ftrace; /* output trace file */ 47 48 #define TRACE_ACTION(action, route) { \ 49 if (tracing) \ 50 traceaction(ftrace, "action", route); \ 51 } 52 #define TRACE_INPUT(ifp, src, size) { \ 53 if (tracing) { \ 54 ifp = if_iflookup(src); \ 55 if (ifp) \ 56 trace(&ifp->int_input, src, &packet[sizeof(struct idp)], size, \ 57 ntohl(ifp->int_metric)); \ 58 } \ 59 if (tracepackets && ftrace) \ 60 dumppacket(ftrace, "from", src, &packet[sizeof(struct idp)], size); \ 61 } 62 #define TRACE_OUTPUT(ifp, dst, size) { \ 63 if (tracing) { \ 64 ifp = if_iflookup(dst); \ 65 if (ifp) \ 66 trace(&ifp->int_output, dst, &packet[sizeof(struct idp)], size, ifp->int_metric); \ 67 } \ 68 if (tracepackets && ftrace) \ 69 dumppacket(ftrace, "to", dst, &packet[sizeof(struct idp)], size); \ 70 } 71