1*24327Ssklower /* 2*24327Ssklower * Copyright (c) 1983 Regents of the University of California. 3*24327Ssklower * All rights reserved. The Berkeley software License Agreement 4*24327Ssklower * specifies the terms and conditions for redistribution. 5*24327Ssklower * 6*24327Ssklower * @(#)trace.h 5.3 (Berkeley) 08/16/85"; 7*24327Ssklower * 8*24327Ssklower * Includes material written at Cornell University by Bill Nesheim, 9*24327Ssklower * by permission of the author. 10*24327Ssklower */ 1124315Ssklower 1224315Ssklower /* 1324315Ssklower * Xerox Routing Information Protocol. 1424315Ssklower */ 1524315Ssklower 1624315Ssklower /* 1724315Ssklower * Trace record format. 1824315Ssklower */ 1924315Ssklower struct iftrace { 2024315Ssklower time_t ift_stamp; /* time stamp */ 2124315Ssklower struct sockaddr ift_who; /* from/to */ 2224315Ssklower char *ift_packet; /* pointer to packet */ 2324315Ssklower short ift_size; /* size of packet */ 2424315Ssklower short ift_metric; /* metric */ 2524315Ssklower }; 2624315Ssklower 2724315Ssklower /* 2824315Ssklower * Per interface packet tracing buffers. An incoming and 2924315Ssklower * outgoing circular buffer of packets is maintained, per 3024315Ssklower * interface, for debugging. Buffers are dumped whenever 3124315Ssklower * an interface is marked down. 3224315Ssklower */ 3324315Ssklower struct ifdebug { 3424315Ssklower struct iftrace *ifd_records; /* array of trace records */ 3524315Ssklower struct iftrace *ifd_front; /* next empty trace record */ 3624315Ssklower int ifd_count; /* number of unprinted records */ 3724315Ssklower struct interface *ifd_if; /* for locating stuff */ 3824315Ssklower }; 3924315Ssklower 4024315Ssklower /* 4124315Ssklower * Packet tracing stuff. 4224315Ssklower */ 4324315Ssklower int tracepackets; /* watch packets as they go by */ 4424315Ssklower int tracing; /* on/off */ 4524315Ssklower FILE *ftrace; /* output trace file */ 4624315Ssklower 4724315Ssklower #define TRACE_ACTION(action, route) { \ 4824315Ssklower if (tracing) \ 4924315Ssklower traceaction(ftrace, "action", route); \ 5024315Ssklower } 5124315Ssklower #define TRACE_INPUT(ifp, src, size) { \ 5224315Ssklower if (tracing) { \ 5324315Ssklower ifp = if_iflookup(src); \ 5424315Ssklower if (ifp) \ 5524315Ssklower trace(&ifp->int_input, src, &packet[sizeof(struct idp)], size, \ 5624315Ssklower ntohl(ifp->int_metric)); \ 5724315Ssklower } \ 5824315Ssklower if (tracepackets) \ 5924315Ssklower dumppacket(stdout, "from", src, &packet[sizeof(struct idp)], size); \ 6024315Ssklower } 6124315Ssklower #define TRACE_OUTPUT(ifp, dst, size) { \ 6224315Ssklower if (tracing) { \ 6324315Ssklower ifp = if_iflookup(dst); \ 6424315Ssklower if (ifp) \ 6524315Ssklower trace(&ifp->int_output, dst, &packet[sizeof(struct idp)], size, ifp->int_metric); \ 6624315Ssklower } \ 6724315Ssklower if (tracepackets) \ 6824315Ssklower dumppacket(stdout, "to", dst, &packet[sizeof(struct idp)], size); \ 6924315Ssklower } 70