BIND 10 trac2892, updated. ec47fdb14d1fd03d386147c1c6cf4afdd118c75f code update for protected function

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Jan 13 21:11:58 UTC 2014


The branch, trac2892 has been updated
       via  ec47fdb14d1fd03d386147c1c6cf4afdd118c75f (commit)
       via  f95358d6ac95166841774c4ee48a060a40d363bb (commit)
      from  bb339dd52f357cf97a3bfc15d68650d9fe2b577d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ec47fdb14d1fd03d386147c1c6cf4afdd118c75f
Author: wlodek <wlodek.wencel at gmail.com>
Date:   Mon Jan 13 22:11:51 2014 +0100

    code update for protected function

commit f95358d6ac95166841774c4ee48a060a40d363bb
Author: wlodek <wlodek.wencel at gmail.com>
Date:   Mon Jan 13 22:11:01 2014 +0100

    unitest for testServerid function

-----------------------------------------------------------------------

Summary of changes:
 src/bin/dhcp6/dhcp6_srv.h                 |   16 ++++++------
 src/bin/dhcp6/tests/dhcp6_srv_unittest.cc |   38 +++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 8 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/dhcp6_srv.h b/src/bin/dhcp6/dhcp6_srv.h
index 8a3dcb4..1e43baa 100644
--- a/src/bin/dhcp6/dhcp6_srv.h
+++ b/src/bin/dhcp6/dhcp6_srv.h
@@ -117,6 +117,14 @@ public:
     /// @param port UDP port on which server should listen.
     static void openActiveSockets(const uint16_t port);
 
+    /// @brief compare received server id with ours server id
+    ///
+    /// Verifies received ServerID with generated ServerID
+    ///
+    /// @param pkt packet to be checked
+    /// @throw ServerID_mismatch if server_ids are not equal
+    void testServerid(const Pkt6Ptr& pkt);
+    
 protected:
 
     /// @brief verifies if specified packet meets RFC requirements
@@ -130,14 +138,6 @@ protected:
     /// @throw RFCViolation if any issues are detected
     void sanityCheck(const Pkt6Ptr& pkt, RequirementLevel clientid,
                      RequirementLevel serverid);
-
-    /// @brief compare received server id with ours server id
-    ///
-    /// Verifies received ServerID with generated ServerID
-    ///
-    /// @param pkt packet to be checked
-    /// @throw ServerID_mismatch if server_ids are not equal
-    void testServerid(const Pkt6Ptr& pkt);
     
     /// @brief Processes incoming SOLICIT and returns response.
     ///
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 393d466..cbc01a8 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -1074,6 +1074,44 @@ TEST_F(Dhcpv6SrvTest, sanityCheck) {
                  RFCViolation);
 }
 
+TEST_F(Dhcpv6SrvTest, testServerid){
+	NakedDhcpv6Srv srv(0);
+	
+    Pkt6Ptr req = Pkt6Ptr(new Pkt6(DHCPV6_REQUEST, 1234));
+    req->setRemoteAddr(IOAddress("fe80::abcd"));
+    boost::shared_ptr<Option6IA> ia = generateIA(D6O_IA_PD, 234, 1500, 3000);
+
+    // with a valid hint
+    IOAddress hint("2001:db8:1:2:f::");
+    ASSERT_TRUE(subnet_->inPool(Lease::TYPE_PD, hint));
+    OptionPtr hint_opt(new Option6IAPrefix(D6O_IAPREFIX, hint, 64, 300, 500));
+    ia->addOption(hint_opt);
+    req->addOption(ia);
+    OptionPtr clientid = generateClientId();
+    req->addOption(clientid);
+
+    // server-id is mandatory in REQUEST
+    // but add there something else
+    std::vector<uint8_t> bin;
+
+    //diud_llt with time = 0, macaddress = 00:00:00:00:00:00
+    isc::util::encode::decodeHex("0001000100000000000000000000", bin);
+    // Now create server-id option
+    OptionPtr serverid = OptionPtr(new Option(Option::V6, D6O_SERVERID, bin));
+
+    req->addOption(serverid);
+    
+    // I moved testServerid in src/bin/dhcp6/dhcp6_srv.h 
+    // above the protected part.
+    EXPECT_THROW(srv.testServerid(req),ServerID_mismatch);
+	
+    req->delOption(D6O_SERVERID);
+    
+    req->addOption(srv.getServerID());
+    
+    EXPECT_NO_THROW(srv.testServerid(req));
+}
+
 // This test verifies if selectSubnet() selects proper subnet for a given
 // source address.
 TEST_F(Dhcpv6SrvTest, selectSubnetAddr) {



More information about the bind10-changes mailing list