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