1 /*
2 * in6_debug.c -- Insipired by Craig Metz's Net/2 in6_debug.c, but
3 * not quite as heavyweight (initially, anyway).
4 *
5 * The idea is to have globals here, and dump netinet6/ data structures.
6 *
7 * Copyright 1995 by Dan McDonald, Bao Phan, and Randall Atkinson,
8 * All Rights Reserved.
9 * All Rights under this copyright have been assigned to NRL.
10 */
11
12 /*----------------------------------------------------------------------
13 # @(#)COPYRIGHT 1.1a (NRL) 17 August 1995
14
15 COPYRIGHT NOTICE
16
17 All of the documentation and software included in this software
18 distribution from the US Naval Research Laboratory (NRL) are
19 copyrighted by their respective developers.
20
21 This software and documentation were developed at NRL by various
22 people. Those developers have each copyrighted the portions that they
23 developed at NRL and have assigned All Rights for those portions to
24 NRL. Outside the USA, NRL also has copyright on the software
25 developed at NRL. The affected files all contain specific copyright
26 notices and those notices must be retained in any derived work.
27
28 NRL LICENSE
29
30 NRL grants permission for redistribution and use in source and binary
31 forms, with or without modification, of the software and documentation
32 created at NRL provided that the following conditions are met:
33
34 1. Redistributions of source code must retain the above copyright
35 notice, this list of conditions and the following disclaimer.
36 2. Redistributions in binary form must reproduce the above copyright
37 notice, this list of conditions and the following disclaimer in the
38 documentation and/or other materials provided with the distribution.
39 3. All advertising materials mentioning features or use of this software
40 must display the following acknowledgement:
41
42 This product includes software developed at the Information
43 Technology Division, US Naval Research Laboratory.
44
45 4. Neither the name of the NRL nor the names of its contributors
46 may be used to endorse or promote products derived from this software
47 without specific prior written permission.
48
49 THE SOFTWARE PROVIDED BY NRL IS PROVIDED BY NRL AND CONTRIBUTORS ``AS
50 IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
51 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
52 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NRL OR
53 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
54 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
55 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
56 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
57 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
58 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60
61 The views and conclusions contained in the software and documentation
62 are those of the authors and should not be interpreted as representing
63 official policies, either expressed or implied, of the US Naval
64 Research Laboratory (NRL).
65
66 ----------------------------------------------------------------------*/
67
68
69 #define INET6_DEBUG_C
70
71 #include <netkey/osdep_44bsd.h>
72
73 #include <sys/types.h>
74 #include <sys/param.h>
75 #include <sys/socket.h>
76 #include <sys/mbuf.h>
77
78 #include <net/if.h>
79 #include <net/if_dl.h>
80 #include <net/route.h>
81
82 #include <netinet/in_systm.h>
83 #include <netinet/ip.h>
84 #include <netinet/in_pcb.h>
85
86 #ifdef INET6
87 #include <netinet6/in6.h>
88 #include <netinet6/in6_var.h>
89 #include <netinet6/ipv6.h>
90 #include <netinet6/ipv6_var.h>
91 #include <netinet6/ipv6_icmp.h>
92 #else /* INET6 */
93 #if 0
94 #include "in6_types.h"
95 #endif
96 #endif /* INET6 */
97
98 #define SA_LEN 1
99 #define SIN_LEN 1
100
101 #ifdef KEY_DEBUG
102 #include <netkey/key.h>
103 #endif /* KEY_DEBUG */
104 #ifdef IPSEC_DEBUG
105 #include <netsec/ipsec.h>
106 #endif /* IPSEC_DEBUG */
107
108 #if 0
109 #include <netinet6/in6_debug.h>
110 #endif
111
112 #ifndef DEFARGS
113 #define DEFARGS(arglist, args) arglist args;
114 #define AND ;
115 #endif /* DEFARGS */
116
117 /*
118 * Globals
119 */
120
121 /* The following should be sysctl-tweakable. */
122
123 unsigned int in6_debug_level = IDL_FINISHED + 1; /* 0 is no debugging */
124
125 /*
126 * Functions and macros.
127 */
128
129 void in6_debug_init DEFARGS((), void)
130 {
131 /* For now, nothing. */
132 }
133
134 /*----------------------------------------------------------------------
135 * dump_* dumps various data structures. These should be called within
136 * the context of a DDO() macro. They assume address and port fields
137 * are in network order.
138 ----------------------------------------------------------------------*/
139
140 #ifdef INET6
141 /*----------------------------------------------------------------------
142 * Dump an IPv6 address. Don't compress 0's out because of debugging.
143 ----------------------------------------------------------------------*/
144 void dump_in_addr6 DEFARGS((in_addr6),
145 struct in_addr6 *in_addr6)
146 {
147 u_short *shorts = (u_short *)in_addr6;
148 int i = 0;
149
150 if (!in_addr6) {
151 printf("Dereference a NULL in_addr6? I don't think so.\n");
152 return;
153 }
154
155 printf("(conv. for printing) ");
156 while (i < 7)
157 printf("%4x:",htons(shorts[i++]));
158 printf("%4x\n",htons(shorts[7]));
159 }
160 #endif /* INET6 */
161
162 /*----------------------------------------------------------------------
163 * Dump and IPv4 address in x.x.x.x form.
164 ----------------------------------------------------------------------*/
165 void dump_in_addr DEFARGS((in_addr),
166 struct in_addr *in_addr)
167 {
168 u_char *chars = (u_char *)in_addr;
169 int i = 0;
170
171 if (!in_addr) {
172 printf("Dereference a NULL in_addr? I don't think so.\n");
173 return;
174 }
175
176 while (i < 3)
177 printf("%d.",chars[i++]);
178 printf("%d\n",chars[3]);
179 }
180
181 #ifdef INET6
182 /*----------------------------------------------------------------------
183 * Dump an IPv6 socket address.
184 ----------------------------------------------------------------------*/
185 void dump_sockaddr_in6 DEFARGS((sin6),
186 struct sockaddr_in6 *sin6)
187 {
188 if (!sin6) {
189 printf("Dereference a NULL sockaddr_in6? I don't think so.\n");
190 return;
191 }
192
193 printf("sin6_len = %d, sin6_family = %d, sin6_port = %d (0x%x)\n",
194 sin6->sin6_len,sin6->sin6_family, htons(sin6->sin6_port),
195 htons(sin6->sin6_port));
196 printf("sin6_flowinfo = 0x%x\n",sin6->sin6_flowinfo);
197 printf("sin6_addr = ");
198 dump_in_addr6(&sin6->sin6_addr);
199 }
200 #endif /* INET6 */
201
202 /*----------------------------------------------------------------------
203 * Dump an IPv4 socket address.
204 ----------------------------------------------------------------------*/
205 void dump_sockaddr_in DEFARGS((sin),
206 struct sockaddr_in *sin)
207 {
208 int i;
209
210 if (!sin) {
211 printf("Dereference a NULL sockaddr_in? I don't think so.\n");
212 return;
213 }
214
215 #ifdef SIN_LEN
216 printf("sin_len = %d, ", sin->sin_len);
217 #endif /* SIN_LEN */
218 printf("sin_family = %d, sin_port (conv.) = %d (0x%x)\n",
219 sin->sin_family, htons(sin->sin_port),
220 htons(sin->sin_port));
221 printf("sin_addr = ");
222 dump_in_addr(&sin->sin_addr);
223 printf("sin_zero == ");
224 for(i=0;i<8;i++)
225 printf("0x%2x ",sin->sin_zero[i]);
226 printf("\n");
227 }
228
229 /*----------------------------------------------------------------------
230 * Dump a generic socket address. Use if no family-specific routine is
231 * available.
232 ----------------------------------------------------------------------*/
233 void dump_sockaddr DEFARGS((sa),
234 SOCKADDR *sa)
235 {
236 if (!sa) {
237 printf("Dereference a NULL sockaddr? I don't think so.\n");
238 return;
239 }
240
241 #ifdef SA_LEN
242 printf("sa_len = %d, ", sa->sa_len);
243 #endif /* SA_LEN */
244 printf("sa_family = %d", sa->sa_family);
245 #ifdef SA_LEN
246 printf(", remaining bytes are:\n");
247 {
248 int i;
249 for (i = 0; i <sa->sa_len - 2; i++)
250 printf("0x%2x ",(unsigned char)sa->sa_data[i]);
251 }
252 #endif /* SA_LEN */
253 printf("\n");
254 }
255
256 /*----------------------------------------------------------------------
257 * Dump a link-layer socket address. (Not that there are user-level link
258 * layer sockets, but there are plenty of link-layer addresses in the kernel.)
259 ----------------------------------------------------------------------*/
260 void dump_sockaddr_dl DEFARGS((sdl),
261 struct sockaddr_dl *sdl)
262 {
263 char buf[256];
264
265 if (!sdl) {
266 printf("Dereference a NULL sockaddr_dl? I don't think so.\n");
267 return;
268 }
269
270 printf("sdl_len = %d, sdl_family = %d, sdl_index = %d, sdl_type = %d,\n",
271 sdl->sdl_len, sdl->sdl_family, sdl->sdl_index, sdl->sdl_type);
272 buf[sdl->sdl_nlen] = 0;
273 if (sdl->sdl_nlen)
274 bcopy(sdl->sdl_data,buf,sdl->sdl_nlen);
275 printf("sdl_nlen = %d, (name = '%s'\n",sdl->sdl_nlen,buf);
276 printf("sdl_alen = %d, ",sdl->sdl_alen);
277 if (sdl->sdl_alen)
278 {
279 int i;
280
281 printf("(addr = ");
282 for (i = 0; i<sdl->sdl_alen; i++)
283 printf("0x%2x ",(unsigned char)sdl->sdl_data[i+sdl->sdl_nlen]);
284 }
285 printf("\n");
286 printf("sdl_slen = %d, ",sdl->sdl_slen);
287 if (sdl->sdl_slen)
288 {
289 int i;
290
291 printf("(addr = ");
292 for (i = 0; i<sdl->sdl_slen; i++)
293 printf("0x%2x ",
294 (unsigned char)sdl->sdl_data[i+sdl->sdl_nlen+sdl->sdl_alen]);
295 }
296 printf("\n");
297 }
298
299 /*----------------------------------------------------------------------
300 * Dump a socket address, calling a family-specific routine if available.
301 ----------------------------------------------------------------------*/
302 void dump_smart_sockaddr DEFARGS((sa),
303 SOCKADDR *sa)
304 {
305 DPRINTF(IDL_MAJOR_EVENT, ("Entering dump_smart_sockaddr\n"));
306 if (!sa) {
307 printf("Dereference a NULL sockaddr? I don't think so.\n");
308 return;
309 }
310
311 switch (sa->sa_family)
312 {
313 #ifdef INET6
314 case AF_INET6:
315 dump_sockaddr_in6((struct sockaddr_in6 *)sa);
316 break;
317 #endif /* INET6 */
318 case AF_INET:
319 dump_sockaddr_in((struct sockaddr_in *)sa);
320 break;
321 case AF_LINK:
322 dump_sockaddr_dl((struct sockaddr_dl *)sa);
323 break;
324 default:
325 dump_sockaddr(sa);
326 break;
327 }
328 }
329
330 #ifdef INET6
331 /*----------------------------------------------------------------------
332 * Dump an IPv6 header.
333 ----------------------------------------------------------------------*/
334 void dump_ipv6 DEFARGS((ipv6),
335 struct ipv6 *ipv6)
336 {
337 if (!ipv6) {
338 printf("Dereference a NULL ipv6? I don't think so.\n");
339 return;
340 }
341
342 printf("Vers & flow label (conv to host order) 0x%x\n",
343 htonl(ipv6->ipv6_versfl));
344 printf("Length (conv) = %d, nexthdr = %d, hoplimit = %d.\n",
345 htons(ipv6->ipv6_length),ipv6->ipv6_nexthdr,ipv6->ipv6_hoplimit);
346 printf("Src: ");
347 dump_in_addr6(&ipv6->ipv6_src);
348 printf("Dst: ");
349 dump_in_addr6(&ipv6->ipv6_dst);
350 }
351
352 /*----------------------------------------------------------------------
353 * Dump an ICMPv6 header. This function is not very smart beyond the
354 * type, code, and checksum.
355 ----------------------------------------------------------------------*/
356 dump_ipv6_icmp DEFARGS((icp),
357 struct ipv6_icmp *icp)
358 {
359 int i;
360
361 if (!icp) {
362 printf("Dereference a NULL ipv6_icmp? I don't think so.\n");
363 return;
364 }
365
366 printf("type %d, code %d, cksum (conv) = 0x%x\n",icp->icmp_type,
367 icp->icmp_code,htons(icp->icmp_cksum));
368 printf("First four bytes: 0x%x",htonl(icp->icmp_unused));
369 printf("Next four bytes: 0x");
370 for (i=0;i<4;i++)
371 printf("%x",icp->icmp_echodata[i]);
372 printf("\n");
373 }
374 #endif /* INET6 */
375
376 /*----------------------------------------------------------------------
377 * Dump only the header fields of a single mbuf.
378 ----------------------------------------------------------------------*/
379 void dump_mbuf_hdr DEFARGS((m),
380 struct mbuf *m)
381 {
382 if (!m) {
383 printf("Dereference a NULL mbuf? I don't think so.\n");
384 return;
385 }
386
387 printf("Single mbuf at %08x\n", m);
388 printf("m_len = %d, m_data = 0x%x, m_type = %d\n",m->m_len,
389 m->m_data, m->m_type);
390 printf("m_flags = 0x%x ",m->m_flags);
391 if (m->m_flags & M_PKTHDR)
392 printf("m_pkthdr.len = %d, m_pkthdr.rcvif = 0x%x",m->m_pkthdr.len,
393 m->m_pkthdr.rcvif);
394 if (m->m_flags & M_EXT)
395 printf(" (IS CLUSTER MBUF)");
396 printf("\nm_next = 0x%x m_nextpkt = 0x%x\n",m->m_next, m->m_nextpkt);
397 }
398
399 /*----------------------------------------------------------------------
400 * Dump the entire contents of a single mbuf.
401 ----------------------------------------------------------------------*/
402 void dump_mbuf DEFARGS((m),
403 struct mbuf *m)
404 {
405 int i;
406
407 dump_mbuf_hdr(m);
408 printf("m_data:\n");
409 for (i = 0; i < m->m_len; i++)
410 printf("0x%2x%s",(unsigned char)m->m_data[i] , ((i+1) % 16)?" ":"\n");
411 printf((i % 16)?"\n":"");
412 }
413
414 /*----------------------------------------------------------------------
415 * Dump the contents of an mbuf chain. (WARNING: Lots of text may
416 * result.
417 ----------------------------------------------------------------------*/
418 void dump_mchain DEFARGS((m),
419 struct mbuf *m)
420 {
421 struct mbuf *walker;
422 int i;
423
424 for (walker = m, i = 0; walker != NULL && (i < 10);
425 walker = walker->m_next, i++)
426 dump_mbuf(walker);
427 }
428
429 /*----------------------------------------------------------------------
430 * Dump an mbuf chain's data in a format similar to tcpdump(8).
431 ----------------------------------------------------------------------*/
432 void dump_tcpdump DEFARGS((m),
433 struct mbuf *m)
434 {
435 struct mbuf *walker;
436 int i, j, count;
437
438 for (i = count = 0; m && (i < 10); m = m->m_next, i++) {
439 for (j = 0; j < m->m_len; j++, count++) {
440 if (!(count % (2 * 8)))
441 printf("\n\t\t\t");
442 if (!(count % 2))
443 printf(" ");
444 printf("%02x", (u_int8)(m->m_data[j]));
445 }
446 }
447 }
448
449 #ifdef INET6
450 /*----------------------------------------------------------------------
451 * Dump an IPv6 header index table, which is terminated by an entry with
452 * a NULL mbuf pointer.
453 ----------------------------------------------------------------------*/
454 void dump_ihitab DEFARGS((ihi),
455 struct in6_hdrindex *ihi)
456 {
457 int i=0;
458
459 if (!ihi) {
460 printf("Dereference a NULL hdrindex/ihi? I don't think so.\n");
461 return;
462 }
463
464 /* This is dangerous, make sure ihitab was bzeroed. */
465 while (ihi[i].ihi_mbuf)
466 {
467 printf("ihi_nexthdr = %d, ihi_mbuf = 0x%x.\n",ihi[i].ihi_nexthdr,
468 ihi[i].ihi_mbuf);
469 i++;
470 }
471 }
472 #endif /* INET6 */
473
474 /*----------------------------------------------------------------------
475 * Dump an interface address.
476 ----------------------------------------------------------------------*/
477 void dump_ifa DEFARGS((ifa),
478 struct ifaddr *ifa)
479 {
480 if (ifa == NULL)
481 {
482 printf("ifa of NULL.\n");
483 return;
484 }
485
486 printf("ifa_addr: ");
487 dump_smart_sockaddr(ifa->ifa_addr);
488 printf("ifa_netmask: ");
489 dump_smart_sockaddr(ifa->ifa_netmask);
490 }
491
492 /*----------------------------------------------------------------------
493 * Dump an interface structure.
494 ----------------------------------------------------------------------*/
495 void dump_ifp DEFARGS((ifp),
496 struct ifnet *ifp)
497 {
498 if (!ifp) {
499 printf("Dereference a NULL ifnet/ifp? I don't think so.\n");
500 return;
501 }
502
503 printf("Interface name: %s.\n",ifp->if_name);
504 printf("Interface type: %d. ",ifp->if_type);
505 printf("MTU: %d.\n",ifp->if_mtu);
506 }
507
508 /*----------------------------------------------------------------------
509 * Dump a route structure (sockaddr/rtentry pair).
510 ----------------------------------------------------------------------*/
511 void dump_route DEFARGS((ro),
512 struct route *ro)
513 {
514 if (!ro) {
515 printf("Dereference a NULL route? I don't think so.\n");
516 return;
517 }
518
519 printf("ro_rt = 0x%x, ro_dst is:\n",ro->ro_rt);
520 dump_smart_sockaddr(&ro->ro_dst);
521 }
522
523 /*----------------------------------------------------------------------
524 * Dump a routing entry.
525 ----------------------------------------------------------------------*/
526 void dump_rtentry DEFARGS((rt),
527 struct rtentry *rt)
528 {
529 if (!rt) {
530 printf("Dereference a NULL rtentry? I don't think so.\n");
531 return;
532 }
533
534 printf("rt_key is:\n");
535 dump_smart_sockaddr(rt_key(rt));
536 printf("rt_mask is:\n");
537 dump_smart_sockaddr(rt_mask(rt));
538 printf("rt_llinfo = 0x%x ",rt->rt_llinfo);
539 printf("rt_rmx.rmx_mtu = %d ",rt->rt_rmx.rmx_mtu);
540 printf("rt_refcnt = %d ",rt->rt_refcnt);
541 printf("rt_flags = 0x%x\n",rt->rt_flags);
542 printf("rt_ifp is:\n");
543 dump_ifp(rt->rt_ifp);
544 printf("rt_ifa is:\n");
545 dump_ifa(rt->rt_ifa);
546 }
547
548 /*----------------------------------------------------------------------
549 * Dump an Internet (v4/v6) protocol control block.
550 ----------------------------------------------------------------------*/
551 void dump_inpcb DEFARGS((inp),
552 struct inpcb *inp)
553 {
554 if (!inp) {
555 printf("Dereference a NULL inpcb? I don't think so.\n");
556 return;
557 }
558
559 printf("inp_next = 0x%x, inp_prev = 0x%x, inp_head = 0x%x.\n",inp->inp_next,
560 inp->inp_prev, inp->inp_head);
561 printf("inp_socket = 0x%x, inp_ppcb\n",inp->inp_socket,inp->inp_ppcb);
562 #ifdef INET6
563 printf("faddr, faddr6:\n");
564 dump_in_addr(&inp->inp_faddr); dump_in_addr6(&inp->inp_faddr6);
565 printf("laddr, laddr6:\n");
566 dump_in_addr(&inp->inp_laddr); dump_in_addr6(&inp->inp_laddr6);
567 #else /* INET6 */
568 printf("faddr:\n");
569 dump_in_addr(&inp->inp_faddr);
570 printf("laddr:\n");
571 dump_in_addr(&inp->inp_laddr);
572 #endif /* INET6 */
573 printf("inp_route: ");
574 dump_route(&inp->inp_route);
575 #ifdef INET6
576 printf("inp_ipv6:");
577 dump_ipv6(&inp->inp_ipv6);
578 #endif /* INET6 */
579 printf("inp_ip:");
580 printf("<Coming soon.>\n");
581 printf("inp_options = 0x%x, inp_moptions{6,} = 0x%x,\n",inp->inp_options,
582 inp->inp_moptions);
583 printf("inp_flags = 0x%x, inp_fport = %d, inp_lport = %d.\n",
584 (unsigned)inp->inp_flags,inp->inp_fport, inp->inp_lport);
585 }
586
587 #ifdef INET6
588 /*----------------------------------------------------------------------
589 * Dump an IPv6 discovery queue structure.
590 ----------------------------------------------------------------------*/
591 void dump_discq DEFARGS((dq),
592 struct discq *dq)
593 {
594 if (!dq) {
595 printf("Dereference a NULL discq? I don't think so.\n");
596 return;
597 }
598
599 printf("dq_next = 0x%x, dq_prev = 0x%x, dq_rt = 0x%x,\n",dq->dq_next,
600 dq->dq_prev, dq->dq_rt);
601 printf("dq_queue = 0x%x.\n",dq->dq_queue);
602 /* Dump first mbuf chain? */
603 /*printf("dq_expire = %d (0x%x).\n",dq->dq_expire,dq->dq_expire);*/
604 }
605 #endif /* INET6 */
606
607 /*----------------------------------------------------------------------
608 * Dump a data buffer
609 ----------------------------------------------------------------------*/
610 void dump_buf DEFARGS((buf, len),
611 char *buf AND
612 int len)
613 {
614 int i;
615
616 printf("buf=0x%x len=%d:\n", (unsigned int)buf, len);
617 for (i = 0; i < len; i++) {
618 printf("0x%x ", (u_int8)*(buf+i));
619 }
620 printf("\n");
621 }
622
623
624 /*----------------------------------------------------------------------
625 * Dump a key_tblnode structrue
626 ----------------------------------------------------------------------*/
627 void dump_keytblnode DEFARGS((ktblnode),
628 struct key_tblnode *ktblnode)
629 {
630 if (!ktblnode) {
631 printf("NULL key table node pointer!\n");
632 return;
633 }
634 printf("solist=0x%x ", (unsigned int)ktblnode->solist);
635 printf("secassoc=0x%x ", (unsigned int)ktblnode->secassoc);
636 printf("next=0x%x\n", (unsigned int)ktblnode->next);
637 }
638
639 /*----------------------------------------------------------------------
640 * Dump an ipsec_assoc structure
641 ----------------------------------------------------------------------*/
642 void dump_secassoc DEFARGS((seca),
643 struct key_secassoc *seca)
644 {
645 u_int8 *p;
646 int i;
647
648 if (seca) {
649 printf("secassoc_len=%u ", seca->len);
650 printf("secassoc_type=%d ", seca->type);
651 printf("secassoc_state=0x%x\n", seca->state);
652 printf("secassoc_label=%u ", seca->label);
653 printf("secassoc_spi=0x%x ", (unsigned int)seca->spi);
654 printf("secassoc_keylen=%u\n", seca->keylen);
655 printf("secassoc_ivlen=%u ", seca->ivlen);
656 printf("secassoc_algorithm=%u ", seca->algorithm);
657 printf("secassoc_lifetype=%u\n", seca->lifetype);
658 printf("secassoc_iv=0x%x:\n", (unsigned int)seca->iv);
659 p = (u_int8 *)(seca->iv);
660 for (i = 0 ; i < seca->ivlen; i++)
661 printf("0x%x ", *(p + i));
662 printf("secassoc_key=0x%x:\n", (unsigned int)seca->key);
663 p = (u_int8 *)(seca->key);
664 for (i = 0 ; i < seca->keylen; i++)
665 printf("0x%x ", *(p + i));
666 printf("secassoc_lifetime1=%u ", (unsigned int)seca->lifetime1);
667 printf("secassoc_lifetime2=%u\n", (unsigned int)seca->lifetime2);
668 dump_smart_sockaddr(seca->src);
669 dump_smart_sockaddr(seca->dst);
670 dump_smart_sockaddr(seca->from);
671 } else
672 printf("can't dump null secassoc pointer!\n");
673 }
674
675
676 /*----------------------------------------------------------------------
677 * Dump a key_msghdr structure
678 ----------------------------------------------------------------------*/
679 void dump_keymsghdr DEFARGS((km),
680 struct key_msghdr *km)
681 {
682 if (km) {
683 printf("key_msglen=%d\n", km->key_msglen);
684 printf("key_msgvers=%d\n", km->key_msgvers);
685 printf("key_msgtype=%d\n", km->key_msgtype);
686 printf("key_pid=%d\n", km->key_pid);
687 printf("key_seq=%d\n", km->key_seq);
688 printf("key_errno=%d\n", km->key_errno);
689 printf("type=0x%x\n", (unsigned int)km->type);
690 printf("state=0x%x\n", (unsigned int)km->state);
691 printf("label=0x%x\n", (unsigned int)km->label);
692 printf("spi=0x%x\n", (unsigned int)km->spi);
693 printf("keylen=%d\n", km->keylen);
694 printf("ivlen=%d\n", km->ivlen);
695 printf("algorithm=%d\n", km->algorithm);
696 printf("lifetype=0x%x\n", (unsigned int)km->lifetype);
697 printf("lifetime1=%u\n", (unsigned int)km->lifetime1);
698 printf("lifetime2=%u\n", (unsigned int)km->lifetime2);
699 } else
700 printf("key_msghdr pointer is NULL!\n");
701 }
702
703
704 /*----------------------------------------------------------------------
705 * Dump a key_msgdata structure
706 ----------------------------------------------------------------------*/
707 void dump_keymsginfo DEFARGS((kp),
708 struct key_msgdata *kp)
709 {
710 int i;
711
712 if (kp) {
713 printf("src addr:\n");
714 dump_smart_sockaddr(kp->src);
715 printf("dest addr:\n");
716 dump_smart_sockaddr(kp->dst);
717 printf("from addr:\n");
718 dump_smart_sockaddr(kp->from);
719 #define dumpbuf(a, b) \
720 { for (i= 0; i < (b); i++) \
721 printf("0x%2x%s", (unsigned char)(*((caddr_t)a+i)),((i+1)%16)?" ":"\n");\
722 printf("\n"); }
723 printf("iv is:\n");
724 dumpbuf(kp->iv, kp->ivlen);
725 printf("key is:\n");
726 dumpbuf(kp->key, kp->keylen);
727 #undef dumpbuf
728 } else
729 printf("key_msgdata point is NULL!\n");
730 }
Cache object: 4a7fad400d183bfdd2405b771dedf6ed
|