trace.h revision 15248
1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Copyright (c) 1995 John Hay. All rights reserved. 6 * 7 * This file includes significant work done at Cornell University by 8 * Bill Nesheim. That work included by permission. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)trace.h 8.1 (Berkeley) 6/5/93 39 * 40 * $Id: trace.h,v 1.2 1995/10/27 10:48:31 julian Exp $ 41 */ 42 43/* 44 * IPX Routing Information Protocol. 45 */ 46 47/* 48 * Trace record format. 49 */ 50struct iftrace { 51 time_t ift_stamp; /* time stamp */ 52 struct sockaddr ift_who; /* from/to */ 53 char *ift_packet; /* pointer to packet */ 54 short ift_size; /* size of packet */ 55 short ift_metric; /* metric */ 56}; 57 58/* 59 * Per interface packet tracing buffers. An incoming and 60 * outgoing circular buffer of packets is maintained, per 61 * interface, for debugging. Buffers are dumped whenever 62 * an interface is marked down. 63 */ 64struct ifdebug { 65 struct iftrace *ifd_records; /* array of trace records */ 66 struct iftrace *ifd_front; /* next empty trace record */ 67 int ifd_count; /* number of unprinted records */ 68 struct interface *ifd_if; /* for locating stuff */ 69}; 70 71/* 72 * Packet tracing stuff. 73 */ 74int tracepackets; /* watch packets as they go by */ 75int tracing; /* on/off */ 76FILE *ftrace; /* output trace file */ 77 78#define TRACE_ACTION(action, route) { \ 79 if (tracing) \ 80 traceaction(ftrace, "action", route); \ 81 } 82#define TRACE_INPUT(ifp, src, size) { \ 83 if (tracing) { \ 84 ifp = if_iflookup(src); \ 85 if (ifp) \ 86 trace(&ifp->int_input, src, \ 87 &packet[sizeof(struct ipx)], size, \ 88 ntohl(ifp->int_metric)); \ 89 } \ 90 if (tracepackets && ftrace) \ 91 dumppacket(ftrace, "from", src, \ 92 &packet[sizeof(struct ipx)], size); \ 93 } 94#define TRACE_OUTPUT(ifp, dst, size) { \ 95 if (tracing) { \ 96 ifp = if_iflookup(dst); \ 97 if (ifp) \ 98 trace(&ifp->int_output, dst, \ 99 &packet[sizeof(struct ipx)], \ 100 size, ifp->int_metric); \ 101 } \ 102 if (tracepackets && ftrace) \ 103 dumppacket(ftrace, "to", dst, \ 104 &packet[sizeof(struct ipx)], size); \ 105 } 106 107#define TRACE_SAP_OUTPUT(ifp, dst, size) { \ 108 if (tracing) { \ 109 ifp = if_iflookup(dst); \ 110 if (ifp) \ 111 trace(&ifp->int_output, dst, \ 112 &packet[sizeof(struct ipx)], \ 113 size, ifp->int_metric); \ 114 } \ 115 if (tracepackets && ftrace) \ 116 dumpsappacket(ftrace, "to", dst, \ 117 &packet[sizeof(struct ipx)], size); \ 118 } 119 120void traceinit(struct interface *); 121void traceon(char *file); 122void traceoff(void); 123void traceaction(FILE *, char *, struct rt_entry *); 124void trace(struct ifdebug *, struct sockaddr *, char *, int, int); 125void dumppacket(FILE *, char *, struct sockaddr *, char *, int); 126void dumpsappacket(FILE *, char *, struct sockaddr *, char *, int); 127void dumpsaptable(FILE *fd, struct sap_hash *sh); 128void dumpriptable(FILE *fd); 129 130char *ipxdp_nettoa(union ipx_net); 131char *ipxdp_ntoa(struct ipx_addr *); 132 133