Browse Source

Prefix delegation: properly parse prefix from Radius

Baptiste Jonglez 7 years ago
parent
commit
7c392b1848
1 changed files with 6 additions and 3 deletions
  1. 6 3
      src/lib/dhcpsrv/radius_host_data_source.cc

+ 6 - 3
src/lib/dhcpsrv/radius_host_data_source.cc

@@ -278,9 +278,12 @@ RadiusHostDataSource::getAll(const Host::IdentifierType& identifier_type,
                     host->addReservation(ipv6_addr);
                 }
                 if (std::string(name) == "Delegated-IPv6-Prefix") {
-                    fprintf(stderr, "Delegated-IPv6-Prefix: %s", value);
-                    /* TODO: parse prefix length. */
-                    IPv6Resrv ipv6_prefix(IPv6Resrv::TYPE_PD, asiolink::IOAddress(value), 42);
+                    /* Split "prefix/prefixlen" appropriately */
+                    std::string value_str(value);
+                    size_t pos = value_str.find('/');
+                    asiolink::IOAddress prefix(value_str.substr(0, pos));
+                    uint8_t prefixlen = std::stoi(value_str.substr(pos + 1));
+                    IPv6Resrv ipv6_prefix(IPv6Resrv::TYPE_PD, prefix, prefixlen);
                     host->addReservation(ipv6_prefix);
                 }
             }