1 |
1254 |
phoenix |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// include/netinet6_sys_debug.h
|
4 |
|
|
//
|
5 |
|
|
//
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
//####BSDCOPYRIGHTBEGIN####
|
9 |
|
|
//
|
10 |
|
|
// -------------------------------------------
|
11 |
|
|
//
|
12 |
|
|
// Portions of this software may have been derived from OpenBSD or other sources,
|
13 |
|
|
// and are covered by the appropriate copyright disclaimers included herein.
|
14 |
|
|
//
|
15 |
|
|
// -------------------------------------------
|
16 |
|
|
//
|
17 |
|
|
//####BSDCOPYRIGHTEND####
|
18 |
|
|
//==========================================================================
|
19 |
|
|
//#####DESCRIPTIONBEGIN####
|
20 |
|
|
//
|
21 |
|
|
// Author(s): gthomas
|
22 |
|
|
// Contributors: gthomas
|
23 |
|
|
// Date: 2000-01-10
|
24 |
|
|
// Purpose:
|
25 |
|
|
// Description:
|
26 |
|
|
//
|
27 |
|
|
//
|
28 |
|
|
//####DESCRIPTIONEND####
|
29 |
|
|
//
|
30 |
|
|
//==========================================================================
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/*
|
34 |
|
|
%%% portions-copyright-nrl-95
|
35 |
|
|
Portions of this software are Copyright 1995-1998 by Randall Atkinson,
|
36 |
|
|
Ronald Lee, Daniel McDonald, Bao Phan, and Chris Winters. All Rights
|
37 |
|
|
Reserved. All rights under this copyright have been assigned to the US
|
38 |
|
|
Naval Research Laboratory (NRL). The NRL Copyright Notice and License
|
39 |
|
|
Agreement Version 1.1 (January 17, 1995) applies to these portions of the
|
40 |
|
|
software.
|
41 |
|
|
You should have received a copy of the license with this software. If you
|
42 |
|
|
didn't get a copy, you may request one from <license@ipv6.nrl.navy.mil>.
|
43 |
|
|
|
44 |
|
|
*/
|
45 |
|
|
|
46 |
|
|
#ifndef _NETINET6_SYS_DEBUG_H
|
47 |
|
|
#define _NETINET6_SYS_DEBUG_H 1
|
48 |
|
|
|
49 |
|
|
#ifdef DEBUG_NRL
|
50 |
|
|
#include <sys/osdep.h>
|
51 |
|
|
#else /* DEBUG_NRL */
|
52 |
|
|
#if __OpenBSD__
|
53 |
|
|
#include <netinet6/osdep.h>
|
54 |
|
|
#else /* __OpenBSD__ */
|
55 |
|
|
#include <sys/osdep.h>
|
56 |
|
|
#endif /* __OpenBSD__ */
|
57 |
|
|
#endif /* DEBUG_NRL */
|
58 |
|
|
|
59 |
|
|
/* Non-ANSI compilers don't stand a chance. You PROBABLY need GNU C. */
|
60 |
|
|
#ifndef __STDC__
|
61 |
|
|
#error An ANSI C compiler is required here.
|
62 |
|
|
#endif /* __STDC__ */
|
63 |
|
|
|
64 |
|
|
#ifndef _KERN_DEBUG_GENERIC_C
|
65 |
|
|
extern int debug_level;
|
66 |
|
|
#endif /* _KERN_DEBUG_GENERIC_DEBUG_C */
|
67 |
|
|
|
68 |
|
|
/* Debugging levels */
|
69 |
|
|
|
70 |
|
|
#define __DEBUG_LEVEL_ALL (INT_MAX-1) /* Report all messages. */
|
71 |
|
|
#define __DEBUG_LEVEL_NONE 0 /* Report no messages. */
|
72 |
|
|
|
73 |
|
|
#define __DEBUG_LEVEL_CRITICAL 3
|
74 |
|
|
#define __DEBUG_LEVEL_ERROR 7
|
75 |
|
|
#define __DEBUG_LEVEL_MAJOREVENT 10
|
76 |
|
|
#define __DEBUG_LEVEL_EVENT 15
|
77 |
|
|
#define __DEBUG_LEVEL_GROSSEVENT 20
|
78 |
|
|
#define __DEBUG_LEVEL_FINISHED 1000
|
79 |
|
|
|
80 |
|
|
/* Compatibility macros */
|
81 |
|
|
|
82 |
|
|
#define __DEBUG_LEVEL_MAJOR_EVENT __DEBUG_LEVEL_MAJOREVENT
|
83 |
|
|
#define __DEBUG_LEVEL_GROSS_EVENT __DEBUG_LEVEL_GROSSEVENT
|
84 |
|
|
#define __DEBUG_LEVEL_IDL_CRITICAL __DEBUG_LEVEL_CRITICAL
|
85 |
|
|
#define __DEBUG_LEVEL_IDL_ERROR __DEBUG_LEVEL_ERROR
|
86 |
|
|
#define __DEBUG_LEVEL_IDL_MAJOR_EVENT __DEBUG_LEVEL_MAJOREVENT
|
87 |
|
|
#define __DEBUG_LEVEL_IDL_EVENT __DEBUG_LEVEL_EVENT
|
88 |
|
|
#define __DEBUG_LEVEL_IDL_GROSS_EVENT __DEBUG_LEVEL_GROSSEVENT
|
89 |
|
|
#define __DEBUG_LEVEL_IDL_FINISHED __DEBUG_LEVEL_FINISHED
|
90 |
|
|
|
91 |
|
|
/* Unless you have optimization turned off and your compiler is drain bamaged,
|
92 |
|
|
this will turn in to a syntactically inert no-op - cmetz */
|
93 |
|
|
#define __DEBUG_NOP do { } while (0)
|
94 |
|
|
|
95 |
|
|
#ifdef DEBUG_NRL
|
96 |
|
|
/*
|
97 |
|
|
* Make sure argument for DPRINTF is in parentheses.
|
98 |
|
|
*
|
99 |
|
|
* For both DPRINTF and DDO, and attempt was made to make both macros
|
100 |
|
|
* be usable as normal C statments. There is a small amount of compiler
|
101 |
|
|
* trickery (if-else clauses with effectively null statements), which may
|
102 |
|
|
* cause a few compilers to complain.
|
103 |
|
|
*/
|
104 |
|
|
|
105 |
|
|
#ifndef __GENERIC_DEBUG_LEVEL
|
106 |
|
|
#define __GENERIC_DEBUG_LEVEL debug_level
|
107 |
|
|
#endif /* __GENERIC_DEBUG_LEVEL */
|
108 |
|
|
|
109 |
|
|
/*
|
110 |
|
|
* DPRINTF() is a general printf statement. The "arg" is literally what
|
111 |
|
|
* would follow the function name printf, which means it has to be in
|
112 |
|
|
* parenthesis. Unlimited arguments can be used this way.
|
113 |
|
|
*
|
114 |
|
|
* EXAMPLE:
|
115 |
|
|
* DPRINTF(IDL_MAJOR_EVENT,("Hello, world. IP version %d.\n",vers));
|
116 |
|
|
*/
|
117 |
|
|
#undef DPRINTF
|
118 |
|
|
#define DPRINTF(lev,arg) \
|
119 |
|
|
if (__DEBUG_LEVEL_ ## lev <= __GENERIC_DEBUG_LEVEL) { \
|
120 |
|
|
printf arg; \
|
121 |
|
|
} else \
|
122 |
|
|
__DEBUG_NOP
|
123 |
|
|
|
124 |
|
|
/*
|
125 |
|
|
* DDO() executes a series of statements at a certain debug level. The
|
126 |
|
|
* "stmt" argument is a statement in the sense of a "statement list" in a
|
127 |
|
|
* C grammar. "stmt" does not have to end with a semicolon.
|
128 |
|
|
*
|
129 |
|
|
* EXAMPLE:
|
130 |
|
|
* DDO(IDL_CRITICAL,dump_ipv6(header), dump_inpcb(inp));
|
131 |
|
|
*/
|
132 |
|
|
#undef DDO
|
133 |
|
|
#define DDO(lev,stmt) \
|
134 |
|
|
if (__DEBUG_LEVEL_ ## lev <= __GENERIC_DEBUG_LEVEL) { \
|
135 |
|
|
stmt ; \
|
136 |
|
|
} else \
|
137 |
|
|
__DEBUG_NOP
|
138 |
|
|
|
139 |
|
|
/*
|
140 |
|
|
* DP() is a shortcut for DPRINTF(). Basically:
|
141 |
|
|
*
|
142 |
|
|
* DP(lev, var, fmt) == DPRINTF(IDL_lev, ("var = %fmt\n", var))
|
143 |
|
|
*
|
144 |
|
|
* It is handy for printing single variables without a lot of typing.
|
145 |
|
|
*
|
146 |
|
|
* EXAMPLE:
|
147 |
|
|
*
|
148 |
|
|
* DP(CRITICAL,length,d);
|
149 |
|
|
* same as DPRINTF(IDL_CRITICAL, ("length = %d\n", length))
|
150 |
|
|
*/
|
151 |
|
|
#undef DP
|
152 |
|
|
#define DP(lev, var, fmt) \
|
153 |
|
|
DPRINTF(lev, (#var " = %" #fmt "\n", var))
|
154 |
|
|
|
155 |
|
|
#undef DEBUG_STATUS
|
156 |
|
|
#if defined(__GNUC__) && (__GNUC__ >= 2)
|
157 |
|
|
#define DEBUG_STATUS debug_status(__FILE__ ":" __FUNCTION__, __LINE__, __builtin_return_address(0))
|
158 |
|
|
#else /* defined(__GNUC__) && (__GNUC__ >= 2) */
|
159 |
|
|
#define DEBUG_STATUS debug_status(__FILE__, __LINE__, (void *)0)
|
160 |
|
|
#endif /* defined(__GNUC__) && (__GNUC__ >= 2) */
|
161 |
|
|
|
162 |
|
|
/* Call as:
|
163 |
|
|
|
164 |
|
|
DS();
|
165 |
|
|
*/
|
166 |
|
|
#undef DS
|
167 |
|
|
#define DS() DPRINTF(IDL_CRITICAL, ("%s\n", DEBUG_STATUS))
|
168 |
|
|
#else /* DEBUG_NRL */
|
169 |
|
|
#undef DPRINTF
|
170 |
|
|
#define DPRINTF(lev,arg) __DEBUG_NOP
|
171 |
|
|
#undef DDO
|
172 |
|
|
#define DDO(lev, stmt) __DEBUG_NOP
|
173 |
|
|
#undef DP
|
174 |
|
|
#define DP(x, y, z) __DEBUG_NOP
|
175 |
|
|
#undef DS
|
176 |
|
|
#define DS() __DEBUG_NOP
|
177 |
|
|
#endif /* DEBUG_NRL */
|
178 |
|
|
|
179 |
|
|
#ifdef DEBUG_MALLOC
|
180 |
|
|
void *debug_malloc_malloc(unsigned int n, char *creator);
|
181 |
|
|
void debug_malloc_free(void *p);
|
182 |
|
|
void debug_malloc_dump(void);
|
183 |
|
|
void debug_malloc_flush(void);
|
184 |
|
|
#endif /* DEBUG_MALLOC */
|
185 |
|
|
|
186 |
|
|
#ifdef DEBUG_NRL
|
187 |
|
|
char *debug_status(char *filefunction, unsigned int line, void *returnaddress);
|
188 |
|
|
void dump_buf_small(void *, int);
|
189 |
|
|
void debug_dump_buf(void *, int);
|
190 |
|
|
void dump_packet(void *buf, int len);
|
191 |
|
|
|
192 |
|
|
struct dump_flags {
|
193 |
|
|
int val;
|
194 |
|
|
char *name;
|
195 |
|
|
};
|
196 |
|
|
void dump_flags(struct dump_flags *, int);
|
197 |
|
|
|
198 |
|
|
struct sockaddr;
|
199 |
|
|
void dump_sockaddr(struct sockaddr *);
|
200 |
|
|
void dump_smart_sockaddr(void *);
|
201 |
|
|
|
202 |
|
|
#ifdef __linux__
|
203 |
|
|
struct sk_buff;
|
204 |
|
|
void dump_skb(struct sk_buff *);
|
205 |
|
|
#endif /* __linux__ */
|
206 |
|
|
|
207 |
|
|
#ifdef OSDEP_BSD
|
208 |
|
|
struct sockaddr_dl;
|
209 |
|
|
void dump_sockaddr_dl(struct sockaddr_dl *);
|
210 |
|
|
struct mbuf;
|
211 |
|
|
void dump_mbuf_flags(struct mbuf *);
|
212 |
|
|
void dump_mbuf_hdr(struct mbuf *);
|
213 |
|
|
void dump_mbuf(struct mbuf *);
|
214 |
|
|
void dump_mchain_hdr(struct mbuf *);
|
215 |
|
|
void dump_mchain(struct mbuf *);
|
216 |
|
|
void dump_mbuf_tcpdump(struct mbuf *);
|
217 |
|
|
struct ifaddr;
|
218 |
|
|
void dump_ifa(struct ifaddr *);
|
219 |
|
|
struct ifnet;
|
220 |
|
|
void dump_ifp(struct ifnet *);
|
221 |
|
|
struct route;
|
222 |
|
|
void dump_route(struct route *);
|
223 |
|
|
struct rtentry;
|
224 |
|
|
void dump_rtentry(struct rtentry *);
|
225 |
|
|
struct inpcb;
|
226 |
|
|
void dump_inpcb(struct inpcb *);
|
227 |
|
|
#if __NetBSD__ || __OpenBSD__
|
228 |
|
|
struct inpcbtable;
|
229 |
|
|
void dump_inpcbs(struct inpcbtable *);
|
230 |
|
|
#else /* __NetBSD__ || __OpenBSD__ */
|
231 |
|
|
void dump_inpcbs(struct inpcb *);
|
232 |
|
|
#endif /* __NetBSD__ || __OpenBSD__ */
|
233 |
|
|
#endif /* OSDEP_BSD */
|
234 |
|
|
|
235 |
|
|
#ifdef INET
|
236 |
|
|
struct in_addr;
|
237 |
|
|
void dump_in_addr(struct in_addr *);
|
238 |
|
|
struct sockaddr_in;
|
239 |
|
|
void dump_sockaddr_in(struct sockaddr_in *);
|
240 |
|
|
#endif /* INET */
|
241 |
|
|
|
242 |
|
|
#ifdef INET6
|
243 |
|
|
#include <netinet6/debug_inet6.h>
|
244 |
|
|
#endif /* INET6 */
|
245 |
|
|
#endif /* DEBUG_NRL */
|
246 |
|
|
|
247 |
|
|
#endif /* _NETINET6_SYS_DEBUG_H */
|