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