1 --- a/networking/udhcp/common.c
2 +++ b/networking/udhcp/common.c
3 @@ -56,6 +56,8 @@ const struct dhcp_optflag dhcp_optflags[
5 { OPTION_STATIC_ROUTES , 0x79 }, /* DHCP_STATIC_ROUTES */
6 { OPTION_STATIC_ROUTES , 0xf9 }, /* DHCP_MS_STATIC_ROUTES */
7 + { OPTION_6RD , 0xd4 }, /* DHCP_6RD (RFC) */
8 + { OPTION_6RD , 0x96 }, /* DHCP_6RD (Comcast) */
9 { OPTION_STRING , 0xfc }, /* DHCP_WPAD */
11 /* Options below have no match in dhcp_option_strings[],
12 @@ -119,6 +121,8 @@ const char dhcp_option_strings[] ALIGN1
13 // is not handled yet by "string->option" conversion code:
14 "staticroutes" "\0"/* DHCP_STATIC_ROUTES */
15 "msstaticroutes""\0"/* DHCP_MS_STATIC_ROUTES */
16 + "ip6rd" "\0" /* DHCP_6RD (RFC) */
17 + "ip6rd" "\0" /* DHCP_6RD (Comcast) */
18 "wpad" "\0" /* DHCP_WPAD */
21 @@ -146,6 +150,7 @@ const uint8_t dhcp_option_lengths[] ALIG
23 /* Just like OPTION_STRING, we use minimum length here */
24 [OPTION_STATIC_ROUTES] = 5,
29 --- a/networking/udhcp/common.h
30 +++ b/networking/udhcp/common.h
31 @@ -88,6 +88,7 @@ enum {
36 #if ENABLE_FEATURE_UDHCP_RFC3397
37 OPTION_DNS_STRING, /* RFC1035 compressed domain name list */
39 --- a/networking/udhcp/dhcpc.c
40 +++ b/networking/udhcp/dhcpc.c
41 @@ -45,6 +45,7 @@ static const uint8_t len_of_option_as_st
42 [OPTION_IP ] = sizeof("255.255.255.255 "),
43 [OPTION_IP_PAIR ] = sizeof("255.255.255.255 ") * 2,
44 [OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "),
45 + [OPTION_6RD ] = sizeof("32 128 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 255.255.255.255 "),
47 #if ENABLE_FEATURE_UDHCP_RFC3397
48 [OPTION_DNS_STRING ] = 1, /* unused */
49 @@ -68,6 +69,23 @@ static int sprint_nip(char *dest, const
50 return sprintf(dest, "%s%u.%u.%u.%u", pre, ip[0], ip[1], ip[2], ip[3]);
53 +static int sprint_nip6(char *dest, const char *pre, const uint8_t *ip)
59 + len += sprintf(dest, "%s", pre);
61 + for (off = 0; off < 16; off += 2)
63 + move_from_unaligned16(word, &ip[off]);
64 + len += sprintf(dest+len, "%s%04X", off ? ":" : "", htons(word));
70 /* really simple implementation, just count the bits */
71 static int mton(uint32_t mask)
73 @@ -177,6 +195,70 @@ static NOINLINE char *xmalloc_optname_op
78 + /* Option binary format:
80 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
81 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
82 + * | OPTION_6RD | option-length | IPv4MaskLen | 6rdPrefixLen |
83 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
90 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
91 + * | 6rdBRIPv4Address(es) |
95 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
97 + * We convert it to a string "IPv4MaskLen 6rdPrefixLen 6rdPrefix 6rdBRIPv4Address"
100 + /* Sanity check: ensure that our length is at least 22 bytes, that
101 + * IPv4MaskLen is <= 32, 6rdPrefixLen <= 128 and that the sum of
102 + * (32 - IPv4MaskLen) + 6rdPrefixLen is less than or equal to 128.
103 + * If any of these requirements is not fulfilled, return with empty
106 + if ((len >= 22) && (*option <= 32) && (*(option+1) <= 128) &&
107 + (((32 - *option) + *(option+1)) <= 128))
110 + dest += sprintf(dest, "%u ", *option++);
114 + dest += sprintf(dest, "%u ", *option++);
118 + dest += sprint_nip6(dest, "", option);
122 + /* 6rdBRIPv4Addresses */
125 + dest += sprint_nip(dest, " ", option);
129 + /* the code to determine the option size fails to work with
130 + * lengths that are not a multiple of the minimum length,
131 + * adding all advertised 6rdBRIPv4Addresses here would
132 + * overflow the destination buffer, therefore skip the rest
141 #if ENABLE_FEATURE_UDHCP_RFC3397
142 case OPTION_DNS_STRING:
143 /* unpack option into dest; use ret for prefix (i.e., "optname=") */