BIND 10 trac3036, updated. 51e47dbf6cb9f1b78321d96c0548f7aae140c583 [3036] Addressed comments from the second review.

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Aug 16 13:36:29 UTC 2013


The branch, trac3036 has been updated
       via  51e47dbf6cb9f1b78321d96c0548f7aae140c583 (commit)
      from  334e3b332c8ad84b4e4c04453a43303cd2706a33 (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 51e47dbf6cb9f1b78321d96c0548f7aae140c583
Author: Marcin Siodelski <marcin at isc.org>
Date:   Fri Aug 16 15:36:12 2013 +0200

    [3036] Addressed comments from the second review.

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

Summary of changes:
 src/bin/dhcp6/tests/dhcp6_srv_unittest.cc |   10 ++++++++--
 src/lib/dhcp/option6_client_fqdn.cc       |   22 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 377fb14..c3435af 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -1851,8 +1851,11 @@ TEST_F(FqdnDhcpv6SrvTest, createNameChangeRequests) {
     addIA(2345, IOAddress("2001:db8:1::2"), answer);
     addIA(3456, IOAddress("2001:db8:1::3"), answer);
 
+    // Use domain name in upper case. It should be converted to lower-case
+    // before DHCID is calculated. So, we should get the same result as if
+    // we typed domain name in lower-case.
     Option6ClientFqdnPtr fqdn = createClientFqdn(Option6ClientFqdn::FLAG_S,
-                                                 "myhost.example.com",
+                                                 "MYHOST.EXAMPLE.COM",
                                                  Option6ClientFqdn::FULL);
 
     // Create NameChangeRequests. Since we have added 3 IAs, it should
@@ -1890,7 +1893,10 @@ TEST_F(FqdnDhcpv6SrvTest, createRemovalNameChangeRequestFwdRev) {
 
     lease_->fqdn_fwd_ = true;
     lease_->fqdn_rev_ = true;
-    lease_->hostname_ = "myhost.example.com.";
+    // Part of the domain name is in upper case, to test that it gets converted
+    // to lower case before DHCID is computed. So, we should get the same DHCID
+    // as if we typed domain-name in lower case.
+    lease_->hostname_ = "MYHOST.example.com.";
 
     ASSERT_NO_THROW(srv.createRemovalNameChangeRequest(lease_));
 
diff --git a/src/lib/dhcp/option6_client_fqdn.cc b/src/lib/dhcp/option6_client_fqdn.cc
index ddced8f..5cd2664 100644
--- a/src/lib/dhcp/option6_client_fqdn.cc
+++ b/src/lib/dhcp/option6_client_fqdn.cc
@@ -107,6 +107,11 @@ public:
 Option6ClientFqdnImpl::
 Option6ClientFqdnImpl(const uint8_t flags,
                       const std::string& domain_name,
+                      // cppcheck 1.57 complains that const enum value is not
+                      // passed by reference. Note that it accepts the non-const
+                      // enum to be passed by value. In both cases it is
+                      // unnecessary to pass the enum by reference.
+                      // cppcheck-suppress passedByValue
                       const Option6ClientFqdn::DomainNameType name_type)
     : flags_(flags),
       domain_name_(),
@@ -138,6 +143,9 @@ Option6ClientFqdnImpl(const Option6ClientFqdnImpl& source)
 }
 
 Option6ClientFqdnImpl&
+// This assignment operator handles assignment to self. It uses copy
+// constructor of Option6ClientFqdnImpl to copy all required values.
+// cppcheck-suppress operatorEqToSelf
 Option6ClientFqdnImpl::operator=(const Option6ClientFqdnImpl& source) {
     if (source.domain_name_) {
         domain_name_.reset(new isc::dns::Name(*source.domain_name_));
@@ -157,6 +165,11 @@ Option6ClientFqdnImpl::operator=(const Option6ClientFqdnImpl& source) {
 void
 Option6ClientFqdnImpl::
 setDomainName(const std::string& domain_name,
+              // cppcheck 1.57 complains that const enum value is not
+              // passed by reference. Note that it accepts the non-const
+              // enum to be passed by value. In both cases it is
+              // unnecessary to pass the enum by reference.
+              // cppcheck-suppress passedByValue
               const Option6ClientFqdn::DomainNameType name_type) {
     // domain-name must be trimmed. Otherwise, string comprising spaces only
     // would be treated as a fully qualified name.
@@ -352,6 +365,11 @@ Option6ClientFqdn::getDomainName() const {
 
 void
 Option6ClientFqdn::packDomainName(isc::util::OutputBuffer& buf) const {
+    // There is nothing to do if domain-name is empty.
+    if (!impl_->domain_name_) {
+        return;
+    }
+
     // Domain name, encoded as a set of labels.
     isc::dns::LabelSequence labels(*impl_->domain_name_);
     if (labels.getDataLength() > 0) {
@@ -395,6 +413,10 @@ Option6ClientFqdn::unpack(OptionBufferConstIter first,
                           OptionBufferConstIter last) {
     setData(first, last);
     impl_->parseWireData(first, last);
+    // Check that the flags in the received option are valid. Ignore MBZ bits
+    // because we don't want to discard the whole option because of MBZ bits
+    // being set.
+    impl_->checkFlags(impl_->flags_, false);
 }
 
 std::string



More information about the bind10-changes mailing list