From: Francis Dupont Date: Mon, 4 Jul 2016 12:02:46 +0000 (+0200) Subject: [4321] Got rid of used once include_address_ X-Git-Tag: trac4551_base~29^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42c8d0bb9d52508b0c3b35ac11d61f957a442a00;p=thirdparty%2Fkea.git [4321] Got rid of used once include_address_ --- diff --git a/src/bin/dhcp6/tests/decline_unittest.cc b/src/bin/dhcp6/tests/decline_unittest.cc index cf824c1a4c..5d0698d630 100644 --- a/src/bin/dhcp6/tests/decline_unittest.cc +++ b/src/bin/dhcp6/tests/decline_unittest.cc @@ -57,7 +57,6 @@ public: /// @brief IAID used for IA_NA. uint32_t na_iaid_; - }; }; @@ -117,6 +116,9 @@ Dhcpv6SrvTest::acquireAndDecline(Dhcp6Client& client, ASSERT_TRUE(declined_global); uint64_t before_global = declined_cnt->getInteger().first; + /// Determines if the client will include address in the messages it sends. + bool include_address_ = true; + // Let's tamper with the address if necessary. switch (addr_type) { case VALID_ADDR: @@ -129,7 +131,7 @@ Dhcpv6SrvTest::acquireAndDecline(Dhcp6Client& client, break; case NO_ADDR: // Tell the client to not include an address in its IA_NA - client.includeAddress(false); + include_address_ = false; break; case NO_IA: // Tell the client to not include IA_NA at all @@ -144,7 +146,7 @@ Dhcpv6SrvTest::acquireAndDecline(Dhcp6Client& client, client.config_.leases_[0].iaid_ = iaid2; // Ok, let's decline the lease. - ASSERT_NO_THROW(client.doDecline()); + ASSERT_NO_THROW(client.doDecline(include_address_)); // Let's check if there's a lease Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, diff --git a/src/bin/dhcp6/tests/dhcp6_client.cc b/src/bin/dhcp6/tests/dhcp6_client.cc index 43d4a7a47f..d917ce0435 100644 --- a/src/bin/dhcp6/tests/dhcp6_client.cc +++ b/src/bin/dhcp6/tests/dhcp6_client.cc @@ -103,8 +103,7 @@ Dhcp6Client::Dhcp6Client() : use_client_id_(true), use_rapid_commit_(false), client_ias_(), - fqdn_(), - include_address_(true) { + fqdn_() { } Dhcp6Client::Dhcp6Client(boost::shared_ptr& srv) : @@ -120,8 +119,7 @@ Dhcp6Client::Dhcp6Client(boost::shared_ptr& srv) : use_client_id_(true), use_rapid_commit_(false), client_ias_(), - fqdn_(), - include_address_(true) { + fqdn_() { } void @@ -551,7 +549,7 @@ Dhcp6Client::doConfirm() { } void -Dhcp6Client::doDecline() { +Dhcp6Client::doDecline(const bool include_address) { Pkt6Ptr query = createMsg(DHCPV6_DECLINE); if (!forced_server_id_) { query->addOption(context_.response_->getOption(D6O_SERVERID)); @@ -559,7 +557,7 @@ Dhcp6Client::doDecline() { query->addOption(forced_server_id_); } - generateIAFromLeases(query); + generateIAFromLeases(query, include_address); context_.query_ = query; sendMsg(context_.query_); @@ -573,7 +571,8 @@ Dhcp6Client::doDecline() { } void -Dhcp6Client::generateIAFromLeases(const Pkt6Ptr& query) { +Dhcp6Client::generateIAFromLeases(const Pkt6Ptr& query, + const bool include_address) { /// @todo: add support for IAPREFIX here. for (std::vector::const_iterator lease = config_.leases_.begin(); @@ -584,7 +583,7 @@ Dhcp6Client::generateIAFromLeases(const Pkt6Ptr& query) { Option6IAPtr ia(new Option6IA(D6O_IA_NA, lease->iaid_)); - if (include_address_) { + if (include_address) { ia->addOption(OptionPtr(new Option6IAAddr(D6O_IAADDR, lease->addr_, lease->preferred_lft_, lease->valid_lft_))); } diff --git a/src/bin/dhcp6/tests/dhcp6_client.h b/src/bin/dhcp6/tests/dhcp6_client.h index 1c526e4b60..612e4a69ff 100644 --- a/src/bin/dhcp6/tests/dhcp6_client.h +++ b/src/bin/dhcp6/tests/dhcp6_client.h @@ -292,7 +292,8 @@ public: /// /// This function simulates sending the Decline message to the server and /// receiving the server's response. - void doDecline(); + /// @param include_address should the address be included? + void doDecline(const bool include_address = true); /// @brief Performs stateless (inf-request / reply) exchange. /// @@ -590,8 +591,8 @@ public: const asiolink::IOAddress& prefix = asiolink::IOAddress::IPV6_ZERO_ADDRESS()); - /// @brief Removes IAs specified with @ref includeAddress and - /// @ref includePrefix methods. + /// @brief Removes IAs specified by @ref requestAddress and + /// @ref requestPrefix methods. /// /// If this method is called and the client initiates an exchange with /// a server the client will only include IAs for which it has leases. @@ -647,13 +648,6 @@ public: void useFQDN(const uint8_t flags, const std::string& fqdn_name, Option6ClientFqdn::DomainNameType fqdn_type); - /// @brief Controls whether the client should send an addres in IA_NA - /// - /// @param send should the address be included? - void includeAddress(const bool send) { - include_address_ = send; - } - /// @brief Lease configuration obtained by the client. Configuration config_; @@ -693,8 +687,9 @@ public: /// @brief Generates IA_NA based on lease information /// /// @param query generated IA_NA options will be added here - void - generateIAFromLeases(const Pkt6Ptr& query); + /// @param include_address should the address be included? + void generateIAFromLeases(const Pkt6Ptr& query, + const bool include_address = true); /// @brief Adds extra option (an option the client will always send) /// @@ -859,12 +854,6 @@ private: /// @brief FQDN requested by the client. Option6ClientFqdnPtr fqdn_; - - /// @brief Determines if the client will include address in the messages - /// it sends. - /// - /// @todo this flag is currently supported in Decline only. - bool include_address_; }; } // end of namespace isc::dhcp::test