1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*
%%% copyright-nrl-95
This software is Copyright 1995-1998 by Randall Atkinson, Ronald Lee,
Daniel McDonald, Bao Phan, and Chris Winters. All Rights Reserved. All
rights under this copyright have been assigned to the US Naval Research
Laboratory (NRL). The NRL Copyright Notice and License Agreement Version
1.1 (January 17, 1995) applies to this software.
You should have received a copy of the license with this software. If you
didn't get a copy, you may request one from <license@ipv6.nrl.navy.mil>.
*/
#include <sys/osdep.h>
#ifdef OSDEP_BSD
#include <netinet6/ipv6.h>
#include <netinet6/ipv6_icmp.h>
#endif /* OSDEP_BSD */
#include <sys/debug.h>
/*
* Globals
*/
/*----------------------------------------------------------------------
* Dump an IPv6 address. Don't compress 0's out because of debugging.
----------------------------------------------------------------------*/
void dump_in6_addr(struct in6_addr *in6_addr)
{
uint16_t *p = (uint16_t *)in6_addr;
int i = 0;
if (!in6_addr) {
printf("Dereference a NULL in6_addr? I don't think so.\n");
return;
}
while (i++ < 7)
printf("%04x:", ntohs(*(p++)));
printf("%04x\n", ntohs(*p));
}
/*----------------------------------------------------------------------
* Dump an IPv6 socket address.
----------------------------------------------------------------------*/
void dump_sockaddr_in6(struct sockaddr_in6 *sin6)
{
printf("sockaddr_in6 at %08x: ", OSDEP_PCAST(sin6));
if (!sin6)
goto ret;
#if OSDEP_SALEN
printf("len=%d, ", sin6->sin6_len);
#endif /* OSDEP_SALEN */
printf("family=%d, port=%d, flowinfo=%lx, addr=", sin6->sin6_family, ntohs(sin6->sin6_port), (unsigned long)ntohl(sin6->sin6_flowinfo));
dump_in6_addr(&sin6->sin6_addr);
ret:
printf("\n");
};
#ifdef OSDEP_BSD
/*----------------------------------------------------------------------
* Dump an IPv6 header.
----------------------------------------------------------------------*/
void dump_ipv6(struct ipv6 *ipv6)
{
if (!ipv6) {
printf("Dereference a NULL ipv6? I don't think so.\n");
return;
}
printf("Vers & flow label (conv to host order) 0x%x\n",
(unsigned int)htonl(ipv6->ipv6_versfl));
printf("Length (conv) = %d, nexthdr = %d, hoplimit = %d.\n",
htons(ipv6->ipv6_length),ipv6->ipv6_nexthdr,ipv6->ipv6_hoplimit);
printf("Src: ");
dump_in6_addr(&ipv6->ipv6_src);
printf("Dst: ");
dump_in6_addr(&ipv6->ipv6_dst);
}
/*----------------------------------------------------------------------
* Dump an ICMPv6 header. This function is not very smart beyond the
* type, code, and checksum.
----------------------------------------------------------------------*/
void dump_ipv6_icmp(struct ipv6_icmp *icp)
{
if (!icp) {
printf("Dereference a NULL ipv6_icmp? I don't think so.\n");
return;
}
printf("type %d, code %d, cksum (conv) = 0x%x\n",icp->icmp_type,
icp->icmp_code,htons(icp->icmp_cksum));
printf("First four bytes: 0x%x", (unsigned int)htonl(icp->icmp_unused));
printf("Next four bytes: 0x");
debug_dump_buf((void *)icp->icmp_echodata, 4);
printf("\n");
}
#ifdef KERNEL
/*----------------------------------------------------------------------
* Dump an IPv6 discovery queue structure.
----------------------------------------------------------------------*/
void dump_discq(struct discq *dq)
{
if (!dq) {
printf("Dereference a NULL discq? I don't think so.\n");
return;
}
printf("dq_next = 0x%lx, dq_prev = 0x%lx, dq_rt = 0x%lx,\n", (unsigned long)dq->dq_next,
(unsigned long)dq->dq_prev, (unsigned long)dq->dq_rt);
printf("dq_queue = 0x%lx.\n", (unsigned long)dq->dq_queue);
/* Dump first mbuf chain? */
/*printf("dq_expire = %d (0x%x).\n",dq->dq_expire,dq->dq_expire);*/
}
#endif /* KERNEL */
#endif /* OSDEP_BSD */
|