1 /*
2 * in6_debug.h -- Insipired by Craig Metz's Net/2 in6_debug.h, but
3 * not quite as heavyweight (initially, anyway).
4 *
5 * In particular, if function exit-entries are to be
6 * documented, do them in a lightweight fashion.
7 *
8 * Copyright 1995 by Dan McDonald, Bao Phan, and Randall Atkinson,
9 * All Rights Reserved.
10 * All Rights under this copyright have been assigned to NRL.
11 */
12
13 /*----------------------------------------------------------------------
14 # @(#)COPYRIGHT 1.1a (NRL) 17 August 1995
15
16 COPYRIGHT NOTICE
17
18 All of the documentation and software included in this software
19 distribution from the US Naval Research Laboratory (NRL) are
20 copyrighted by their respective developers.
21
22 This software and documentation were developed at NRL by various
23 people. Those developers have each copyrighted the portions that they
24 developed at NRL and have assigned All Rights for those portions to
25 NRL. Outside the USA, NRL also has copyright on the software
26 developed at NRL. The affected files all contain specific copyright
27 notices and those notices must be retained in any derived work.
28
29 NRL LICENSE
30
31 NRL grants permission for redistribution and use in source and binary
32 forms, with or without modification, of the software and documentation
33 created at NRL provided that the following conditions are met:
34
35 1. Redistributions of source code must retain the above copyright
36 notice, this list of conditions and the following disclaimer.
37 2. Redistributions in binary form must reproduce the above copyright
38 notice, this list of conditions and the following disclaimer in the
39 documentation and/or other materials provided with the distribution.
40 3. All advertising materials mentioning features or use of this software
41 must display the following acknowledgement:
42
43 This product includes software developed at the Information
44 Technology Division, US Naval Research Laboratory.
45
46 4. Neither the name of the NRL nor the names of its contributors
47 may be used to endorse or promote products derived from this software
48 without specific prior written permission.
49
50 THE SOFTWARE PROVIDED BY NRL IS PROVIDED BY NRL AND CONTRIBUTORS ``AS
51 IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
52 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
53 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NRL OR
54 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
55 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
56 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
57 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
58 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
59 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
60 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61
62 The views and conclusions contained in the software and documentation
63 are those of the authors and should not be interpreted as representing
64 official policies, either expressed or implied, of the US Naval
65 Research Laboratory (NRL).
66
67 ----------------------------------------------------------------------*/
68
69 /* IDL_* is IPv6 Debug Level */
70
71 #define IDL_ALL 0xFFFFFFFE /* Report all messages. */
72 #define IDL_NONE 0 /* Report no messages. */
73
74 #define IDL_CRITICAL 3
75 #define IDL_ERROR 7
76 #define IDL_MAJOR_EVENT 10
77 #define IDL_EVENT 15
78 #define IDL_GROSS_EVENT 20
79 #define IDL_FINISHED 0xFFFFFFF0
80
81 /*
82 * Make sure argument for DPRINTF is in parentheses.
83 *
84 * For both DPRINTF and DDO, and attempt was made to make both macros
85 * be usable as normal C statments. There is a small amount of compiler
86 * trickery (if-else clauses with effectively null statements), which may
87 * cause a few compilers to complain.
88 */
89
90 #ifdef INET6_DEBUG
91
92 /*
93 * DPRINTF() is a general printf statement. The "arg" is literally what
94 * would follow the function name printf, which means it has to be in
95 * parenthesis. Unlimited arguments can be used this way.
96 *
97 * EXAMPLE:
98 * DPRINTF(IDL_MAJOR_EVENT,("Hello, world. IP version %d.\n",vers));
99 */
100 #define DPRINTF(lev,arg) if ((lev) < in6_debug_level) { \
101 printf arg; \
102 } \
103 else in6_debug_level = in6_debug_level
104
105 /*
106 * DDO() executes a series of statements at a certain debug level. The
107 * "stmt" argument is a statement in the sense of a "statement list" in a
108 * C grammar. "stmt" does not have to end with a semicolon.
109 *
110 * EXAMPLE:
111 * DDO(IDL_CRITICAL,dump_ipv6(header), dump_inpcb(inp));
112 */
113 #define DDO(lev,stmt) if ((lev) < in6_debug_level) { stmt ; } \
114 else in6_debug_level = in6_debug_level
115
116 /*
117 * DP() is a shortcut for DPRINTF(). Basically:
118 *
119 * DP(lev, var, fmt) == DPRINTF(IDL_lev, ("var = %fmt\n", var))
120 *
121 * It is handy for printing single variables without a lot of typing.
122 *
123 * EXAMPLE:
124 *
125 * DP(CRITICAL,length,d);
126 * same as DPRINTF(IDL_CRITICAL, ("length = %d\n", length))
127 */
128 #define DP(lev, var, fmt) DPRINTF(IDL_ ## lev, (#var " = %" #fmt "\n", var))
129
130 #ifndef SOCKADDR
131 #define SOCKADDR struct sockaddr
132 #endif /* SOCKADDR */
133
134 void dump_buf __P((char *, int));
135 void dump_sockaddr __P((SOCKADDR *));
136 void dump_smart_sockaddr __P((SOCKADDR *));
137 void dump_keytblnode __P((struct key_tblnode *));
138 void dump_secassoc __P((struct key_secassoc *));
139 void dump_keymsghdr __P((struct key_msghdr *));
140
141 #else /* ! INET6_DEBUG */
142
143 #define DPRINTF(lev,arg)
144 #define DDO(lev, stmt)
145 #define DP(x, y, z)
146
147 #endif /* INET6_DEBUG */
148
149 #ifndef INET6_DEBUG_C
150 extern unsigned int in6_debug_level;
151 #endif
Cache object: fc66f08d9a40852dabcf4150bb47144b
|