xref: /titanic_50/usr/src/cmd/cmd-inet/usr.lib/in.ripngd/trace.h (revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1999 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 /*
31  * Portions of this source code were derived from Berkeley 4.3 BSD
32  * under license from the Regents of the University of California.
33  */
34 
35 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 /*
38  * Routing table management daemon.
39  */
40 
41 /*
42  * Trace record format.
43  */
44 struct	iftrace {
45 	time_t	ift_stamp;		/* time stamp */
46 	struct	sockaddr_in6 ift_who;	/* from/to */
47 	char	*ift_packet;		/* pointer to packet */
48 	int	ift_size;		/* size of packet */
49 	int	ift_metric;		/* metric on associated metric */
50 };
51 
52 /*
53  * Per interface packet tracing buffers.  An incoming and
54  * outgoing circular buffer of packets is maintained, per
55  * interface, for debugging.  Buffers are dumped whenever
56  * an interface is marked down.
57  */
58 struct	ifdebug {
59 	struct	iftrace *ifd_records;	/* array of trace records */
60 	struct	iftrace *ifd_front;	/* next empty trace record */
61 	int	ifd_count;		/* number of unprinted records */
62 	struct	interface *ifd_if;	/* for locating stuff */
63 };
64 
65 /*
66  * Packet tracing stuff.
67  */
68 extern FILE		*ftrace;
69 extern boolean_t	tracepackets;
70 extern int		tracing;
71 
72 #define	ACTION_BIT	0x0001
73 #define	INPUT_BIT	0x0002
74 #define	OUTPUT_BIT	0x0004
75 
76 #define	TRACE_ACTION(action, route) { \
77 	if (tracing & ACTION_BIT) \
78 		traceaction(ftrace, (action), (route)); \
79 }
80 
81 #define	TRACE_INPUT(ifp, src, size) { \
82 	if ((tracing & INPUT_BIT) && ((ifp) != NULL)) { \
83 		trace(&(ifp)->int_input, (src), packet, (size), \
84 		    (ifp)->int_metric); \
85 	} \
86 	if (tracepackets) { \
87 		dumppacket(stdout, "from", (struct sockaddr_in6 *)(src), \
88 		    packet, (size)); \
89 	} \
90 }
91 #define	TRACE_OUTPUT(ifp, dst, size) { \
92 	if ((tracing & OUTPUT_BIT) && ((ifp) != NULL)) { \
93 		trace(&(ifp)->int_output, (dst), packet, (size), \
94 		    (ifp)->int_metric); \
95 	} \
96 	if (tracepackets) { \
97 		dumppacket(stdout, "to", (struct sockaddr_in6 *)(dst), \
98 		    packet, (size)); \
99 	} \
100 }
101 
102 extern void	dumppacket(FILE *, char *, struct sockaddr_in6 *, char *, int);
103 extern void	trace(struct ifdebug *, struct sockaddr_in6 *, char *, int,
104     int);
105 extern void	traceaction(FILE *, char *, struct rt_entry *);
106 extern void	traceinit(struct interface *);
107 extern void	traceon(char *);
108 extern void	traceonfp(FILE *);
109