1 --- a/networking/udhcp/common.c
2 +++ b/networking/udhcp/common.c
3 @@ -54,6 +54,7 @@ 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 */
8 { OPTION_STRING , 0xfc }, /* DHCP_WPAD */
10 /* Options below have no match in dhcp_option_strings[],
11 @@ -114,6 +115,7 @@ const char dhcp_option_strings[] ALIGN1
12 // doesn't work in udhcpd.conf since OPTION_STATIC_ROUTES
13 // is not handled yet by "string->option" conversion code:
14 "staticroutes" "\0"/* DHCP_STATIC_ROUTES */
15 + "ip6rd" "\0" /* DHCP_6RD */
16 "wpad" "\0" /* DHCP_WPAD */
19 @@ -141,6 +143,7 @@ const uint8_t dhcp_option_lengths[] ALIG
21 /* Just like OPTION_STRING, we use minimum length here */
22 [OPTION_STATIC_ROUTES] = 5,
27 --- a/networking/udhcp/dhcpc.c
28 +++ b/networking/udhcp/dhcpc.c
29 @@ -45,6 +45,7 @@ static const uint8_t len_of_option_as_st
30 [OPTION_IP ] = sizeof("255.255.255.255 "),
31 [OPTION_IP_PAIR ] = sizeof("255.255.255.255 ") * 2,
32 [OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "),
33 + [OPTION_6RD ] = sizeof("32 128 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 255.255.255.255 "),
35 #if ENABLE_FEATURE_UDHCP_RFC3397
36 [OPTION_DNS_STRING ] = 1, /* unused */
37 @@ -68,6 +69,23 @@ static int sprint_nip(char *dest, const
38 return sprintf(dest, "%s%u.%u.%u.%u", pre, ip[0], ip[1], ip[2], ip[3]);
41 +static int sprint_nip6(char *dest, const char *pre, const uint8_t *ip)
47 + len += sprintf(dest, "%s", pre);
49 + for (off = 0; off < 16; off += 2)
51 + move_from_unaligned16(word, &ip[off]);
52 + len += sprintf(dest+len, "%s%04X", off ? ":" : "", htons(word));
58 /* really simple implementation, just count the bits */
59 static int mton(uint32_t mask)
61 @@ -177,6 +195,70 @@ static NOINLINE char *xmalloc_optname_op
66 + /* Option binary format:
68 + * 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
69 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70 + * | OPTION_6RD | option-length | IPv4MaskLen | 6rdPrefixLen |
71 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
78 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
79 + * | 6rdBRIPv4Address(es) |
83 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
85 + * We convert it to a string "IPv4MaskLen 6rdPrefixLen 6rdPrefix 6rdBRIPv4Address"
88 + /* Sanity check: ensure that our length is at least 22 bytes, that
89 + * IPv4MaskLen is <= 32, 6rdPrefixLen <= 128 and that the sum of
90 + * (32 - IPv4MaskLen) + 6rdPrefixLen is less than or equal to 128.
91 + * If any of these requirements is not fulfilled, return with empty
94 + if ((len >= 22) && (*option <= 32) && (*(option+1) <= 128) &&
95 + (((32 - *option) + *(option+1)) <= 128))
98 + dest += sprintf(dest, "%u ", *option++);
102 + dest += sprintf(dest, "%u ", *option++);
106 + dest += sprint_nip6(dest, "", option);
110 + /* 6rdBRIPv4Addresses */
113 + dest += sprint_nip(dest, " ", option);
117 + /* the code to determine the option size fails to work with
118 + * lengths that are not a multiple of the minimum length,
119 + * adding all advertised 6rdBRIPv4Addresses here would
120 + * overflow the destination buffer, therefore skip the rest
129 #if ENABLE_FEATURE_UDHCP_RFC3397
130 case OPTION_DNS_STRING:
131 /* unpack option into dest; use ret for prefix (i.e., "optname=") */
132 --- a/networking/udhcp/common.h
133 +++ b/networking/udhcp/common.h
134 @@ -88,6 +88,7 @@ enum {
137 OPTION_STATIC_ROUTES,
139 #if ENABLE_FEATURE_UDHCP_RFC3397
140 OPTION_DNS_STRING, /* RFC1035 compressed domain name list */