xref: /original-bsd/sbin/routed/trace.h (revision a9c19d04)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)trace.h	5.2 (Berkeley) 04/20/86
7  */
8 
9 /*
10  * Routing table management daemon.
11  */
12 
13 /*
14  * Trace record format.
15  */
16 struct	iftrace {
17 	time_t	ift_stamp;		/* time stamp */
18 	struct	sockaddr ift_who;	/* from/to */
19 	char	*ift_packet;		/* pointer to packet */
20 	short	ift_size;		/* size of packet */
21 	short	ift_metric;		/* metric on associated metric */
22 };
23 
24 /*
25  * Per interface packet tracing buffers.  An incoming and
26  * outgoing circular buffer of packets is maintained, per
27  * interface, for debugging.  Buffers are dumped whenever
28  * an interface is marked down.
29  */
30 struct	ifdebug {
31 	struct	iftrace *ifd_records;	/* array of trace records */
32 	struct	iftrace *ifd_front;	/* next empty trace record */
33 	int	ifd_count;		/* number of unprinted records */
34 	struct	interface *ifd_if;	/* for locating stuff */
35 };
36 
37 /*
38  * Packet tracing stuff.
39  */
40 int	tracepackets;		/* watch packets as they go by */
41 int	tracing;		/* on/off */
42 FILE	*ftrace;		/* output trace file */
43 
44 #define	TRACE_ACTION(action, route) { \
45 	  if (tracing) \
46 		traceaction(ftrace, "action", route); \
47 	}
48 #define	TRACE_INPUT(ifp, src, size) { \
49 	  if (tracing) { \
50 		ifp = if_iflookup(src); \
51 		if (ifp) \
52 			trace(&ifp->int_input, src, packet, size, \
53 				ntohl(ifp->int_metric)); \
54 	  } \
55 	  if (tracepackets) \
56 		dumppacket(stdout, "from", src, packet, size); \
57 	}
58 #define	TRACE_OUTPUT(ifp, dst, size) { \
59 	  if (tracing && ifp) \
60 		trace(&ifp->int_output, dst, packet, size, ifp->int_metric); \
61 	  if (tracepackets) \
62 		dumppacket(stdout, "to", dst, packet, size); \
63 	}
64