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