2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[4321] Got rid of used once include_address_

This commit is contained in:
Francis Dupont
2016-07-04 14:02:46 +02:00
parent b239ccf360
commit 42c8d0bb9d
3 changed files with 19 additions and 29 deletions

View File

@@ -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,

View File

@@ -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<NakedDhcpv6Srv>& srv) :
@@ -120,8 +119,7 @@ Dhcp6Client::Dhcp6Client(boost::shared_ptr<NakedDhcpv6Srv>& 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<Lease6>::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_)));
}

View File

@@ -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