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