1 /* $NetBSD: key_debug.c,v 1.34 2009/03/14 14:46:11 dsl Exp $ */
2 /* $KAME: key_debug.c,v 1.36 2003/06/27 06:46:01 itojun 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/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: key_debug.c,v 1.34 2009/03/14 14:46:11 dsl Exp $");
40 #include <sys/param.h>
42 #include <sys/systm.h>
45 #include <sys/socket.h>
47 #include <net/route.h>
49 #include <netkey/key_var.h>
50 #include <netkey/key_debug.h>
52 #include <netinet/in.h>
53 #include <netinet6/ipsec.h>
65 #define TYPESTR(x) { "SADB_" #x, SADB_ ## x }
67 static const char *kdebug_typestr(u_int
, const struct typestr
*);
68 static const char *kdebug_sadb_msg_typestr(u_int
);
69 static const char *kdebug_sadb_ext_typestr(u_int
);
70 static void kdebug_sadb_prop(struct sadb_ext
*);
71 static void kdebug_sadb_identity(struct sadb_ext
*);
72 static void kdebug_sadb_supported(struct sadb_ext
*);
73 static void kdebug_sadb_lifetime(struct sadb_ext
*);
74 static void kdebug_sadb_sa(struct sadb_ext
*);
75 static void kdebug_sadb_address(struct sadb_ext
*);
76 static void kdebug_sadb_key(struct sadb_ext
*);
77 static void kdebug_sadb_x_sa2(struct sadb_ext
*);
79 static void kdebug_sadb_x_tag(struct sadb_ext
*);
83 static void kdebug_secreplay(struct secreplay
*);
87 #define panic(param) { printf(param); exit(1); }
91 kdebug_typestr(u_int type
, const struct typestr
*list
)
95 while (list
->string
!= NULL
) {
96 if (type
== list
->type
)
97 return (list
->string
);
100 snprintf(buf
, sizeof(buf
), "%u", type
);
106 kdebug_sadb_msg_typestr(u_int type
)
108 static const struct typestr list
[] = {
122 TYPESTR(X_SPDUPDATE
),
124 TYPESTR(X_SPDDELETE
),
126 TYPESTR(X_SPDACQUIRE
),
129 TYPESTR(X_SPDSETIDX
),
130 TYPESTR(X_SPDEXPIRE
),
131 TYPESTR(X_SPDDELETE2
),
135 return kdebug_typestr(type
, list
);
139 kdebug_sadb_ext_typestr(u_int type
)
141 static const struct typestr list
[] = {
142 TYPESTR(EXT_RESERVED
),
144 TYPESTR(EXT_LIFETIME_CURRENT
),
145 TYPESTR(EXT_LIFETIME_HARD
),
146 TYPESTR(EXT_LIFETIME_SOFT
),
147 TYPESTR(EXT_ADDRESS_SRC
),
148 TYPESTR(EXT_ADDRESS_DST
),
149 TYPESTR(EXT_ADDRESS_PROXY
),
150 TYPESTR(EXT_KEY_AUTH
),
151 TYPESTR(EXT_KEY_ENCRYPT
),
152 TYPESTR(EXT_IDENTITY_SRC
),
153 TYPESTR(EXT_IDENTITY_DST
),
154 TYPESTR(EXT_SENSITIVITY
),
155 TYPESTR(EXT_PROPOSAL
),
156 TYPESTR(EXT_SUPPORTED_AUTH
),
157 TYPESTR(EXT_SUPPORTED_ENCRYPT
),
158 TYPESTR(EXT_SPIRANGE
),
159 TYPESTR(X_EXT_KMPRIVATE
),
160 TYPESTR(X_EXT_POLICY
),
162 #ifdef SADB_X_EXT_TAG
168 return kdebug_typestr(type
, list
);
171 /* NOTE: host byte order */
173 /* %%%: about struct sadb_msg */
175 kdebug_sadb(struct sadb_msg
*base
)
177 struct sadb_ext
*ext
;
182 panic("kdebug_sadb: NULL pointer was passed.");
184 printf("sadb_msg{ version=%u type=%s errno=%u satype=%u\n",
185 base
->sadb_msg_version
,
186 kdebug_sadb_msg_typestr(base
->sadb_msg_type
),
187 base
->sadb_msg_errno
, base
->sadb_msg_satype
);
188 printf(" len=%u reserved=%u seq=%u pid=%u\n",
189 base
->sadb_msg_len
, base
->sadb_msg_reserved
,
190 base
->sadb_msg_seq
, base
->sadb_msg_pid
);
192 tlen
= PFKEY_UNUNIT64(base
->sadb_msg_len
) - sizeof(struct sadb_msg
);
193 ext
= (struct sadb_ext
*)((char *)base
+ sizeof(struct sadb_msg
));
196 printf("sadb_ext{ len=%u type=%s }\n",
198 kdebug_sadb_ext_typestr(ext
->sadb_ext_type
));
200 if (ext
->sadb_ext_len
== 0) {
201 printf("kdebug_sadb: invalid ext_len=0 was passed.\n");
204 if (ext
->sadb_ext_len
> tlen
) {
205 printf("kdebug_sadb: ext_len exceeds end of buffer.\n");
209 switch (ext
->sadb_ext_type
) {
213 case SADB_EXT_LIFETIME_CURRENT
:
214 case SADB_EXT_LIFETIME_HARD
:
215 case SADB_EXT_LIFETIME_SOFT
:
216 kdebug_sadb_lifetime(ext
);
218 case SADB_EXT_ADDRESS_SRC
:
219 case SADB_EXT_ADDRESS_DST
:
220 case SADB_EXT_ADDRESS_PROXY
:
221 kdebug_sadb_address(ext
);
223 case SADB_EXT_KEY_AUTH
:
224 case SADB_EXT_KEY_ENCRYPT
:
225 kdebug_sadb_key(ext
);
227 case SADB_EXT_IDENTITY_SRC
:
228 case SADB_EXT_IDENTITY_DST
:
229 kdebug_sadb_identity(ext
);
231 case SADB_EXT_SENSITIVITY
:
233 case SADB_EXT_PROPOSAL
:
234 kdebug_sadb_prop(ext
);
236 case SADB_EXT_SUPPORTED_AUTH
:
237 case SADB_EXT_SUPPORTED_ENCRYPT
:
238 kdebug_sadb_supported(ext
);
240 case SADB_EXT_SPIRANGE
:
241 case SADB_X_EXT_KMPRIVATE
:
243 case SADB_X_EXT_POLICY
:
244 kdebug_sadb_x_policy(ext
);
247 kdebug_sadb_x_sa2(ext
);
249 #ifdef SADB_X_EXT_TAG
251 kdebug_sadb_x_tag(ext
);
255 printf("kdebug_sadb: invalid ext_type %u was passed.\n",
260 extlen
= PFKEY_UNUNIT64(ext
->sadb_ext_len
);
262 ext
= (struct sadb_ext
*)((char *)ext
+ extlen
);
269 kdebug_sadb_prop(struct sadb_ext
*ext
)
271 struct sadb_prop
*prop
= (struct sadb_prop
*)ext
;
272 struct sadb_comb
*comb
;
277 panic("kdebug_sadb_prop: NULL pointer was passed.");
279 len
= (PFKEY_UNUNIT64(prop
->sadb_prop_len
) - sizeof(*prop
))
281 comb
= (struct sadb_comb
*)(prop
+ 1);
282 printf("sadb_prop{ replay=%u\n", prop
->sadb_prop_replay
);
285 printf("sadb_comb{ auth=%u encrypt=%u "
286 "flags=0x%04x reserved=0x%08x\n",
287 comb
->sadb_comb_auth
, comb
->sadb_comb_encrypt
,
288 comb
->sadb_comb_flags
, comb
->sadb_comb_reserved
);
290 printf(" auth_minbits=%u auth_maxbits=%u "
291 "encrypt_minbits=%u encrypt_maxbits=%u\n",
292 comb
->sadb_comb_auth_minbits
,
293 comb
->sadb_comb_auth_maxbits
,
294 comb
->sadb_comb_encrypt_minbits
,
295 comb
->sadb_comb_encrypt_maxbits
);
297 printf(" soft_alloc=%u hard_alloc=%u "
298 "soft_bytes=%lu hard_bytes=%lu\n",
299 comb
->sadb_comb_soft_allocations
,
300 comb
->sadb_comb_hard_allocations
,
301 (unsigned long)comb
->sadb_comb_soft_bytes
,
302 (unsigned long)comb
->sadb_comb_hard_bytes
);
304 printf(" soft_alloc=%lu hard_alloc=%lu "
305 "soft_bytes=%lu hard_bytes=%lu }\n",
306 (unsigned long)comb
->sadb_comb_soft_addtime
,
307 (unsigned long)comb
->sadb_comb_hard_addtime
,
308 (unsigned long)comb
->sadb_comb_soft_usetime
,
309 (unsigned long)comb
->sadb_comb_hard_usetime
);
318 kdebug_sadb_identity(struct sadb_ext
*ext
)
320 struct sadb_ident
*id
= (struct sadb_ident
*)ext
;
325 panic("kdebug_sadb_identity: NULL pointer was passed.");
327 len
= PFKEY_UNUNIT64(id
->sadb_ident_len
) - sizeof(*id
);
328 printf("sadb_ident_%s{",
329 id
->sadb_ident_exttype
== SADB_EXT_IDENTITY_SRC
? "src" : "dst");
330 switch (id
->sadb_ident_type
) {
332 printf(" type=%u id=%lu",
333 id
->sadb_ident_type
, (u_long
)id
->sadb_ident_id
);
336 ipsec_hexdump((void *)(id
+ 1), len
); /*XXX cast ?*/
338 unsigned char *p
, *ep
;
340 p
= (void *)(id
+ 1);
342 for (/*nothing*/; *p
&& p
< ep
; p
++) {
346 printf("\\%03o", *p
);
360 kdebug_sadb_supported(struct sadb_ext
*ext
)
362 struct sadb_supported
*sup
= (struct sadb_supported
*)ext
;
363 struct sadb_alg
*alg
;
368 panic("kdebug_sadb_supported: NULL pointer was passed.");
370 len
= (PFKEY_UNUNIT64(sup
->sadb_supported_len
) - sizeof(*sup
))
372 alg
= (struct sadb_alg
*)(sup
+ 1);
373 printf("sadb_sup{\n");
375 printf(" { id=%u ivlen=%u min=%u max=%u }\n",
376 alg
->sadb_alg_id
, alg
->sadb_alg_ivlen
,
377 alg
->sadb_alg_minbits
, alg
->sadb_alg_maxbits
);
386 kdebug_sadb_lifetime(struct sadb_ext
*ext
)
388 struct sadb_lifetime
*lft
= (struct sadb_lifetime
*)ext
;
392 printf("kdebug_sadb_lifetime: NULL pointer was passed.\n");
394 printf("sadb_lifetime{ alloc=%u, bytes=%u\n",
395 lft
->sadb_lifetime_allocations
,
396 (u_int32_t
)lft
->sadb_lifetime_bytes
);
397 printf(" addtime=%u, usetime=%u }\n",
398 (u_int32_t
)lft
->sadb_lifetime_addtime
,
399 (u_int32_t
)lft
->sadb_lifetime_usetime
);
405 kdebug_sadb_sa(struct sadb_ext
*ext
)
407 struct sadb_sa
*sa
= (struct sadb_sa
*)ext
;
411 panic("kdebug_sadb_sa: NULL pointer was passed.");
413 printf("sadb_sa{ spi=%u replay=%u state=%u\n",
414 (u_int32_t
)ntohl(sa
->sadb_sa_spi
), sa
->sadb_sa_replay
,
416 printf(" auth=%u encrypt=%u flags=0x%08x }\n",
417 sa
->sadb_sa_auth
, sa
->sadb_sa_encrypt
, sa
->sadb_sa_flags
);
423 kdebug_sadb_address(struct sadb_ext
*ext
)
425 struct sadb_address
*addr
= (struct sadb_address
*)ext
;
429 panic("kdebug_sadb_address: NULL pointer was passed.");
431 printf("sadb_address{ proto=%u prefixlen=%u reserved=0x%02x%02x }\n",
432 addr
->sadb_address_proto
, addr
->sadb_address_prefixlen
,
433 ((u_char
*)&addr
->sadb_address_reserved
)[0],
434 ((u_char
*)&addr
->sadb_address_reserved
)[1]);
436 kdebug_sockaddr((struct sockaddr
*)((char *)ext
+ sizeof(*addr
)));
442 kdebug_sadb_key(struct sadb_ext
*ext
)
444 struct sadb_key
*key
= (struct sadb_key
*)ext
;
448 panic("kdebug_sadb_key: NULL pointer was passed.");
450 printf("sadb_key{ bits=%u reserved=%u\n",
451 key
->sadb_key_bits
, key
->sadb_key_reserved
);
455 if ((key
->sadb_key_bits
>> 3) >
456 (PFKEY_UNUNIT64(key
->sadb_key_len
) - sizeof(struct sadb_key
))) {
457 printf("kdebug_sadb_key: key length mismatch, bit:%u len:%ld.\n",
458 key
->sadb_key_bits
>> 3,
459 (long)PFKEY_UNUNIT64(key
->sadb_key_len
) - sizeof(struct sadb_key
));
462 ipsec_hexdump((char *)key
+ sizeof(struct sadb_key
),
463 key
->sadb_key_bits
>> 3);
469 kdebug_sadb_x_sa2(struct sadb_ext
*ext
)
471 struct sadb_x_sa2
*sa2
= (struct sadb_x_sa2
*)ext
;
475 panic("kdebug_sadb_x_sa2: NULL pointer was passed.");
477 printf("sadb_x_sa2{ mode=%u reqid=%u\n",
478 sa2
->sadb_x_sa2_mode
, sa2
->sadb_x_sa2_reqid
);
479 printf(" reserved1=%u reserved2=%u sequence=%u }\n",
480 sa2
->sadb_x_sa2_reserved1
, sa2
->sadb_x_sa2_reserved2
,
481 sa2
->sadb_x_sa2_sequence
);
486 #ifdef SADB_X_EXT_TAG
488 kdebug_sadb_x_tag(struct sadb_ext
*ext
)
490 struct sadb_x_tag
*tag
= (struct sadb_x_tag
*)ext
;
494 panic("kdebug_sadb_x_tag: NULL pointer was passed.");
496 printf("sadb_x_sa2{ tag=\"%s\" }\n", tag
->sadb_x_tag_name
);
503 kdebug_sadb_x_policy(struct sadb_ext
*ext
)
505 struct sadb_x_policy
*xpl
= (struct sadb_x_policy
*)ext
;
506 struct sockaddr
*addr
;
510 panic("kdebug_sadb_x_policy: NULL pointer was passed.");
512 printf("sadb_x_policy{ type=%u dir=%u id=%x }\n",
513 xpl
->sadb_x_policy_type
, xpl
->sadb_x_policy_dir
,
514 xpl
->sadb_x_policy_id
);
516 if (xpl
->sadb_x_policy_type
== IPSEC_POLICY_IPSEC
) {
518 struct sadb_x_ipsecrequest
*xisr
;
520 tlen
= PFKEY_UNUNIT64(xpl
->sadb_x_policy_len
) - sizeof(*xpl
);
521 xisr
= (struct sadb_x_ipsecrequest
*)(xpl
+ 1);
524 printf(" { len=%u proto=%u mode=%u level=%u reqid=%u\n",
525 xisr
->sadb_x_ipsecrequest_len
,
526 xisr
->sadb_x_ipsecrequest_proto
,
527 xisr
->sadb_x_ipsecrequest_mode
,
528 xisr
->sadb_x_ipsecrequest_level
,
529 xisr
->sadb_x_ipsecrequest_reqid
);
531 if (xisr
->sadb_x_ipsecrequest_len
> sizeof(*xisr
)) {
532 addr
= (struct sockaddr
*)(xisr
+ 1);
533 kdebug_sockaddr(addr
);
534 addr
= (struct sockaddr
*)((char *)addr
536 kdebug_sockaddr(addr
);
541 /* prevent infinite loop */
542 if (xisr
->sadb_x_ipsecrequest_len
<= 0) {
543 printf("kdebug_sadb_x_policy: wrong policy struct.\n");
546 /* prevent overflow */
547 if (xisr
->sadb_x_ipsecrequest_len
> tlen
) {
548 printf("invalid ipsec policy length\n");
552 tlen
-= xisr
->sadb_x_ipsecrequest_len
;
554 xisr
= (struct sadb_x_ipsecrequest
*)((char *)xisr
555 + xisr
->sadb_x_ipsecrequest_len
);
559 panic("kdebug_sadb_x_policy: wrong policy struct.");
566 /* %%%: about SPD and SAD */
568 kdebug_secpolicy(struct secpolicy
*sp
)
572 panic("kdebug_secpolicy: NULL pointer was passed.");
574 printf("secpolicy{ refcnt=%u state=%u policy=%u dir=%u\n",
575 sp
->refcnt
, sp
->state
, sp
->policy
, sp
->dir
);
578 kdebug_secpolicyindex(sp
->spidx
);
580 switch (sp
->policy
) {
581 case IPSEC_POLICY_DISCARD
:
582 printf(" type=discard }\n");
584 case IPSEC_POLICY_NONE
:
585 printf(" type=none }\n");
587 case IPSEC_POLICY_IPSEC
:
589 struct ipsecrequest
*isr
;
590 for (isr
= sp
->req
; isr
!= NULL
; isr
= isr
->next
) {
592 printf(" level=%u\n", isr
->level
);
593 kdebug_secasindex(&isr
->saidx
);
595 if (isr
->sav
!= NULL
)
596 kdebug_secasv(isr
->sav
);
601 case IPSEC_POLICY_BYPASS
:
602 printf(" type=bypass }\n");
604 case IPSEC_POLICY_ENTRUST
:
605 printf(" type=entrust }\n");
608 printf("kdebug_secpolicy: Invalid policy found. %u\n",
617 kdebug_secpolicyindex(struct secpolicyindex
*spidx
)
621 panic("kdebug_secpolicyindex: NULL pointer was passed.");
623 printf("secpolicyindex{ prefs=%u prefd=%u ul_proto=%u\n",
624 spidx
->prefs
, spidx
->prefd
, spidx
->ul_proto
);
626 ipsec_hexdump((void *)&spidx
->src
,
627 ((struct sockaddr
*)&spidx
->src
)->sa_len
);
629 ipsec_hexdump((void *)&spidx
->dst
,
630 ((struct sockaddr
*)&spidx
->dst
)->sa_len
);
637 kdebug_secasindex(struct secasindex
*saidx
)
641 panic("kdebug_secpolicyindex: NULL pointer was passed.");
643 printf("secasindex{ mode=%u proto=%u\n",
644 saidx
->mode
, saidx
->proto
);
646 ipsec_hexdump((void *)&saidx
->src
,
647 ((struct sockaddr
*)&saidx
->src
)->sa_len
);
649 ipsec_hexdump((void *)&saidx
->dst
,
650 ((struct sockaddr
*)&saidx
->dst
)->sa_len
);
657 kdebug_secasv(struct secasvar
*sav
)
661 panic("kdebug_secasv: NULL pointer was passed.");
664 kdebug_secasindex(&sav
->sah
->saidx
);
666 printf(" refcnt=%u state=%u auth=%u enc=%u\n",
667 sav
->refcnt
, sav
->state
, sav
->alg_auth
, sav
->alg_enc
);
668 printf(" spi=%u flags=%u\n",
669 (u_int32_t
)ntohl(sav
->spi
), sav
->flags
);
671 if (sav
->key_auth
!= NULL
)
672 kdebug_sadb_key((struct sadb_ext
*)sav
->key_auth
);
673 if (sav
->key_enc
!= NULL
)
674 kdebug_sadb_key((struct sadb_ext
*)sav
->key_enc
);
675 if (sav
->iv
!= NULL
) {
677 ipsec_hexdump(sav
->iv
, sav
->ivlen
? sav
->ivlen
: 8);
681 if (sav
->replay
!= NULL
)
682 kdebug_secreplay(sav
->replay
);
683 if (sav
->lft_c
!= NULL
)
684 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_c
);
685 if (sav
->lft_h
!= NULL
)
686 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_h
);
687 if (sav
->lft_s
!= NULL
)
688 kdebug_sadb_lifetime((struct sadb_ext
*)sav
->lft_s
);
691 /* XXX: misc[123] ? */
698 kdebug_secreplay(struct secreplay
*rpl
)
704 panic("kdebug_secreplay: NULL pointer was passed.");
706 printf(" secreplay{ count=%llu wsize=%u seq=%llu lastseq=%llu",
707 (unsigned long long)rpl
->count
, rpl
->wsize
,
708 (unsigned long long)rpl
->seq
, (unsigned long long)rpl
->lastseq
);
710 if (rpl
->bitmap
== NULL
) {
715 printf("\n bitmap { ");
717 for (len
= 0; len
< rpl
->wsize
; len
++) {
718 for (l
= 7; l
>= 0; l
--)
719 printf("%u", (((rpl
->bitmap
)[len
] >> l
) & 1) ? 1 : 0);
727 kdebug_mbufhdr(struct mbuf
*m
)
733 printf("mbuf(%p){ m_next:%p m_nextpkt:%p m_data:%p "
734 "m_len:%d m_type:0x%02x m_flags:0x%02x }\n",
735 m
, m
->m_next
, m
->m_nextpkt
, m
->m_data
,
736 m
->m_len
, m
->m_type
, m
->m_flags
);
738 if (m
->m_flags
& M_PKTHDR
) {
739 printf(" m_pkthdr{ len:%d rcvif:%p }\n",
740 m
->m_pkthdr
.len
, m
->m_pkthdr
.rcvif
);
748 kdebug_mbuf(struct mbuf
*m0
)
753 for (j
= 0; m
; m
= m
->m_next
) {
755 printf(" m_data:\n");
756 for (i
= 0; i
< m
->m_len
; i
++) {
757 if (i
&& i
% 32 == 0)
761 printf("%02x", mtod(m
, u_char
*)[i
]);
772 kdebug_sockaddr(struct sockaddr
*addr
)
774 struct sockaddr_in
*sin4
;
776 struct sockaddr_in6
*sin6
;
781 panic("kdebug_sockaddr: NULL pointer was passed.");
783 /* NOTE: We deal with port number as host byte order. */
784 printf("sockaddr{ len=%u family=%u", addr
->sa_len
, addr
->sa_family
);
786 switch (addr
->sa_family
) {
788 sin4
= (struct sockaddr_in
*)addr
;
789 printf(" port=%u\n", ntohs(sin4
->sin_port
));
790 ipsec_hexdump((void *)&sin4
->sin_addr
, sizeof(sin4
->sin_addr
));
794 sin6
= (struct sockaddr_in6
*)addr
;
795 printf(" port=%u\n", ntohs(sin6
->sin6_port
));
796 printf(" flowinfo=0x%08x, scope_id=0x%08x\n",
797 sin6
->sin6_flowinfo
, sin6
->sin6_scope_id
);
798 ipsec_hexdump((void *)&sin6
->sin6_addr
,
799 sizeof(sin6
->sin6_addr
));
810 ipsec_bindump(void *bufv
, int len
)
815 for (i
= 0; i
< len
; i
++)
816 printf("%c", (unsigned char)buf
[i
]);
823 ipsec_hexdump(void *bufv
, int len
)
828 for (i
= 0; i
< len
; i
++) {
829 if (i
!= 0 && i
% 32 == 0) printf("\n");
830 if (i
% 4 == 0) printf(" ");
831 printf("%02x", (unsigned char)buf
[i
]);
834 if (i
% 32 != 0) printf("\n");