xref: /netbsd-src/sys/netipsec/key_debug.h (revision f59d9812aa2fa325795737f577a975822b05570b)
1*f59d9812Schristos /*	$NetBSD: key_debug.h,v 1.11 2022/05/18 15:20:18 christos Exp $	*/
2e2c8a664Smaxv /*	$FreeBSD: key_debug.h,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $	*/
374029031Sjonathan /*	$KAME: key_debug.h,v 1.10 2001/08/05 08:37:52 itojun Exp $	*/
474029031Sjonathan 
574029031Sjonathan /*
674029031Sjonathan  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
774029031Sjonathan  * All rights reserved.
874029031Sjonathan  *
974029031Sjonathan  * Redistribution and use in source and binary forms, with or without
1074029031Sjonathan  * modification, are permitted provided that the following conditions
1174029031Sjonathan  * are met:
1274029031Sjonathan  * 1. Redistributions of source code must retain the above copyright
1374029031Sjonathan  *    notice, this list of conditions and the following disclaimer.
1474029031Sjonathan  * 2. Redistributions in binary form must reproduce the above copyright
1574029031Sjonathan  *    notice, this list of conditions and the following disclaimer in the
1674029031Sjonathan  *    documentation and/or other materials provided with the distribution.
1774029031Sjonathan  * 3. Neither the name of the project nor the names of its contributors
1874029031Sjonathan  *    may be used to endorse or promote products derived from this software
1974029031Sjonathan  *    without specific prior written permission.
2074029031Sjonathan  *
2174029031Sjonathan  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
2274029031Sjonathan  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2374029031Sjonathan  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2474029031Sjonathan  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
2574029031Sjonathan  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2674029031Sjonathan  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2774029031Sjonathan  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2874029031Sjonathan  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2974029031Sjonathan  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3074029031Sjonathan  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3174029031Sjonathan  * SUCH DAMAGE.
3274029031Sjonathan  */
3374029031Sjonathan 
3474029031Sjonathan #ifndef _NETIPSEC_KEY_DEBUG_H_
3574029031Sjonathan #define _NETIPSEC_KEY_DEBUG_H_
3674029031Sjonathan 
3774029031Sjonathan #ifdef _KERNEL
3874029031Sjonathan /* debug flags */
3974029031Sjonathan #define KEYDEBUG_STAMP		0x00000001 /* path */
4074029031Sjonathan #define KEYDEBUG_DATA		0x00000002 /* data */
4174029031Sjonathan #define KEYDEBUG_DUMP		0x00000004 /* dump */
429347deb6Schristos #define KEYDEBUG_MATCH		0x00000008 /* match */
4374029031Sjonathan 
4474029031Sjonathan #define KEYDEBUG_KEY		0x00000010 /* key processing */
4574029031Sjonathan #define KEYDEBUG_ALG		0x00000020 /* ciph & auth algorithm */
4674029031Sjonathan #define KEYDEBUG_IPSEC		0x00000040 /* ipsec processing */
4774029031Sjonathan 
4874029031Sjonathan #define KEYDEBUG_KEY_STAMP	(KEYDEBUG_KEY | KEYDEBUG_STAMP)
4974029031Sjonathan #define KEYDEBUG_KEY_DATA	(KEYDEBUG_KEY | KEYDEBUG_DATA)
5074029031Sjonathan #define KEYDEBUG_KEY_DUMP	(KEYDEBUG_KEY | KEYDEBUG_DUMP)
5174029031Sjonathan #define KEYDEBUG_ALG_STAMP	(KEYDEBUG_ALG | KEYDEBUG_STAMP)
5274029031Sjonathan #define KEYDEBUG_ALG_DATA	(KEYDEBUG_ALG | KEYDEBUG_DATA)
5374029031Sjonathan #define KEYDEBUG_ALG_DUMP	(KEYDEBUG_ALG | KEYDEBUG_DUMP)
5474029031Sjonathan #define KEYDEBUG_IPSEC_STAMP	(KEYDEBUG_IPSEC | KEYDEBUG_STAMP)
5574029031Sjonathan #define KEYDEBUG_IPSEC_DATA	(KEYDEBUG_IPSEC | KEYDEBUG_DATA)
5674029031Sjonathan #define KEYDEBUG_IPSEC_DUMP	(KEYDEBUG_IPSEC | KEYDEBUG_DUMP)
5774029031Sjonathan 
586208c225Sozaki-r #define KEYDEBUG_ON(lev)	((key_debug_level & (lev)) == (lev))
596208c225Sozaki-r 
606208c225Sozaki-r #define KEYDEBUG_PRINTF(lev, fmt, ...)				\
616208c225Sozaki-r 	do {							\
626208c225Sozaki-r 		if (KEYDEBUG_ON((lev)))				\
63*f59d9812Schristos 			log(LOG_DEBUG, "%s: " fmt, __func__	\
64*f59d9812Schristos 			    __VA_OPT__(,) __VA_ARGS__);		\
656208c225Sozaki-r 	} while (0)
6674029031Sjonathan 
6774029031Sjonathan extern u_int32_t key_debug_level;
6874029031Sjonathan #endif /*_KERNEL*/
6974029031Sjonathan 
7074029031Sjonathan struct sadb_msg;
7174029031Sjonathan struct sadb_ext;
727a1d44a2Sdrochner void kdebug_sadb(const struct sadb_msg *);
73d6d612dcSchristos void kdebug_sadb_xpolicy(const char *, const struct sadb_ext *);
7474029031Sjonathan 
7574029031Sjonathan #ifdef _KERNEL
7674029031Sjonathan struct secpolicy;
7774029031Sjonathan struct secpolicyindex;
7874029031Sjonathan struct secasindex;
7974029031Sjonathan struct secasvar;
8074029031Sjonathan struct secreplay;
8174029031Sjonathan struct mbuf;
827a1d44a2Sdrochner void kdebug_secpolicy(const struct secpolicy *);
83d6d612dcSchristos void kdebug_secpolicyindex(const char *, const struct secpolicyindex *);
84d6d612dcSchristos void kdebug_mbuf(const char *, const struct mbuf *);
8574029031Sjonathan #endif /*_KERNEL*/
8674029031Sjonathan 
87adf9419cSelad #endif /* !_NETIPSEC_KEY_DEBUG_H_ */
88