BIND 10 trac3035, updated. 847cada3ef9794906046f1b1094e066bed55b581 [3035] Implemented DHCPv4 Client FQDN option processing.

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Sep 2 10:13:25 UTC 2013


The branch, trac3035 has been updated
       via  847cada3ef9794906046f1b1094e066bed55b581 (commit)
      from  41c4d829e66dfce48146a227ed396bf249a41344 (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 847cada3ef9794906046f1b1094e066bed55b581
Author: Marcin Siodelski <marcin at isc.org>
Date:   Wed Aug 28 16:15:56 2013 +0200

    [3035] Implemented DHCPv4 Client FQDN option processing.

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

Summary of changes:
 src/bin/dhcp4/dhcp4_srv.cc           |   16 ++++++++--
 src/bin/dhcp4/dhcp4_srv.h            |    6 ++--
 src/bin/dhcp4/tests/fqdn_unittest.cc |   53 +++++++++++++++++++++++++++++++++-
 3 files changed, 69 insertions(+), 6 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc
index 31efc5d..253270a 100644
--- a/src/bin/dhcp4/dhcp4_srv.cc
+++ b/src/bin/dhcp4/dhcp4_srv.cc
@@ -18,7 +18,6 @@
 #include <dhcp/hwaddr.h>
 #include <dhcp/iface_mgr.h>
 #include <dhcp/option4_addrlst.h>
-#include <dhcp/option4_client_fqdn.h>
 #include <dhcp/option_custom.h>
 #include <dhcp/option_int.h>
 #include <dhcp/option_int_array.h>
@@ -672,7 +671,7 @@ Dhcpv4Srv::processClientName(const Pkt4Ptr& query, Pkt4Ptr& answer) {
     Option4ClientFqdnPtr fqdn = boost::dynamic_pointer_cast<Option4ClientFqdn>
         (query->getOption(DHO_FQDN));
     if (fqdn) {
-        processClientFqdnOption(query, answer);
+        processClientFqdnOption(fqdn, answer);
 
     } else {
         OptionCustomPtr hostname = boost::dynamic_pointer_cast<OptionCustom>
@@ -685,7 +684,18 @@ Dhcpv4Srv::processClientName(const Pkt4Ptr& query, Pkt4Ptr& answer) {
 }
 
 void
-Dhcpv4Srv::processClientFqdnOption(const Pkt4Ptr&, Pkt4Ptr&) {
+Dhcpv4Srv::processClientFqdnOption(const Option4ClientFqdnPtr& fqdn,
+                                   Pkt4Ptr& answer) {
+    // Create the DHCPv4 Client FQDN Option to be included in the server's
+    // response to a client.
+    Option4ClientFqdnPtr fqdn_resp(new Option4ClientFqdn(*fqdn));
+
+    // RFC4702, section 4 - set 'NOS' flags to 0.
+    fqdn_resp->setFlag(Option4ClientFqdn::FLAG_S, 0);
+    fqdn_resp->setFlag(Option4ClientFqdn::FLAG_O, 0);
+    fqdn_resp->setFlag(Option4ClientFqdn::FLAG_N, 0);
+
+    answer->addOption(fqdn_resp);
 }
 
 void
diff --git a/src/bin/dhcp4/dhcp4_srv.h b/src/bin/dhcp4/dhcp4_srv.h
index 5ff6b57..5c9d776 100644
--- a/src/bin/dhcp4/dhcp4_srv.h
+++ b/src/bin/dhcp4/dhcp4_srv.h
@@ -18,6 +18,7 @@
 #include <dhcp/dhcp4.h>
 #include <dhcp/pkt4.h>
 #include <dhcp/option.h>
+#include <dhcp/option4_client_fqdn.h>
 #include <dhcpsrv/subnet.h>
 #include <dhcpsrv/alloc_engine.h>
 #include <hooks/callout_handle.h>
@@ -289,9 +290,10 @@ protected:
 private:
     /// @brief Process Client FQDN %Option sent by a client.
     ///
-    /// @param query A DISCOVER or REQUEST message from a cient.
+    /// @param fqdn An DHCPv4 Client FQDN %Option sent by a client.
     /// @param [out] answer A response message to be sent to a client.
-    void processClientFqdnOption(const Pkt4Ptr& query, Pkt4Ptr& answer);
+    void processClientFqdnOption(const Option4ClientFqdnPtr& fqdn,
+                                 Pkt4Ptr& answer);
 
     /// @brief Process Hostname %Option sent by a client.
     ///
diff --git a/src/bin/dhcp4/tests/fqdn_unittest.cc b/src/bin/dhcp4/tests/fqdn_unittest.cc
index 656bd30..0b4c2c9 100644
--- a/src/bin/dhcp4/tests/fqdn_unittest.cc
+++ b/src/bin/dhcp4/tests/fqdn_unittest.cc
@@ -126,7 +126,9 @@ private:
 
 };
 
-TEST_F(FqdnDhcpv4SrvTest, basic) {
+// Test that server confirms to perform the forward and reverse DNS update,
+// when client asks for it.
+TEST_F(FqdnDhcpv4SrvTest, serverUpdateForward) {
     Pkt4Ptr query = generatePktWithFqdn(DHCPREQUEST,
                                         Option4ClientFqdn::FLAG_E |
                                         Option4ClientFqdn::FLAG_S,
@@ -140,4 +142,53 @@ TEST_F(FqdnDhcpv4SrvTest, basic) {
 
 }
 
+// Test that server generates the fully qualified domain name for the client
+// if client supplies the partial name.
+TEST_F(FqdnDhcpv4SrvTest, serverUpdateForwardPartialName) {
+    Pkt4Ptr query = generatePktWithFqdn(DHCPREQUEST,
+                                        Option4ClientFqdn::FLAG_E |
+                                        Option4ClientFqdn::FLAG_S,
+                                        "myhost",
+                                        Option4ClientFqdn::PARTIAL,
+                                        true);
+
+    testProcessFqdn(query,
+                    Option4ClientFqdn::FLAG_E | Option4ClientFqdn::FLAG_S,
+                    "myhost.example.com.");
+
+}
+
+// Test that server generates the fully qualified domain name for the client
+// if clietn supplies empty domain name.
+TEST_F(FqdnDhcpv4SrvTest, serverUpdateForwardNoName) {
+    Pkt4Ptr query = generatePktWithFqdn(DHCPREQUEST,
+                                        Option4ClientFqdn::FLAG_E |
+                                        Option4ClientFqdn::FLAG_S,
+                                        "",
+                                        Option4ClientFqdn::PARTIAL,
+                                        true);
+
+    testProcessFqdn(query,
+                    Option4ClientFqdn::FLAG_E | Option4ClientFqdn::FLAG_S,
+                    "myhost.example.com.");
+
+}
+
+// Test that server does not accept delegation of the forward DNS update
+// to a client.
+TEST_F(FqdnDhcpv4SrvTest, clientUpdateNotAllowed) {
+    Pkt4Ptr query = generatePktWithFqdn(DHCPREQUEST,
+                                        Option4ClientFqdn::FLAG_E,
+                                        "myhost.example.com.",
+                                        Option4ClientFqdn::PARTIAL,
+                                        true);
+
+    testProcessFqdn(query, Option4ClientFqdn::FLAG_E |
+                    Option4ClientFqdn::FLAG_S | Option4ClientFqdn::FLAG_O,
+                    "myhost.example.com.");
+
+}
+
+
+
 } // end of anonymous namespace



More information about the bind10-changes mailing list