trace.h revision 11840
160786Sps/* 2191930Sdelphij * Copyright (c) 1983, 1993 360786Sps * The Regents of the University of California. All rights reserved. 4191930Sdelphij * 560786Sps * Copyright (c) 1995 John Hay. All rights reserved. 660786Sps * 760786Sps * This file includes significant work done at Cornell University by 860786Sps * Bill Nesheim. That work included by permission. 960786Sps * 1060786Sps * Redistribution and use in source and binary forms, with or without 11191930Sdelphij * modification, are permitted provided that the following conditions 1260786Sps * are met: 1360786Sps * 1. Redistributions of source code must retain the above copyright 1460786Sps * notice, this list of conditions and the following disclaimer. 1560786Sps * 2. Redistributions in binary form must reproduce the above copyright 1689019Sps * notice, this list of conditions and the following disclaimer in the 1789019Sps * documentation and/or other materials provided with the distribution. 1860786Sps * 3. All advertising materials mentioning features or use of this software 1960786Sps * must display the following acknowledgement: 2060786Sps * This product includes software developed by the University of 2160786Sps * California, Berkeley and its contributors. 2260786Sps * 4. Neither the name of the University nor the names of its contributors 2360786Sps * may be used to endorse or promote products derived from this software 2460786Sps * without specific prior written permission. 2560786Sps * 2660786Sps * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2760786Sps * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2860786Sps * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2960786Sps * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3060786Sps * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3160786Sps * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3260786Sps * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3360786Sps * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3460786Sps * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3560786Sps * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3660786Sps * SUCH DAMAGE. 3760786Sps * 3860786Sps * @(#)trace.h 8.1 (Berkeley) 6/5/93 3960786Sps * 4060786Sps * $Id: trace.h,v 1.1 1995/10/26 21:28:30 julian Exp $ 4160786Sps */ 4260786Sps 43170256Sdelphij/* 4460786Sps * IPX Routing Information Protocol. 4560786Sps */ 4660786Sps 4760786Sps/* 4860786Sps * Trace record format. 4960786Sps */ 5060786Spsstruct iftrace { 5160786Sps time_t ift_stamp; /* time stamp */ 5260786Sps struct sockaddr ift_who; /* from/to */ 5360786Sps char *ift_packet; /* pointer to packet */ 5460786Sps short ift_size; /* size of packet */ 55161475Sdelphij short ift_metric; /* metric */ 56161475Sdelphij}; 57161475Sdelphij 58161475Sdelphij/* 5960786Sps * Per interface packet tracing buffers. An incoming and 60170256Sdelphij * outgoing circular buffer of packets is maintained, per 6160786Sps * interface, for debugging. Buffers are dumped whenever 6260786Sps * an interface is marked down. 6360786Sps */ 6460786Spsstruct ifdebug { 6560786Sps struct iftrace *ifd_records; /* array of trace records */ 6660786Sps struct iftrace *ifd_front; /* next empty trace record */ 6760786Sps int ifd_count; /* number of unprinted records */ 6860786Sps struct interface *ifd_if; /* for locating stuff */ 6960786Sps}; 7060786Sps 7160786Sps/* 7260786Sps * Packet tracing stuff. 7360786Sps */ 7460786Spsint tracepackets; /* watch packets as they go by */ 7560786Spsint tracing; /* on/off */ 7660786SpsFILE *ftrace; /* output trace file */ 7760786Sps 7860786Sps#define TRACE_ACTION(action, route) { \ 7960786Sps if (tracing) \ 8060786Sps traceaction(ftrace, "action", route); \ 8160786Sps } 8260786Sps#define TRACE_INPUT(ifp, src, size) { \ 8360786Sps if (tracing) { \ 8460786Sps ifp = if_iflookup(src); \ 8560786Sps if (ifp) \ 8660786Sps trace(&ifp->int_input, src, \ 8760786Sps &packet[sizeof(struct ipx)], size, \ 8860786Sps ntohl(ifp->int_metric)); \ 8960786Sps } \ 9060786Sps if (tracepackets && ftrace) \ 9189019Sps dumppacket(ftrace, "from", src, \ 9260786Sps &packet[sizeof(struct ipx)], size); \ 9360786Sps } 9460786Sps#define TRACE_OUTPUT(ifp, dst, size) { \ 9560786Sps if (tracing) { \ 9660786Sps ifp = if_iflookup(dst); \ 9760786Sps if (ifp) \ 9860786Sps trace(&ifp->int_output, dst, \ 9960786Sps &packet[sizeof(struct ipx)], \ 10060786Sps size, ifp->int_metric); \ 10160786Sps } \ 10260786Sps if (tracepackets && ftrace) \ 10360786Sps dumppacket(ftrace, "to", dst, \ 10460786Sps &packet[sizeof(struct ipx)], size); \ 10560786Sps } 10663128Sps 10760786Sps#define TRACE_SAP_OUTPUT(ifp, dst, size) { \ 10860786Sps if (tracing) { \ 10960786Sps ifp = if_iflookup(dst); \ 11060786Sps if (ifp) \ 11160786Sps trace(&ifp->int_output, dst, \ 11260786Sps &packet[sizeof(struct ipx)], \ 11360786Sps size, ifp->int_metric); \ 11460786Sps } \ 11560786Sps if (tracepackets && ftrace) \ 11660786Sps dumpsappacket(ftrace, "to", dst, \ 11760786Sps &packet[sizeof(struct ipx)], size); \ 11860786Sps } 11960786Sps 12060786Spsvoid traceinit(struct interface *); 12160786Spsvoid traceon(char *file); 12260786Spsvoid traceoff(void); 12360786Spsvoid traceaction(FILE *, char *, struct rt_entry *); 12460786Spsvoid trace(struct ifdebug *, struct sockaddr *, char *, int, int); 12560786Spsvoid dumppacket(FILE *, char *, struct sockaddr *, char *, int); 12660786Spsvoid dumpsappacket(FILE *, char *, struct sockaddr *, char *, int); 12760786Spsvoid dumpsaptable(FILE *fd, struct sap_hash *sh); 12860786Sps 12960786Spschar *ipxdp_nettoa(union ipx_net); 13060786Spschar *ipxdp_ntoa(struct ipx_addr *); 13160786Sps 13260786Sps