Browse Source

[3036] Added function to generate NameChangeRequest.

This function is empty now, so it needs to be implemented.
Marcin Siodelski 11 years ago
parent
commit
76aa17ae5f
3 changed files with 80 additions and 34 deletions
  1. 31 12
      src/bin/dhcp6/dhcp6_srv.cc
  2. 27 5
      src/bin/dhcp6/dhcp6_srv.h
  3. 22 17
      src/bin/dhcp6/tests/dhcp6_srv_unittest.cc

+ 31 - 12
src/bin/dhcp6/dhcp6_srv.cc

@@ -50,6 +50,7 @@
 
 using namespace isc;
 using namespace isc::asiolink;
+using namespace isc::d2;
 using namespace isc::dhcp;
 using namespace isc::util;
 using namespace std;
@@ -190,21 +191,22 @@ bool Dhcpv6Srv::run() {
                       .arg(query->toText());
 
             try {
+                NameChangeRequestPtr ncr;
                 switch (query->getType()) {
                 case DHCPV6_SOLICIT:
                     rsp = processSolicit(query);
                     break;
 
                 case DHCPV6_REQUEST:
-                    rsp = processRequest(query);
+                    rsp = processRequest(query, ncr);
                     break;
 
                 case DHCPV6_RENEW:
-                    rsp = processRenew(query);
+                    rsp = processRenew(query, ncr);
                     break;
 
                 case DHCPV6_REBIND:
-                    rsp = processRebind(query);
+                    rsp = processRebind(query, ncr);
                     break;
 
                 case DHCPV6_CONFIRM:
@@ -212,7 +214,7 @@ bool Dhcpv6Srv::run() {
                     break;
 
                 case DHCPV6_RELEASE:
-                    rsp = processRelease(query);
+                    rsp = processRelease(query, ncr);
                     break;
 
                 case DHCPV6_DECLINE:
@@ -269,6 +271,7 @@ bool Dhcpv6Srv::run() {
                     } catch (const std::exception& e) {
                         LOG_ERROR(dhcp6_logger, DHCP6_PACKET_SEND_FAIL).arg(e.what());
                     }
+
                 } else {
                     LOG_ERROR(dhcp6_logger, DHCP6_PACK_FAIL);
                 }
@@ -661,7 +664,8 @@ Dhcpv6Srv::assignLeases(const Pkt6Ptr& question, Pkt6Ptr& answer) {
 }
 
 void
-Dhcpv6Srv::processClientFqdn(const Pkt6Ptr& question, Pkt6Ptr& answer) {
+Dhcpv6Srv::processClientFqdn(const Pkt6Ptr& question, Pkt6Ptr& answer,
+                             NameChangeRequestPtr& ncr) {
     // Get Client FQDN Option from the client's message. If this option hasn't
     // been included, do nothing.
     Option6ClientFqdnPtr fqdn = boost::dynamic_pointer_cast<
@@ -751,8 +755,18 @@ Dhcpv6Srv::processClientFqdn(const Pkt6Ptr& question, Pkt6Ptr& answer) {
     if (include_fqdn) {
         answer->addOption(fqdn_resp);
     }
+
+    createNameChangeRequest(answer, fqdn_resp, ncr);
+}
+
+void
+Dhcpv6Srv::createNameChangeRequest(const Pkt6Ptr&,
+                                   const Option6ClientFqdnPtr&,
+                                   isc::d2::NameChangeRequestPtr&) {
+    // @todo Create NameChangeRequest here.
 }
 
+
 OptionPtr
 Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
                        Pkt6Ptr question, boost::shared_ptr<Option6IA> ia) {
@@ -1147,13 +1161,15 @@ Dhcpv6Srv::processSolicit(const Pkt6Ptr& solicit) {
 
     assignLeases(solicit, advertise);
 
-    processClientFqdn(solicit, advertise);
+    NameChangeRequestPtr ncr;
+    processClientFqdn(solicit, advertise, ncr);
 
     return (advertise);
 }
 
 Pkt6Ptr
-Dhcpv6Srv::processRequest(const Pkt6Ptr& request) {
+Dhcpv6Srv::processRequest(const Pkt6Ptr& request,
+                          NameChangeRequestPtr& ncr) {
 
     sanityCheck(request, MANDATORY, MANDATORY);
 
@@ -1165,13 +1181,14 @@ Dhcpv6Srv::processRequest(const Pkt6Ptr& request) {
 
     assignLeases(request, reply);
 
-    processClientFqdn(request, reply);
+    processClientFqdn(request, reply, ncr);
 
     return (reply);
 }
 
 Pkt6Ptr
-Dhcpv6Srv::processRenew(const Pkt6Ptr& renew) {
+Dhcpv6Srv::processRenew(const Pkt6Ptr& renew,
+                        NameChangeRequestPtr& ncr) {
 
     sanityCheck(renew, MANDATORY, MANDATORY);
 
@@ -1181,7 +1198,7 @@ Dhcpv6Srv::processRenew(const Pkt6Ptr& renew) {
     appendDefaultOptions(renew, reply);
     appendRequestedOptions(renew, reply);
 
-    processClientFqdn(renew, reply);
+    processClientFqdn(renew, reply, ncr);
 
     renewLeases(renew, reply);
 
@@ -1189,7 +1206,8 @@ Dhcpv6Srv::processRenew(const Pkt6Ptr& renew) {
 }
 
 Pkt6Ptr
-Dhcpv6Srv::processRebind(const Pkt6Ptr& rebind) {
+Dhcpv6Srv::processRebind(const Pkt6Ptr& rebind,
+                         NameChangeRequestPtr&) {
     /// @todo: Implement this
     Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, rebind->getTransid()));
     return reply;
@@ -1203,7 +1221,8 @@ Dhcpv6Srv::processConfirm(const Pkt6Ptr& confirm) {
 }
 
 Pkt6Ptr
-Dhcpv6Srv::processRelease(const Pkt6Ptr& release) {
+Dhcpv6Srv::processRelease(const Pkt6Ptr& release,
+                          NameChangeRequestPtr&) {
 
     sanityCheck(release, MANDATORY, MANDATORY);
 

+ 27 - 5
src/bin/dhcp6/dhcp6_srv.h

@@ -15,9 +15,11 @@
 #ifndef DHCPV6_SRV_H
 #define DHCPV6_SRV_H
 
+#include <d2/ncr_msg.h>
 #include <dhcp/dhcp6.h>
 #include <dhcp/duid.h>
 #include <dhcp/option.h>
+#include <dhcp/option6_client_fqdn.h>
 #include <dhcp/option6_ia.h>
 #include <dhcp/option_definition.h>
 #include <dhcp/pkt6.h>
@@ -128,17 +130,20 @@ protected:
     /// @param request a message received from client
     ///
     /// @return REPLY message or NULL
-    Pkt6Ptr processRequest(const Pkt6Ptr& request);
+    Pkt6Ptr processRequest(const Pkt6Ptr& request,
+                           isc::d2::NameChangeRequestPtr& ncr);
 
     /// @brief Stub function that will handle incoming RENEW messages.
     ///
     /// @param renew message received from client
-    Pkt6Ptr processRenew(const Pkt6Ptr& renew);
+    Pkt6Ptr processRenew(const Pkt6Ptr& renew,
+                         isc::d2::NameChangeRequestPtr& ncr);
 
     /// @brief Stub function that will handle incoming REBIND messages.
     ///
     /// @param rebind message received from client
-    Pkt6Ptr processRebind(const Pkt6Ptr& rebind);
+    Pkt6Ptr processRebind(const Pkt6Ptr& rebind,
+                          isc::d2::NameChangeRequestPtr& ncr);
 
     /// @brief Stub function that will handle incoming CONFIRM messages.
     ///
@@ -148,7 +153,8 @@ protected:
     /// @brief Stub function that will handle incoming RELEASE messages.
     ///
     /// @param release message received from client
-    Pkt6Ptr processRelease(const Pkt6Ptr& release);
+    Pkt6Ptr processRelease(const Pkt6Ptr& release,
+                           isc::d2::NameChangeRequestPtr& ncr);
 
     /// @brief Stub function that will handle incoming DECLINE messages.
     ///
@@ -283,7 +289,23 @@ protected:
     ///
     /// @param question Client's message.
     /// @param answer Server's response to the client.
-    void processClientFqdn(const Pkt6Ptr& question, Pkt6Ptr& answer);
+    void processClientFqdn(const Pkt6Ptr& question, Pkt6Ptr& answer,
+                           d2::NameChangeRequestPtr& ncr);
+
+    /// @brief Creates a @c isc::d2::NameChangeRequest based on the DHCPv6
+    /// Client FQDN %Option stored in the response to the client.
+    ///
+    /// The @c isc:d2::NameChangeRequest class encapsulates the request from
+    /// the DHCPv6 server to the DHCP-DDNS module to perform DNS Update.
+    ///
+    /// @param answer A response being sent to a client.
+    /// @param fqdn_answer A DHCPv6 Client FQDN %Option which is included in the
+    /// response message sent to a client.
+    /// @param [out] ncr A @c isc::d2::NameChangeRequest object to be sent to
+    /// the DHCP-DDNS module as a result of the Client FQDN %Option processing.
+    void createNameChangeRequest(const Pkt6Ptr& answer,
+                                 const Option6ClientFqdnPtr& fqdn_answer,
+                                 isc::d2::NameChangeRequestPtr& ncr);
 
     /// @brief Attempts to renew received addresses
     ///

+ 22 - 17
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc

@@ -16,6 +16,7 @@
 
 #include <asiolink/io_address.h>
 #include <config/ccsession.h>
+#include <d2/ncr_msg.h>
 #include <dhcp/dhcp6.h>
 #include <dhcp/duid.h>
 #include <dhcp/option.h>
@@ -45,6 +46,7 @@
 using namespace isc;
 using namespace isc::asiolink;
 using namespace isc::config;
+using namespace isc::d2;
 using namespace isc::data;
 using namespace isc::dhcp;
 using namespace isc::util;
@@ -244,6 +246,9 @@ public:
 
     int rcode_;
     ConstElementPtr comment_;
+
+    // A NameChangeRequest used in many tests.
+    NameChangeRequestPtr ncr_;
 };
 
 // Provides suport for tests against a preconfigured subnet6
@@ -336,6 +341,7 @@ public:
 
     // A pool used in most tests
     Pool6Ptr pool_;
+
 };
 
 class FqdnDhcpv6SrvTest : public NakedDhcpv6SrvTest {
@@ -406,7 +412,7 @@ public:
 
         }
 
-        ASSERT_NO_THROW(srv.processClientFqdn(question, answer));
+        ASSERT_NO_THROW(srv.processClientFqdn(question, answer, ncr_));
 
         Option6ClientFqdnPtr answ_fqdn = getClientFqdnOption(answer);
         ASSERT_TRUE(answ_fqdn);
@@ -475,7 +481,7 @@ TEST_F(NakedDhcpv6SrvTest, RequestNoSubnet) {
     req->addOption(srv.getServerID());
 
     // Pass it to the server and hope for a REPLY
-    Pkt6Ptr reply = srv.processRequest(req);
+    Pkt6Ptr reply = srv.processRequest(req, ncr_);
 
     // check that we get the right NAK
     checkNakResponse (reply, DHCPV6_REPLY, 1234, STATUS_NoAddrsAvail);
@@ -510,7 +516,7 @@ TEST_F(NakedDhcpv6SrvTest, RenewNoSubnet) {
     req->addOption(srv.getServerID());
 
     // Pass it to the server and hope for a REPLY
-    Pkt6Ptr reply = srv.processRenew(req);
+    Pkt6Ptr reply = srv.processRenew(req, ncr_);
 
     // check that we get the right NAK
     checkNakResponse (reply, DHCPV6_REPLY, 1234, STATUS_NoBinding);
@@ -545,7 +551,7 @@ TEST_F(NakedDhcpv6SrvTest, ReleaseNoSubnet) {
     req->addOption(srv.getServerID());
 
     // Pass it to the server and hope for a REPLY
-    Pkt6Ptr reply = srv.processRelease(req);
+    Pkt6Ptr reply = srv.processRelease(req, ncr_);
 
     // check that we get the right NAK
     checkNakResponse (reply, DHCPV6_REPLY, 1234, STATUS_NoBinding);
@@ -1013,7 +1019,7 @@ TEST_F(Dhcpv6SrvTest, RequestBasic) {
     req->addOption(srv.getServerID());
 
     // Pass it to the server and hope for a REPLY
-    Pkt6Ptr reply = srv.processRequest(req);
+    Pkt6Ptr reply = srv.processRequest(req, ncr_);
 
     // check if we get response at all
     checkResponse(reply, DHCPV6_REPLY, 1234);
@@ -1078,9 +1084,9 @@ TEST_F(Dhcpv6SrvTest, ManyRequests) {
     req3->addOption(srv.getServerID());
 
     // Pass it to the server and get an advertise
-    Pkt6Ptr reply1 = srv.processRequest(req1);
-    Pkt6Ptr reply2 = srv.processRequest(req2);
-    Pkt6Ptr reply3 = srv.processRequest(req3);
+    Pkt6Ptr reply1 = srv.processRequest(req1, ncr_);
+    Pkt6Ptr reply2 = srv.processRequest(req2, ncr_);
+    Pkt6Ptr reply3 = srv.processRequest(req3, ncr_);
 
     // check if we get response at all
     checkResponse(reply1, DHCPV6_REPLY, 1234);
@@ -1175,7 +1181,7 @@ TEST_F(Dhcpv6SrvTest, RenewBasic) {
     req->addOption(srv.getServerID());
 
     // Pass it to the server and hope for a REPLY
-    Pkt6Ptr reply = srv.processRenew(req);
+    Pkt6Ptr reply = srv.processRenew(req, ncr_);
 
     // Check if we get response at all
     checkResponse(reply, DHCPV6_REPLY, 1234);
@@ -1261,7 +1267,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
     // Case 1: No lease known to server
 
     // Pass it to the server and hope for a REPLY
-    Pkt6Ptr reply = srv.processRenew(req);
+    Pkt6Ptr reply = srv.processRenew(req, ncr_);
 
     // Check if we get response at all
     checkResponse(reply, DHCPV6_REPLY, transid);
@@ -1287,7 +1293,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
 
     // Pass it to the server and hope for a REPLY
-    reply = srv.processRenew(req);
+    reply = srv.processRenew(req, ncr_);
     checkResponse(reply, DHCPV6_REPLY, transid);
     tmp = reply->getOption(D6O_IA_NA);
     ASSERT_TRUE(tmp);
@@ -1306,7 +1312,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
     req->addOption(generateClientId(13)); // generate different DUID
                                           // (with length 13)
 
-    reply = srv.processRenew(req);
+    reply = srv.processRenew(req, ncr_);
     checkResponse(reply, DHCPV6_REPLY, transid);
     tmp = reply->getOption(D6O_IA_NA);
     ASSERT_TRUE(tmp);
@@ -1369,7 +1375,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
     req->addOption(srv.getServerID());
 
     // Pass it to the server and hope for a REPLY
-    Pkt6Ptr reply = srv.processRelease(req);
+    Pkt6Ptr reply = srv.processRelease(req, ncr_);
 
     // Check if we get response at all
     checkResponse(reply, DHCPV6_REPLY, 1234);
@@ -1447,7 +1453,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
     SCOPED_TRACE("CASE 1: No lease known to server");
 
     // Pass it to the server and hope for a REPLY
-    Pkt6Ptr reply = srv.processRelease(req);
+    Pkt6Ptr reply = srv.processRelease(req, ncr_);
 
     // Check if we get response at all
     checkResponse(reply, DHCPV6_REPLY, transid);
@@ -1471,7 +1477,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
 
     // Pass it to the server and hope for a REPLY
-    reply = srv.processRelease(req);
+    reply = srv.processRelease(req, ncr_);
     checkResponse(reply, DHCPV6_REPLY, transid);
     tmp = reply->getOption(D6O_IA_NA);
     ASSERT_TRUE(tmp);
@@ -1494,7 +1500,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
     req->addOption(generateClientId(13)); // generate different DUID
                                           // (with length 13)
 
-    reply = srv.processRelease(req);
+    reply = srv.processRelease(req, ncr_);
     checkResponse(reply, DHCPV6_REPLY, transid);
     tmp = reply->getOption(D6O_IA_NA);
     ASSERT_TRUE(tmp);
@@ -1892,7 +1898,6 @@ TEST_F(FqdnDhcpv6SrvTest, noUpdate) {
 // Test server's response when client requests that server delegates the AAAA
 // update to the client and this delegation is not allowed.
 TEST_F(FqdnDhcpv6SrvTest, clientAAAAUpdateNotAllowed) {
-    SCOPED_TRACE("Client AAAA Update is not allowed");
     testFqdn(DHCPV6_SOLICIT, true, 0, "myhost.example.com.",
              Option6ClientFqdn::FULL, FQDN_FLAG_S | FQDN_FLAG_O,
              "myhost.example.com.");