124327Ssklower /* 2*35551Sbostic * Copyright (c) 1983 The Regents of the University of California. 3*35551Sbostic * All rights reserved. 424327Ssklower * 5*35551Sbostic * This file includes significant work done at Cornell University by 6*35551Sbostic * Bill Nesheim. That work included by permission. 724327Ssklower * 8*35551Sbostic * Redistribution and use in source and binary forms are permitted 9*35551Sbostic * provided that the above copyright notice and this paragraph are 10*35551Sbostic * duplicated in all such forms and that any documentation, 11*35551Sbostic * advertising materials, and other materials related to such 12*35551Sbostic * distribution and use acknowledge that the software was developed 13*35551Sbostic * by the University of California, Berkeley. The name of the 14*35551Sbostic * University may not be used to endorse or promote products derived 15*35551Sbostic * from this software without specific prior written permission. 16*35551Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17*35551Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18*35551Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19*35551Sbostic * 20*35551Sbostic * @(#)trace.h 5.5 (Berkeley) 09/19/88 2124327Ssklower */ 2224315Ssklower 2324315Ssklower /* 2424315Ssklower * Xerox Routing Information Protocol. 2524315Ssklower */ 2624315Ssklower 2724315Ssklower /* 2824315Ssklower * Trace record format. 2924315Ssklower */ 3024315Ssklower struct iftrace { 3124315Ssklower time_t ift_stamp; /* time stamp */ 3224315Ssklower struct sockaddr ift_who; /* from/to */ 3324315Ssklower char *ift_packet; /* pointer to packet */ 3424315Ssklower short ift_size; /* size of packet */ 3524315Ssklower short ift_metric; /* metric */ 3624315Ssklower }; 3724315Ssklower 3824315Ssklower /* 3924315Ssklower * Per interface packet tracing buffers. An incoming and 4024315Ssklower * outgoing circular buffer of packets is maintained, per 4124315Ssklower * interface, for debugging. Buffers are dumped whenever 4224315Ssklower * an interface is marked down. 4324315Ssklower */ 4424315Ssklower struct ifdebug { 4524315Ssklower struct iftrace *ifd_records; /* array of trace records */ 4624315Ssklower struct iftrace *ifd_front; /* next empty trace record */ 4724315Ssklower int ifd_count; /* number of unprinted records */ 4824315Ssklower struct interface *ifd_if; /* for locating stuff */ 4924315Ssklower }; 5024315Ssklower 5124315Ssklower /* 5224315Ssklower * Packet tracing stuff. 5324315Ssklower */ 5424315Ssklower int tracepackets; /* watch packets as they go by */ 5524315Ssklower int tracing; /* on/off */ 5624315Ssklower FILE *ftrace; /* output trace file */ 5724315Ssklower 5824315Ssklower #define TRACE_ACTION(action, route) { \ 5924315Ssklower if (tracing) \ 6024315Ssklower traceaction(ftrace, "action", route); \ 6124315Ssklower } 6224315Ssklower #define TRACE_INPUT(ifp, src, size) { \ 6324315Ssklower if (tracing) { \ 6424315Ssklower ifp = if_iflookup(src); \ 6524315Ssklower if (ifp) \ 6624315Ssklower trace(&ifp->int_input, src, &packet[sizeof(struct idp)], size, \ 6724315Ssklower ntohl(ifp->int_metric)); \ 6824315Ssklower } \ 6924875Ssklower if (tracepackets && ftrace) \ 7024875Ssklower dumppacket(ftrace, "from", src, &packet[sizeof(struct idp)], size); \ 7124315Ssklower } 7224315Ssklower #define TRACE_OUTPUT(ifp, dst, size) { \ 7324315Ssklower if (tracing) { \ 7424315Ssklower ifp = if_iflookup(dst); \ 7524315Ssklower if (ifp) \ 7624315Ssklower trace(&ifp->int_output, dst, &packet[sizeof(struct idp)], size, ifp->int_metric); \ 7724315Ssklower } \ 7824875Ssklower if (tracepackets && ftrace) \ 7924875Ssklower dumppacket(ftrace, "to", dst, &packet[sizeof(struct idp)], size); \ 8024315Ssklower } 81