Fix homenet filter
authorSteven Barth <steven@midlink.org>
Wed, 5 Feb 2014 15:41:51 +0000 (16:41 +0100)
committerSteven Barth <steven@midlink.org>
Wed, 5 Feb 2014 15:41:51 +0000 (16:41 +0100)
src/dhcpv6.c
src/dhcpv6.h

index 9b802c48bb1cc6dee618695a2c87817c510f400e..bf48d78f639525ff852f85cf1fe08331d34cb161 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);
@@ -275,6 +277,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
+                       }
                }
        }
 
index 7b3b484dbb5854c5634cad67786a961ae7ca65b1..9b382830df65b57632a678f183e816a63263e050 100644 (file)
@@ -44,6 +44,7 @@
 #define DHCPV6_OPT_STATUS 13
 #define DHCPV6_OPT_RELAY_MSG 9
 #define DHCPV6_OPT_AUTH 11
+#define DHCPV6_OPT_USER_CLASS 15
 #define DHCPV6_OPT_INTERFACE_ID 18
 #define DHCPV6_OPT_RECONF_MSG 19
 #define DHCPV6_OPT_RECONF_ACCEPT 20