1 /* 2 * Copyright (c) 1983, 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)trace.h 5.7 (Berkeley) 02/20/89 18 */ 19 20 /* 21 * Routing table management daemon. 22 */ 23 24 /* 25 * Trace record format. 26 */ 27 struct iftrace { 28 struct timeval ift_stamp; /* time stamp */ 29 struct sockaddr ift_who; /* from/to */ 30 char *ift_packet; /* pointer to packet */ 31 short ift_size; /* size of packet */ 32 short ift_metric; /* metric on associated metric */ 33 }; 34 35 /* 36 * Per interface packet tracing buffers. An incoming and 37 * outgoing circular buffer of packets is maintained, per 38 * interface, for debugging. Buffers are dumped whenever 39 * an interface is marked down. 40 */ 41 struct ifdebug { 42 struct iftrace *ifd_records; /* array of trace records */ 43 struct iftrace *ifd_front; /* next empty trace record */ 44 int ifd_count; /* number of unprinted records */ 45 struct interface *ifd_if; /* for locating stuff */ 46 }; 47 48 /* 49 * Packet tracing stuff. 50 */ 51 int tracepackets; /* watch packets as they go by */ 52 int tracecontents; /* watch packet contents as they go by */ 53 int traceactions; /* on/off */ 54 int tracehistory; /* on/off */ 55 FILE *ftrace; /* output trace file */ 56 57 #define TRACE_ACTION(action, route) { \ 58 if (traceactions) \ 59 traceaction(ftrace, action, route); \ 60 } 61 #define TRACE_NEWMETRIC(route, newmetric) { \ 62 if (traceactions) \ 63 tracenewmetric(ftrace, route, newmetric); \ 64 } 65 #define TRACE_INPUT(ifp, src, pack, size) { \ 66 if (tracehistory) { \ 67 ifp = if_iflookup(src); \ 68 if (ifp) \ 69 trace(&ifp->int_input, src, pack, size, \ 70 ntohl(ifp->int_metric)); \ 71 } \ 72 if (tracepackets) \ 73 dumppacket(ftrace, "from", src, pack, size, &now); \ 74 } 75 #define TRACE_OUTPUT(ifp, dst, size) { \ 76 if (tracehistory && ifp) \ 77 trace(&ifp->int_output, dst, packet, size, ifp->int_metric); \ 78 if (tracepackets) \ 79 dumppacket(ftrace, "to", dst, packet, size, &now); \ 80 } 81