trace.h revision 15248
111820Sjulian/* 211820Sjulian * Copyright (c) 1983, 1993 311820Sjulian * The Regents of the University of California. All rights reserved. 411820Sjulian * 511820Sjulian * Copyright (c) 1995 John Hay. All rights reserved. 611820Sjulian * 711820Sjulian * This file includes significant work done at Cornell University by 811820Sjulian * Bill Nesheim. That work included by permission. 911820Sjulian * 1011820Sjulian * Redistribution and use in source and binary forms, with or without 1111820Sjulian * modification, are permitted provided that the following conditions 1211820Sjulian * are met: 1311820Sjulian * 1. Redistributions of source code must retain the above copyright 1411820Sjulian * notice, this list of conditions and the following disclaimer. 1511820Sjulian * 2. Redistributions in binary form must reproduce the above copyright 1611820Sjulian * notice, this list of conditions and the following disclaimer in the 1711820Sjulian * documentation and/or other materials provided with the distribution. 1811820Sjulian * 3. All advertising materials mentioning features or use of this software 1911820Sjulian * must display the following acknowledgement: 2011820Sjulian * This product includes software developed by the University of 2111820Sjulian * California, Berkeley and its contributors. 2211820Sjulian * 4. Neither the name of the University nor the names of its contributors 2311820Sjulian * may be used to endorse or promote products derived from this software 2411820Sjulian * without specific prior written permission. 2511820Sjulian * 2611820Sjulian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2711820Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2811820Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2911820Sjulian * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3011820Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3111820Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3211820Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3311820Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3411820Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3511820Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3611820Sjulian * SUCH DAMAGE. 3711820Sjulian * 3811820Sjulian * @(#)trace.h 8.1 (Berkeley) 6/5/93 3911820Sjulian * 4015248Sjhay * $Id: trace.h,v 1.2 1995/10/27 10:48:31 julian Exp $ 4111820Sjulian */ 4211820Sjulian 4311820Sjulian/* 4411820Sjulian * IPX Routing Information Protocol. 4511820Sjulian */ 4611820Sjulian 4711820Sjulian/* 4811820Sjulian * Trace record format. 4911820Sjulian */ 5011820Sjulianstruct iftrace { 5111820Sjulian time_t ift_stamp; /* time stamp */ 5211820Sjulian struct sockaddr ift_who; /* from/to */ 5311820Sjulian char *ift_packet; /* pointer to packet */ 5411820Sjulian short ift_size; /* size of packet */ 5511820Sjulian short ift_metric; /* metric */ 5611820Sjulian}; 5711820Sjulian 5811820Sjulian/* 5911820Sjulian * Per interface packet tracing buffers. An incoming and 6011820Sjulian * outgoing circular buffer of packets is maintained, per 6111820Sjulian * interface, for debugging. Buffers are dumped whenever 6211820Sjulian * an interface is marked down. 6311820Sjulian */ 6411820Sjulianstruct ifdebug { 6511820Sjulian struct iftrace *ifd_records; /* array of trace records */ 6611820Sjulian struct iftrace *ifd_front; /* next empty trace record */ 6711820Sjulian int ifd_count; /* number of unprinted records */ 6811820Sjulian struct interface *ifd_if; /* for locating stuff */ 6911820Sjulian}; 7011820Sjulian 7111820Sjulian/* 7211820Sjulian * Packet tracing stuff. 7311820Sjulian */ 7411820Sjulianint tracepackets; /* watch packets as they go by */ 7511820Sjulianint tracing; /* on/off */ 7611820SjulianFILE *ftrace; /* output trace file */ 7711820Sjulian 7811820Sjulian#define TRACE_ACTION(action, route) { \ 7911820Sjulian if (tracing) \ 8011820Sjulian traceaction(ftrace, "action", route); \ 8111820Sjulian } 8211820Sjulian#define TRACE_INPUT(ifp, src, size) { \ 8311820Sjulian if (tracing) { \ 8411820Sjulian ifp = if_iflookup(src); \ 8511820Sjulian if (ifp) \ 8611840Sjulian trace(&ifp->int_input, src, \ 8711840Sjulian &packet[sizeof(struct ipx)], size, \ 8811820Sjulian ntohl(ifp->int_metric)); \ 8911820Sjulian } \ 9011820Sjulian if (tracepackets && ftrace) \ 9111840Sjulian dumppacket(ftrace, "from", src, \ 9211840Sjulian &packet[sizeof(struct ipx)], size); \ 9311820Sjulian } 9411820Sjulian#define TRACE_OUTPUT(ifp, dst, size) { \ 9511820Sjulian if (tracing) { \ 9611820Sjulian ifp = if_iflookup(dst); \ 9711820Sjulian if (ifp) \ 9811840Sjulian trace(&ifp->int_output, dst, \ 9911840Sjulian &packet[sizeof(struct ipx)], \ 10011840Sjulian size, ifp->int_metric); \ 10111820Sjulian } \ 10211820Sjulian if (tracepackets && ftrace) \ 10311840Sjulian dumppacket(ftrace, "to", dst, \ 10411840Sjulian &packet[sizeof(struct ipx)], size); \ 10511820Sjulian } 10611820Sjulian 10711820Sjulian#define TRACE_SAP_OUTPUT(ifp, dst, size) { \ 10811820Sjulian if (tracing) { \ 10911820Sjulian ifp = if_iflookup(dst); \ 11011820Sjulian if (ifp) \ 11111840Sjulian trace(&ifp->int_output, dst, \ 11211840Sjulian &packet[sizeof(struct ipx)], \ 11311840Sjulian size, ifp->int_metric); \ 11411820Sjulian } \ 11511820Sjulian if (tracepackets && ftrace) \ 11611840Sjulian dumpsappacket(ftrace, "to", dst, \ 11711840Sjulian &packet[sizeof(struct ipx)], size); \ 11811820Sjulian } 11911820Sjulian 12011820Sjulianvoid traceinit(struct interface *); 12111820Sjulianvoid traceon(char *file); 12211820Sjulianvoid traceoff(void); 12311820Sjulianvoid traceaction(FILE *, char *, struct rt_entry *); 12411820Sjulianvoid trace(struct ifdebug *, struct sockaddr *, char *, int, int); 12511820Sjulianvoid dumppacket(FILE *, char *, struct sockaddr *, char *, int); 12611820Sjulianvoid dumpsappacket(FILE *, char *, struct sockaddr *, char *, int); 12711820Sjulianvoid dumpsaptable(FILE *fd, struct sap_hash *sh); 12815248Sjhayvoid dumpriptable(FILE *fd); 12911820Sjulian 13011820Sjulianchar *ipxdp_nettoa(union ipx_net); 13111820Sjulianchar *ipxdp_ntoa(struct ipx_addr *); 13211820Sjulian 133