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
__P((struct sadb_ext
*));
74 static void kdebug_sadb_identity
__P((struct sadb_ext
*));
75 static void kdebug_sadb_supported
__P((struct sadb_ext
*));
76 static void kdebug_sadb_lifetime
__P((struct sadb_ext
*));
77 static void kdebug_sadb_sa
__P((struct sadb_ext
*));
78 static void kdebug_sadb_address
__P((struct sadb_ext
*));
79 static void kdebug_sadb_key
__P((struct sadb_ext
*));
80 static void kdebug_sadb_x_sa2
__P((struct sadb_ext
*));
81 static void kdebug_sadb_session_id
__P((struct sadb_ext
*));
82 static void kdebug_sadb_sastat
__P((struct sadb_ext
*));
83 static void kdebug_sadb_x_policy
__P((struct sadb_ext
*ext
));
84 static void kdebug_sockaddr
__P((struct sockaddr_storage
*addr
));
86 #ifdef SADB_X_EXT_NAT_T_TYPE
87 static void kdebug_sadb_x_nat_t_type
__P((struct sadb_ext
*ext
));
88 static void kdebug_sadb_x_nat_t_port
__P((struct sadb_ext
*ext
));
92 static void kdebug_secreplay
__P((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 kdebug_sadb_address(ext
);
151 case SADB_EXT_KEY_AUTH
:
152 case SADB_EXT_KEY_ENCRYPT
:
153 kdebug_sadb_key(ext
);
155 case SADB_EXT_IDENTITY_SRC
:
156 case SADB_EXT_IDENTITY_DST
:
157 kdebug_sadb_identity(ext
);
159 case SADB_EXT_SENSITIVITY
:
161 case SADB_EXT_PROPOSAL
:
162 kdebug_sadb_prop(ext
);
164 case SADB_EXT_SUPPORTED_AUTH
:
165 case SADB_EXT_SUPPORTED_ENCRYPT
:
166 kdebug_sadb_supported(ext
);
168 case SADB_EXT_SPIRANGE
:
169 case SADB_X_EXT_KMPRIVATE
:
171 case SADB_X_EXT_POLICY
:
172 kdebug_sadb_x_policy(ext
);
175 kdebug_sadb_x_sa2(ext
);
177 case SADB_EXT_SESSION_ID
:
178 kdebug_sadb_session_id(ext
);
180 case SADB_EXT_SASTAT
:
181 kdebug_sadb_sastat(ext
);
183 #ifdef SADB_X_EXT_NAT_T_TYPE
184 case SADB_X_EXT_NAT_T_TYPE
:
185 kdebug_sadb_x_nat_t_type(ext
);
187 case SADB_X_EXT_NAT_T_SPORT
:
188 case SADB_X_EXT_NAT_T_DPORT
:
189 kdebug_sadb_x_nat_t_port(ext
);
191 case SADB_X_EXT_NAT_T_OA
:
192 kdebug_sadb_address(ext
);
196 printf("kdebug_sadb: invalid ext_type %u was passed.\n",
201 extlen
= PFKEY_UNUNIT64(ext
->sadb_ext_len
);
203 ext
= (void *)((caddr_t
)(void *)ext
+ extlen
);
210 kdebug_sadb_prop(ext
)
211 struct sadb_ext
*ext
;
213 struct sadb_prop
*prop
= (void *)ext
;
214 struct sadb_comb
*comb
;
219 panic("kdebug_sadb_prop: NULL pointer was passed.\n");
221 len
= (PFKEY_UNUNIT64(prop
->sadb_prop_len
) - sizeof(*prop
))
223 comb
= (void *)(prop
+ 1);
224 printf("sadb_prop{ replay=%u\n", prop
->sadb_prop_replay
);
227 printf("sadb_comb{ auth=%u encrypt=%u "
228 "flags=0x%04x reserved=0x%08x\n",
229 comb
->sadb_comb_auth
, comb
->sadb_comb_encrypt
,
230 comb
->sadb_comb_flags
, comb
->sadb_comb_reserved
);
232 printf(" auth_minbits=%u auth_maxbits=%u "
233 "encrypt_minbits=%u encrypt_maxbits=%u\n",
234 comb
->sadb_comb_auth_minbits
,
235 comb
->sadb_comb_auth_maxbits
,
236 comb
->sadb_comb_encrypt_minbits
,
237 comb
->sadb_comb_encrypt_maxbits
);
239 printf(" soft_alloc=%u hard_alloc=%u "
240 "soft_bytes=%lu hard_bytes=%lu\n",
241 comb
->sadb_comb_soft_allocations
,
242 comb
->sadb_comb_hard_allocations
,
243 (unsigned long)comb
->sadb_comb_soft_bytes
,
244 (unsigned long)comb
->sadb_comb_hard_bytes
);
246 printf(" soft_alloc=%lu hard_alloc=%lu "
247 "soft_bytes=%lu hard_bytes=%lu }\n",
248 (unsigned long)comb
->sadb_comb_soft_addtime
,
249 (unsigned long)comb
->sadb_comb_hard_addtime
,
250 (unsigned long)comb
->sadb_comb_soft_usetime
,
251 (unsigned long)comb
->sadb_comb_hard_usetime
);
260 kdebug_sadb_identity(ext
)
261 struct sadb_ext
*ext
;
263 struct sadb_ident
*id
= (void *)ext
;
268 panic("kdebug_sadb_identity: NULL pointer was passed.\n");
270 len
= PFKEY_UNUNIT64(id
->sadb_ident_len
) - sizeof(*id
);
271 printf("sadb_ident_%s{",
272 id
->sadb_ident_exttype
== SADB_EXT_IDENTITY_SRC
? "src" : "dst");
273 switch (id
->sadb_ident_type
) {
275 printf(" type=%d id=%lu",
276 id
->sadb_ident_type
, (u_long
)id
->sadb_ident_id
);
279 ipsec_hexdump((caddr_t
)(id
+ 1), len
); /*XXX cast ?*/
283 p
= (void *)(id
+ 1);
285 for (/*nothing*/; *p
&& p
< ep
; p
++) {
286 if (isprint((int)*p
))
287 printf("%c", *p
& 0xff);
289 printf("\\%03o", *p
& 0xff);
303 kdebug_sadb_supported(ext
)
304 struct sadb_ext
*ext
;
306 struct sadb_supported
*sup
= (void *)ext
;
307 struct sadb_alg
*alg
;
312 panic("kdebug_sadb_supported: NULL pointer was passed.\n");
314 len
= (PFKEY_UNUNIT64(sup
->sadb_supported_len
) - sizeof(*sup
))
316 alg
= (void *)(sup
+ 1);
317 printf("sadb_sup{\n");
319 printf(" { id=%d ivlen=%d min=%d max=%d }\n",
320 alg
->sadb_alg_id
, alg
->sadb_alg_ivlen
,
321 alg
->sadb_alg_minbits
, alg
->sadb_alg_maxbits
);
330 kdebug_sadb_lifetime(ext
)
331 struct sadb_ext
*ext
;
333 struct sadb_lifetime
*lft
= (void *)ext
;
337 printf("kdebug_sadb_lifetime: NULL pointer was passed.\n");
339 printf("sadb_lifetime{ alloc=%u, bytes=%u\n",
340 lft
->sadb_lifetime_allocations
,
341 (u_int32_t
)lft
->sadb_lifetime_bytes
);
342 printf(" addtime=%u, usetime=%u }\n",
343 (u_int32_t
)lft
->sadb_lifetime_addtime
,
344 (u_int32_t
)lft
->sadb_lifetime_usetime
);
351 struct sadb_ext
*ext
;
353 struct sadb_sa
*sa
= (void *)ext
;
357 panic("kdebug_sadb_sa: NULL pointer was passed.\n");
359 printf("sadb_sa{ spi=%u replay=%u state=%u\n",
360 (u_int32_t
)ntohl(sa
->sadb_sa_spi
), sa
->sadb_sa_replay
,
362 printf(" auth=%u encrypt=%u flags=0x%08x }\n",
363 sa
->sadb_sa_auth
, sa
->sadb_sa_encrypt
, sa
->sadb_sa_flags
);
369 kdebug_sadb_address(ext
)
370 struct sadb_ext
*ext
;
372 struct sadb_address
*addr
= (void *)ext
;
376 panic("kdebug_sadb_address: NULL pointer was passed.\n");
378 printf("sadb_address{ proto=%u prefixlen=%u reserved=0x%02x%02x }\n",
379 addr
->sadb_address_proto
, addr
->sadb_address_prefixlen
,
380 ((u_char
*)(void *)&addr
->sadb_address_reserved
)[0],
381 ((u_char
*)(void *)&addr
->sadb_address_reserved
)[1]);
383 kdebug_sockaddr((void *)((caddr_t
)(void *)ext
+ sizeof(*addr
)));
390 struct sadb_ext
*ext
;
392 struct sadb_key
*key
= (void *)ext
;
396 panic("kdebug_sadb_key: NULL pointer was passed.\n");
398 printf("sadb_key{ bits=%u reserved=%u\n",
399 key
->sadb_key_bits
, key
->sadb_key_reserved
);
403 if (((uint32_t)key
->sadb_key_bits
>> 3) >
404 (PFKEY_UNUNIT64(key
->sadb_key_len
) - sizeof(struct sadb_key
))) {
405 printf("kdebug_sadb_key: key length mismatch, bit:%d len:%ld.\n",
406 (uint32_t)key
->sadb_key_bits
>> 3,
407 (long)PFKEY_UNUNIT64(key
->sadb_key_len
) - sizeof(struct sadb_key
));
410 ipsec_hexdump(key
+ sizeof(struct sadb_key
),
411 (int)((uint32_t)key
->sadb_key_bits
>> 3));
417 kdebug_sadb_x_sa2(ext
)
418 struct sadb_ext
*ext
;
420 struct sadb_x_sa2
*sa2
= (void *)ext
;
424 panic("kdebug_sadb_x_sa2: NULL pointer was passed.\n");
426 printf("sadb_x_sa2{ mode=%u reqid=%u\n",
427 sa2
->sadb_x_sa2_mode
, sa2
->sadb_x_sa2_reqid
);
428 printf(" reserved1=%u reserved2=%u sequence=%u }\n",
429 sa2
->sadb_x_sa2_reserved1
, sa2
->sadb_x_sa2_reserved2
,
430 sa2
->sadb_x_sa2_sequence
);
436 kdebug_sadb_session_id(ext
)
437 struct sadb_ext
*ext
;
439 struct sadb_session_id
*p
= ALIGNED_CAST(__typeof__(p
))ext
; // Wcast-align fix (void*) - sadb structs come from and aligned buffer
443 printf("kdebug_sadb_session_id: NULL pointer was passed.\n");
447 printf("sadb_session_id{ id0=%llx, id1=%llx}\n",
448 p
->sadb_session_id_v
[0],
449 p
->sadb_session_id_v
[1]);
453 kdebug_sadb_sastat(ext
)
454 struct sadb_ext
*ext
;
456 struct sadb_sastat
*p
= ALIGNED_CAST(__typeof__(p
))ext
; // Wcast-align fix (void*) - sadb structs come from and aligned buffer
457 struct sastat
*stats
;
462 printf("kdebug_sadb_sastat: NULL pointer was passed.\n");
466 printf("sadb_sastat{ dir=%u num=%u\n",
467 p
->sadb_sastat_dir
, p
->sadb_sastat_list_len
);
468 stats
= (__typeof__(stats
))(p
+ 1);
469 for (i
= 0; i
< p
->sadb_sastat_list_len
; i
++) {
477 kdebug_sadb_x_policy(ext
)
478 struct sadb_ext
*ext
;
480 struct sadb_x_policy
*xpl
= (void *)ext
;
481 struct sockaddr_storage
*addr
;
485 panic("kdebug_sadb_x_policy: NULL pointer was passed.\n");
487 #ifdef HAVE_PFKEY_POLICY_PRIORITY
488 printf("sadb_x_policy{ type=%u dir=%u id=%x priority=%u }\n",
490 printf("sadb_x_policy{ type=%u dir=%u id=%x }\n",
492 xpl
->sadb_x_policy_type
, xpl
->sadb_x_policy_dir
,
493 #ifdef HAVE_PFKEY_POLICY_PRIORITY
494 xpl
->sadb_x_policy_id
, xpl
->sadb_x_policy_priority
);
496 xpl
->sadb_x_policy_id
);
499 if (xpl
->sadb_x_policy_type
== IPSEC_POLICY_IPSEC
) {
501 struct sadb_x_ipsecrequest
*xisr
;
503 tlen
= PFKEY_UNUNIT64(xpl
->sadb_x_policy_len
) - sizeof(*xpl
);
504 xisr
= (void *)(xpl
+ 1);
507 printf(" { len=%u proto=%u mode=%u level=%u reqid=%u\n",
508 xisr
->sadb_x_ipsecrequest_len
,
509 xisr
->sadb_x_ipsecrequest_proto
,
510 xisr
->sadb_x_ipsecrequest_mode
,
511 xisr
->sadb_x_ipsecrequest_level
,
512 xisr
->sadb_x_ipsecrequest_reqid
);
514 if (xisr
->sadb_x_ipsecrequest_len
> sizeof(*xisr
)) {
515 addr
= (void *)(xisr
+ 1);
516 kdebug_sockaddr(addr
);
517 addr
= (void *)((caddr_t
)(void *)addr
518 + sysdep_sa_len((struct sockaddr
*)addr
));
519 kdebug_sockaddr(addr
);
524 /* prevent infinite loop */
525 if (xisr
->sadb_x_ipsecrequest_len
== 0) {
526 printf("kdebug_sadb_x_policy: wrong policy struct.\n");
529 /* prevent overflow */
530 if (xisr
->sadb_x_ipsecrequest_len
> tlen
) {
531 printf("invalid ipsec policy length\n");
535 tlen
-= xisr
->sadb_x_ipsecrequest_len
;
537 xisr
= (void *)((caddr_t
)(void *)xisr
538 + xisr
->sadb_x_ipsecrequest_len
);
542 panic("kdebug_sadb_x_policy: wrong policy struct.\n");
548 #ifdef SADB_X_EXT_NAT_T_TYPE
550 kdebug_sadb_x_nat_t_type(struct sadb_ext
*ext
)
552 struct sadb_x_nat_t_type
*ntt
= (void *)ext
;
556 panic("kdebug_sadb_x_nat_t_type: NULL pointer was passed.\n");
558 printf("sadb_x_nat_t_type{ type=%u }\n", ntt
->sadb_x_nat_t_type_type
);
564 kdebug_sadb_x_nat_t_port(struct sadb_ext
*ext
)
566 struct sadb_x_nat_t_port
*ntp
= (void *)ext
;
570 panic("kdebug_sadb_x_nat_t_port: NULL pointer was passed.\n");
572 printf("sadb_x_nat_t_port{ port=%u }\n", ntohs(ntp
->sadb_x_nat_t_port_port
));
579 /* %%%: about SPD and SAD */
582 struct secpolicy
*sp
;
586 panic("kdebug_secpolicy: NULL pointer was passed.\n");
588 printf("secpolicy{ refcnt=%u state=%u policy=%u\n",
589 sp
->refcnt
, sp
->state
, sp
->policy
);
591 kdebug_secpolicyindex(&sp
->spidx
);
593 switch (sp
->policy
) {
594 case IPSEC_POLICY_DISCARD
:
595 printf(" type=discard }\n");
597 case IPSEC_POLICY_GENERATE
:
598 printf(" type=generate }\n");
600 case IPSEC_POLICY_NONE
:
601 printf(" type=none }\n");
603 case IPSEC_POLICY_IPSEC
:
605 struct ipsecrequest
*isr
;
606 for (isr
= sp
->req
; isr
!= NULL
; isr
= isr
->next
) {
608 printf(" level=%u\n", isr
->level
);
609 kdebug_secasindex(&isr
->saidx
);
611 if (isr
->sav
!= NULL
)
612 kdebug_secasv(isr
->sav
);
617 case IPSEC_POLICY_BYPASS
:
618 printf(" type=bypass }\n");
620 case IPSEC_POLICY_ENTRUST
:
621 printf(" type=entrust }\n");
624 printf("kdebug_secpolicy: Invalid policy found. %d\n",
633 kdebug_secpolicyindex(spidx
)
634 struct secpolicyindex
*spidx
;
638 panic("kdebug_secpolicyindex: NULL pointer was passed.\n");
640 printf("secpolicyindex{ dir=%u prefs=%u prefd=%u ul_proto=%u\n",
641 spidx
->dir
, spidx
->prefs
, spidx
->prefd
, spidx
->ul_proto
);
643 ipsec_hexdump((caddr_t
)&spidx
->src
,
644 sysdep_sa_len((struct sockaddr
*)&spidx
->src
));
646 ipsec_hexdump((caddr_t
)&spidx
->dst
,
647 sysdep_sa_len((struct sockaddr
*)&spidx
->dst
));
654 kdebug_secasindex(saidx
)
655 struct secasindex
*saidx
;
659 panic("kdebug_secpolicyindex: NULL pointer was passed.\n");
661 printf("secasindex{ mode=%u proto=%u\n",
662 saidx
->mode
, saidx
->proto
);
664 ipsec_hexdump((caddr_t
)&saidx
->src
,
665 sysdep_sa_len((struct sockaddr
*)&saidx
->src
));
667 ipsec_hexdump((caddr_t
)&saidx
->dst
,
668 sysdep_sa_len((struct sockaddr
*)&saidx
->dst
));
676 struct secasvar
*sav
;
680 panic("kdebug_secasv: NULL pointer was passed.\n");
683 kdebug_secasindex(&sav
->sah
->saidx
);
685 printf(" refcnt=%u state=%u auth=%u enc=%u\n",
686 sav
->refcnt
, sav
->state
, sav
->alg_auth
, sav
->alg_enc
);
687 printf(" spi=%u flags=%u\n",
688 (u_int32_t
)ntohl(sav
->spi
), sav
->flags
);
690 if (sav
->key_auth
!= NULL
)
691 kdebug_sadb_key((struct sadb_ext
*)sav
->key_auth
);
692 if (sav
->key_enc
!= NULL
)
693 kdebug_sadb_key((struct sadb_ext
*)sav
->key_enc
);
694 if (sav
->iv
!= NULL
) {
696 ipsec_hexdump(sav
->iv
, sav
->ivlen
? sav
->ivlen
: 8);
700 if (sav
->replay
!= NULL
)
701 kdebug_secreplay(sav
->replay
);
702 if (sav
->lft_c
!= NULL
)
703 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_c
);
704 if (sav
->lft_h
!= NULL
)
705 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_h
);
706 if (sav
->lft_s
!= NULL
)
707 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_s
);
710 /* XXX: misc[123] ? */
717 kdebug_secreplay(rpl
)
718 struct secreplay
*rpl
;
724 panic("kdebug_secreplay: NULL pointer was passed.\n");
726 printf(" secreplay{ count=%u wsize=%u seq=%u lastseq=%u",
727 rpl
->count
, rpl
->wsize
, rpl
->seq
, rpl
->lastseq
);
729 if (rpl
->bitmap
== NULL
) {
734 printf("\n bitmap { ");
736 for (len
= 0; len
< rpl
->wsize
; len
++) {
737 for (l
= 7; l
>= 0; l
--)
738 printf("%u", (((rpl
->bitmap
)[len
] >> l
) & 1) ? 1 : 0);
753 printf("mbuf(%p){ m_next:%p m_nextpkt:%p m_data:%p "
754 "m_len:%d m_type:0x%02x m_flags:0x%02x }\n",
755 m
, m
->m_next
, m
->m_nextpkt
, m
->m_data
,
756 m
->m_len
, m
->m_type
, m
->m_flags
);
758 if (m
->m_flags
& M_PKTHDR
) {
759 printf(" m_pkthdr{ len:%d rcvif:%p }\n",
760 m
->m_pkthdr
.len
, m
->m_pkthdr
.rcvif
);
764 if (m
->m_flags
& M_EXT
) {
765 printf(" m_ext{ ext_buf:%p ext_free:%p "
766 "ext_size:%u ext_ref:%p }\n",
767 m
->m_ext
.ext_buf
, m
->m_ext
.ext_free
,
768 m
->m_ext
.ext_size
, m
->m_ext
.ext_ref
);
782 for (j
= 0; m
; m
= m
->m_next
) {
784 printf(" m_data:\n");
785 for (i
= 0; i
< m
->m_len
; i
++) {
786 if (i
&& i
% 32 == 0)
790 printf("%02x", mtod(m
, u_char
*)[i
]);
801 kdebug_sockaddr(addr
)
802 struct sockaddr_storage
*addr
;
804 struct sockaddr_in
*sin4
;
806 struct sockaddr_in6
*sin6
;
811 panic("kdebug_sockaddr: NULL pointer was passed.\n");
813 /* NOTE: We deal with port number as host byte order. */
814 printf("sockaddr_storage{ len=%u family=%u", sysdep_sa_len((struct sockaddr
*)addr
), addr
->ss_family
);
816 switch (addr
->ss_family
) {
819 printf(" port=%u\n", ntohs(sin4
->sin_port
));
820 ipsec_hexdump(&sin4
->sin_addr
, sizeof(sin4
->sin_addr
));
825 printf(" port=%u\n", ntohs(sin6
->sin6_port
));
826 printf(" flowinfo=0x%08x, scope_id=0x%08x\n",
827 sin6
->sin6_flowinfo
, sin6
->sin6_scope_id
);
828 ipsec_hexdump(&sin6
->sin6_addr
, sizeof(sin6
->sin6_addr
));
839 ipsec_bindump(buf
, len
)
845 for (i
= 0; i
< len
; i
++)
846 printf("%c", (unsigned char)buf
[i
]);
853 ipsec_hexdump(buf
, len
)
859 for (i
= 0; i
< len
; i
++) {
860 if (i
!= 0 && i
% 32 == 0) printf("\n");
861 if (i
% 4 == 0) printf(" ");
862 printf("%02x", ((const unsigned char *)buf
)[i
]);
865 if (i
% 32 != 0) printf("\n");