2010-11-14 05:32:45 +00:00
|
|
|
--- a/networking/udhcp/common.c
|
|
|
|
+++ b/networking/udhcp/common.c
|
2011-10-21 23:08:45 +00:00
|
|
|
@@ -60,6 +60,8 @@ const struct dhcp_optflag dhcp_optflags[
|
|
|
|
{ OPTION_U8 , 0x85 }, /* DHCP_VLAN_PRIORITY */
|
2010-11-14 05:32:45 +00:00
|
|
|
#endif
|
2011-04-03 18:31:00 +00:00
|
|
|
{ OPTION_STATIC_ROUTES , 0xf9 }, /* DHCP_MS_STATIC_ROUTES */
|
2010-12-04 19:15:16 +00:00
|
|
|
+ { OPTION_6RD , 0xd4 }, /* DHCP_6RD (RFC) */
|
|
|
|
+ { OPTION_6RD , 0x96 }, /* DHCP_6RD (Comcast) */
|
2010-11-14 05:32:45 +00:00
|
|
|
{ OPTION_STRING , 0xfc }, /* DHCP_WPAD */
|
|
|
|
|
|
|
|
/* Options below have no match in dhcp_option_strings[],
|
2012-03-18 19:46:52 +00:00
|
|
|
@@ -127,6 +129,8 @@ const char dhcp_option_strings[] ALIGN1
|
2011-10-21 23:08:45 +00:00
|
|
|
"vlanpriority" "\0"/* DHCP_VLAN_PRIORITY */
|
|
|
|
#endif
|
2011-04-20 02:56:17 +00:00
|
|
|
"msstaticroutes""\0"/* DHCP_MS_STATIC_ROUTES */
|
2010-12-04 19:15:16 +00:00
|
|
|
+ "ip6rd" "\0" /* DHCP_6RD (RFC) */
|
|
|
|
+ "ip6rd" "\0" /* DHCP_6RD (Comcast) */
|
2010-11-14 05:32:45 +00:00
|
|
|
"wpad" "\0" /* DHCP_WPAD */
|
|
|
|
;
|
2011-04-20 02:56:17 +00:00
|
|
|
|
2011-10-21 23:08:45 +00:00
|
|
|
@@ -154,6 +158,7 @@ const uint8_t dhcp_option_lengths[] ALIG
|
2010-11-14 05:32:45 +00:00
|
|
|
[OPTION_S32] = 4,
|
|
|
|
/* Just like OPTION_STRING, we use minimum length here */
|
|
|
|
[OPTION_STATIC_ROUTES] = 5,
|
|
|
|
+ [OPTION_6RD] = 22,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-04-03 18:31:00 +00:00
|
|
|
--- a/networking/udhcp/common.h
|
|
|
|
+++ b/networking/udhcp/common.h
|
|
|
|
@@ -88,6 +88,7 @@ enum {
|
|
|
|
OPTION_S32,
|
|
|
|
OPTION_BIN,
|
|
|
|
OPTION_STATIC_ROUTES,
|
|
|
|
+ OPTION_6RD,
|
|
|
|
#if ENABLE_FEATURE_UDHCP_RFC3397
|
|
|
|
OPTION_DNS_STRING, /* RFC1035 compressed domain name list */
|
|
|
|
OPTION_SIP_SERVERS,
|
2010-11-14 05:32:45 +00:00
|
|
|
--- a/networking/udhcp/dhcpc.c
|
|
|
|
+++ b/networking/udhcp/dhcpc.c
|
2011-10-21 23:08:45 +00:00
|
|
|
@@ -100,6 +100,7 @@ static const uint8_t len_of_option_as_st
|
2010-11-14 05:32:45 +00:00
|
|
|
[OPTION_IP ] = sizeof("255.255.255.255 "),
|
|
|
|
[OPTION_IP_PAIR ] = sizeof("255.255.255.255 ") * 2,
|
|
|
|
[OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "),
|
|
|
|
+ [OPTION_6RD ] = sizeof("32 128 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 255.255.255.255 "),
|
|
|
|
[OPTION_STRING ] = 1,
|
|
|
|
#if ENABLE_FEATURE_UDHCP_RFC3397
|
|
|
|
[OPTION_DNS_STRING ] = 1, /* unused */
|
2012-03-18 19:46:52 +00:00
|
|
|
@@ -123,6 +124,23 @@ static int sprint_nip(char *dest, const
|
2010-11-14 05:32:45 +00:00
|
|
|
return sprintf(dest, "%s%u.%u.%u.%u", pre, ip[0], ip[1], ip[2], ip[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
+static int sprint_nip6(char *dest, const char *pre, const uint8_t *ip)
|
|
|
|
+{
|
|
|
|
+ int len = 0;
|
|
|
|
+ int off;
|
|
|
|
+ uint16_t word;
|
|
|
|
+
|
|
|
|
+ len += sprintf(dest, "%s", pre);
|
|
|
|
+
|
|
|
|
+ for (off = 0; off < 16; off += 2)
|
|
|
|
+ {
|
|
|
|
+ move_from_unaligned16(word, &ip[off]);
|
|
|
|
+ len += sprintf(dest+len, "%s%04X", off ? ":" : "", htons(word));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return len;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/* really simple implementation, just count the bits */
|
|
|
|
static int mton(uint32_t mask)
|
|
|
|
{
|
2012-03-18 19:46:52 +00:00
|
|
|
@@ -231,6 +249,70 @@ static NOINLINE char *xmalloc_optname_op
|
|
|
|
}
|
2010-11-14 05:32:45 +00:00
|
|
|
|
|
|
|
return ret;
|
2012-03-18 19:46:52 +00:00
|
|
|
+ }
|
2010-11-14 05:32:45 +00:00
|
|
|
+ case OPTION_6RD: {
|
|
|
|
+ /* Option binary format:
|
|
|
|
+ * 0 1 2 3
|
|
|
|
+ * 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
|
|
|
|
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
+ * | OPTION_6RD | option-length | IPv4MaskLen | 6rdPrefixLen |
|
|
|
|
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
+ * | |
|
|
|
|
+ * | 6rdPrefix |
|
|
|
|
+ * | (16 octets) |
|
|
|
|
+ * | |
|
|
|
|
+ * | |
|
|
|
|
+ * | |
|
|
|
|
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
+ * | 6rdBRIPv4Address(es) |
|
|
|
|
+ * . .
|
|
|
|
+ * . .
|
|
|
|
+ * . .
|
|
|
|
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
+ *
|
|
|
|
+ * We convert it to a string "IPv4MaskLen 6rdPrefixLen 6rdPrefix 6rdBRIPv4Address"
|
|
|
|
+ */
|
|
|
|
+
|
2010-11-14 05:58:34 +00:00
|
|
|
+ /* Sanity check: ensure that our length is at least 22 bytes, that
|
|
|
|
+ * IPv4MaskLen is <= 32, 6rdPrefixLen <= 128 and that the sum of
|
|
|
|
+ * (32 - IPv4MaskLen) + 6rdPrefixLen is less than or equal to 128.
|
|
|
|
+ * If any of these requirements is not fulfilled, return with empty
|
|
|
|
+ * value.
|
|
|
|
+ */
|
|
|
|
+ if ((len >= 22) && (*option <= 32) && (*(option+1) <= 128) &&
|
|
|
|
+ (((32 - *option) + *(option+1)) <= 128))
|
|
|
|
+ {
|
|
|
|
+ /* IPv4MaskLen */
|
|
|
|
+ dest += sprintf(dest, "%u ", *option++);
|
|
|
|
+ len--;
|
2010-11-14 05:32:45 +00:00
|
|
|
+
|
2010-11-14 05:58:34 +00:00
|
|
|
+ /* 6rdPrefixLen */
|
|
|
|
+ dest += sprintf(dest, "%u ", *option++);
|
|
|
|
+ len--;
|
2010-11-14 05:32:45 +00:00
|
|
|
+
|
2010-11-14 05:58:34 +00:00
|
|
|
+ /* 6rdPrefix */
|
|
|
|
+ dest += sprint_nip6(dest, "", option);
|
|
|
|
+ option += 16;
|
|
|
|
+ len -= 16;
|
2010-11-14 05:32:45 +00:00
|
|
|
+
|
2010-11-14 05:58:34 +00:00
|
|
|
+ /* 6rdBRIPv4Addresses */
|
|
|
|
+ while (len >= 4)
|
|
|
|
+ {
|
|
|
|
+ dest += sprint_nip(dest, " ", option);
|
|
|
|
+ option += 4;
|
|
|
|
+ len -= 4;
|
2010-11-14 05:32:45 +00:00
|
|
|
+
|
2010-11-14 05:58:34 +00:00
|
|
|
+ /* the code to determine the option size fails to work with
|
|
|
|
+ * lengths that are not a multiple of the minimum length,
|
|
|
|
+ * adding all advertised 6rdBRIPv4Addresses here would
|
|
|
|
+ * overflow the destination buffer, therefore skip the rest
|
|
|
|
+ * for now
|
|
|
|
+ */
|
|
|
|
+ break;
|
|
|
|
+ }
|
2010-11-14 05:32:45 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ret;
|
2012-03-18 19:46:52 +00:00
|
|
|
}
|
2010-11-14 05:32:45 +00:00
|
|
|
#if ENABLE_FEATURE_UDHCP_RFC3397
|
|
|
|
case OPTION_DNS_STRING:
|