xref: /csrg-svn/sbin/XNSrouted/trace.h (revision 61474)
124327Ssklower /*
2*61474Sbostic  * Copyright (c) 1983, 1993
3*61474Sbostic  *	The Regents of the University of California.  All rights reserved.
424327Ssklower  *
535551Sbostic  * This file includes significant work done at Cornell University by
635551Sbostic  * Bill Nesheim.  That work included by permission.
724327Ssklower  *
842699Sbostic  * %sccs.include.redist.c%
935551Sbostic  *
10*61474Sbostic  *	@(#)trace.h	8.1 (Berkeley) 06/05/93
1124327Ssklower  */
1224315Ssklower 
1324315Ssklower /*
1424315Ssklower  * Xerox Routing Information Protocol.
1524315Ssklower  */
1624315Ssklower 
1724315Ssklower /*
1824315Ssklower  * Trace record format.
1924315Ssklower  */
2024315Ssklower struct	iftrace {
2124315Ssklower 	time_t	ift_stamp;		/* time stamp */
2224315Ssklower 	struct	sockaddr ift_who;	/* from/to */
2324315Ssklower 	char	*ift_packet;		/* pointer to packet */
2424315Ssklower 	short	ift_size;		/* size of packet */
2524315Ssklower 	short	ift_metric;		/* metric  */
2624315Ssklower };
2724315Ssklower 
2824315Ssklower /*
2924315Ssklower  * Per interface packet tracing buffers.  An incoming and
3024315Ssklower  * outgoing circular buffer of packets is maintained, per
3124315Ssklower  * interface, for debugging.  Buffers are dumped whenever
3224315Ssklower  * an interface is marked down.
3324315Ssklower  */
3424315Ssklower struct	ifdebug {
3524315Ssklower 	struct	iftrace *ifd_records;	/* array of trace records */
3624315Ssklower 	struct	iftrace *ifd_front;	/* next empty trace record */
3724315Ssklower 	int	ifd_count;		/* number of unprinted records */
3824315Ssklower 	struct	interface *ifd_if;	/* for locating stuff */
3924315Ssklower };
4024315Ssklower 
4124315Ssklower /*
4224315Ssklower  * Packet tracing stuff.
4324315Ssklower  */
4424315Ssklower int	tracepackets;		/* watch packets as they go by */
4524315Ssklower int	tracing;		/* on/off */
4624315Ssklower FILE	*ftrace;		/* output trace file */
4724315Ssklower 
4824315Ssklower #define	TRACE_ACTION(action, route) { \
4924315Ssklower 	  if (tracing) \
5024315Ssklower 		traceaction(ftrace, "action", route); \
5124315Ssklower 	}
5224315Ssklower #define	TRACE_INPUT(ifp, src, size) { \
5324315Ssklower 	  if (tracing) { \
5424315Ssklower 		ifp = if_iflookup(src); \
5524315Ssklower 		if (ifp) \
5624315Ssklower 			trace(&ifp->int_input, src, &packet[sizeof(struct idp)], size, \
5724315Ssklower 				ntohl(ifp->int_metric)); \
5824315Ssklower 	  } \
5924875Ssklower 	  if (tracepackets && ftrace) \
6024875Ssklower 		dumppacket(ftrace, "from", src, &packet[sizeof(struct idp)], size); \
6124315Ssklower 	}
6224315Ssklower #define	TRACE_OUTPUT(ifp, dst, size) { \
6324315Ssklower 	  if (tracing) { \
6424315Ssklower 		ifp = if_iflookup(dst); \
6524315Ssklower 		if (ifp) \
6624315Ssklower 		    trace(&ifp->int_output, dst, &packet[sizeof(struct idp)], size, ifp->int_metric); \
6724315Ssklower 	  } \
6824875Ssklower 	  if (tracepackets && ftrace) \
6924875Ssklower 		dumppacket(ftrace, "to", dst, &packet[sizeof(struct idp)], size); \
7024315Ssklower 	}
71