print-dhcp6.c (236192) | print-dhcp6.c (252283) |
---|---|
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 --- 15 unchanged lines hidden (view full) --- 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 27 * SUCH DAMAGE. 28 */ 29/* 30 * RFC3315: DHCPv6 31 * supported DHCPv6 options: | 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 --- 15 unchanged lines hidden (view full) --- 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 27 * SUCH DAMAGE. 28 */ 29/* 30 * RFC3315: DHCPv6 31 * supported DHCPv6 options: |
32 * RFC3319, 33 * RFC3633, 34 * RFC3646, 35 * RFC3898, 36 * RFC4075, 37 * RFC4242, 38 * RFC4280, | 32 * RFC3319: Session Initiation Protocol (SIP) Servers options, 33 * RFC3633: IPv6 Prefix options, 34 * RFC3646: DNS Configuration options, 35 * RFC3898: Network Information Service (NIS) Configuration options, 36 * RFC4075: Simple Network Time Protocol (SNTP) Configuration option, 37 * RFC4242: Information Refresh Time option, 38 * RFC4280: Broadcast and Multicast Control Servers options, 39 * RFC6334: Dual-Stack Lite option, |
39 */ 40 41#ifndef lint 42static const char rcsid[] _U_ = 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 --- 118 unchanged lines hidden (view full) --- 165#define DH6OPT_NEW_POSIX_TIMEZONE 41 166#define DH6OPT_NEW_TZDB_TIMEZONE 42 167#define DH6OPT_ERO 43 168#define DH6OPT_LQ_QUERY 44 169#define DH6OPT_CLIENT_DATA 45 170#define DH6OPT_CLT_TIME 46 171#define DH6OPT_LQ_RELAY_DATA 47 172#define DH6OPT_LQ_CLIENT_LINK 48 | 40 */ 41 42#ifndef lint 43static const char rcsid[] _U_ = 44 "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.37 2008-02-06 10:26:09 guy Exp $"; 45#endif 46 47#ifdef HAVE_CONFIG_H --- 118 unchanged lines hidden (view full) --- 166#define DH6OPT_NEW_POSIX_TIMEZONE 41 167#define DH6OPT_NEW_TZDB_TIMEZONE 42 168#define DH6OPT_ERO 43 169#define DH6OPT_LQ_QUERY 44 170#define DH6OPT_CLIENT_DATA 45 171#define DH6OPT_CLT_TIME 46 172#define DH6OPT_LQ_RELAY_DATA 47 173#define DH6OPT_LQ_CLIENT_LINK 48 |
174#define DH6OPT_AFTR_NAME 64 |
|
173 174struct dhcp6opt { 175 u_int16_t dh6opt_type; 176 u_int16_t dh6opt_len; 177 /* type-dependent data follows */ 178}; 179 180static const char * --- 92 unchanged lines hidden (view full) --- 273 case DH6OPT_CLIENT_DATA: 274 return "LQ-client-data"; 275 case DH6OPT_CLT_TIME: 276 return "Clt-time"; 277 case DH6OPT_LQ_RELAY_DATA: 278 return "LQ-relay-data"; 279 case DH6OPT_LQ_CLIENT_LINK: 280 return "LQ-client-link"; | 175 176struct dhcp6opt { 177 u_int16_t dh6opt_type; 178 u_int16_t dh6opt_len; 179 /* type-dependent data follows */ 180}; 181 182static const char * --- 92 unchanged lines hidden (view full) --- 275 case DH6OPT_CLIENT_DATA: 276 return "LQ-client-data"; 277 case DH6OPT_CLT_TIME: 278 return "Clt-time"; 279 case DH6OPT_LQ_RELAY_DATA: 280 return "LQ-relay-data"; 281 case DH6OPT_LQ_CLIENT_LINK: 282 return "LQ-client-link"; |
283 case DH6OPT_AFTR_NAME: 284 return "AFTR-Name"; |
|
281 default: 282 snprintf(genstr, sizeof(genstr), "opt_%d", type); 283 return(genstr); 284 } 285} 286 287static const char * 288dhcp6stcode(int code) --- 44 unchanged lines hidden (view full) --- 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; | 285 default: 286 snprintf(genstr, sizeof(genstr), "opt_%d", type); 287 return(genstr); 288 } 289} 290 291static const char * 292dhcp6stcode(int code) --- 44 unchanged lines hidden (view full) --- 337 u_int authinfolen, authrealmlen; 338 339 if (cp == ep) 340 return; 341 while (cp < ep) { 342 if (ep < cp + sizeof(*dh6o)) 343 goto trunc; 344 dh6o = (struct dhcp6opt *)cp; |
345 TCHECK(*dh6o); |
|
341 optlen = EXTRACT_16BITS(&dh6o->dh6opt_len); 342 if (ep < cp + sizeof(*dh6o) + optlen) 343 goto trunc; 344 opttype = EXTRACT_16BITS(&dh6o->dh6opt_type); 345 printf(" (%s", dhcp6opt_name(opttype)); 346 switch (opttype) { 347 case DH6OPT_CLIENTID: 348 case DH6OPT_SERVERID: --- 56 unchanged lines hidden (view full) --- 405 } 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) { 412 /* there are sub-options */ | 346 optlen = EXTRACT_16BITS(&dh6o->dh6opt_len); 347 if (ep < cp + sizeof(*dh6o) + optlen) 348 goto trunc; 349 opttype = EXTRACT_16BITS(&dh6o->dh6opt_type); 350 printf(" (%s", dhcp6opt_name(opttype)); 351 switch (opttype) { 352 case DH6OPT_CLIENTID: 353 case DH6OPT_SERVERID: --- 56 unchanged lines hidden (view full) --- 410 } 411 tp = (u_char *)(dh6o + 1); 412 printf(" %s", ip6addr_string(&tp[0])); 413 printf(" pltime:%u vltime:%u", 414 EXTRACT_32BITS(&tp[16]), 415 EXTRACT_32BITS(&tp[20])); 416 if (optlen > 24) { 417 /* there are sub-options */ |
413 dhcp6opt_print(tp + 24, tp + 24 + optlen); | 418 dhcp6opt_print(tp + 24, tp + optlen); |
414 } 415 printf(")"); 416 break; 417 case DH6OPT_ORO: 418 case DH6OPT_ERO: 419 if (optlen % 2) { 420 printf(" ?)"); 421 break; --- 183 unchanged lines hidden (view full) --- 605 } 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) { 612 /* there are sub-options */ | 419 } 420 printf(")"); 421 break; 422 case DH6OPT_ORO: 423 case DH6OPT_ERO: 424 if (optlen % 2) { 425 printf(" ?)"); 426 break; --- 183 unchanged lines hidden (view full) --- 610 } 611 tp = (u_char *)(dh6o + 1); 612 printf(" IAID:%u T1:%u T2:%u", 613 EXTRACT_32BITS(&tp[0]), 614 EXTRACT_32BITS(&tp[4]), 615 EXTRACT_32BITS(&tp[8])); 616 if (optlen > 12) { 617 /* there are sub-options */ |
613 dhcp6opt_print(tp + 12, tp + 12 + optlen); | 618 dhcp6opt_print(tp + 12, tp + optlen); |
614 } 615 printf(")"); 616 break; 617 case DH6OPT_IA_TA: 618 if (optlen < 4) { 619 printf(" ?)"); 620 break; 621 } 622 tp = (u_char *)(dh6o + 1); 623 printf(" IAID:%u", EXTRACT_32BITS(tp)); 624 if (optlen > 4) { 625 /* there are sub-options */ | 619 } 620 printf(")"); 621 break; 622 case DH6OPT_IA_TA: 623 if (optlen < 4) { 624 printf(" ?)"); 625 break; 626 } 627 tp = (u_char *)(dh6o + 1); 628 printf(" IAID:%u", EXTRACT_32BITS(tp)); 629 if (optlen > 4) { 630 /* there are sub-options */ |
626 dhcp6opt_print(tp + 4, tp + 4 + optlen); | 631 dhcp6opt_print(tp + 4, tp + optlen); |
627 } 628 printf(")"); 629 break; 630 case DH6OPT_IA_PD_PREFIX: 631 if (optlen < 25) { 632 printf(" ?)"); 633 break; 634 } 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) { 641 /* there are sub-options */ | 632 } 633 printf(")"); 634 break; 635 case DH6OPT_IA_PD_PREFIX: 636 if (optlen < 25) { 637 printf(" ?)"); 638 break; 639 } 640 tp = (u_char *)(dh6o + 1); 641 printf(" %s/%d", ip6addr_string(&tp[9]), tp[8]); 642 printf(" pltime:%u vltime:%u", 643 EXTRACT_32BITS(&tp[0]), 644 EXTRACT_32BITS(&tp[4])); 645 if (optlen > 25) { 646 /* there are sub-options */ |
642 dhcp6opt_print(tp + 25, tp + 25 + optlen); | 647 dhcp6opt_print(tp + 25, tp + optlen); |
643 } 644 printf(")"); 645 break; 646 case DH6OPT_LIFETIME: 647 case DH6OPT_CLT_TIME: 648 if (optlen != 4) { 649 printf(" ?)"); 650 break; --- 56 unchanged lines hidden (view full) --- 707 printf(" %s ", ip6addr_string(&tp[0])); 708 /* 709 * Print hex dump first 10 characters. 710 */ 711 for (i = 16; i < optlen && i < 26; i++) 712 printf("%02x", tp[i]); 713 printf("...)"); 714 break; | 648 } 649 printf(")"); 650 break; 651 case DH6OPT_LIFETIME: 652 case DH6OPT_CLT_TIME: 653 if (optlen != 4) { 654 printf(" ?)"); 655 break; --- 56 unchanged lines hidden (view full) --- 712 printf(" %s ", ip6addr_string(&tp[0])); 713 /* 714 * Print hex dump first 10 characters. 715 */ 716 for (i = 16; i < optlen && i < 26; i++) 717 printf("%02x", tp[i]); 718 printf("...)"); 719 break; |
720 case DH6OPT_AFTR_NAME: 721 if (optlen < 3) { 722 printf(" ?)"); 723 break; 724 } 725 tp = (u_char *)(dh6o + 1); 726 int remain_len = optlen; 727 printf(" "); 728 /* Encoding is described in section 3.1 of RFC 1035 */ 729 int label_len; /* Label length */ 730 while (remain_len && *tp) { 731 label_len = *tp++; 732 if (label_len < remain_len - 1) { 733 printf("%.*s", label_len, tp); 734 tp += label_len; 735 remain_len -= (label_len + 1); 736 if(*tp) printf("."); 737 } else { 738 printf(" ?"); 739 break; 740 } 741 } 742 printf(")"); 743 break; |
|
715 default: 716 printf(")"); 717 break; 718 } 719 720 cp += sizeof(*dh6o) + optlen; 721 } 722 return; --- 118 unchanged lines hidden --- | 744 default: 745 printf(")"); 746 break; 747 } 748 749 cp += sizeof(*dh6o) + optlen; 750 } 751 return; --- 118 unchanged lines hidden --- |