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
);
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
:
189 #ifdef SADB_X_EXT_NAT_T_TYPE
190 case SADB_X_EXT_NAT_T_TYPE
:
191 kdebug_sadb_x_nat_t_type(ext
);
193 case SADB_X_EXT_NAT_T_SPORT
:
194 case SADB_X_EXT_NAT_T_DPORT
:
195 kdebug_sadb_x_nat_t_port(ext
);
197 case SADB_X_EXT_NAT_T_OA
:
198 kdebug_sadb_address(ext
);
202 printf("kdebug_sadb: invalid ext_type %u was passed.\n",
207 extlen
= PFKEY_UNUNIT64(ext
->sadb_ext_len
);
209 ext
= (void *)((caddr_t
)(void *)ext
+ extlen
);
216 kdebug_sadb_prop(ext
)
217 struct sadb_ext
*ext
;
219 struct sadb_prop
*prop
= (void *)ext
;
220 struct sadb_comb
*comb
;
225 panic("kdebug_sadb_prop: NULL pointer was passed.\n");
227 len
= (PFKEY_UNUNIT64(prop
->sadb_prop_len
) - sizeof(*prop
))
229 comb
= (void *)(prop
+ 1);
230 printf("sadb_prop{ replay=%u\n", prop
->sadb_prop_replay
);
233 printf("sadb_comb{ auth=%u encrypt=%u "
234 "flags=0x%04x reserved=0x%08x\n",
235 comb
->sadb_comb_auth
, comb
->sadb_comb_encrypt
,
236 comb
->sadb_comb_flags
, comb
->sadb_comb_reserved
);
238 printf(" auth_minbits=%u auth_maxbits=%u "
239 "encrypt_minbits=%u encrypt_maxbits=%u\n",
240 comb
->sadb_comb_auth_minbits
,
241 comb
->sadb_comb_auth_maxbits
,
242 comb
->sadb_comb_encrypt_minbits
,
243 comb
->sadb_comb_encrypt_maxbits
);
245 printf(" soft_alloc=%u hard_alloc=%u "
246 "soft_bytes=%lu hard_bytes=%lu\n",
247 comb
->sadb_comb_soft_allocations
,
248 comb
->sadb_comb_hard_allocations
,
249 (unsigned long)comb
->sadb_comb_soft_bytes
,
250 (unsigned long)comb
->sadb_comb_hard_bytes
);
252 printf(" soft_alloc=%lu hard_alloc=%lu "
253 "soft_bytes=%lu hard_bytes=%lu }\n",
254 (unsigned long)comb
->sadb_comb_soft_addtime
,
255 (unsigned long)comb
->sadb_comb_hard_addtime
,
256 (unsigned long)comb
->sadb_comb_soft_usetime
,
257 (unsigned long)comb
->sadb_comb_hard_usetime
);
266 kdebug_sadb_identity(ext
)
267 struct sadb_ext
*ext
;
269 struct sadb_ident
*id
= (void *)ext
;
274 panic("kdebug_sadb_identity: NULL pointer was passed.\n");
276 len
= PFKEY_UNUNIT64(id
->sadb_ident_len
) - sizeof(*id
);
277 printf("sadb_ident_%s{",
278 id
->sadb_ident_exttype
== SADB_EXT_IDENTITY_SRC
? "src" : "dst");
279 switch (id
->sadb_ident_type
) {
281 printf(" type=%d id=%lu",
282 id
->sadb_ident_type
, (u_long
)id
->sadb_ident_id
);
285 ipsec_hexdump((caddr_t
)(id
+ 1), len
); /*XXX cast ?*/
289 p
= (void *)(id
+ 1);
291 for (/*nothing*/; *p
&& p
< ep
; p
++) {
292 if (isprint((int)*p
))
293 printf("%c", *p
& 0xff);
295 printf("\\%03o", *p
& 0xff);
309 kdebug_sadb_supported(ext
)
310 struct sadb_ext
*ext
;
312 struct sadb_supported
*sup
= (void *)ext
;
313 struct sadb_alg
*alg
;
318 panic("kdebug_sadb_supported: NULL pointer was passed.\n");
320 len
= (PFKEY_UNUNIT64(sup
->sadb_supported_len
) - sizeof(*sup
))
322 alg
= (void *)(sup
+ 1);
323 printf("sadb_sup{\n");
325 printf(" { id=%d ivlen=%d min=%d max=%d }\n",
326 alg
->sadb_alg_id
, alg
->sadb_alg_ivlen
,
327 alg
->sadb_alg_minbits
, alg
->sadb_alg_maxbits
);
336 kdebug_sadb_lifetime(ext
)
337 struct sadb_ext
*ext
;
339 struct sadb_lifetime
*lft
= (void *)ext
;
343 printf("kdebug_sadb_lifetime: NULL pointer was passed.\n");
345 printf("sadb_lifetime{ alloc=%u, bytes=%u\n",
346 lft
->sadb_lifetime_allocations
,
347 (u_int32_t
)lft
->sadb_lifetime_bytes
);
348 printf(" addtime=%u, usetime=%u }\n",
349 (u_int32_t
)lft
->sadb_lifetime_addtime
,
350 (u_int32_t
)lft
->sadb_lifetime_usetime
);
357 struct sadb_ext
*ext
;
359 struct sadb_sa
*sa
= (void *)ext
;
363 panic("kdebug_sadb_sa: NULL pointer was passed.\n");
365 printf("sadb_sa{ spi=%u replay=%u state=%u\n",
366 (u_int32_t
)ntohl(sa
->sadb_sa_spi
), sa
->sadb_sa_replay
,
368 printf(" auth=%u encrypt=%u flags=0x%08x }\n",
369 sa
->sadb_sa_auth
, sa
->sadb_sa_encrypt
, sa
->sadb_sa_flags
);
375 kdebug_sadb_address(ext
)
376 struct sadb_ext
*ext
;
378 struct sadb_address
*addr
= (void *)ext
;
382 panic("kdebug_sadb_address: NULL pointer was passed.\n");
384 printf("sadb_address{ proto=%u prefixlen=%u reserved=0x%02x%02x }\n",
385 addr
->sadb_address_proto
, addr
->sadb_address_prefixlen
,
386 ((u_char
*)(void *)&addr
->sadb_address_reserved
)[0],
387 ((u_char
*)(void *)&addr
->sadb_address_reserved
)[1]);
389 kdebug_sockaddr((void *)((caddr_t
)(void *)ext
+ sizeof(*addr
)));
396 struct sadb_ext
*ext
;
398 struct sadb_key
*key
= (void *)ext
;
402 panic("kdebug_sadb_key: NULL pointer was passed.\n");
404 printf("sadb_key{ bits=%u reserved=%u\n",
405 key
->sadb_key_bits
, key
->sadb_key_reserved
);
409 if (((uint32_t)key
->sadb_key_bits
>> 3) >
410 (PFKEY_UNUNIT64(key
->sadb_key_len
) - sizeof(struct sadb_key
))) {
411 printf("kdebug_sadb_key: key length mismatch, bit:%d len:%ld.\n",
412 (uint32_t)key
->sadb_key_bits
>> 3,
413 (long)PFKEY_UNUNIT64(key
->sadb_key_len
) - sizeof(struct sadb_key
));
416 ipsec_hexdump(key
+ sizeof(struct sadb_key
),
417 (int)((uint32_t)key
->sadb_key_bits
>> 3));
423 kdebug_sadb_x_sa2(ext
)
424 struct sadb_ext
*ext
;
426 struct sadb_x_sa2
*sa2
= (void *)ext
;
430 panic("kdebug_sadb_x_sa2: NULL pointer was passed.\n");
432 printf("sadb_x_sa2{ mode=%u reqid=%u\n",
433 sa2
->sadb_x_sa2_mode
, sa2
->sadb_x_sa2_reqid
);
434 printf(" reserved1=%u reserved2=%u sequence=%u }\n",
435 sa2
->sadb_x_sa2_reserved1
, sa2
->sadb_x_sa2_reserved2
,
436 sa2
->sadb_x_sa2_sequence
);
442 kdebug_sadb_session_id(ext
)
443 struct sadb_ext
*ext
;
445 struct sadb_session_id
*p
= ALIGNED_CAST(__typeof__(p
))ext
; // Wcast-align fix (void*) - sadb structs come from and aligned buffer
449 printf("kdebug_sadb_session_id: NULL pointer was passed.\n");
453 printf("sadb_session_id{ id0=%llx, id1=%llx}\n",
454 p
->sadb_session_id_v
[0],
455 p
->sadb_session_id_v
[1]);
459 kdebug_sadb_sastat(ext
)
460 struct sadb_ext
*ext
;
462 struct sadb_sastat
*p
= ALIGNED_CAST(__typeof__(p
))ext
; // Wcast-align fix (void*) - sadb structs come from and aligned buffer
463 struct sastat
*stats
;
468 printf("kdebug_sadb_sastat: NULL pointer was passed.\n");
472 printf("sadb_sastat{ dir=%u num=%u\n",
473 p
->sadb_sastat_dir
, p
->sadb_sastat_list_len
);
474 stats
= (__typeof__(stats
))(p
+ 1);
475 for (i
= 0; i
< p
->sadb_sastat_list_len
; i
++) {
483 kdebug_sadb_x_policy(ext
)
484 struct sadb_ext
*ext
;
486 struct sadb_x_policy
*xpl
= (void *)ext
;
487 struct sockaddr_storage
*addr
;
491 panic("kdebug_sadb_x_policy: NULL pointer was passed.\n");
493 #ifdef HAVE_PFKEY_POLICY_PRIORITY
494 printf("sadb_x_policy{ type=%u dir=%u id=%x priority=%u }\n",
496 printf("sadb_x_policy{ type=%u dir=%u id=%x }\n",
498 xpl
->sadb_x_policy_type
, xpl
->sadb_x_policy_dir
,
499 #ifdef HAVE_PFKEY_POLICY_PRIORITY
500 xpl
->sadb_x_policy_id
, xpl
->sadb_x_policy_priority
);
502 xpl
->sadb_x_policy_id
);
505 if (xpl
->sadb_x_policy_type
== IPSEC_POLICY_IPSEC
) {
507 struct sadb_x_ipsecrequest
*xisr
;
509 tlen
= PFKEY_UNUNIT64(xpl
->sadb_x_policy_len
) - sizeof(*xpl
);
510 xisr
= (void *)(xpl
+ 1);
513 printf(" { len=%u proto=%u mode=%u level=%u reqid=%u\n",
514 xisr
->sadb_x_ipsecrequest_len
,
515 xisr
->sadb_x_ipsecrequest_proto
,
516 xisr
->sadb_x_ipsecrequest_mode
,
517 xisr
->sadb_x_ipsecrequest_level
,
518 xisr
->sadb_x_ipsecrequest_reqid
);
520 if (xisr
->sadb_x_ipsecrequest_len
> sizeof(*xisr
)) {
521 addr
= (void *)(xisr
+ 1);
522 kdebug_sockaddr(addr
);
523 addr
= (void *)((caddr_t
)(void *)addr
524 + sysdep_sa_len((struct sockaddr
*)addr
));
525 kdebug_sockaddr(addr
);
530 /* prevent infinite loop */
531 if (xisr
->sadb_x_ipsecrequest_len
== 0) {
532 printf("kdebug_sadb_x_policy: wrong policy struct.\n");
535 /* prevent overflow */
536 if (xisr
->sadb_x_ipsecrequest_len
> tlen
) {
537 printf("invalid ipsec policy length\n");
541 tlen
-= xisr
->sadb_x_ipsecrequest_len
;
543 xisr
= (void *)((caddr_t
)(void *)xisr
544 + xisr
->sadb_x_ipsecrequest_len
);
548 panic("kdebug_sadb_x_policy: wrong policy struct.\n");
554 #ifdef SADB_X_EXT_NAT_T_TYPE
556 kdebug_sadb_x_nat_t_type(struct sadb_ext
*ext
)
558 struct sadb_x_nat_t_type
*ntt
= (void *)ext
;
562 panic("kdebug_sadb_x_nat_t_type: NULL pointer was passed.\n");
564 printf("sadb_x_nat_t_type{ type=%u }\n", ntt
->sadb_x_nat_t_type_type
);
570 kdebug_sadb_x_nat_t_port(struct sadb_ext
*ext
)
572 struct sadb_x_nat_t_port
*ntp
= (void *)ext
;
576 panic("kdebug_sadb_x_nat_t_port: NULL pointer was passed.\n");
578 printf("sadb_x_nat_t_port{ port=%u }\n", ntohs(ntp
->sadb_x_nat_t_port_port
));
585 /* %%%: about SPD and SAD */
588 struct secpolicy
*sp
;
592 panic("kdebug_secpolicy: NULL pointer was passed.\n");
594 printf("secpolicy{ refcnt=%u state=%u policy=%u\n",
595 sp
->refcnt
, sp
->state
, sp
->policy
);
597 kdebug_secpolicyindex(&sp
->spidx
);
599 switch (sp
->policy
) {
600 case IPSEC_POLICY_DISCARD
:
601 printf(" type=discard }\n");
603 case IPSEC_POLICY_GENERATE
:
604 printf(" type=generate }\n");
606 case IPSEC_POLICY_NONE
:
607 printf(" type=none }\n");
609 case IPSEC_POLICY_IPSEC
:
611 struct ipsecrequest
*isr
;
612 for (isr
= sp
->req
; isr
!= NULL
; isr
= isr
->next
) {
614 printf(" level=%u\n", isr
->level
);
615 kdebug_secasindex(&isr
->saidx
);
617 if (isr
->sav
!= NULL
)
618 kdebug_secasv(isr
->sav
);
623 case IPSEC_POLICY_BYPASS
:
624 printf(" type=bypass }\n");
626 case IPSEC_POLICY_ENTRUST
:
627 printf(" type=entrust }\n");
630 printf("kdebug_secpolicy: Invalid policy found. %d\n",
639 kdebug_secpolicyindex(spidx
)
640 struct secpolicyindex
*spidx
;
644 panic("kdebug_secpolicyindex: NULL pointer was passed.\n");
646 printf("secpolicyindex{ dir=%u prefs=%u prefd=%u ul_proto=%u\n",
647 spidx
->dir
, spidx
->prefs
, spidx
->prefd
, spidx
->ul_proto
);
649 ipsec_hexdump((caddr_t
)&spidx
->src
,
650 sysdep_sa_len((struct sockaddr
*)&spidx
->src
));
652 ipsec_hexdump((caddr_t
)&spidx
->dst
,
653 sysdep_sa_len((struct sockaddr
*)&spidx
->dst
));
660 kdebug_secasindex(saidx
)
661 struct secasindex
*saidx
;
665 panic("kdebug_secpolicyindex: NULL pointer was passed.\n");
667 printf("secasindex{ mode=%u proto=%u\n",
668 saidx
->mode
, saidx
->proto
);
670 ipsec_hexdump((caddr_t
)&saidx
->src
,
671 sysdep_sa_len((struct sockaddr
*)&saidx
->src
));
673 ipsec_hexdump((caddr_t
)&saidx
->dst
,
674 sysdep_sa_len((struct sockaddr
*)&saidx
->dst
));
682 struct secasvar
*sav
;
686 panic("kdebug_secasv: NULL pointer was passed.\n");
689 kdebug_secasindex(&sav
->sah
->saidx
);
691 printf(" refcnt=%u state=%u auth=%u enc=%u\n",
692 sav
->refcnt
, sav
->state
, sav
->alg_auth
, sav
->alg_enc
);
693 printf(" spi=%u flags=%u\n",
694 (u_int32_t
)ntohl(sav
->spi
), sav
->flags
);
696 if (sav
->key_auth
!= NULL
)
697 kdebug_sadb_key((struct sadb_ext
*)sav
->key_auth
);
698 if (sav
->key_enc
!= NULL
)
699 kdebug_sadb_key((struct sadb_ext
*)sav
->key_enc
);
700 if (sav
->iv
!= NULL
) {
702 ipsec_hexdump(sav
->iv
, sav
->ivlen
? sav
->ivlen
: 8);
706 if (sav
->replay
!= NULL
)
707 kdebug_secreplay(sav
->replay
);
708 if (sav
->lft_c
!= NULL
)
709 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_c
);
710 if (sav
->lft_h
!= NULL
)
711 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_h
);
712 if (sav
->lft_s
!= NULL
)
713 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_s
);
716 /* XXX: misc[123] ? */
723 kdebug_secreplay(rpl
)
724 struct secreplay
*rpl
;
730 panic("kdebug_secreplay: NULL pointer was passed.\n");
732 printf(" secreplay{ count=%u wsize=%u seq=%u lastseq=%u",
733 rpl
->count
, rpl
->wsize
, rpl
->seq
, rpl
->lastseq
);
735 if (rpl
->bitmap
== NULL
) {
740 printf("\n bitmap { ");
742 for (len
= 0; len
< rpl
->wsize
; len
++) {
743 for (l
= 7; l
>= 0; l
--)
744 printf("%u", (((rpl
->bitmap
)[len
] >> l
) & 1) ? 1 : 0);
759 printf("mbuf(%p){ m_next:%p m_nextpkt:%p m_data:%p "
760 "m_len:%d m_type:0x%02x m_flags:0x%02x }\n",
761 m
, m
->m_next
, m
->m_nextpkt
, m
->m_data
,
762 m
->m_len
, m
->m_type
, m
->m_flags
);
764 if (m
->m_flags
& M_PKTHDR
) {
765 printf(" m_pkthdr{ len:%d rcvif:%p }\n",
766 m
->m_pkthdr
.len
, m
->m_pkthdr
.rcvif
);
770 if (m
->m_flags
& M_EXT
) {
771 printf(" m_ext{ ext_buf:%p ext_free:%p "
772 "ext_size:%u ext_ref:%p }\n",
773 m
->m_ext
.ext_buf
, m
->m_ext
.ext_free
,
774 m
->m_ext
.ext_size
, m
->m_ext
.ext_ref
);
788 for (j
= 0; m
; m
= m
->m_next
) {
790 printf(" m_data:\n");
791 for (i
= 0; i
< m
->m_len
; i
++) {
792 if (i
&& i
% 32 == 0)
796 printf("%02x", mtod(m
, u_char
*)[i
]);
807 kdebug_sockaddr(addr
)
808 struct sockaddr_storage
*addr
;
810 struct sockaddr_in
*sin4
;
812 struct sockaddr_in6
*sin6
;
817 panic("kdebug_sockaddr: NULL pointer was passed.\n");
819 /* NOTE: We deal with port number as host byte order. */
820 printf("sockaddr_storage{ len=%u family=%u", sysdep_sa_len((struct sockaddr
*)addr
), addr
->ss_family
);
822 switch (addr
->ss_family
) {
825 printf(" port=%u\n", ntohs(sin4
->sin_port
));
826 ipsec_hexdump(&sin4
->sin_addr
, sizeof(sin4
->sin_addr
));
831 printf(" port=%u\n", ntohs(sin6
->sin6_port
));
832 printf(" flowinfo=0x%08x, scope_id=0x%08x\n",
833 sin6
->sin6_flowinfo
, sin6
->sin6_scope_id
);
834 ipsec_hexdump(&sin6
->sin6_addr
, sizeof(sin6
->sin6_addr
));
845 ipsec_bindump(buf
, len
)
851 for (i
= 0; i
< len
; i
++)
852 printf("%c", (unsigned char)buf
[i
]);
859 ipsec_hexdump(buf
, len
)
865 for (i
= 0; i
< len
; i
++) {
866 if (i
!= 0 && i
% 32 == 0) printf("\n");
867 if (i
% 4 == 0) printf(" ");
868 printf("%02x", ((const unsigned char *)buf
)[i
]);
871 if (i
% 32 != 0) printf("\n");