Deleted Added
full compact
print-dhcp6.c (190207) print-dhcp6.c (214478)
1/*
2 * Copyright (C) 1998 and 1999 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 26 unchanged lines hidden (view full) ---

35 * RFC3898,
36 * RFC4075,
37 * RFC4242,
38 * RFC4280,
39 */
40
41#ifndef lint
42static const char rcsid[] _U_ =
1/*
2 * Copyright (C) 1998 and 1999 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 26 unchanged lines hidden (view full) ---

35 * RFC3898,
36 * RFC4075,
37 * RFC4242,
38 * RFC4280,
39 */
40
41#ifndef lint
42static const char rcsid[] _U_ =
43 "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.36.2.1 2008-02-06 10:26:27 guy Exp $";
43 "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.37 2008-02-06 10:26:09 guy Exp $";
44#endif
45
46#ifdef HAVE_CONFIG_H
47#include "config.h"
48#endif
49
50#include <tcpdump-stdinc.h>
51

--- 120 unchanged lines hidden (view full) ---

172#define DH6OPT_LQ_CLIENT_LINK 48
173
174struct dhcp6opt {
175 u_int16_t dh6opt_type;
176 u_int16_t dh6opt_len;
177 /* type-dependent data follows */
178};
179
44#endif
45
46#ifdef HAVE_CONFIG_H
47#include "config.h"
48#endif
49
50#include <tcpdump-stdinc.h>
51

--- 120 unchanged lines hidden (view full) ---

172#define DH6OPT_LQ_CLIENT_LINK 48
173
174struct dhcp6opt {
175 u_int16_t dh6opt_type;
176 u_int16_t dh6opt_len;
177 /* type-dependent data follows */
178};
179
180struct dhcp6_ia {
181 u_int16_t dh6opt_ia_type;
182 u_int16_t dh6opt_ia_len;
183 u_int32_t dh6opt_ia_iaid;
184 u_int32_t dh6opt_ia_t1;
185 u_int32_t dh6opt_ia_t2;
186};
187
188struct dhcp6_ia_addr {
189 u_int16_t dh6opt_ia_addr_type;
190 u_int16_t dh6opt_ia_addr_len;
191 struct in6_addr dh6opt_ia_addr_addr;
192 u_int32_t dh6opt_ia_addr_pltime;
193 u_int32_t dh6opt_ia_addr_vltime;
194} __attribute__ ((__packed__));
195
196struct dhcp6_ia_prefix {
197 u_int16_t dh6opt_ia_prefix_type;
198 u_int16_t dh6opt_ia_prefix_len;
199 u_int32_t dh6opt_ia_prefix_pltime;
200 u_int32_t dh6opt_ia_prefix_vltime;
201 u_int8_t dh6opt_ia_prefix_plen;
202 struct in6_addr dh6opt_ia_prefix_addr;
203} __attribute__ ((__packed__));
204
205struct dhcp6_auth {
206 u_int16_t dh6opt_auth_type;
207 u_int16_t dh6opt_auth_len;
208 u_int8_t dh6opt_auth_proto;
209 u_int8_t dh6opt_auth_alg;
210 u_int8_t dh6opt_auth_rdm;
211 u_int8_t dh6opt_auth_rdinfo[8];
212 /* authentication information follows */
213} __attribute__ ((__packed__));
214
215static const char *
216dhcp6opt_name(int type)
217{
218 static char genstr[sizeof("opt_65535") + 1]; /* XXX thread unsafe */
219
220 if (type > 65535)
180static const char *
181dhcp6opt_name(int type)
182{
183 static char genstr[sizeof("opt_65535") + 1]; /* XXX thread unsafe */
184
185 if (type > 65535)
221 return "INVALID option";
186 return "INVALID-option";
222
223 switch(type) {
224 case DH6OPT_CLIENTID:
187
188 switch(type) {
189 case DH6OPT_CLIENTID:
225 return "client ID";
190 return "client-ID";
226 case DH6OPT_SERVERID:
191 case DH6OPT_SERVERID:
227 return "server ID";
192 return "server-ID";
228 case DH6OPT_IA_NA:
229 return "IA_NA";
230 case DH6OPT_IA_TA:
231 return "IA_TA";
232 case DH6OPT_IA_ADDR:
233 return "IA_ADDR";
234 case DH6OPT_ORO:
193 case DH6OPT_IA_NA:
194 return "IA_NA";
195 case DH6OPT_IA_TA:
196 return "IA_TA";
197 case DH6OPT_IA_ADDR:
198 return "IA_ADDR";
199 case DH6OPT_ORO:
235 return "option request";
200 return "option-request";
236 case DH6OPT_PREFERENCE:
237 return "preference";
238 case DH6OPT_ELAPSED_TIME:
201 case DH6OPT_PREFERENCE:
202 return "preference";
203 case DH6OPT_ELAPSED_TIME:
239 return "elapsed time";
204 return "elapsed-time";
240 case DH6OPT_RELAY_MSG:
205 case DH6OPT_RELAY_MSG:
241 return "relay message";
206 return "relay-message";
242 case DH6OPT_AUTH:
243 return "authentication";
244 case DH6OPT_UNICAST:
207 case DH6OPT_AUTH:
208 return "authentication";
209 case DH6OPT_UNICAST:
245 return "server unicast";
210 return "server-unicast";
246 case DH6OPT_STATUS_CODE:
211 case DH6OPT_STATUS_CODE:
247 return "status code";
212 return "status-code";
248 case DH6OPT_RAPID_COMMIT:
213 case DH6OPT_RAPID_COMMIT:
249 return "rapid commit";
214 return "rapid-commit";
250 case DH6OPT_USER_CLASS:
215 case DH6OPT_USER_CLASS:
251 return "user class";
216 return "user-class";
252 case DH6OPT_VENDOR_CLASS:
217 case DH6OPT_VENDOR_CLASS:
253 return "vendor class";
218 return "vendor-class";
254 case DH6OPT_VENDOR_OPTS:
219 case DH6OPT_VENDOR_OPTS:
255 return "vendor-specific info";
220 return "vendor-specific-info";
256 case DH6OPT_INTERFACE_ID:
221 case DH6OPT_INTERFACE_ID:
257 return "interface ID";
222 return "interface-ID";
258 case DH6OPT_RECONF_MSG:
223 case DH6OPT_RECONF_MSG:
259 return "reconfigure message";
224 return "reconfigure-message";
260 case DH6OPT_RECONF_ACCEPT:
225 case DH6OPT_RECONF_ACCEPT:
261 return "reconfigure accept";
226 return "reconfigure-accept";
262 case DH6OPT_SIP_SERVER_D:
227 case DH6OPT_SIP_SERVER_D:
263 return "SIP servers domain";
228 return "SIP-servers-domain";
264 case DH6OPT_SIP_SERVER_A:
229 case DH6OPT_SIP_SERVER_A:
265 return "SIP servers address";
230 return "SIP-servers-address";
266 case DH6OPT_DNS:
267 return "DNS";
268 case DH6OPT_DNSNAME:
231 case DH6OPT_DNS:
232 return "DNS";
233 case DH6OPT_DNSNAME:
269 return "DNS name";
234 return "DNS-name";
270 case DH6OPT_IA_PD:
271 return "IA_PD";
272 case DH6OPT_IA_PD_PREFIX:
235 case DH6OPT_IA_PD:
236 return "IA_PD";
237 case DH6OPT_IA_PD_PREFIX:
273 return "IA_PD prefix";
238 return "IA_PD-prefix";
274 case DH6OPT_NTP_SERVERS:
239 case DH6OPT_NTP_SERVERS:
275 return "NTP Server";
240 return "NTP-Server";
276 case DH6OPT_LIFETIME:
277 return "lifetime";
278 case DH6OPT_NIS_SERVERS:
241 case DH6OPT_LIFETIME:
242 return "lifetime";
243 case DH6OPT_NIS_SERVERS:
279 return "NIS server";
244 return "NIS-server";
280 case DH6OPT_NISP_SERVERS:
245 case DH6OPT_NISP_SERVERS:
281 return "NIS+ server";
246 return "NIS+-server";
282 case DH6OPT_NIS_NAME:
247 case DH6OPT_NIS_NAME:
283 return "NIS domain name";
248 return "NIS-domain-name";
284 case DH6OPT_NISP_NAME:
249 case DH6OPT_NISP_NAME:
285 return "NIS+ domain name";
250 return "NIS+-domain-name";
286 case DH6OPT_BCMCS_SERVER_D:
251 case DH6OPT_BCMCS_SERVER_D:
287 return "BCMCS domain name";
252 return "BCMCS-domain-name";
288 case DH6OPT_BCMCS_SERVER_A:
253 case DH6OPT_BCMCS_SERVER_A:
289 return "BCMCS server";
254 return "BCMCS-server";
290 case DH6OPT_GEOCONF_CIVIC:
255 case DH6OPT_GEOCONF_CIVIC:
291 return "Geoconf Civic";
256 return "Geoconf-Civic";
292 case DH6OPT_REMOTE_ID:
257 case DH6OPT_REMOTE_ID:
293 return "Remote ID";
258 return "Remote-ID";
294 case DH6OPT_SUBSCRIBER_ID:
259 case DH6OPT_SUBSCRIBER_ID:
295 return "Subscriber ID";
260 return "Subscriber-ID";
296 case DH6OPT_CLIENT_FQDN:
261 case DH6OPT_CLIENT_FQDN:
297 return "Client FQDN";
262 return "Client-FQDN";
298 case DH6OPT_PANA_AGENT:
263 case DH6OPT_PANA_AGENT:
299 return "PANA agent";
264 return "PANA-agent";
300 case DH6OPT_NEW_POSIX_TIMEZONE:
265 case DH6OPT_NEW_POSIX_TIMEZONE:
301 return "POSIX timezone";
266 return "POSIX-timezone";
302 case DH6OPT_NEW_TZDB_TIMEZONE:
267 case DH6OPT_NEW_TZDB_TIMEZONE:
303 return "POSIX tz database";
268 return "POSIX-tz-database";
304 case DH6OPT_ERO:
269 case DH6OPT_ERO:
305 return "Echo request option";
270 return "Echo-request-option";
306 case DH6OPT_LQ_QUERY:
271 case DH6OPT_LQ_QUERY:
307 return "Lease query";
272 return "Lease-query";
308 case DH6OPT_CLIENT_DATA:
273 case DH6OPT_CLIENT_DATA:
309 return "LQ client data";
274 return "LQ-client-data";
310 case DH6OPT_CLT_TIME:
275 case DH6OPT_CLT_TIME:
311 return "Clt time";
276 return "Clt-time";
312 case DH6OPT_LQ_RELAY_DATA:
277 case DH6OPT_LQ_RELAY_DATA:
313 return "LQ relay data";
278 return "LQ-relay-data";
314 case DH6OPT_LQ_CLIENT_LINK:
279 case DH6OPT_LQ_CLIENT_LINK:
315 return "LQ client link";
280 return "LQ-client-link";
316 default:
317 snprintf(genstr, sizeof(genstr), "opt_%d", type);
318 return(genstr);
319 }
320}
321
322static const char *
323dhcp6stcode(int code)

--- 35 unchanged lines hidden (view full) ---

359static void
360dhcp6opt_print(const u_char *cp, const u_char *ep)
361{
362 struct dhcp6opt *dh6o;
363 u_char *tp;
364 size_t i;
365 u_int16_t opttype;
366 size_t optlen;
281 default:
282 snprintf(genstr, sizeof(genstr), "opt_%d", type);
283 return(genstr);
284 }
285}
286
287static const char *
288dhcp6stcode(int code)

--- 35 unchanged lines hidden (view full) ---

324static void
325dhcp6opt_print(const u_char *cp, const u_char *ep)
326{
327 struct dhcp6opt *dh6o;
328 u_char *tp;
329 size_t i;
330 u_int16_t opttype;
331 size_t optlen;
367 u_int16_t val16;
368 u_int32_t val32;
369 struct dhcp6_ia ia;
370 struct dhcp6_ia_prefix ia_prefix;
371 struct dhcp6_ia_addr ia_addr;
372 struct dhcp6_auth authopt;
332 u_int8_t auth_proto;
373 u_int authinfolen, authrealmlen;
374
375 if (cp == ep)
376 return;
377 while (cp < ep) {
378 if (ep < cp + sizeof(*dh6o))
379 goto trunc;
380 dh6o = (struct dhcp6opt *)cp;

--- 52 unchanged lines hidden (view full) ---

433 }
434 break;
435 default:
436 printf(" type %d)", EXTRACT_16BITS(tp));
437 break;
438 }
439 break;
440 case DH6OPT_IA_ADDR:
333 u_int authinfolen, authrealmlen;
334
335 if (cp == ep)
336 return;
337 while (cp < ep) {
338 if (ep < cp + sizeof(*dh6o))
339 goto trunc;
340 dh6o = (struct dhcp6opt *)cp;

--- 52 unchanged lines hidden (view full) ---

393 }
394 break;
395 default:
396 printf(" type %d)", EXTRACT_16BITS(tp));
397 break;
398 }
399 break;
400 case DH6OPT_IA_ADDR:
441 if (optlen < sizeof(ia_addr) - 4) {
401 if (optlen < 24) {
402 /*(*/
442 printf(" ?)");
443 break;
444 }
403 printf(" ?)");
404 break;
405 }
445 memcpy(&ia_addr, (u_char *)dh6o, sizeof(ia_addr));
446 printf(" %s",
447 ip6addr_string(&ia_addr.dh6opt_ia_addr_addr));
448 ia_addr.dh6opt_ia_addr_pltime =
449 ntohl(ia_addr.dh6opt_ia_addr_pltime);
450 ia_addr.dh6opt_ia_addr_vltime =
451 ntohl(ia_addr.dh6opt_ia_addr_vltime);
452 printf(" pltime:%lu vltime:%lu",
453 (unsigned long)ia_addr.dh6opt_ia_addr_pltime,
454 (unsigned long)ia_addr.dh6opt_ia_addr_vltime);
455 if (optlen > sizeof(ia_addr) - 4) {
406 tp = (u_char *)(dh6o + 1);
407 printf(" %s", ip6addr_string(&tp[0]));
408 printf(" pltime:%u vltime:%u",
409 EXTRACT_32BITS(&tp[16]),
410 EXTRACT_32BITS(&tp[20]));
411 if (optlen > 24) {
456 /* there are sub-options */
412 /* there are sub-options */
457 dhcp6opt_print((u_char *)dh6o +
458 sizeof(ia_addr),
459 (u_char *)(dh6o + 1) + optlen);
413 dhcp6opt_print(tp + 24, tp + 24 + optlen);
460 }
461 printf(")");
462 break;
463 case DH6OPT_ORO:
464 case DH6OPT_ERO:
465 if (optlen % 2) {
466 printf(" ?)");
467 break;
468 }
469 tp = (u_char *)(dh6o + 1);
470 for (i = 0; i < optlen; i += 2) {
414 }
415 printf(")");
416 break;
417 case DH6OPT_ORO:
418 case DH6OPT_ERO:
419 if (optlen % 2) {
420 printf(" ?)");
421 break;
422 }
423 tp = (u_char *)(dh6o + 1);
424 for (i = 0; i < optlen; i += 2) {
471 u_int16_t opt;
472
473 memcpy(&opt, &tp[i], sizeof(opt));
474 printf(" %s", dhcp6opt_name(ntohs(opt)));
425 printf(" %s",
426 dhcp6opt_name(EXTRACT_16BITS(&tp[i])));
475 }
476 printf(")");
477 break;
478 case DH6OPT_PREFERENCE:
479 if (optlen != 1) {
480 printf(" ?)");
481 break;
482 }
427 }
428 printf(")");
429 break;
430 case DH6OPT_PREFERENCE:
431 if (optlen != 1) {
432 printf(" ?)");
433 break;
434 }
483 printf(" %d)", *((u_char *)(dh6o + 1) + 1));
435 tp = (u_char *)(dh6o + 1);
436 printf(" %d)", *tp);
484 break;
485 case DH6OPT_ELAPSED_TIME:
486 if (optlen != 2) {
487 printf(" ?)");
488 break;
489 }
437 break;
438 case DH6OPT_ELAPSED_TIME:
439 if (optlen != 2) {
440 printf(" ?)");
441 break;
442 }
490 memcpy(&val16, dh6o + 1, sizeof(val16));
491 val16 = ntohs(val16);
492 printf(" %d)", (int)val16);
443 tp = (u_char *)(dh6o + 1);
444 printf(" %d)", EXTRACT_16BITS(tp));
493 break;
494 case DH6OPT_RELAY_MSG:
495 printf(" (");
445 break;
446 case DH6OPT_RELAY_MSG:
447 printf(" (");
496 dhcp6_print((const u_char *)(dh6o + 1), optlen);
448 tp = (u_char *)(dh6o + 1);
449 dhcp6_print(tp, optlen);
497 printf(")");
498 break;
499 case DH6OPT_AUTH:
450 printf(")");
451 break;
452 case DH6OPT_AUTH:
500 if (optlen < sizeof(authopt) - sizeof(*dh6o)) {
453 if (optlen < 11) {
501 printf(" ?)");
502 break;
503 }
454 printf(" ?)");
455 break;
456 }
504 memcpy(&authopt, dh6o, sizeof(authopt));
505 switch (authopt.dh6opt_auth_proto) {
457 tp = (u_char *)(dh6o + 1);
458 auth_proto = *tp;
459 switch (auth_proto) {
506 case DH6OPT_AUTHPROTO_DELAYED:
507 printf(" proto: delayed");
508 break;
509 case DH6OPT_AUTHPROTO_RECONFIG:
510 printf(" proto: reconfigure");
511 break;
512 default:
460 case DH6OPT_AUTHPROTO_DELAYED:
461 printf(" proto: delayed");
462 break;
463 case DH6OPT_AUTHPROTO_RECONFIG:
464 printf(" proto: reconfigure");
465 break;
466 default:
513 printf(" proto: %d",
514 authopt.dh6opt_auth_proto);
467 printf(" proto: %d", auth_proto);
515 break;
516 }
468 break;
469 }
517 switch (authopt.dh6opt_auth_alg) {
470 tp++;
471 switch (*tp) {
518 case DH6OPT_AUTHALG_HMACMD5:
519 /* XXX: may depend on the protocol */
520 printf(", alg: HMAC-MD5");
521 break;
522 default:
472 case DH6OPT_AUTHALG_HMACMD5:
473 /* XXX: may depend on the protocol */
474 printf(", alg: HMAC-MD5");
475 break;
476 default:
523 printf(", alg: %d", authopt.dh6opt_auth_alg);
477 printf(", alg: %d", *tp);
524 break;
525 }
478 break;
479 }
526 switch (authopt.dh6opt_auth_rdm) {
480 tp++;
481 switch (*tp) {
527 case DH6OPT_AUTHRDM_MONOCOUNTER:
528 printf(", RDM: mono");
529 break;
530 default:
482 case DH6OPT_AUTHRDM_MONOCOUNTER:
483 printf(", RDM: mono");
484 break;
485 default:
531 printf(", RDM: %d", authopt.dh6opt_auth_rdm);
486 printf(", RDM: %d", *tp);
532 break;
533 }
487 break;
488 }
534 tp = (u_char *)&authopt.dh6opt_auth_rdinfo;
489 tp++;
535 printf(", RD:");
490 printf(", RD:");
536 for (i = 0; i < 4; i++, tp += sizeof(val16))
491 for (i = 0; i < 4; i++, tp += 2)
537 printf(" %04x", EXTRACT_16BITS(tp));
538
539 /* protocol dependent part */
492 printf(" %04x", EXTRACT_16BITS(tp));
493
494 /* protocol dependent part */
540 tp = (u_char *)dh6o + sizeof(authopt);
541 authinfolen =
542 optlen + sizeof(*dh6o) - sizeof(authopt);
543 switch (authopt.dh6opt_auth_proto) {
495 authinfolen = optlen - 11;
496 switch (auth_proto) {
544 case DH6OPT_AUTHPROTO_DELAYED:
545 if (authinfolen == 0)
546 break;
547 if (authinfolen < 20) {
548 printf(" ??");
549 break;
550 }
551 authrealmlen = authinfolen - 20;

--- 39 unchanged lines hidden (view full) ---

591 printf(")");
592 break;
593 case DH6OPT_INTERFACE_ID:
594 case DH6OPT_SUBSCRIBER_ID:
595 /*
596 * Since we cannot predict the encoding, print hex dump
597 * at most 10 characters.
598 */
497 case DH6OPT_AUTHPROTO_DELAYED:
498 if (authinfolen == 0)
499 break;
500 if (authinfolen < 20) {
501 printf(" ??");
502 break;
503 }
504 authrealmlen = authinfolen - 20;

--- 39 unchanged lines hidden (view full) ---

544 printf(")");
545 break;
546 case DH6OPT_INTERFACE_ID:
547 case DH6OPT_SUBSCRIBER_ID:
548 /*
549 * Since we cannot predict the encoding, print hex dump
550 * at most 10 characters.
551 */
552 tp = (u_char *)(dh6o + 1);
599 printf(" ");
600 for (i = 0; i < optlen && i < 10; i++)
553 printf(" ");
554 for (i = 0; i < optlen && i < 10; i++)
601 printf("%02x", ((u_char *)(dh6o + 1))[i]);
555 printf("%02x", tp[i]);
602 printf("...)");
603 break;
604 case DH6OPT_RECONF_MSG:
605 tp = (u_char *)(dh6o + 1);
606 switch (*tp) {
607 case DH6_RENEW:
608 printf(" for renew)");
609 break;

--- 25 unchanged lines hidden (view full) ---

635 printf(" %s", ip6addr_string(&tp[i]));
636 printf(")");
637 break;
638 case DH6OPT_STATUS_CODE:
639 if (optlen < 2) {
640 printf(" ?)");
641 break;
642 }
556 printf("...)");
557 break;
558 case DH6OPT_RECONF_MSG:
559 tp = (u_char *)(dh6o + 1);
560 switch (*tp) {
561 case DH6_RENEW:
562 printf(" for renew)");
563 break;

--- 25 unchanged lines hidden (view full) ---

589 printf(" %s", ip6addr_string(&tp[i]));
590 printf(")");
591 break;
592 case DH6OPT_STATUS_CODE:
593 if (optlen < 2) {
594 printf(" ?)");
595 break;
596 }
643 memcpy(&val16, (u_char *)(dh6o + 1), sizeof(val16));
644 val16 = ntohs(val16);
645 printf(" %s)", dhcp6stcode(val16));
597 tp = (u_char *)(dh6o + 1);
598 printf(" %s)", dhcp6stcode(EXTRACT_16BITS(&tp[0])));
646 break;
647 case DH6OPT_IA_NA:
648 case DH6OPT_IA_PD:
599 break;
600 case DH6OPT_IA_NA:
601 case DH6OPT_IA_PD:
649 if (optlen < sizeof(ia) - 4) {
602 if (optlen < 12) {
650 printf(" ?)");
651 break;
652 }
603 printf(" ?)");
604 break;
605 }
653 memcpy(&ia, (u_char *)dh6o, sizeof(ia));
654 ia.dh6opt_ia_iaid = ntohl(ia.dh6opt_ia_iaid);
655 ia.dh6opt_ia_t1 = ntohl(ia.dh6opt_ia_t1);
656 ia.dh6opt_ia_t2 = ntohl(ia.dh6opt_ia_t2);
657 printf(" IAID:%lu T1:%lu T2:%lu",
658 (unsigned long)ia.dh6opt_ia_iaid,
659 (unsigned long)ia.dh6opt_ia_t1,
660 (unsigned long)ia.dh6opt_ia_t2);
661 if (optlen > sizeof(ia) - 4) {
606 tp = (u_char *)(dh6o + 1);
607 printf(" IAID:%u T1:%u T2:%u",
608 EXTRACT_32BITS(&tp[0]),
609 EXTRACT_32BITS(&tp[4]),
610 EXTRACT_32BITS(&tp[8]));
611 if (optlen > 12) {
662 /* there are sub-options */
612 /* there are sub-options */
663 dhcp6opt_print((u_char *)dh6o + sizeof(ia),
664 (u_char *)(dh6o + 1) + optlen);
613 dhcp6opt_print(tp + 12, tp + 12 + optlen);
665 }
666 printf(")");
667 break;
668 case DH6OPT_IA_TA:
669 if (optlen < 4) {
670 printf(" ?)");
671 break;
672 }
614 }
615 printf(")");
616 break;
617 case DH6OPT_IA_TA:
618 if (optlen < 4) {
619 printf(" ?)");
620 break;
621 }
673 memcpy(&val32, dh6o + 1, sizeof(val32));
674 val32 = ntohl(val32);
675 printf(" IAID:%lu", (unsigned long)val32);
622 tp = (u_char *)(dh6o + 1);
623 printf(" IAID:%u", EXTRACT_32BITS(tp));
676 if (optlen > 4) {
677 /* there are sub-options */
624 if (optlen > 4) {
625 /* there are sub-options */
678 dhcp6opt_print((u_char *)(dh6o + 1) + 4,
679 (u_char *)(dh6o + 1) + optlen);
626 dhcp6opt_print(tp + 4, tp + 4 + optlen);
680 }
681 printf(")");
682 break;
683 case DH6OPT_IA_PD_PREFIX:
627 }
628 printf(")");
629 break;
630 case DH6OPT_IA_PD_PREFIX:
684 if (optlen < sizeof(ia_prefix) - 4) {
631 if (optlen < 25) {
685 printf(" ?)");
686 break;
687 }
632 printf(" ?)");
633 break;
634 }
688 memcpy(&ia_prefix, (u_char *)dh6o, sizeof(ia_prefix));
689 printf(" %s/%d",
690 ip6addr_string(&ia_prefix.dh6opt_ia_prefix_addr),
691 ia_prefix.dh6opt_ia_prefix_plen);
692 ia_prefix.dh6opt_ia_prefix_pltime =
693 ntohl(ia_prefix.dh6opt_ia_prefix_pltime);
694 ia_prefix.dh6opt_ia_prefix_vltime =
695 ntohl(ia_prefix.dh6opt_ia_prefix_vltime);
696 printf(" pltime:%lu vltime:%lu",
697 (unsigned long)ia_prefix.dh6opt_ia_prefix_pltime,
698 (unsigned long)ia_prefix.dh6opt_ia_prefix_vltime);
699 if (optlen > sizeof(ia_prefix) - 4) {
635 tp = (u_char *)(dh6o + 1);
636 printf(" %s/%d", ip6addr_string(&tp[9]), tp[8]);
637 printf(" pltime:%u vltime:%u",
638 EXTRACT_32BITS(&tp[0]),
639 EXTRACT_32BITS(&tp[4]));
640 if (optlen > 25) {
700 /* there are sub-options */
641 /* there are sub-options */
701 dhcp6opt_print((u_char *)dh6o +
702 sizeof(ia_prefix),
703 (u_char *)(dh6o + 1) + optlen);
642 dhcp6opt_print(tp + 25, tp + 25 + optlen);
704 }
705 printf(")");
706 break;
707 case DH6OPT_LIFETIME:
708 case DH6OPT_CLT_TIME:
709 if (optlen != 4) {
710 printf(" ?)");
711 break;
712 }
643 }
644 printf(")");
645 break;
646 case DH6OPT_LIFETIME:
647 case DH6OPT_CLT_TIME:
648 if (optlen != 4) {
649 printf(" ?)");
650 break;
651 }
713 memcpy(&val32, dh6o + 1, sizeof(val32));
714 val32 = ntohl(val32);
715 printf(" %d)", (int)val32);
652 tp = (u_char *)(dh6o + 1);
653 printf(" %d)", EXTRACT_32BITS(tp));
716 break;
717 case DH6OPT_REMOTE_ID:
718 if (optlen < 4) {
719 printf(" ?)");
720 break;
721 }
722 tp = (u_char *)(dh6o + 1);
654 break;
655 case DH6OPT_REMOTE_ID:
656 if (optlen < 4) {
657 printf(" ?)");
658 break;
659 }
660 tp = (u_char *)(dh6o + 1);
723 memcpy(&val32, &tp[0], sizeof(val32));
724 val32 = ntohl(val32);
725 printf(" %d ", (int)val32);
661 printf(" %d ", EXTRACT_32BITS(tp));
726 /*
727 * Print hex dump first 10 characters.
728 */
729 for (i = 4; i < optlen && i < 14; i++)
730 printf("%02x", tp[i]);
731 printf("...)");
732 break;
733 case DH6OPT_LQ_QUERY:

--- 16 unchanged lines hidden (view full) ---

750 printf(" %s", ip6addr_string(&tp[1]));
751 if (optlen > 17) {
752 /* there are query-options */
753 dhcp6opt_print(tp + 17, tp + optlen);
754 }
755 printf(")");
756 break;
757 case DH6OPT_CLIENT_DATA:
662 /*
663 * Print hex dump first 10 characters.
664 */
665 for (i = 4; i < optlen && i < 14; i++)
666 printf("%02x", tp[i]);
667 printf("...)");
668 break;
669 case DH6OPT_LQ_QUERY:

--- 16 unchanged lines hidden (view full) ---

686 printf(" %s", ip6addr_string(&tp[1]));
687 if (optlen > 17) {
688 /* there are query-options */
689 dhcp6opt_print(tp + 17, tp + optlen);
690 }
691 printf(")");
692 break;
693 case DH6OPT_CLIENT_DATA:
694 tp = (u_char *)(dh6o + 1);
758 if (optlen > 0) {
759 /* there are encapsulated options */
695 if (optlen > 0) {
696 /* there are encapsulated options */
760 dhcp6opt_print((u_char *)(dh6o + 1),
761 (u_char *)(dh6o + 1) + optlen);
697 dhcp6opt_print(tp, tp + optlen);
762 }
763 printf(")");
764 break;
765 case DH6OPT_LQ_RELAY_DATA:
766 if (optlen < 16) {
767 printf(" ?)");
768 break;
769 }

--- 135 unchanged lines hidden ---
698 }
699 printf(")");
700 break;
701 case DH6OPT_LQ_RELAY_DATA:
702 if (optlen < 16) {
703 printf(" ?)");
704 break;
705 }

--- 135 unchanged lines hidden ---