1 /* $KAME: key_debug.c,v 1.29 2001/08/16 14:25:41 itojun Exp $ */
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
39 #include "opt_inet6.h"
40 #include "opt_ipsec.h"
47 #include <sys/types.h>
48 #include <sys/param.h>
50 #include <sys/systm.h>
52 #include <sys/queue.h>
54 #include <sys/socket.h>
56 #include <netinet/in.h>
57 #ifdef HAVE_NETINET6_IPSEC
58 # include <netinet6/ipsec.h>
60 # include <netinet/ipsec.h>
73 static void kdebug_sadb_prop (struct sadb_ext
*);
74 static void kdebug_sadb_identity (struct sadb_ext
*);
75 static void kdebug_sadb_supported (struct sadb_ext
*);
76 static void kdebug_sadb_lifetime (struct sadb_ext
*);
77 static void kdebug_sadb_sa (struct sadb_ext
*);
78 static void kdebug_sadb_address (struct sadb_ext
*);
79 static void kdebug_sadb_key (struct sadb_ext
*);
80 static void kdebug_sadb_x_sa2 (struct sadb_ext
*);
81 static void kdebug_sadb_session_id (struct sadb_ext
*);
82 static void kdebug_sadb_sastat (struct sadb_ext
*);
83 static void kdebug_sadb_x_policy (struct sadb_ext
*ext
);
84 static void kdebug_sockaddr (struct sockaddr_storage
*addr
);
85 static void kdebug_sadb_x_ipsecif (struct sadb_ext
*ext
);
86 #ifdef SADB_X_EXT_NAT_T_TYPE
87 static void kdebug_sadb_x_nat_t_type (struct sadb_ext
*ext
);
88 static void kdebug_sadb_x_nat_t_port (struct sadb_ext
*ext
);
92 static void kdebug_secreplay (struct secreplay
*);
96 #define panic(param) { printf(param); exit(1); }
100 /* NOTE: host byte order */
102 /* %%%: about struct sadb_msg */
105 struct sadb_msg
*base
;
107 struct sadb_ext
*ext
;
112 panic("kdebug_sadb: NULL pointer was passed.\n");
114 printf("sadb_msg{ version=%u type=%u errno=%u satype=%u\n",
115 base
->sadb_msg_version
, base
->sadb_msg_type
,
116 base
->sadb_msg_errno
, base
->sadb_msg_satype
);
117 printf(" len=%u reserved=%u seq=%u pid=%u\n",
118 base
->sadb_msg_len
, base
->sadb_msg_reserved
,
119 base
->sadb_msg_seq
, base
->sadb_msg_pid
);
121 tlen
= PFKEY_UNUNIT64(base
->sadb_msg_len
) - sizeof(struct sadb_msg
);
122 ext
= (void *)((caddr_t
)(void *)base
+ sizeof(struct sadb_msg
));
125 printf("sadb_ext{ len=%u type=%u }\n",
126 ext
->sadb_ext_len
, ext
->sadb_ext_type
);
128 if (ext
->sadb_ext_len
== 0) {
129 printf("kdebug_sadb: invalid ext_len=0 was passed.\n");
132 if (ext
->sadb_ext_len
> tlen
) {
133 printf("kdebug_sadb: ext_len exceeds end of buffer.\n");
137 switch (ext
->sadb_ext_type
) {
141 case SADB_EXT_LIFETIME_CURRENT
:
142 case SADB_EXT_LIFETIME_HARD
:
143 case SADB_EXT_LIFETIME_SOFT
:
144 kdebug_sadb_lifetime(ext
);
146 case SADB_EXT_ADDRESS_SRC
:
147 case SADB_EXT_ADDRESS_DST
:
148 case SADB_EXT_ADDRESS_PROXY
:
149 case SADB_X_EXT_ADDR_RANGE_SRC_START
:
150 case SADB_X_EXT_ADDR_RANGE_SRC_END
:
151 case SADB_X_EXT_ADDR_RANGE_DST_START
:
152 case SADB_X_EXT_ADDR_RANGE_DST_END
:
153 kdebug_sadb_address(ext
);
155 case SADB_EXT_KEY_AUTH
:
156 case SADB_EXT_KEY_ENCRYPT
:
157 kdebug_sadb_key(ext
);
159 case SADB_EXT_IDENTITY_SRC
:
160 case SADB_EXT_IDENTITY_DST
:
161 kdebug_sadb_identity(ext
);
163 case SADB_EXT_SENSITIVITY
:
165 case SADB_EXT_PROPOSAL
:
166 kdebug_sadb_prop(ext
);
168 case SADB_EXT_SUPPORTED_AUTH
:
169 case SADB_EXT_SUPPORTED_ENCRYPT
:
170 kdebug_sadb_supported(ext
);
172 case SADB_EXT_SPIRANGE
:
173 case SADB_X_EXT_KMPRIVATE
:
175 case SADB_X_EXT_POLICY
:
176 kdebug_sadb_x_policy(ext
);
179 kdebug_sadb_x_sa2(ext
);
181 case SADB_EXT_SESSION_ID
:
182 kdebug_sadb_session_id(ext
);
184 case SADB_EXT_SASTAT
:
185 kdebug_sadb_sastat(ext
);
187 case SADB_X_EXT_IPSECIF
:
188 kdebug_sadb_x_ipsecif(ext
);
190 #ifdef SADB_X_EXT_NAT_T_TYPE
191 case SADB_X_EXT_NAT_T_TYPE
:
192 kdebug_sadb_x_nat_t_type(ext
);
194 case SADB_X_EXT_NAT_T_SPORT
:
195 case SADB_X_EXT_NAT_T_DPORT
:
196 kdebug_sadb_x_nat_t_port(ext
);
198 case SADB_X_EXT_NAT_T_OA
:
199 kdebug_sadb_address(ext
);
203 printf("kdebug_sadb: invalid ext_type %u was passed.\n",
208 extlen
= PFKEY_UNUNIT64(ext
->sadb_ext_len
);
210 ext
= (void *)((caddr_t
)(void *)ext
+ extlen
);
217 kdebug_sadb_prop(ext
)
218 struct sadb_ext
*ext
;
220 struct sadb_prop
*prop
= (void *)ext
;
221 struct sadb_comb
*comb
;
226 panic("kdebug_sadb_prop: NULL pointer was passed.\n");
228 len
= (PFKEY_UNUNIT64(prop
->sadb_prop_len
) - sizeof(*prop
))
230 comb
= (void *)(prop
+ 1);
231 printf("sadb_prop{ replay=%u\n", prop
->sadb_prop_replay
);
234 printf("sadb_comb{ auth=%u encrypt=%u "
235 "flags=0x%04x reserved=0x%08x\n",
236 comb
->sadb_comb_auth
, comb
->sadb_comb_encrypt
,
237 comb
->sadb_comb_flags
, comb
->sadb_comb_reserved
);
239 printf(" auth_minbits=%u auth_maxbits=%u "
240 "encrypt_minbits=%u encrypt_maxbits=%u\n",
241 comb
->sadb_comb_auth_minbits
,
242 comb
->sadb_comb_auth_maxbits
,
243 comb
->sadb_comb_encrypt_minbits
,
244 comb
->sadb_comb_encrypt_maxbits
);
246 printf(" soft_alloc=%u hard_alloc=%u "
247 "soft_bytes=%lu hard_bytes=%lu\n",
248 comb
->sadb_comb_soft_allocations
,
249 comb
->sadb_comb_hard_allocations
,
250 (unsigned long)comb
->sadb_comb_soft_bytes
,
251 (unsigned long)comb
->sadb_comb_hard_bytes
);
253 printf(" soft_alloc=%lu hard_alloc=%lu "
254 "soft_bytes=%lu hard_bytes=%lu }\n",
255 (unsigned long)comb
->sadb_comb_soft_addtime
,
256 (unsigned long)comb
->sadb_comb_hard_addtime
,
257 (unsigned long)comb
->sadb_comb_soft_usetime
,
258 (unsigned long)comb
->sadb_comb_hard_usetime
);
267 kdebug_sadb_identity(ext
)
268 struct sadb_ext
*ext
;
270 struct sadb_ident
*id
= (void *)ext
;
275 panic("kdebug_sadb_identity: NULL pointer was passed.\n");
277 len
= PFKEY_UNUNIT64(id
->sadb_ident_len
) - sizeof(*id
);
278 printf("sadb_ident_%s{",
279 id
->sadb_ident_exttype
== SADB_EXT_IDENTITY_SRC
? "src" : "dst");
280 switch (id
->sadb_ident_type
) {
282 printf(" type=%d id=%lu",
283 id
->sadb_ident_type
, (u_long
)id
->sadb_ident_id
);
286 ipsec_hexdump((caddr_t
)(id
+ 1), len
); /*XXX cast ?*/
290 p
= (void *)(id
+ 1);
292 for (/*nothing*/; *p
&& p
< ep
; p
++) {
293 if (isprint((int)*p
))
294 printf("%c", *p
& 0xff);
296 printf("\\%03o", *p
& 0xff);
310 kdebug_sadb_supported(ext
)
311 struct sadb_ext
*ext
;
313 struct sadb_supported
*sup
= (void *)ext
;
314 struct sadb_alg
*alg
;
319 panic("kdebug_sadb_supported: NULL pointer was passed.\n");
321 len
= (PFKEY_UNUNIT64(sup
->sadb_supported_len
) - sizeof(*sup
))
323 alg
= (void *)(sup
+ 1);
324 printf("sadb_sup{\n");
326 printf(" { id=%d ivlen=%d min=%d max=%d }\n",
327 alg
->sadb_alg_id
, alg
->sadb_alg_ivlen
,
328 alg
->sadb_alg_minbits
, alg
->sadb_alg_maxbits
);
337 kdebug_sadb_lifetime(ext
)
338 struct sadb_ext
*ext
;
340 struct sadb_lifetime
*lft
= (void *)ext
;
344 printf("kdebug_sadb_lifetime: NULL pointer was passed.\n");
346 printf("sadb_lifetime{ alloc=%u, bytes=%u\n",
347 lft
->sadb_lifetime_allocations
,
348 (u_int32_t
)lft
->sadb_lifetime_bytes
);
349 printf(" addtime=%u, usetime=%u }\n",
350 (u_int32_t
)lft
->sadb_lifetime_addtime
,
351 (u_int32_t
)lft
->sadb_lifetime_usetime
);
358 struct sadb_ext
*ext
;
360 struct sadb_sa
*sa
= (void *)ext
;
364 panic("kdebug_sadb_sa: NULL pointer was passed.\n");
366 printf("sadb_sa{ spi=%u replay=%u state=%u\n",
367 (u_int32_t
)ntohl(sa
->sadb_sa_spi
), sa
->sadb_sa_replay
,
369 printf(" auth=%u encrypt=%u flags=0x%08x }\n",
370 sa
->sadb_sa_auth
, sa
->sadb_sa_encrypt
, sa
->sadb_sa_flags
);
376 kdebug_sadb_address(ext
)
377 struct sadb_ext
*ext
;
379 struct sadb_address
*addr
= (void *)ext
;
383 panic("kdebug_sadb_address: NULL pointer was passed.\n");
385 printf("sadb_address{ proto=%u prefixlen=%u reserved=0x%02x%02x }\n",
386 addr
->sadb_address_proto
, addr
->sadb_address_prefixlen
,
387 ((u_char
*)(void *)&addr
->sadb_address_reserved
)[0],
388 ((u_char
*)(void *)&addr
->sadb_address_reserved
)[1]);
390 kdebug_sockaddr((void *)((caddr_t
)(void *)ext
+ sizeof(*addr
)));
397 struct sadb_ext
*ext
;
399 struct sadb_key
*key
= (void *)ext
;
403 panic("kdebug_sadb_key: NULL pointer was passed.\n");
405 printf("sadb_key{ bits=%u reserved=%u\n",
406 key
->sadb_key_bits
, key
->sadb_key_reserved
);
410 if (((uint32_t)key
->sadb_key_bits
>> 3) >
411 (PFKEY_UNUNIT64(key
->sadb_key_len
) - sizeof(struct sadb_key
))) {
412 printf("kdebug_sadb_key: key length mismatch, bit:%d len:%ld.\n",
413 (uint32_t)key
->sadb_key_bits
>> 3,
414 (long)PFKEY_UNUNIT64(key
->sadb_key_len
) - sizeof(struct sadb_key
));
417 ipsec_hexdump(key
+ sizeof(struct sadb_key
),
418 (int)((uint32_t)key
->sadb_key_bits
>> 3));
424 kdebug_sadb_x_sa2(ext
)
425 struct sadb_ext
*ext
;
427 struct sadb_x_sa2
*sa2
= (void *)ext
;
431 panic("kdebug_sadb_x_sa2: NULL pointer was passed.\n");
433 printf("sadb_x_sa2{ mode=%u reqid=%u\n",
434 sa2
->sadb_x_sa2_mode
, sa2
->sadb_x_sa2_reqid
);
435 printf(" reserved1=%u reserved2=%u sequence=%u }\n",
436 sa2
->sadb_x_sa2_reserved1
, sa2
->sadb_x_sa2_reserved2
,
437 sa2
->sadb_x_sa2_sequence
);
443 kdebug_sadb_session_id(ext
)
444 struct sadb_ext
*ext
;
446 struct sadb_session_id
*p
= ALIGNED_CAST(__typeof__(p
))ext
; // Wcast-align fix (void*) - sadb structs come from and aligned buffer
450 printf("kdebug_sadb_session_id: NULL pointer was passed.\n");
454 printf("sadb_session_id{ id0=%llx, id1=%llx}\n",
455 p
->sadb_session_id_v
[0],
456 p
->sadb_session_id_v
[1]);
460 kdebug_sadb_x_ipsecif(struct sadb_ext
*ext
)
462 struct sadb_x_ipsecif
*p
= ALIGNED_CAST(__typeof__(p
))ext
;
465 printf("sadb_x_ipsecif: NULL pointer was passed.\n");
469 printf("sadb_x_ipsec_if{ ipsecif=%s outgoing=%s\n", p
->sadb_x_ipsecif_ipsec_if
, p
->sadb_x_ipsecif_outgoing_if
);
470 printf(" internal=%s disabled=%d }\n", p
->sadb_x_ipsecif_internal_if
, p
->sadb_x_ipsecif_init_disabled
);
474 kdebug_sadb_sastat(ext
)
475 struct sadb_ext
*ext
;
477 struct sadb_sastat
*p
= ALIGNED_CAST(__typeof__(p
))ext
; // Wcast-align fix (void*) - sadb structs come from and aligned buffer
478 struct sastat
*stats
;
483 printf("kdebug_sadb_sastat: NULL pointer was passed.\n");
487 printf("sadb_sastat{ dir=%u num=%u\n",
488 p
->sadb_sastat_dir
, p
->sadb_sastat_list_len
);
489 stats
= (__typeof__(stats
))(p
+ 1);
490 for (i
= 0; i
< p
->sadb_sastat_list_len
; i
++) {
498 kdebug_sadb_x_policy(ext
)
499 struct sadb_ext
*ext
;
501 struct sadb_x_policy
*xpl
= (void *)ext
;
502 struct sockaddr_storage
*addr
;
506 panic("kdebug_sadb_x_policy: NULL pointer was passed.\n");
508 #ifdef HAVE_PFKEY_POLICY_PRIORITY
509 printf("sadb_x_policy{ type=%u dir=%u id=%x priority=%u }\n",
511 printf("sadb_x_policy{ type=%u dir=%u id=%x }\n",
513 xpl
->sadb_x_policy_type
, xpl
->sadb_x_policy_dir
,
514 #ifdef HAVE_PFKEY_POLICY_PRIORITY
515 xpl
->sadb_x_policy_id
, xpl
->sadb_x_policy_priority
);
517 xpl
->sadb_x_policy_id
);
520 if (xpl
->sadb_x_policy_type
== IPSEC_POLICY_IPSEC
) {
522 struct sadb_x_ipsecrequest
*xisr
;
524 tlen
= PFKEY_UNUNIT64(xpl
->sadb_x_policy_len
) - sizeof(*xpl
);
525 xisr
= (void *)(xpl
+ 1);
528 printf(" { len=%u proto=%u mode=%u level=%u reqid=%u\n",
529 xisr
->sadb_x_ipsecrequest_len
,
530 xisr
->sadb_x_ipsecrequest_proto
,
531 xisr
->sadb_x_ipsecrequest_mode
,
532 xisr
->sadb_x_ipsecrequest_level
,
533 xisr
->sadb_x_ipsecrequest_reqid
);
535 if (xisr
->sadb_x_ipsecrequest_len
> sizeof(*xisr
)) {
536 addr
= (void *)(xisr
+ 1);
537 kdebug_sockaddr(addr
);
538 addr
= (void *)((caddr_t
)(void *)addr
539 + sysdep_sa_len((struct sockaddr
*)addr
));
540 kdebug_sockaddr(addr
);
545 /* prevent infinite loop */
546 if (xisr
->sadb_x_ipsecrequest_len
== 0) {
547 printf("kdebug_sadb_x_policy: wrong policy struct.\n");
550 /* prevent overflow */
551 if (xisr
->sadb_x_ipsecrequest_len
> tlen
) {
552 printf("invalid ipsec policy length\n");
556 tlen
-= xisr
->sadb_x_ipsecrequest_len
;
558 xisr
= (void *)((caddr_t
)(void *)xisr
559 + xisr
->sadb_x_ipsecrequest_len
);
563 panic("kdebug_sadb_x_policy: wrong policy struct.\n");
569 #ifdef SADB_X_EXT_NAT_T_TYPE
571 kdebug_sadb_x_nat_t_type(struct sadb_ext
*ext
)
573 struct sadb_x_nat_t_type
*ntt
= (void *)ext
;
577 panic("kdebug_sadb_x_nat_t_type: NULL pointer was passed.\n");
579 printf("sadb_x_nat_t_type{ type=%u }\n", ntt
->sadb_x_nat_t_type_type
);
585 kdebug_sadb_x_nat_t_port(struct sadb_ext
*ext
)
587 struct sadb_x_nat_t_port
*ntp
= (void *)ext
;
591 panic("kdebug_sadb_x_nat_t_port: NULL pointer was passed.\n");
593 printf("sadb_x_nat_t_port{ port=%u }\n", ntohs(ntp
->sadb_x_nat_t_port_port
));
600 /* %%%: about SPD and SAD */
603 struct secpolicy
*sp
;
607 panic("kdebug_secpolicy: NULL pointer was passed.\n");
609 printf("secpolicy{ refcnt=%u state=%u policy=%u\n",
610 sp
->refcnt
, sp
->state
, sp
->policy
);
612 kdebug_secpolicyindex(&sp
->spidx
);
614 switch (sp
->policy
) {
615 case IPSEC_POLICY_DISCARD
:
616 printf(" type=discard }\n");
618 case IPSEC_POLICY_GENERATE
:
619 printf(" type=generate }\n");
621 case IPSEC_POLICY_NONE
:
622 printf(" type=none }\n");
624 case IPSEC_POLICY_IPSEC
:
626 struct ipsecrequest
*isr
;
627 for (isr
= sp
->req
; isr
!= NULL
; isr
= isr
->next
) {
629 printf(" level=%u\n", isr
->level
);
630 kdebug_secasindex(&isr
->saidx
);
632 if (isr
->sav
!= NULL
)
633 kdebug_secasv(isr
->sav
);
638 case IPSEC_POLICY_BYPASS
:
639 printf(" type=bypass }\n");
641 case IPSEC_POLICY_ENTRUST
:
642 printf(" type=entrust }\n");
645 printf("kdebug_secpolicy: Invalid policy found. %d\n",
654 kdebug_secpolicyindex(spidx
)
655 struct secpolicyindex
*spidx
;
659 panic("kdebug_secpolicyindex: NULL pointer was passed.\n");
661 printf("secpolicyindex{ dir=%u prefs=%u prefd=%u ul_proto=%u\n",
662 spidx
->dir
, spidx
->prefs
, spidx
->prefd
, spidx
->ul_proto
);
664 ipsec_hexdump((caddr_t
)&spidx
->src
,
665 sysdep_sa_len((struct sockaddr
*)&spidx
->src
));
667 ipsec_hexdump((caddr_t
)&spidx
->dst
,
668 sysdep_sa_len((struct sockaddr
*)&spidx
->dst
));
675 kdebug_secasindex(saidx
)
676 struct secasindex
*saidx
;
680 panic("kdebug_secpolicyindex: NULL pointer was passed.\n");
682 printf("secasindex{ mode=%u proto=%u\n",
683 saidx
->mode
, saidx
->proto
);
685 ipsec_hexdump((caddr_t
)&saidx
->src
,
686 sysdep_sa_len((struct sockaddr
*)&saidx
->src
));
688 ipsec_hexdump((caddr_t
)&saidx
->dst
,
689 sysdep_sa_len((struct sockaddr
*)&saidx
->dst
));
697 struct secasvar
*sav
;
701 panic("kdebug_secasv: NULL pointer was passed.\n");
704 kdebug_secasindex(&sav
->sah
->saidx
);
706 printf(" refcnt=%u state=%u auth=%u enc=%u\n",
707 sav
->refcnt
, sav
->state
, sav
->alg_auth
, sav
->alg_enc
);
708 printf(" spi=%u flags=%u\n",
709 (u_int32_t
)ntohl(sav
->spi
), sav
->flags
);
711 if (sav
->key_auth
!= NULL
)
712 kdebug_sadb_key((struct sadb_ext
*)sav
->key_auth
);
713 if (sav
->key_enc
!= NULL
)
714 kdebug_sadb_key((struct sadb_ext
*)sav
->key_enc
);
715 if (sav
->iv
!= NULL
) {
717 ipsec_hexdump(sav
->iv
, sav
->ivlen
? sav
->ivlen
: 8);
721 if (sav
->replay
!= NULL
)
722 kdebug_secreplay(sav
->replay
);
723 if (sav
->lft_c
!= NULL
)
724 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_c
);
725 if (sav
->lft_h
!= NULL
)
726 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_h
);
727 if (sav
->lft_s
!= NULL
)
728 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_s
);
731 /* XXX: misc[123] ? */
738 kdebug_secreplay(rpl
)
739 struct secreplay
*rpl
;
745 panic("kdebug_secreplay: NULL pointer was passed.\n");
747 printf(" secreplay{ count=%u wsize=%u seq=%u lastseq=%u",
748 rpl
->count
, rpl
->wsize
, rpl
->seq
, rpl
->lastseq
);
750 if (rpl
->bitmap
== NULL
) {
755 printf("\n bitmap { ");
757 for (len
= 0; len
< rpl
->wsize
; len
++) {
758 for (l
= 7; l
>= 0; l
--)
759 printf("%u", (((rpl
->bitmap
)[len
] >> l
) & 1) ? 1 : 0);
774 printf("mbuf(%p){ m_next:%p m_nextpkt:%p m_data:%p "
775 "m_len:%d m_type:0x%02x m_flags:0x%02x }\n",
776 m
, m
->m_next
, m
->m_nextpkt
, m
->m_data
,
777 m
->m_len
, m
->m_type
, m
->m_flags
);
779 if (m
->m_flags
& M_PKTHDR
) {
780 printf(" m_pkthdr{ len:%d rcvif:%p }\n",
781 m
->m_pkthdr
.len
, m
->m_pkthdr
.rcvif
);
785 if (m
->m_flags
& M_EXT
) {
786 printf(" m_ext{ ext_buf:%p ext_free:%p "
787 "ext_size:%u ext_ref:%p }\n",
788 m
->m_ext
.ext_buf
, m
->m_ext
.ext_free
,
789 m
->m_ext
.ext_size
, m
->m_ext
.ext_ref
);
803 for (j
= 0; m
; m
= m
->m_next
) {
805 printf(" m_data:\n");
806 for (i
= 0; i
< m
->m_len
; i
++) {
807 if (i
&& i
% 32 == 0)
811 printf("%02x", mtod(m
, u_char
*)[i
]);
822 kdebug_sockaddr(addr
)
823 struct sockaddr_storage
*addr
;
825 struct sockaddr_in
*sin4
;
827 struct sockaddr_in6
*sin6
;
832 panic("kdebug_sockaddr: NULL pointer was passed.\n");
834 /* NOTE: We deal with port number as host byte order. */
835 printf("sockaddr_storage{ len=%u family=%u", sysdep_sa_len((struct sockaddr
*)addr
), addr
->ss_family
);
837 switch (addr
->ss_family
) {
840 printf(" port=%u\n", ntohs(sin4
->sin_port
));
841 ipsec_hexdump(&sin4
->sin_addr
, sizeof(sin4
->sin_addr
));
846 printf(" port=%u\n", ntohs(sin6
->sin6_port
));
847 printf(" flowinfo=0x%08x, scope_id=0x%08x\n",
848 sin6
->sin6_flowinfo
, sin6
->sin6_scope_id
);
849 ipsec_hexdump(&sin6
->sin6_addr
, sizeof(sin6
->sin6_addr
));
860 ipsec_bindump(buf
, len
)
866 for (i
= 0; i
< len
; i
++)
867 printf("%c", (unsigned char)buf
[i
]);
874 ipsec_hexdump(buf
, len
)
880 for (i
= 0; i
< len
; i
++) {
881 if (i
!= 0 && i
% 32 == 0) printf("\n");
882 if (i
% 4 == 0) printf(" ");
883 printf("%02x", ((const unsigned char *)buf
)[i
]);
886 if (i
% 32 != 0) printf("\n");