1 /* $FreeBSD: src/sys/netkey/key_debug.c,v 1.10.2.5 2002/04/28 05:40:28 suz Exp $ */
2 /* $KAME: key_debug.c,v 1.26 2001/06/27 10:46:50 sakane Exp $ */
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the project nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <sys/types.h>
34 #include <sys/param.h>
36 #include <sys/systm.h>
38 #include <sys/queue.h>
40 #include <sys/socket.h>
42 #include <net/route.h>
44 #include <netkey/key_var.h>
45 #include <netkey/key_debug.h>
47 #include <netinet/in.h>
48 #include <netinet6/ipsec.h>
56 #if !defined(KERNEL) || (defined(KERNEL) && defined(IPSEC_DEBUG))
58 static void kdebug_sadb_prop(struct sadb_ext
*);
59 static void kdebug_sadb_identity(struct sadb_ext
*);
60 static void kdebug_sadb_supported(struct sadb_ext
*);
61 static void kdebug_sadb_lifetime(struct sadb_ext
*);
62 static void kdebug_sadb_sa(struct sadb_ext
*);
63 static void kdebug_sadb_address(struct sadb_ext
*);
64 static void kdebug_sadb_key(struct sadb_ext
*);
65 static void kdebug_sadb_x_sa2(struct sadb_ext
*);
68 static void kdebug_secreplay(struct secreplay
*);
72 #define panic(param) { printf(param); exit(-1); }
75 /* NOTE: host byte order */
77 /* %%%: about struct sadb_msg */
80 struct sadb_msg
*base
;
87 panic("kdebug_sadb: NULL pointer was passed.\n");
90 printf("sadb_msg{ version=%u type=%u errno=%u satype=%u\n",
91 base
->sadb_msg_version
, base
->sadb_msg_type
,
92 base
->sadb_msg_errno
, base
->sadb_msg_satype
);
93 printf(" len=%u reserved=%u seq=%u pid=%u\n",
94 base
->sadb_msg_len
, base
->sadb_msg_reserved
,
95 base
->sadb_msg_seq
, base
->sadb_msg_pid
);
97 tlen
= PFKEY_UNUNIT64(base
->sadb_msg_len
) - sizeof(struct sadb_msg
);
98 ext
= (struct sadb_ext
*)((caddr_t
)base
+ sizeof(struct sadb_msg
));
101 printf("sadb_ext{ len=%u type=%u }\n",
102 ext
->sadb_ext_len
, ext
->sadb_ext_type
);
104 if (ext
->sadb_ext_len
== 0) {
105 printf("kdebug_sadb: invalid ext_len=0 was passed.\n");
108 if (ext
->sadb_ext_len
> tlen
) {
109 printf("kdebug_sadb: ext_len exceeds end of buffer.\n");
113 switch (ext
->sadb_ext_type
) {
117 case SADB_EXT_LIFETIME_CURRENT
:
118 case SADB_EXT_LIFETIME_HARD
:
119 case SADB_EXT_LIFETIME_SOFT
:
120 kdebug_sadb_lifetime(ext
);
122 case SADB_EXT_ADDRESS_SRC
:
123 case SADB_EXT_ADDRESS_DST
:
124 case SADB_EXT_ADDRESS_PROXY
:
125 kdebug_sadb_address(ext
);
127 case SADB_EXT_KEY_AUTH
:
128 case SADB_EXT_KEY_ENCRYPT
:
129 kdebug_sadb_key(ext
);
131 case SADB_EXT_IDENTITY_SRC
:
132 case SADB_EXT_IDENTITY_DST
:
133 kdebug_sadb_identity(ext
);
135 case SADB_EXT_SENSITIVITY
:
137 case SADB_EXT_PROPOSAL
:
138 kdebug_sadb_prop(ext
);
140 case SADB_EXT_SUPPORTED_AUTH
:
141 case SADB_EXT_SUPPORTED_ENCRYPT
:
142 kdebug_sadb_supported(ext
);
144 case SADB_EXT_SPIRANGE
:
145 case SADB_X_EXT_KMPRIVATE
:
147 case SADB_X_EXT_POLICY
:
148 kdebug_sadb_x_policy(ext
);
151 kdebug_sadb_x_sa2(ext
);
153 case SADB_EXT_SESSION_ID
:
154 kdebug_sadb_session_id(ext
);
156 case SADB_EXT_SASTAT
:
157 kdebug_sadb_sastat(ext
);
160 printf("kdebug_sadb: invalid ext_type %u was passed.\n",
165 extlen
= PFKEY_UNUNIT64(ext
->sadb_ext_len
);
167 ext
= (struct sadb_ext
*)((caddr_t
)ext
+ extlen
);
174 kdebug_sadb_prop(ext
)
175 struct sadb_ext
*ext
;
177 struct sadb_prop
*prop
= (struct sadb_prop
*)ext
;
178 struct sadb_comb
*comb
;
183 panic("kdebug_sadb_prop: NULL pointer was passed.\n");
186 len
= (PFKEY_UNUNIT64(prop
->sadb_prop_len
) - sizeof(*prop
))
188 comb
= (struct sadb_comb
*)(prop
+ 1);
189 printf("sadb_prop{ replay=%u\n", prop
->sadb_prop_replay
);
192 printf("sadb_comb{ auth=%u encrypt=%u "
193 "flags=0x%04x reserved=0x%08x\n",
194 comb
->sadb_comb_auth
, comb
->sadb_comb_encrypt
,
195 comb
->sadb_comb_flags
, comb
->sadb_comb_reserved
);
197 printf(" auth_minbits=%u auth_maxbits=%u "
198 "encrypt_minbits=%u encrypt_maxbits=%u\n",
199 comb
->sadb_comb_auth_minbits
,
200 comb
->sadb_comb_auth_maxbits
,
201 comb
->sadb_comb_encrypt_minbits
,
202 comb
->sadb_comb_encrypt_maxbits
);
204 printf(" soft_alloc=%u hard_alloc=%u "
205 "soft_bytes=%lu hard_bytes=%lu\n",
206 comb
->sadb_comb_soft_allocations
,
207 comb
->sadb_comb_hard_allocations
,
208 (u_int32_t
)comb
->sadb_comb_soft_bytes
,
209 (u_int32_t
)comb
->sadb_comb_hard_bytes
);
211 printf(" soft_alloc=%lu hard_alloc=%lu "
212 "soft_bytes=%lu hard_bytes=%lu }\n",
213 (u_int32_t
)comb
->sadb_comb_soft_addtime
,
214 (u_int32_t
)comb
->sadb_comb_hard_addtime
,
215 (u_int32_t
)comb
->sadb_comb_soft_usetime
,
216 (u_int32_t
)comb
->sadb_comb_hard_usetime
);
225 kdebug_sadb_identity(ext
)
226 struct sadb_ext
*ext
;
228 struct sadb_ident
*id
= (struct sadb_ident
*)ext
;
233 panic("kdebug_sadb_identity: NULL pointer was passed.\n");
236 len
= PFKEY_UNUNIT64(id
->sadb_ident_len
) - sizeof(*id
);
237 printf("sadb_ident_%s{",
238 id
->sadb_ident_exttype
== SADB_EXT_IDENTITY_SRC
? "src" : "dst");
239 switch (id
->sadb_ident_type
) {
241 printf(" type=%d id=%lu",
242 id
->sadb_ident_type
, (u_int32_t
)id
->sadb_ident_id
);
245 ipsec_hexdump((caddr_t
)(id
+ 1), len
); /*XXX cast ?*/
249 p
= (char *)(id
+ 1);
251 for (/*nothing*/; *p
&& p
< ep
; p
++) {
253 printf("%c", *p
& 0xff);
255 printf("\\%03o", *p
& 0xff);
270 kdebug_sadb_supported(ext
)
271 struct sadb_ext
*ext
;
273 struct sadb_supported
*sup
= (struct sadb_supported
*)ext
;
274 struct sadb_alg
*alg
;
279 panic("kdebug_sadb_supported: NULL pointer was passed.\n");
282 len
= (PFKEY_UNUNIT64(sup
->sadb_supported_len
) - sizeof(*sup
))
284 alg
= (struct sadb_alg
*)(sup
+ 1);
285 printf("sadb_sup{\n");
287 printf(" { id=%d ivlen=%d min=%d max=%d }\n",
288 alg
->sadb_alg_id
, alg
->sadb_alg_ivlen
,
289 alg
->sadb_alg_minbits
, alg
->sadb_alg_maxbits
);
298 kdebug_sadb_lifetime(ext
)
299 struct sadb_ext
*ext
;
301 struct sadb_lifetime
*lft
= (struct sadb_lifetime
*)ext
;
305 printf("kdebug_sadb_lifetime: NULL pointer was passed.\n");
308 printf("sadb_lifetime{ alloc=%u, bytes=%u\n",
309 lft
->sadb_lifetime_allocations
,
310 (u_int32_t
)lft
->sadb_lifetime_bytes
);
311 printf(" addtime=%u, usetime=%u }\n",
312 (u_int32_t
)lft
->sadb_lifetime_addtime
,
313 (u_int32_t
)lft
->sadb_lifetime_usetime
);
320 struct sadb_ext
*ext
;
322 struct sadb_sa
*sa
= (struct sadb_sa
*)ext
;
326 panic("kdebug_sadb_sa: NULL pointer was passed.\n");
329 printf("sadb_sa{ spi=%u replay=%u state=%u\n",
330 (u_int32_t
)ntohl(sa
->sadb_sa_spi
), sa
->sadb_sa_replay
,
332 printf(" auth=%u encrypt=%u flags=0x%08x }\n",
333 sa
->sadb_sa_auth
, sa
->sadb_sa_encrypt
, sa
->sadb_sa_flags
);
339 kdebug_sadb_address(ext
)
340 struct sadb_ext
*ext
;
342 struct sadb_address
*addr
= (struct sadb_address
*)ext
;
346 panic("kdebug_sadb_address: NULL pointer was passed.\n");
349 printf("sadb_address{ proto=%u prefixlen=%u reserved=0x%02x%02x }\n",
350 addr
->sadb_address_proto
, addr
->sadb_address_prefixlen
,
351 ((u_char
*)&addr
->sadb_address_reserved
)[0],
352 ((u_char
*)&addr
->sadb_address_reserved
)[1]);
354 kdebug_sockaddr((struct sockaddr
*)((caddr_t
)ext
+ sizeof(*addr
)));
361 struct sadb_ext
*ext
;
363 struct sadb_key
*key
= (struct sadb_key
*)ext
;
367 panic("kdebug_sadb_key: NULL pointer was passed.\n");
370 printf("sadb_key{ bits=%u reserved=%u\n",
371 key
->sadb_key_bits
, key
->sadb_key_reserved
);
375 if ((key
->sadb_key_bits
>> 3) >
376 (PFKEY_UNUNIT64(key
->sadb_key_len
) - sizeof(struct sadb_key
))) {
377 printf("kdebug_sadb_key: key length mismatch, bit:%d len:%ld.\n",
378 key
->sadb_key_bits
>> 3,
379 (long)PFKEY_UNUNIT64(key
->sadb_key_len
) - sizeof(struct sadb_key
));
382 ipsec_hexdump((caddr_t
)key
+ sizeof(struct sadb_key
),
383 key
->sadb_key_bits
>> 3);
389 kdebug_sadb_x_sa2(ext
)
390 struct sadb_ext
*ext
;
392 struct sadb_x_sa2
*sa2
= (struct sadb_x_sa2
*)ext
;
396 panic("kdebug_sadb_x_sa2: NULL pointer was passed.\n");
399 printf("sadb_x_sa2{ mode=%u reqid=%u\n",
400 sa2
->sadb_x_sa2_mode
, sa2
->sadb_x_sa2_reqid
);
401 printf(" reserved1=%u reserved2=%u sequence=%u }\n",
402 sa2
->sadb_x_sa2_reserved1
, sa2
->sadb_x_sa2_reserved2
,
403 sa2
->sadb_x_sa2_sequence
);
409 kdebug_sadb_session_id(ext
)
410 struct sadb_ext
*ext
;
412 struct sadb_session_id
*p
= (__typeof__(p
))ext
;
416 panic("kdebug_sadb_session_id: NULL pointer was passed.\n");
419 printf("sadb_session_id{ id0=%llx, id1=%llx}\n",
420 p
->sadb_session_id_v
[0],
421 p
->sadb_session_id_v
[1]);
427 kdebug_sadb_sastat(ext
)
428 struct sadb_ext
*ext
;
430 struct sadb_sastat
*p
= (__typeof__(p
))ext
;
431 struct sastat
*stats
;
436 panic("kdebug_sadb_sastat: NULL pointer was passed.\n");
439 printf("sadb_sastat{ dir=%u num=%u\n",
440 p
->sadb_sastat_dir
, p
->sadb_sastat_list_len
);
441 stats
= (__typeof__(stats
))(p
+ 1);
442 for (i
= 0; i
< p
->sadb_sastat_list_len
; i
++) {
452 kdebug_sadb_x_policy(ext
)
453 struct sadb_ext
*ext
;
455 struct sadb_x_policy
*xpl
= (struct sadb_x_policy
*)ext
;
456 struct sockaddr
*addr
;
460 panic("kdebug_sadb_x_policy: NULL pointer was passed.\n");
463 printf("sadb_x_policy{ type=%u dir=%u id=%x }\n",
464 xpl
->sadb_x_policy_type
, xpl
->sadb_x_policy_dir
,
465 xpl
->sadb_x_policy_id
);
467 if (xpl
->sadb_x_policy_type
== IPSEC_POLICY_IPSEC
) {
469 struct sadb_x_ipsecrequest
*xisr
;
471 tlen
= PFKEY_UNUNIT64(xpl
->sadb_x_policy_len
) - sizeof(*xpl
);
472 xisr
= (struct sadb_x_ipsecrequest
*)(xpl
+ 1);
475 printf(" { len=%u proto=%u mode=%u level=%u reqid=%u\n",
476 xisr
->sadb_x_ipsecrequest_len
,
477 xisr
->sadb_x_ipsecrequest_proto
,
478 xisr
->sadb_x_ipsecrequest_mode
,
479 xisr
->sadb_x_ipsecrequest_level
,
480 xisr
->sadb_x_ipsecrequest_reqid
);
482 if (xisr
->sadb_x_ipsecrequest_len
> sizeof(*xisr
)) {
483 addr
= (struct sockaddr
*)(xisr
+ 1);
484 kdebug_sockaddr(addr
);
485 addr
= (struct sockaddr
*)((caddr_t
)addr
487 kdebug_sockaddr(addr
);
492 /* prevent infinite loop */
493 if (xisr
->sadb_x_ipsecrequest_len
<= 0) {
494 printf("kdebug_sadb_x_policy: wrong policy struct.\n");
497 /* prevent overflow */
498 if (xisr
->sadb_x_ipsecrequest_len
> tlen
) {
499 printf("invalid ipsec policy length\n");
503 tlen
-= xisr
->sadb_x_ipsecrequest_len
;
505 xisr
= (struct sadb_x_ipsecrequest
*)((caddr_t
)xisr
506 + xisr
->sadb_x_ipsecrequest_len
);
510 panic("kdebug_sadb_x_policy: wrong policy struct.\n");
518 /* %%%: about SPD and SAD */
521 struct secpolicy
*sp
;
525 panic("kdebug_secpolicy: NULL pointer was passed.\n");
528 printf("secpolicy{ refcnt=%u state=%u policy=%u\n",
529 sp
->refcnt
, sp
->state
, sp
->policy
);
531 kdebug_secpolicyindex(&sp
->spidx
);
533 switch (sp
->policy
) {
534 case IPSEC_POLICY_DISCARD
:
535 case IPSEC_POLICY_GENERATE
:
536 printf(" type=discard }\n");
538 case IPSEC_POLICY_NONE
:
539 printf(" type=none }\n");
541 case IPSEC_POLICY_IPSEC
:
543 struct ipsecrequest
*isr
;
544 for (isr
= sp
->req
; isr
!= NULL
; isr
= isr
->next
) {
545 printf(" level=%u\n", isr
->level
);
546 kdebug_secasindex(&isr
->saidx
);
551 case IPSEC_POLICY_BYPASS
:
552 printf(" type=bypass }\n");
554 case IPSEC_POLICY_ENTRUST
:
555 printf(" type=entrust }\n");
558 printf("kdebug_secpolicy: Invalid policy found. %d\n",
567 kdebug_secpolicyindex(spidx
)
568 struct secpolicyindex
*spidx
;
572 panic("kdebug_secpolicyindex: NULL pointer was passed.\n");
575 printf("secpolicyindex{ dir=%u prefs=%u prefd=%u ul_proto=%u internal_if=%s\n",
576 spidx
->dir
, spidx
->prefs
, spidx
->prefd
, spidx
->ul_proto
,
577 (spidx
->internal_if
) ? spidx
->internal_if
->if_xname
: "N/A");
579 ipsec_hexdump((caddr_t
)&spidx
->src
,
580 ((struct sockaddr
*)&spidx
->src
)->sa_len
);
582 ipsec_hexdump((caddr_t
)&spidx
->dst
,
583 ((struct sockaddr
*)&spidx
->dst
)->sa_len
);
590 kdebug_secasindex(saidx
)
591 struct secasindex
*saidx
;
595 panic("kdebug_secpolicyindex: NULL pointer was passed.\n");
598 printf("secasindex{ mode=%u proto=%u\n",
599 saidx
->mode
, saidx
->proto
);
601 ipsec_hexdump((caddr_t
)&saidx
->src
,
602 ((struct sockaddr
*)&saidx
->src
)->sa_len
);
604 ipsec_hexdump((caddr_t
)&saidx
->dst
,
605 ((struct sockaddr
*)&saidx
->dst
)->sa_len
);
613 struct secasvar
*sav
;
617 panic("kdebug_secasv: NULL pointer was passed.\n");
621 kdebug_secasindex(&sav
->sah
->saidx
);
623 printf(" refcnt=%u state=%u auth=%u enc=%u\n",
624 sav
->refcnt
, sav
->state
, sav
->alg_auth
, sav
->alg_enc
);
625 printf(" spi=%u flags=%u\n",
626 (u_int32_t
)ntohl(sav
->spi
), sav
->flags
);
628 if (sav
->key_auth
!= NULL
) {
629 kdebug_sadb_key((struct sadb_ext
*)sav
->key_auth
);
631 if (sav
->key_enc
!= NULL
) {
632 kdebug_sadb_key((struct sadb_ext
*)sav
->key_enc
);
634 if (sav
->iv
!= NULL
) {
636 ipsec_hexdump(sav
->iv
, sav
->ivlen
? sav
->ivlen
: 8);
640 if (sav
->replay
[0] != NULL
) {
641 kdebug_secreplay(sav
->replay
[0]);
643 if (sav
->lft_c
!= NULL
) {
644 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_c
);
646 if (sav
->lft_h
!= NULL
) {
647 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_h
);
649 if (sav
->lft_s
!= NULL
) {
650 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_s
);
654 /* XXX: misc[123] ? */
661 kdebug_secreplay(rpl
)
662 struct secreplay
*rpl
;
669 panic("kdebug_secreplay: NULL pointer was passed.\n");
672 printf(" secreplay{ count=%u wsize=%zu seq=%u lastseq=%u",
673 rpl
->count
, rpl
->wsize
, rpl
->seq
, rpl
->lastseq
);
675 if (rpl
->bitmap
== NULL
) {
680 printf("\n bitmap { ");
682 for (len
= 0; len
< rpl
->wsize
; len
++) {
683 for (l
= 7; l
>= 0; l
--) {
684 printf("%u", (((rpl
->bitmap
)[len
] >> l
) & 1) ? 1 : 0);
701 printf("mbuf(0x%llx){ m_next:0x%llx m_nextpkt:0x%llx m_data:0x%llx "
702 "m_len:%d m_type:0x%02x m_flags:0x%02x }\n",
703 (uint64_t)VM_KERNEL_ADDRPERM(m
),
704 (uint64_t)VM_KERNEL_ADDRPERM(m
->m_next
),
705 (uint64_t)VM_KERNEL_ADDRPERM(m
->m_nextpkt
),
706 (uint64_t)VM_KERNEL_ADDRPERM(m
->m_data
),
707 m
->m_len
, m
->m_type
, m
->m_flags
);
709 if (m
->m_flags
& M_PKTHDR
) {
710 printf(" m_pkthdr{ len:%d rcvif:0x%llx }\n",
712 (uint64_t)VM_KERNEL_ADDRPERM(m
->m_pkthdr
.rcvif
));
715 if (m
->m_flags
& M_EXT
) {
716 printf(" m_ext{ ext_buf:0x%llx ext_free:0x%llx "
717 "ext_size:%u ext_ref:0x%llx }\n",
718 (uint64_t)VM_KERNEL_ADDRPERM(m
->m_ext
.ext_buf
),
719 (uint64_t)VM_KERNEL_ADDRPERM(m_get_ext_free(m
)),
721 (uint64_t)VM_KERNEL_ADDRPERM(m_get_rfa(m
)));
734 for (j
= 0; m
; m
= m
->m_next
) {
736 printf(" m_data:\n");
737 for (i
= 0; i
< m
->m_len
; i
++) {
738 if (i
&& i
% 32 == 0) {
744 printf("%02x", mtod(m
, u_char
*)[i
]);
755 kdebug_sockaddr(addr
)
756 struct sockaddr
*addr
;
758 struct sockaddr_in
*sin4
;
759 struct sockaddr_in6
*sin6
;
763 panic("kdebug_sockaddr: NULL pointer was passed.\n");
766 /* NOTE: We deal with port number as host byte order. */
767 printf("sockaddr{ len=%u family=%u", addr
->sa_len
, addr
->sa_family
);
769 switch (addr
->sa_family
) {
771 sin4
= (struct sockaddr_in
*)addr
;
772 printf(" port=%u\n", ntohs(sin4
->sin_port
));
773 ipsec_hexdump((caddr_t
)&sin4
->sin_addr
, sizeof(sin4
->sin_addr
));
776 sin6
= (struct sockaddr_in6
*)addr
;
777 printf(" port=%u\n", ntohs(sin6
->sin6_port
));
778 printf(" flowinfo=0x%08x, scope_id=0x%08x\n",
779 sin6
->sin6_flowinfo
, sin6
->sin6_scope_id
);
780 ipsec_hexdump((caddr_t
)&sin6
->sin6_addr
,
781 sizeof(sin6
->sin6_addr
));
791 ipsec_bindump(buf
, len
)
797 for (i
= 0; i
< len
; i
++) {
798 printf("%c", (unsigned char)buf
[i
]);
806 ipsec_hexdump(buf
, len
)
812 for (i
= 0; i
< len
; i
++) {
813 if (i
!= 0 && i
% 32 == 0) {
819 printf("%02x", (unsigned char)buf
[i
]);
830 #endif /* !defined(KERNEL) || (defined(KERNEL) && defined(IPSEC_DEBUG)) */