Managed PD: initial support
[project/odhcpd.git] / src / dhcpv6.c
index 9b802c48bb1cc6dee618695a2c87817c510f400e..3fa2acfec3ac741106bd494e8c72853ed9e24d38 100644 (file)
@@ -22,6 +22,8 @@
 #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);
@@ -173,6 +175,9 @@ static void handle_client_request(void *addr, void *data, size_t len,
                uint16_t duid_type;
                uint16_t hardware_type;
                uint8_t mac[6];
+               uint16_t solmaxrt_type;
+               uint16_t solmaxrt_length;
+               uint32_t solmaxrt_value;
                uint16_t clientid_type;
                uint16_t clientid_length;
                uint8_t clientid_buf[130];
@@ -182,6 +187,9 @@ static void handle_client_request(void *addr, void *data, size_t len,
                .serverid_length = htons(10),
                .duid_type = htons(3),
                .hardware_type = htons(1),
+               .solmaxrt_type = htons(DHCPV6_OPT_SOL_MAX_RT),
+               .solmaxrt_length = htons(4),
+               .solmaxrt_value = htonl(60),
                .clientid_type = htons(DHCPV6_OPT_CLIENTID),
                .clientid_buf = {0}
        };
@@ -275,6 +283,13 @@ 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
+               } else if (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]]) {
+                               size_t elen = strlen(excluded_class);
+                               if (((((size_t)c[0]) << 8) | c[1]) == elen && !memcmp(&c[2], excluded_class, elen))
+                                       return; // Ignore from homenet
+                       }
                }
        }