]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4057] Addressed review comments
authorFrancis Dupont <fdupont@isc.org>
Fri, 9 Oct 2015 18:34:53 +0000 (20:34 +0200)
committerFrancis Dupont <fdupont@isc.org>
Fri, 9 Oct 2015 18:34:53 +0000 (20:34 +0200)
src/bin/dhcp4/dhcp4_srv.cc

index e286e49a869a722ddb3d1f219cdf7df2edf3eb47..59bfd9d1f08657715b54e1c099c062c15e7e23aa 100644 (file)
@@ -292,16 +292,24 @@ Dhcpv4Srv::selectSubnet(const Pkt4Ptr& query) const {
     selector.client_classes_ = query->classes_;
     selector.iface_name_ = query->getIface();
 
+    // If the link-selection sub-option is present, extract its value.
+    // "The link-selection sub-option is used by any DHCP relay agent
+    // that desires to specify a subnet/link for a DHCP client request
+    // that it is relaying but needs the subnet/link specification to
+    // be different from the IP address the DHCP server should use
+    // when communicating with the relay agent." (RFC 3257)
     OptionPtr rai = query->getOption(DHO_DHCP_AGENT_OPTIONS);
     if (rai) {
-        OptionCustomPtr oc = boost::dynamic_pointer_cast<OptionCustom>(rai);
-        if (oc) {
-            OptionPtr ols = oc->getOption(RAI_OPTION_LINK_SELECTION);
-            if (ols) {
-                OptionBuffer lsb = ols->getData();
-                if (lsb.size() == sizeof(uint32_t)) {
+        OptionCustomPtr rai_custom =
+            boost::dynamic_pointer_cast<OptionCustom>(rai);
+        if (rai_custom) {
+            OptionPtr link_select =
+                rai_custom->getOption(RAI_OPTION_LINK_SELECTION);
+            if (link_select) {
+                OptionBuffer link_select_buf = link_select->getData();
+                if (link_select_buf.size() == sizeof(uint32_t)) {
                     selector.option_select_ =
-                        IOAddress::fromBytes(AF_INET, &lsb[0]);
+                        IOAddress::fromBytes(AF_INET, &link_select_buf[0]);
                 }
             }
         }