Browse Source

[3035] Include HW type in the digest when generating DHCID from HW addr.

Marcin Siodelski 11 years ago
parent
commit
cafeb7250b
2 changed files with 11 additions and 3 deletions
  1. 9 1
      src/lib/dhcp_ddns/ncr_msg.cc
  2. 2 2
      src/lib/dhcp_ddns/tests/ncr_unittests.cc

+ 9 - 1
src/lib/dhcp_ddns/ncr_msg.cc

@@ -93,8 +93,16 @@ D2Dhcid::fromHWAddr(const isc::dhcp::HWAddrPtr& hwaddr,
         isc_throw(isc::dhcp_ddns::DhcidRdataComputeError,
                   "unable to compute DHCID from the HW address, "
                   "NULL pointer has been specified");
+    } else if (hwaddr->hwaddr_.empty()) {
+        isc_throw(isc::dhcp_ddns::DhcidRdataComputeError,
+                  "unable to compute DHCID from the HW address, "
+                  "HW address is empty");
     }
-    createDigest(DHCID_ID_HWADDR, hwaddr->hwaddr_, wire_fqdn);
+    std::vector<uint8_t> hwaddr_data;
+    hwaddr_data.push_back(hwaddr->htype_);
+    hwaddr_data.insert(hwaddr_data.end(), hwaddr->hwaddr_.begin(),
+                       hwaddr->hwaddr_.end());
+    createDigest(DHCID_ID_HWADDR, hwaddr_data, wire_fqdn);
 }
 
 

+ 2 - 2
src/lib/dhcp_ddns/tests/ncr_unittests.cc

@@ -549,8 +549,8 @@ TEST_F(DhcidTest, fromHWAddr) {
 
     // The reference DHCID (represented as string of hexadecimal digits)
     // has been calculated using one of the online calculators.
-    std::string dhcid_ref = "0000012191B7B21AF97E0E656DF887C5E2D"
-        "EF30E7758A207EDF4CCB2DE8CA37066021C";
+    std::string dhcid_ref = "0000012247F6DC4423C3E8627434A9D686860"
+        "9D88948F78018B215EDCAA30C0C135035";
 
     // Make sure that the DHCID is valid.
     EXPECT_EQ(dhcid_ref, dhcid.toStr());