Browse Source

Set real IP address returned by Radius in DHCP responses

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

+ 7 - 7
src/lib/dhcpsrv/radius_host_data_source.cc

@@ -207,18 +207,18 @@ RadiusHostDataSource::getAll(const Host::IdentifierType& identifier_type,
 
         fprintf(stderr, "\"%s\" RADIUS Authentication OK\n", identifier_hex);
 
-        /* print the known attributes in the reply */
+        /* parse the known attributes in the reply */
         while(vp != NULL) {
             if (rc_avpair_tostr(rh, vp, name, sizeof(name), value, sizeof(value)) == 0) {
-                fprintf(stderr, "%s:\t%s\n", name, value);
+                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);
+                }
             }
             vp = vp->next;
         }
-        host.reset(new Host(identifier_begin, identifier_len,
-                            identifier_type, SubnetID(),
-                            // TODO: set real IP address
-                            SubnetID(), asiolink::IOAddress("10.42.42.42")));
-        result.push_back(host);
     } else {
         fprintf(stderr, "\"%s\" RADIUS Authentication failure (RC=%i)\n", identifier_hex, res);
     }