19d8a9f43Sdist /* 2*6160dbd1Sbostic * Copyright (c) 1983, 1988, 1993 3*6160dbd1Sbostic * The Regents of the University of California. All rights reserved. 49d8a9f43Sdist * 54839fc90Sbostic * %sccs.include.redist.c% 6cf60b4c8Sbostic * 7*6160dbd1Sbostic * @(#)trace.h 8.1 (Berkeley) 06/05/93 89d8a9f43Sdist */ 91aef945dSsam 101aef945dSsam /* 111aef945dSsam * Routing table management daemon. 121aef945dSsam */ 131aef945dSsam 141aef945dSsam /* 151aef945dSsam * Trace record format. 161aef945dSsam */ 171aef945dSsam struct iftrace { 18a3f24c4fSkarels struct timeval ift_stamp; /* time stamp */ 191aef945dSsam struct sockaddr ift_who; /* from/to */ 201aef945dSsam char *ift_packet; /* pointer to packet */ 211aef945dSsam short ift_size; /* size of packet */ 221aef945dSsam short ift_metric; /* metric on associated metric */ 231aef945dSsam }; 241aef945dSsam 251aef945dSsam /* 261aef945dSsam * Per interface packet tracing buffers. An incoming and 271aef945dSsam * outgoing circular buffer of packets is maintained, per 281aef945dSsam * interface, for debugging. Buffers are dumped whenever 291aef945dSsam * an interface is marked down. 301aef945dSsam */ 311aef945dSsam struct ifdebug { 321aef945dSsam struct iftrace *ifd_records; /* array of trace records */ 331aef945dSsam struct iftrace *ifd_front; /* next empty trace record */ 34c96a0062Skarels int ifd_count; /* number of unprinted records */ 351aef945dSsam struct interface *ifd_if; /* for locating stuff */ 361aef945dSsam }; 371aef945dSsam 381aef945dSsam /* 391aef945dSsam * Packet tracing stuff. 401aef945dSsam */ 414ec9493eSsam int tracepackets; /* watch packets as they go by */ 42a3f24c4fSkarels int tracecontents; /* watch packet contents as they go by */ 43658b12b0Skarels int traceactions; /* on/off */ 44658b12b0Skarels int tracehistory; /* on/off */ 451aef945dSsam FILE *ftrace; /* output trace file */ 464ec9493eSsam 471aef945dSsam #define TRACE_ACTION(action, route) { \ 48658b12b0Skarels if (traceactions) \ 49658b12b0Skarels traceaction(ftrace, action, route); \ 50658b12b0Skarels } 51658b12b0Skarels #define TRACE_NEWMETRIC(route, newmetric) { \ 52658b12b0Skarels if (traceactions) \ 53658b12b0Skarels tracenewmetric(ftrace, route, newmetric); \ 541aef945dSsam } 55554657d9Skarels #define TRACE_INPUT(ifp, src, pack, size) { \ 56658b12b0Skarels if (tracehistory) { \ 574ec9493eSsam ifp = if_iflookup(src); \ 581aef945dSsam if (ifp) \ 59554657d9Skarels trace(&ifp->int_input, src, pack, size, \ 60202044daSsam ntohl(ifp->int_metric)); \ 611aef945dSsam } \ 62a3f24c4fSkarels if (tracepackets) \ 63554657d9Skarels dumppacket(ftrace, "from", src, pack, size, &now); \ 641aef945dSsam } 654ec9493eSsam #define TRACE_OUTPUT(ifp, dst, size) { \ 66658b12b0Skarels if (tracehistory && ifp) \ 674ec9493eSsam trace(&ifp->int_output, dst, packet, size, ifp->int_metric); \ 68a3f24c4fSkarels if (tracepackets) \ 69a3f24c4fSkarels dumppacket(ftrace, "to", dst, packet, size, &now); \ 701aef945dSsam } 71