1 --- a/networking/udhcp/common.c
2 +++ b/networking/udhcp/common.c
3 @@ -54,6 +54,8 @@ const struct dhcp_optflag dhcp_optflags[
4 { OPTION_SIP_SERVERS , 0x78 }, /* DHCP_SIP_SERVERS */
6 { OPTION_STATIC_ROUTES , 0x79 }, /* DHCP_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 @@ -114,6 +116,8 @@ const char dhcp_option_strings[] ALIGN1
13 // doesn't work in udhcpd.conf since OPTION_STATIC_ROUTES
14 // is not handled yet by "string->option" conversion code:
15 "staticroutes" "\0"/* DHCP_STATIC_ROUTES */
16 + "ip6rd" "\0" /* DHCP_6RD (RFC) */
17 + "ip6rd" "\0" /* DHCP_6RD (Comcast) */
18 "wpad" "\0" /* DHCP_WPAD */
21 @@ -141,6 +145,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/dhcpc.c
30 +++ b/networking/udhcp/dhcpc.c
31 @@ -45,6 +45,7 @@ static const uint8_t len_of_option_as_st
32 [OPTION_IP ] = sizeof("255.255.255.255 "),
33 [OPTION_IP_PAIR ] = sizeof("255.255.255.255 ") * 2,
34 [OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "),
35 + [OPTION_6RD ] = sizeof("32 128 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 255.255.255.255 "),
37 #if ENABLE_FEATURE_UDHCP_RFC3397
38 [OPTION_DNS_STRING ] = 1, /* unused */
39 @@ -68,6 +69,23 @@ static int sprint_nip(char *dest, const
40 return sprintf(dest, "%s%u.%u.%u.%u", pre, ip[0], ip[1], ip[2], ip[3]);
43 +static int sprint_nip6(char *dest, const char *pre, const uint8_t *ip)
49 + len += sprintf(dest, "%s", pre);
51 + for (off = 0; off < 16; off += 2)
53 + move_from_unaligned16(word, &ip[off]);
54 + len += sprintf(dest+len, "%s%04X", off ? ":" : "", htons(word));
60 /* really simple implementation, just count the bits */
61 static int mton(uint32_t mask)
63 @@ -177,6 +195,70 @@ static NOINLINE char *xmalloc_optname_op
68 + /* Option binary format:
70 + * 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
71 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72 + * | OPTION_6RD | option-length | IPv4MaskLen | 6rdPrefixLen |
73 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81 + * | 6rdBRIPv4Address(es) |
85 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
87 + * We convert it to a string "IPv4MaskLen 6rdPrefixLen 6rdPrefix 6rdBRIPv4Address"
90 + /* Sanity check: ensure that our length is at least 22 bytes, that
91 + * IPv4MaskLen is <= 32, 6rdPrefixLen <= 128 and that the sum of
92 + * (32 - IPv4MaskLen) + 6rdPrefixLen is less than or equal to 128.
93 + * If any of these requirements is not fulfilled, return with empty
96 + if ((len >= 22) && (*option <= 32) && (*(option+1) <= 128) &&
97 + (((32 - *option) + *(option+1)) <= 128))
100 + dest += sprintf(dest, "%u ", *option++);
104 + dest += sprintf(dest, "%u ", *option++);
108 + dest += sprint_nip6(dest, "", option);
112 + /* 6rdBRIPv4Addresses */
115 + dest += sprint_nip(dest, " ", option);
119 + /* the code to determine the option size fails to work with
120 + * lengths that are not a multiple of the minimum length,
121 + * adding all advertised 6rdBRIPv4Addresses here would
122 + * overflow the destination buffer, therefore skip the rest
131 #if ENABLE_FEATURE_UDHCP_RFC3397
132 case OPTION_DNS_STRING:
133 /* unpack option into dest; use ret for prefix (i.e., "optname=") */
134 --- a/networking/udhcp/common.h
135 +++ b/networking/udhcp/common.h
136 @@ -88,6 +88,7 @@ enum {
139 OPTION_STATIC_ROUTES,
141 #if ENABLE_FEATURE_UDHCP_RFC3397
142 OPTION_DNS_STRING, /* RFC1035 compressed domain name list */