]>
The Tcpdump Group git mirrors - tcpdump/blob - print-dhcp6.c
2 * Copyright (C) 1998 and 1999 WIDE Project.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the project nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * draft-ietf-dhc-dhcpv6-22.txt
34 static const char rcsid
[] =
35 "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.16 2002-01-19 08:05:54 guy Exp $";
42 #include <sys/param.h>
44 #include <sys/socket.h>
49 #include <netinet/in.h>
54 #include <arpa/inet.h>
56 #include "interface.h"
57 #include "addrtoname.h"
60 #define DH6ERR_FAILURE 16
61 #define DH6ERR_AUTHFAIL 17
62 #define DH6ERR_POORLYFORMED 18
63 #define DH6ERR_UNAVAIL 19
64 #define DH6ERR_OPTUNAVAIL 20
68 #define DH6_INFORM_REQ 11
70 /* DHCP6 base packet format */
76 struct in6_addr dh6_servaddr
;
78 } __attribute__ ((__packed__
));
79 #define dh6_msgtype dh6_msgtypexid.m
80 #define dh6_xid dh6_msgtypexid.x
81 #define DH6_XIDMASK 0x00ffffff
84 #define DH6OPT_DUID 1 /* TBD */
85 #define DH6OPT_DNS 11 /* TBD */
87 u_int16_t dh6opt_type
;
89 /* type-dependent data follows */
90 } __attribute__ ((__packed__
));
93 dhcp6opt_print(u_char
*cp
, u_char
*ep
)
95 struct dhcp6opt
*dh6o
;
103 if (ep
- cp
< sizeof(*dh6o
))
105 dh6o
= (struct dhcp6opt
*)cp
;
106 optlen
= ntohs(dh6o
->dh6opt_len
);
107 if (ep
- cp
< sizeof(*dh6o
) + optlen
)
109 switch (ntohs(dh6o
->dh6opt_type
)) {
111 printf(" (duid"); /*)*/
117 tp
= (u_char
*)(dh6o
+ 1);
118 switch (ntohs(*(u_int16_t
*)tp
)) {
120 if (optlen
>= 2 + 6) {
121 printf(" hwaddr/time time %u type %u ",
122 ntohl(*(u_int32_t
*)&tp
[2]),
123 ntohs(*(u_int16_t
*)&tp
[6]));
124 for (i
= 8; i
< optlen
; i
++)
125 printf("%02x", tp
[i
]);
134 if (optlen
>= 2 + 8) {
136 for (i
= 2; i
< 2 + 8; i
++)
137 printf("%02x", tp
[i
]);
146 if (optlen
>= 2 + 2) {
147 printf(" hwaddr type %u ",
148 ntohs(*(u_int16_t
*)&tp
[2]));
149 for (i
= 4; i
< optlen
; i
++)
150 printf("%02x", tp
[i
]);
160 printf(" (dnsserver"); /*)*/
166 tp
= (u_char
*)(dh6o
+ 1);
167 for (i
= 0; i
< optlen
; i
+= 16)
168 printf(" %s", ip6addr_string(&tp
[i
]));
172 printf(" (opt-%u)", ntohs(dh6o
->dh6opt_type
));
176 cp
+= sizeof(*dh6o
) + optlen
;
181 printf("[|dhcp6ext]");
185 * Print dhcp6 packets
188 dhcp6_print(register const u_char
*cp
, u_int length
,
189 u_int16_t sport
, u_int16_t dport
)
198 ep
= (u_char
*)snapend
;
200 dh6
= (struct dhcp6
*)cp
;
201 TCHECK(dh6
->dh6_servaddr
);
202 switch (dh6
->dh6_msgtype
) {
218 printf(" msgtype-%u", dh6
->dh6_msgtype
);
222 /* XXX relay agent messages have to be handled differently */
225 printf(" %s (", name
); /*)*/
227 printf(" msgtype-%u (", dh6
->dh6_msgtype
); /*)*/
228 printf("xid=%x", ntohl(dh6
->dh6_xid
) & DH6_XIDMASK
);
229 printf(" server=%s", ip6addr_string(&dh6
->dh6_servaddr
));
230 extp
= (u_char
*)(dh6
+ 1);
231 dhcp6opt_print(extp
, ep
);