1 /* trace.h 1.0 4/16/85 */ 2 3 /* 4 * Xerox Routing Information Protocol. 5 */ 6 7 /* 8 * Trace record format. 9 */ 10 struct iftrace { 11 time_t ift_stamp; /* time stamp */ 12 struct sockaddr ift_who; /* from/to */ 13 char *ift_packet; /* pointer to packet */ 14 short ift_size; /* size of packet */ 15 short ift_metric; /* metric */ 16 }; 17 18 /* 19 * Per interface packet tracing buffers. An incoming and 20 * outgoing circular buffer of packets is maintained, per 21 * interface, for debugging. Buffers are dumped whenever 22 * an interface is marked down. 23 */ 24 struct ifdebug { 25 struct iftrace *ifd_records; /* array of trace records */ 26 struct iftrace *ifd_front; /* next empty trace record */ 27 int ifd_count; /* number of unprinted records */ 28 struct interface *ifd_if; /* for locating stuff */ 29 }; 30 31 /* 32 * Packet tracing stuff. 33 */ 34 int tracepackets; /* watch packets as they go by */ 35 int tracing; /* on/off */ 36 FILE *ftrace; /* output trace file */ 37 38 #define TRACE_ACTION(action, route) { \ 39 if (tracing) \ 40 traceaction(ftrace, "action", route); \ 41 } 42 #define TRACE_INPUT(ifp, src, size) { \ 43 if (tracing) { \ 44 ifp = if_iflookup(src); \ 45 if (ifp) \ 46 trace(&ifp->int_input, src, &packet[sizeof(struct idp)], size, \ 47 ntohl(ifp->int_metric)); \ 48 } \ 49 if (tracepackets) \ 50 dumppacket(stdout, "from", src, &packet[sizeof(struct idp)], size); \ 51 } 52 #define TRACE_OUTPUT(ifp, dst, size) { \ 53 if (tracing) { \ 54 ifp = if_iflookup(dst); \ 55 if (ifp) \ 56 trace(&ifp->int_output, dst, &packet[sizeof(struct idp)], size, ifp->int_metric); \ 57 } \ 58 if (tracepackets) \ 59 dumppacket(stdout, "to", dst, &packet[sizeof(struct idp)], size); \ 60 } 61