Browse Source

Set IPv6 reservation received from Radius (Framed-IPv6-Address and Delegated-IPv6-Prefix)

Baptiste Jonglez 7 years ago
parent
commit
a78c1f673d
1 changed files with 15 additions and 4 deletions
  1. 15 4
      src/lib/dhcpsrv/radius_host_data_source.cc

+ 15 - 4
src/lib/dhcpsrv/radius_host_data_source.cc

@@ -261,6 +261,9 @@ RadiusHostDataSource::getAll(const Host::IdentifierType& identifier_type,
         VALUE_PAIR *vp = received;
         VALUE_PAIR *vp = received;
         char name[128];
         char name[128];
         char value[128];
         char value[128];
+        HostPtr host(new Host(identifier_begin, identifier_len,
+                              identifier_type, SubnetID(),
+                              SubnetID(), asiolink::IOAddress::IPV4_ZERO_ADDRESS()));
 
 
         fprintf(stderr, "\"%s\" RADIUS Authentication OK\n", identifier_hex);
         fprintf(stderr, "\"%s\" RADIUS Authentication OK\n", identifier_hex);
 
 
@@ -268,14 +271,22 @@ RadiusHostDataSource::getAll(const Host::IdentifierType& identifier_type,
         while(vp != NULL) {
         while(vp != NULL) {
             if (rc_avpair_tostr(rh, vp, name, sizeof(name), value, sizeof(value)) == 0) {
             if (rc_avpair_tostr(rh, vp, name, sizeof(name), value, sizeof(value)) == 0) {
                 if (std::string(name) == "Framed-IP-Address") {
                 if (std::string(name) == "Framed-IP-Address") {
-                    host.reset(new Host(identifier_begin, identifier_len,
-                                        identifier_type, SubnetID(),
-                                        SubnetID(), asiolink::IOAddress(value)));
-                    result.push_back(host);
+                    host->setIPv4Reservation(asiolink::IOAddress(value));
+                }
+                if (std::string(name) == "Framed-IPv6-Address") {
+                    IPv6Resrv ipv6_addr(IPv6Resrv::TYPE_NA, asiolink::IOAddress(value), 128);
+                    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);
+                    host->addReservation(ipv6_prefix);
                 }
                 }
             }
             }
             vp = vp->next;
             vp = vp->next;
         }
         }
+        result.push_back(host);
     } else {
     } else {
         fprintf(stderr, "\"%s\" RADIUS Authentication failure (RC=%i)\n", identifier_hex, res);
         fprintf(stderr, "\"%s\" RADIUS Authentication failure (RC=%i)\n", identifier_hex, res);
     }
     }