xref: /freebsd/sys/netipsec/key_debug.h (revision 71625ec9ad2a9bc8c09784fbd23b759830e0ee5f)
188768458SSam Leffler /*	$KAME: key_debug.h,v 1.10 2001/08/05 08:37:52 itojun Exp $	*/
288768458SSam Leffler 
3c398230bSWarner Losh /*-
4*51369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
5*51369649SPedro F. Giffuni  *
688768458SSam Leffler  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
788768458SSam Leffler  * All rights reserved.
888768458SSam Leffler  *
988768458SSam Leffler  * Redistribution and use in source and binary forms, with or without
1088768458SSam Leffler  * modification, are permitted provided that the following conditions
1188768458SSam Leffler  * are met:
1288768458SSam Leffler  * 1. Redistributions of source code must retain the above copyright
1388768458SSam Leffler  *    notice, this list of conditions and the following disclaimer.
1488768458SSam Leffler  * 2. Redistributions in binary form must reproduce the above copyright
1588768458SSam Leffler  *    notice, this list of conditions and the following disclaimer in the
1688768458SSam Leffler  *    documentation and/or other materials provided with the distribution.
1788768458SSam Leffler  * 3. Neither the name of the project nor the names of its contributors
1888768458SSam Leffler  *    may be used to endorse or promote products derived from this software
1988768458SSam Leffler  *    without specific prior written permission.
2088768458SSam Leffler  *
2188768458SSam Leffler  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
2288768458SSam Leffler  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2388768458SSam Leffler  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2488768458SSam Leffler  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
2588768458SSam Leffler  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2688768458SSam Leffler  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2788768458SSam Leffler  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2888768458SSam Leffler  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2988768458SSam Leffler  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3088768458SSam Leffler  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3188768458SSam Leffler  * SUCH DAMAGE.
3288768458SSam Leffler  */
3388768458SSam Leffler 
3488768458SSam Leffler #ifndef _NETIPSEC_KEY_DEBUG_H_
3588768458SSam Leffler #define _NETIPSEC_KEY_DEBUG_H_
3688768458SSam Leffler 
3788768458SSam Leffler #ifdef _KERNEL
3888768458SSam Leffler /* debug flags */
3988768458SSam Leffler #define KEYDEBUG_STAMP		0x00000001 /* path */
4088768458SSam Leffler #define KEYDEBUG_DATA		0x00000002 /* data */
4188768458SSam Leffler #define KEYDEBUG_DUMP		0x00000004 /* dump */
4288768458SSam Leffler 
4388768458SSam Leffler #define KEYDEBUG_KEY		0x00000010 /* key processing */
4488768458SSam Leffler #define KEYDEBUG_ALG		0x00000020 /* ciph & auth algorithm */
4588768458SSam Leffler #define KEYDEBUG_IPSEC		0x00000040 /* ipsec processing */
4688768458SSam Leffler 
4788768458SSam Leffler #define KEYDEBUG_KEY_STAMP	(KEYDEBUG_KEY | KEYDEBUG_STAMP)
4888768458SSam Leffler #define KEYDEBUG_KEY_DATA	(KEYDEBUG_KEY | KEYDEBUG_DATA)
4988768458SSam Leffler #define KEYDEBUG_KEY_DUMP	(KEYDEBUG_KEY | KEYDEBUG_DUMP)
5088768458SSam Leffler #define KEYDEBUG_ALG_STAMP	(KEYDEBUG_ALG | KEYDEBUG_STAMP)
5188768458SSam Leffler #define KEYDEBUG_ALG_DATA	(KEYDEBUG_ALG | KEYDEBUG_DATA)
5288768458SSam Leffler #define KEYDEBUG_ALG_DUMP	(KEYDEBUG_ALG | KEYDEBUG_DUMP)
5388768458SSam Leffler #define KEYDEBUG_IPSEC_STAMP	(KEYDEBUG_IPSEC | KEYDEBUG_STAMP)
5488768458SSam Leffler #define KEYDEBUG_IPSEC_DATA	(KEYDEBUG_IPSEC | KEYDEBUG_DATA)
5588768458SSam Leffler #define KEYDEBUG_IPSEC_DUMP	(KEYDEBUG_IPSEC | KEYDEBUG_DUMP)
5688768458SSam Leffler 
577f1f6591SAndrey V. Elsukov #ifdef IPSEC_DEBUG
58fcf59617SAndrey V. Elsukov #define KEYDBG(lev, arg)	\
59fcf59617SAndrey V. Elsukov     if ((V_key_debug_level & (KEYDEBUG_ ## lev)) == (KEYDEBUG_ ## lev)) { \
60fcf59617SAndrey V. Elsukov 	    arg;		\
61fcf59617SAndrey V. Elsukov     }
627f1f6591SAndrey V. Elsukov #else
637f1f6591SAndrey V. Elsukov #define	KEYDBG(lev, arg)
647f1f6591SAndrey V. Elsukov #endif /* !IPSEC_DEBUG */
6588768458SSam Leffler 
66fcf59617SAndrey V. Elsukov VNET_DECLARE(uint32_t, key_debug_level);
671e77c105SRobert Watson #define	V_key_debug_level	VNET(key_debug_level)
6888768458SSam Leffler #endif /*_KERNEL*/
6988768458SSam Leffler 
7088768458SSam Leffler struct sadb_msg;
7188768458SSam Leffler struct sadb_ext;
7218961126SAndrey V. Elsukov extern void kdebug_sadb(struct sadb_msg *);
7318961126SAndrey V. Elsukov extern void kdebug_sadb_x_policy(struct sadb_ext *);
7488768458SSam Leffler 
7588768458SSam Leffler #ifdef _KERNEL
7688768458SSam Leffler struct secpolicy;
7788768458SSam Leffler struct secpolicyindex;
7888768458SSam Leffler struct secasindex;
79fcf59617SAndrey V. Elsukov struct secashead;
8088768458SSam Leffler struct secasvar;
8188768458SSam Leffler struct secreplay;
8288768458SSam Leffler struct mbuf;
83fcf59617SAndrey V. Elsukov union sockaddr_union;
84fcf59617SAndrey V. Elsukov const char* kdebug_secpolicy_state(u_int);
85fcf59617SAndrey V. Elsukov const char* kdebug_secpolicy_policy(u_int);
86fcf59617SAndrey V. Elsukov const char* kdebug_secpolicyindex_dir(u_int);
87fcf59617SAndrey V. Elsukov const char* kdebug_ipsecrequest_level(u_int);
88fcf59617SAndrey V. Elsukov const char* kdebug_secasindex_mode(u_int);
89fcf59617SAndrey V. Elsukov const char* kdebug_secasv_state(u_int);
90fcf59617SAndrey V. Elsukov void kdebug_secpolicy(struct secpolicy *);
91fcf59617SAndrey V. Elsukov void kdebug_secpolicyindex(struct secpolicyindex *, const char *);
92fcf59617SAndrey V. Elsukov void kdebug_secasindex(const struct secasindex *, const char *);
93fcf59617SAndrey V. Elsukov void kdebug_secash(struct secashead *, const char *);
94fcf59617SAndrey V. Elsukov void kdebug_secasv(struct secasvar *);
95fcf59617SAndrey V. Elsukov void kdebug_mbufhdr(const struct mbuf *);
96fcf59617SAndrey V. Elsukov void kdebug_mbuf(const struct mbuf *);
97fcf59617SAndrey V. Elsukov char *ipsec_address(const union sockaddr_union *, char *, socklen_t);
98fcf59617SAndrey V. Elsukov char *ipsec_sa2str(struct secasvar *, char *, size_t);
9988768458SSam Leffler #endif /*_KERNEL*/
10088768458SSam Leffler 
10188768458SSam Leffler struct sockaddr;
10218961126SAndrey V. Elsukov extern void kdebug_sockaddr(struct sockaddr *);
10388768458SSam Leffler 
10418961126SAndrey V. Elsukov extern void ipsec_hexdump(caddr_t, int);
10518961126SAndrey V. Elsukov extern void ipsec_bindump(caddr_t, int);
10688768458SSam Leffler 
10788768458SSam Leffler #endif /* _NETIPSEC_KEY_DEBUG_H_ */
108