Add default DHCPv4 range for prefixes down to /28
[project/odhcpd.git] / src / dhcpv6.c
index 55b9ea9..aaefa5e 100644 (file)
@@ -22,8 +22,6 @@
 #include "odhcpd.h"
 #include "dhcpv6.h"
 
 #include "odhcpd.h"
 #include "dhcpv6.h"
 
-static const char *excluded_class = "HOMENET";
-
 
 static void relay_client_request(struct sockaddr_in6 *source,
                const void *data, size_t len, struct interface *iface);
 
 static void relay_client_request(struct sockaddr_in6 *source,
                const void *data, size_t len, struct interface *iface);
@@ -124,8 +122,8 @@ static void handle_nested_message(uint8_t *data, size_t len,
        uint8_t *odata;
        dhcpv6_for_each_option(hdr->options, data + len, otype, olen, odata) {
                if (otype == DHCPV6_OPT_RELAY_MSG) {
        uint8_t *odata;
        dhcpv6_for_each_option(hdr->options, data + len, otype, olen, odata) {
                if (otype == DHCPV6_OPT_RELAY_MSG) {
-                       iov[8].iov_base = odata + olen;
-                       iov[8].iov_len = (((uint8_t*)iov[0].iov_base) + iov[0].iov_len)
+                       iov[9].iov_base = odata + olen;
+                       iov[9].iov_len = (((uint8_t*)iov[0].iov_base) + iov[0].iov_len)
                                        - (odata + olen);
                        handle_nested_message(odata, olen, opts, end, iov);
                        return;
                                        - (odata + olen);
                        handle_nested_message(odata, olen, opts, end, iov);
                        return;
@@ -262,6 +260,7 @@ static void handle_client_request(void *addr, void *data, size_t len,
                        {search_domain, search_len},
                        {pdbuf, 0},
                        {&cerid, 0},
                        {search_domain, search_len},
                        {pdbuf, 0},
                        {&cerid, 0},
+                       {iface->dhcpv6_raw, iface->dhcpv6_raw_len},
                        {NULL, 0}};
 
        uint8_t *opts = (uint8_t*)&hdr[1], *opts_end = (uint8_t*)data + len;
                        {NULL, 0}};
 
        uint8_t *opts = (uint8_t*)&hdr[1], *opts_end = (uint8_t*)data + len;
@@ -292,11 +291,11 @@ static void handle_client_request(void *addr, void *data, size_t len,
                        if (olen != ntohs(dest.serverid_length) ||
                                        memcmp(odata, &dest.duid_type, olen))
                                return; // Not for us
                        if (olen != ntohs(dest.serverid_length) ||
                                        memcmp(odata, &dest.duid_type, olen))
                                return; // Not for us
-               } else if (otype == DHCPV6_OPT_USER_CLASS) {
+               } else if (iface->filter_class && otype == DHCPV6_OPT_USER_CLASS) {
                        uint8_t *c = odata, *cend = &odata[olen];
                        for (; &c[2] <= cend && &c[2 + (c[0] << 8) + c[1]] <= cend; c = &c[2 + (c[0] << 8) + c[1]]) {
                        uint8_t *c = odata, *cend = &odata[olen];
                        for (; &c[2] <= cend && &c[2 + (c[0] << 8) + c[1]] <= cend; c = &c[2 + (c[0] << 8) + c[1]]) {
-                               size_t elen = strlen(excluded_class);
-                               if (((((size_t)c[0]) << 8) | c[1]) == elen && !memcmp(&c[2], excluded_class, elen))
+                               size_t elen = strlen(iface->filter_class);
+                               if (((((size_t)c[0]) << 8) | c[1]) == elen && !memcmp(&c[2], iface->filter_class, elen))
                                        return; // Ignore from homenet
                        }
                } else if (otype == DHCPV6_OPT_IA_PD) {
                                        return; // Ignore from homenet
                        }
                } else if (otype == DHCPV6_OPT_IA_PD) {