From: Roy Marples Date: Thu, 10 Sep 2015 08:41:37 +0000 (+0000) Subject: Remove the custom SixRD decode function and replace with a generic X-Git-Tag: v6.9.4~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8918cc500c62ebdb2b0219bc165bc1a1caa1e06;p=thirdparty%2Fdhcpcd.git Remove the custom SixRD decode function and replace with a generic definition. This does mean any 3rd party hook scripts using this will need to be changed. --- diff --git a/dhcp-common.c b/dhcp-common.c index b6339888..47bf47d9 100644 --- a/dhcp-common.c +++ b/dhcp-common.c @@ -103,8 +103,6 @@ dhcp_print_option_encoding(const struct dhcp_opt *opt, int cols) printf(" rfc3361"); if (opt->type & RFC3442) printf(" rfc3442"); - if (opt->type & RFC5969) - printf(" rfc5969"); if (opt->type & REQUEST) printf(" request"); if (opt->type & NOREQ) @@ -559,7 +557,7 @@ dhcp_optlen(const struct dhcp_opt *opt, size_t dl) size_t sz; if (opt->type == 0 || - opt->type & (STRING | BINHEX | RFC3442 | RFC5969)) + opt->type & (STRING | BINHEX | RFC3442)) { if (opt->len) { if ((size_t)opt->len > dl) @@ -639,9 +637,6 @@ print_option(char *s, size_t len, const struct dhcp_opt *opt, if (opt->type & RFC3442) return decode_rfc3442(s, len, data, dl); - - if (opt->type & RFC5969) - return decode_rfc5969(s, len, data, dl); #endif if (opt->type & STRING) diff --git a/dhcp-common.h b/dhcp-common.h index 5a4cfc14..3899fc7f 100644 --- a/dhcp-common.h +++ b/dhcp-common.h @@ -52,7 +52,7 @@ #define RFC3361 (1 << 9) #define RFC1035 (1 << 10) #define RFC3442 (1 << 11) -#define RFC5969 (1 << 12) +/* unassigned (1 << 12) */ #define ADDRIPV6 (1 << 13) #define BINHEX (1 << 14) #define FLAG (1 << 15) diff --git a/dhcp.c b/dhcp.c index 83053f61..c4451f92 100644 --- a/dhcp.c +++ b/dhcp.c @@ -480,74 +480,6 @@ decode_rfc3361(const uint8_t *data, size_t dl) return sip; } -/* Decode an RFC5969 6rd order option into a space - * separated string. Returns length of string (including - * terminating zero) or zero on error. */ -ssize_t -decode_rfc5969(char *out, size_t len, const uint8_t *p, size_t pl) -{ - uint8_t ipv4masklen, ipv6prefixlen; - uint8_t ipv6prefix[16]; - uint8_t br[4]; - int i; - ssize_t b, bytes = 0; - - if (pl < 22) { - errno = EINVAL; - return 0; - } - - ipv4masklen = *p++; - pl--; - ipv6prefixlen = *p++; - pl--; - - for (i = 0; i < 16; i++) { - ipv6prefix[i] = *p++; - pl--; - } - if (out) { - b= snprintf(out, len, - "%d %d " - "%02x%02x:%02x%02x:" - "%02x%02x:%02x%02x:" - "%02x%02x:%02x%02x:" - "%02x%02x:%02x%02x", - ipv4masklen, ipv6prefixlen, - ipv6prefix[0], ipv6prefix[1], ipv6prefix[2], ipv6prefix[3], - ipv6prefix[4], ipv6prefix[5], ipv6prefix[6], ipv6prefix[7], - ipv6prefix[8], ipv6prefix[9], ipv6prefix[10],ipv6prefix[11], - ipv6prefix[12],ipv6prefix[13],ipv6prefix[14], ipv6prefix[15] - ); - - len -= (size_t)b; - out += b; - bytes += b; - } else { - bytes += 16 * 2 + 8 + 2 + 1 + 2; - } - - while (pl >= 4) { - br[0] = *p++; - br[1] = *p++; - br[2] = *p++; - br[3] = *p++; - pl -= 4; - - if (out) { - b= snprintf(out, len, " %d.%d.%d.%d", - br[0], br[1], br[2], br[3]); - len -= (size_t)b; - out += b; - bytes += b; - } else { - bytes += (4 * 4); - } - } - - return bytes; -} - static char * get_option_string(struct dhcpcd_ctx *ctx, const struct dhcp_message *dhcp, uint8_t option) diff --git a/dhcp.h b/dhcp.h index 4cd242f7..6bbca2a3 100644 --- a/dhcp.h +++ b/dhcp.h @@ -237,7 +237,6 @@ struct dhcp_state { #ifdef INET char *decode_rfc3361(const uint8_t *, size_t); ssize_t decode_rfc3442(char *, size_t, const uint8_t *p, size_t); -ssize_t decode_rfc5969(char *, size_t, const uint8_t *p, size_t); void dhcp_printoptions(const struct dhcpcd_ctx *, const struct dhcp_opt *, size_t); diff --git a/dhcpcd-definitions.conf b/dhcpcd-definitions.conf index 2b695a6e..5c8b6225 100644 --- a/dhcpcd-definitions.conf +++ b/dhcpcd-definitions.conf @@ -270,7 +270,11 @@ define 210 string path_prefix define 211 uint32 reboot_time # DHCP IPv6 Rapid Deployment on IPv4 Infrastructures, RFC5969 -define 212 rfc5969 sixrd +define 212 embed sixrd +embed byte mask_len +embed byte prefix_len +embed ip6address prefix +embed array ipaddress brip_address # DHCP Access Network Domain Name, RFC5986 define 213 domain access_domain diff --git a/if-options.c b/if-options.c index 57ccbbad..c03f7d3f 100644 --- a/if-options.c +++ b/if-options.c @@ -1658,8 +1658,6 @@ err_sla: t |= STRING | RFC3361; else if (strcasecmp(arg, "rfc3442") ==0) t |= STRING | RFC3442; - else if (strcasecmp(arg, "rfc5969") == 0) - t |= STRING | RFC5969; else if (strcasecmp(arg, "option") == 0) t |= OPTION; else {