More minor IPI work.
[dragonfly/vkernel-mp.git] / usr.sbin / IPXrouted / trace.h
blob2b60f51a36bb59606a86ba47658fe50a7c1ba295
1 /*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1995 John Hay. All rights reserved.
7 * This file includes significant work done at Cornell University by
8 * Bill Nesheim. That work included by permission.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
38 * @(#)trace.h 8.1 (Berkeley) 6/5/93
40 * $FreeBSD: src/usr.sbin/IPXrouted/trace.h,v 1.7 1999/08/28 01:15:07 peter Exp $
41 * $DragonFly: src/usr.sbin/IPXrouted/trace.h,v 1.2 2003/06/17 06:29:52 dillon Exp $
45 * IPX Routing Information Protocol.
49 * Trace record format.
51 struct iftrace {
52 time_t ift_stamp; /* time stamp */
53 struct sockaddr ift_who; /* from/to */
54 char *ift_packet; /* pointer to packet */
55 short ift_size; /* size of packet */
56 short ift_metric; /* metric */
60 * Per interface packet tracing buffers. An incoming and
61 * outgoing circular buffer of packets is maintained, per
62 * interface, for debugging. Buffers are dumped whenever
63 * an interface is marked down.
65 struct ifdebug {
66 struct iftrace *ifd_records; /* array of trace records */
67 struct iftrace *ifd_front; /* next empty trace record */
68 int ifd_count; /* number of unprinted records */
69 struct interface *ifd_if; /* for locating stuff */
73 * Packet tracing stuff.
75 int tracepackets; /* watch packets as they go by */
76 int tracing; /* on/off */
77 FILE *ftrace; /* output trace file */
79 #define TRACE_ACTION(action, route) { \
80 if (tracing) \
81 traceaction(ftrace, "action", route); \
82 traceactionlog(action, route); \
84 #define TRACE_SAP_ACTION(action, service) { \
85 tracesapactionlog(action, service); \
87 #define TRACE_INPUT(ifp, src, size) { \
88 if (tracing) { \
89 ifp = if_iflookup(src); \
90 if (ifp) \
91 trace(&ifp->int_input, src, \
92 &packet[sizeof(struct ipx)], size, \
93 ntohl(ifp->int_metric)); \
94 } \
95 if (tracepackets && ftrace) \
96 dumppacket(ftrace, "from", src, \
97 &packet[sizeof(struct ipx)], size); \
99 #define TRACE_OUTPUT(ifp, dst, size) { \
100 if (tracing) { \
101 ifp = if_iflookup(dst); \
102 if (ifp) \
103 trace(&ifp->int_output, dst, \
104 &packet[sizeof(struct ipx)], \
105 size, ifp->int_metric); \
107 if (tracepackets && ftrace) \
108 dumppacket(ftrace, "to", dst, \
109 &packet[sizeof(struct ipx)], size); \
112 #define TRACE_SAP_OUTPUT(ifp, dst, size) { \
113 if (tracing) { \
114 ifp = if_iflookup(dst); \
115 if (ifp) \
116 trace(&ifp->int_output, dst, \
117 &packet[sizeof(struct ipx)], \
118 size, ifp->int_metric); \
120 if (tracepackets && ftrace) \
121 dumpsappacket(ftrace, "to", dst, \
122 &packet[sizeof(struct ipx)], size); \
125 void traceinit(struct interface *);
126 void traceon(char *file);
127 void traceoff(void);
128 void traceaction(FILE *, char *, struct rt_entry *);
129 void traceactionlog(char *, struct rt_entry *);
130 void tracesapactionlog(char *action, struct sap_entry *sap);
131 void trace(struct ifdebug *, struct sockaddr *, char *, int, int);
132 void dumppacket(FILE *, char *, struct sockaddr *, char *, int);
133 void dumpsappacket(FILE *, char *, struct sockaddr *, char *, int);
134 void dumpsaptable(FILE *fd, struct sap_hash *sh);
135 void dumpriptable(FILE *fd);
137 char *ipxdp_nettoa(union ipx_net);
138 char *ipxdp_ntoa(struct ipx_addr *);