Browse Source

[3573] Assign host specific options by the DHCPv6 server.

Also, fixes in the host unit tests.
Marcin Siodelski 9 years ago
parent
commit
e720266dcd
2 changed files with 17 additions and 12 deletions
  1. 6 1
      src/bin/dhcp6/dhcp6_srv.cc
  2. 11 11
      src/bin/dhcp6/tests/host_unittest.cc

+ 6 - 1
src/bin/dhcp6/dhcp6_srv.cc

@@ -794,7 +794,12 @@ void
 Dhcpv6Srv::buildCfgOptionList(const Pkt6Ptr& question,
                               AllocEngine::ClientContext6& ctx,
                               CfgOptionList& co_list) {
-    // First subnet configured options
+    // Firstly, host specific options.
+    if (ctx.host_ && !ctx.host_->getCfgOption6()->empty()) {
+        co_list.push_back(ctx.host_->getCfgOption6());
+    }
+
+    // Next, subnet configured options.
     if (ctx.subnet_ && !ctx.subnet_->getCfgOption()->empty()) {
         co_list.push_back(ctx.subnet_->getCfgOption());
     }

+ 11 - 11
src/bin/dhcp6/tests/host_unittest.cc

@@ -139,7 +139,7 @@ const char* CONFIGS[] = {
         "\"renew-timer\": 1000, "
         "\"option-data\": [ {"
         "    \"name\": \"nisp-servers\","
-        "    \"data\": \"3001:3::123\""
+        "    \"data\": \"3000:3::123\""
         "} ],"
         "\"subnet6\": [ "
         " { "
@@ -148,15 +148,15 @@ const char* CONFIGS[] = {
         "    \"interface\" : \"eth0\","
         "    \"option-data\": [ {"
         "        \"name\": \"dns-servers\","
-        "        \"data\": \"3001:2::123\""
+        "        \"data\": \"3000:2::123\""
         "    },"
         "    {"
         "        \"name\": \"nis-servers\","
-        "        \"data\": \"3001:2::123\""
+        "        \"data\": \"3000:2::123\""
         "    },"
         "    {"
         "        \"name\": \"sntp-servers\","
-        "        \"data\": \"3001:2::123\""
+        "        \"data\": \"3000:2::123\""
         "    } ],"
         "    \"reservations\": ["
         "    {"
@@ -164,11 +164,11 @@ const char* CONFIGS[] = {
         "        \"ip-addresses\": [ \"2001:db8:1::2\" ],"
         "        \"option-data\": [ {"
         "            \"name\": \"dns-servers\","
-        "            \"data\": \"3001:1::234\""
+        "            \"data\": \"3000:1::234\""
         "        },"
         "        {"
         "            \"name\": \"nis-servers\","
-        "            \"data\": \"3001:1::234\""
+        "            \"data\": \"3000:1::234\""
         "        } ]"
         "    } ]"
         " } ]"
@@ -195,11 +195,11 @@ const char* CONFIGS[] = {
         "        \"ip-addresses\": [ \"2001:db8:1::2\" ],"
         "        \"option-data\": [ {"
         "            \"name\": \"dns-servers\","
-        "            \"data\": \"3001:1::234\""
+        "            \"data\": \"3000:1::234\""
         "        },"
         "        {"
         "            \"name\": \"nis-servers\","
-        "            \"data\": \"3001:1::234\""
+        "            \"data\": \"3000:1::234\""
         "        } ]"
         "    } ]"
         " } ]"
@@ -222,7 +222,7 @@ const char* CONFIGS[] = {
         "{"
         "    \"name\": \"tftp-servers\","
         "    \"space\": \"vendor-4491\","
-        "    \"data\": \"3001:3::123\""
+        "    \"data\": \"3000:3::123\""
         "} ],"
         "\"subnet6\": [ "
         " { "
@@ -240,7 +240,7 @@ const char* CONFIGS[] = {
         "        {"
         "            \"name\": \"tftp-servers\","
         "            \"space\": \"vendor-4491\","
-        "            \"data\": \"3001:1::234\""
+        "            \"data\": \"3000:1::234\""
         "        } ]"
         "    } ]"
         " } ]"
@@ -490,7 +490,7 @@ HostTest::testOverrideVendorOptions(const uint16_t msg_type) {
     // Address specified in the host scope should be used.
     Option6AddrLst::AddressContainer addrs = tftp->getAddresses();
     ASSERT_EQ(addrs.size(), 1);
-    EXPECT_EQ("3001:1::234", addrs[0].toText());
+    EXPECT_EQ("3000:1::234", addrs[0].toText());
 }
 
 // Test basic SARR scenarios against a server configured with one subnet