trace.h revision 11820
150472Speter/* 233975Sjdp * Copyright (c) 1983, 1993 374313Sobrien * The Regents of the University of California. All rights reserved. 474313Sobrien * 574313Sobrien * Copyright (c) 1995 John Hay. All rights reserved. 674313Sobrien * 733975Sjdp * This file includes significant work done at Cornell University by 868675Sobrien * Bill Nesheim. That work included by permission. 998623Sobrien * 1033975Sjdp * Redistribution and use in source and binary forms, with or without 1184951Sobrien * modification, are permitted provided that the following conditions 1285193Sobrien * are met: 1384951Sobrien * 1. Redistributions of source code must retain the above copyright 1446328Sdfr * notice, this list of conditions and the following disclaimer. 1546291Sdfr * 2. Redistributions in binary form must reproduce the above copyright 1646291Sdfr * notice, this list of conditions and the following disclaimer in the 1733975Sjdp * 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.4 1995/10/11 18:57:34 jhay 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, &packet[sizeof(struct ipxdp)], size, \ 87 ntohl(ifp->int_metric)); \ 88 } \ 89 if (tracepackets && ftrace) \ 90 dumppacket(ftrace, "from", src, &packet[sizeof(struct ipxdp)], size); \ 91 } 92#define TRACE_OUTPUT(ifp, dst, size) { \ 93 if (tracing) { \ 94 ifp = if_iflookup(dst); \ 95 if (ifp) \ 96 trace(&ifp->int_output, dst, &packet[sizeof(struct ipxdp)], size, ifp->int_metric); \ 97 } \ 98 if (tracepackets && ftrace) \ 99 dumppacket(ftrace, "to", dst, &packet[sizeof(struct ipxdp)], size); \ 100 } 101 102#define TRACE_SAP_OUTPUT(ifp, dst, size) { \ 103 if (tracing) { \ 104 ifp = if_iflookup(dst); \ 105 if (ifp) \ 106 trace(&ifp->int_output, dst, &packet[sizeof(struct ipxdp)], size, ifp->int_metric); \ 107 } \ 108 if (tracepackets && ftrace) \ 109 dumpsappacket(ftrace, "to", dst, &packet[sizeof(struct ipxdp)], size); \ 110 } 111 112void traceinit(struct interface *); 113void traceon(char *file); 114void traceoff(void); 115void traceaction(FILE *, char *, struct rt_entry *); 116void trace(struct ifdebug *, struct sockaddr *, char *, int, int); 117void dumppacket(FILE *, char *, struct sockaddr *, char *, int); 118void dumpsappacket(FILE *, char *, struct sockaddr *, char *, int); 119void dumpsaptable(FILE *fd, struct sap_hash *sh); 120 121char *ipxdp_nettoa(union ipx_net); 122char *ipxdp_ntoa(struct ipx_addr *); 123 124