carp: add carp_group_demote_adj()
[dragonfly.git] / usr.sbin / IPXrouted / trace.h
CommitLineData
984263bc
MD
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Copyright (c) 1995 John Hay. All rights reserved.
6 *
7 * This file includes significant work done at Cornell University by
8 * Bill Nesheim. That work included by permission.
9 *
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.
25 *
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.
37 *
38 * @(#)trace.h 8.1 (Berkeley) 6/5/93
39 *
40 * $FreeBSD: src/usr.sbin/IPXrouted/trace.h,v 1.7 1999/08/28 01:15:07 peter Exp $
1de703da 41 * $DragonFly: src/usr.sbin/IPXrouted/trace.h,v 1.2 2003/06/17 04:29:52 dillon Exp $
984263bc
MD
42 */
43
44/*
45 * IPX Routing Information Protocol.
46 */
47
48/*
49 * Trace record format.
50 */
51struct 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 */
57};
58
59/*
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.
64 */
65struct 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 */
70};
71
72/*
73 * Packet tracing stuff.
74 */
75int tracepackets; /* watch packets as they go by */
76int tracing; /* on/off */
77FILE *ftrace; /* output trace file */
78
79#define TRACE_ACTION(action, route) { \
80 if (tracing) \
81 traceaction(ftrace, "action", route); \
82 traceactionlog(action, route); \
83 }
84#define TRACE_SAP_ACTION(action, service) { \
85 tracesapactionlog(action, service); \
86 }
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); \
98 }
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); \
106 } \
107 if (tracepackets && ftrace) \
108 dumppacket(ftrace, "to", dst, \
109 &packet[sizeof(struct ipx)], size); \
110 }
111
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); \
119 } \
120 if (tracepackets && ftrace) \
121 dumpsappacket(ftrace, "to", dst, \
122 &packet[sizeof(struct ipx)], size); \
123 }
124
125void traceinit(struct interface *);
126void traceon(char *file);
127void traceoff(void);
128void traceaction(FILE *, char *, struct rt_entry *);
129void traceactionlog(char *, struct rt_entry *);
130void tracesapactionlog(char *action, struct sap_entry *sap);
131void trace(struct ifdebug *, struct sockaddr *, char *, int, int);
132void dumppacket(FILE *, char *, struct sockaddr *, char *, int);
133void dumpsappacket(FILE *, char *, struct sockaddr *, char *, int);
134void dumpsaptable(FILE *fd, struct sap_hash *sh);
135void dumpriptable(FILE *fd);
136
137char *ipxdp_nettoa(union ipx_net);
138char *ipxdp_ntoa(struct ipx_addr *);
139