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 *
4050479Speter * $FreeBSD$
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); \
8127244Sjhay	  traceactionlog(action, route); \
8211820Sjulian	}
8327244Sjhay#define TRACE_SAP_ACTION(action, service) { \
8427244Sjhay	  tracesapactionlog(action, service); \
8527244Sjhay	}
8611820Sjulian#define	TRACE_INPUT(ifp, src, size) { \
8711820Sjulian	  if (tracing) { \
8811820Sjulian		ifp = if_iflookup(src); \
8911820Sjulian		if (ifp) \
9011840Sjulian			trace(&ifp->int_input, src, \
9111840Sjulian				&packet[sizeof(struct ipx)], size, \
9211820Sjulian				ntohl(ifp->int_metric)); \
9311820Sjulian	  } \
9411820Sjulian	  if (tracepackets && ftrace) \
9511840Sjulian		dumppacket(ftrace, "from", src, \
9611840Sjulian				&packet[sizeof(struct ipx)], size); \
9711820Sjulian	}
9811820Sjulian#define	TRACE_OUTPUT(ifp, dst, size) { \
9911820Sjulian	  if (tracing) { \
10011820Sjulian		ifp = if_iflookup(dst); \
10111820Sjulian		if (ifp) \
10211840Sjulian		    trace(&ifp->int_output, dst, \
10311840Sjulian				&packet[sizeof(struct ipx)], \
10411840Sjulian				size, ifp->int_metric); \
10511820Sjulian	  } \
10611820Sjulian	  if (tracepackets && ftrace) \
10711840Sjulian		dumppacket(ftrace, "to", dst, \
10811840Sjulian				&packet[sizeof(struct ipx)], size); \
10911820Sjulian	}
11011820Sjulian
11111820Sjulian#define	TRACE_SAP_OUTPUT(ifp, dst, size) { \
11211820Sjulian	  if (tracing) { \
11311820Sjulian		ifp = if_iflookup(dst); \
11411820Sjulian		if (ifp) \
11511840Sjulian		    trace(&ifp->int_output, dst, \
11611840Sjulian				&packet[sizeof(struct ipx)], \
11711840Sjulian				size, ifp->int_metric); \
11811820Sjulian	  } \
11911820Sjulian	  if (tracepackets && ftrace) \
12011840Sjulian		dumpsappacket(ftrace, "to", dst, \
12111840Sjulian				&packet[sizeof(struct ipx)], size); \
12211820Sjulian	}
12311820Sjulian
12411820Sjulianvoid traceinit(struct interface *);
12511820Sjulianvoid traceon(char *file);
12611820Sjulianvoid traceoff(void);
12711820Sjulianvoid traceaction(FILE *, char *, struct rt_entry *);
12827244Sjhayvoid traceactionlog(char *, struct rt_entry *);
12927244Sjhayvoid tracesapactionlog(char *action, struct sap_entry *sap);
13011820Sjulianvoid trace(struct ifdebug *, struct sockaddr *, char *, int, int);
13111820Sjulianvoid dumppacket(FILE *, char *, struct sockaddr *, char *, int);
13211820Sjulianvoid dumpsappacket(FILE *, char *, struct sockaddr *, char *, int);
13311820Sjulianvoid dumpsaptable(FILE *fd, struct sap_hash *sh);
13415248Sjhayvoid dumpriptable(FILE *fd);
13511820Sjulian
13611820Sjulianchar *ipxdp_nettoa(union ipx_net);
13711820Sjulianchar *ipxdp_ntoa(struct ipx_addr *);
13811820Sjulian
139