ASSERT_NO_THROW(configure(DECLINE_CONFIGS[0], *client.getServer()));
// Let's get the subnet-id and generate statistics name out of it.
- const Subnet4Collection* subnets =
- CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
+ const Subnet6Collection* subnets =
+ CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
ASSERT_EQ(1, subnets->size());
std::stringstream name;
name << "subnet[" << subnets->at(0)->getID() << "].declined-addresses";
// Set this statistic explicitly to zero.
isc::stats::StatsMgr::instance().setValue(name.str(), static_cast<int64_t>(0));
-
+
// Perform 4-way exchange.
ASSERT_NO_THROW(client.doSARR());
if (!decline_correct_address) {
// Simple increase by one.
- leases_client_na[0].addr_ = IOAddress::increase(leases_client_na[0].addr_);
+ client.config_.leases_[0].addr_ =
+ IOAddress::increase(client.config_.leases_[0].addr_);
}
-
- // Ok, let's decline the lease.
+
+ // Use the second duid
client.setDUID(duid2);
- client.useNA(iaid2);
+
+ // Use the second IAID
+ client.config_.leases_[0].iaid_ = iaid2;
+
+ // Ok, let's decline the lease.
ASSERT_NO_THROW(client.doDecline());
// Let's check if there's a lease
- Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, acquired_address);
+ Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
+ acquired_address);
ASSERT_TRUE(lease);
declined_cnt = StatsMgr::instance().getObservation(name.str());
}
// This test checks that the client can acquire and decline the lease.
-TEST_F(DeclineTest, declineBasic) {
+TEST_F(DeclineTest, basic) {
acquireAndDecline("01:02:03:04:05:06", 1234,
"01:02:03:04:05:06", 1234,
true, SHOULD_PASS);
// - Client acquires new lease using duid, iaid
// - Client sends the DHCPDECLINE with duid, iaid, but uses wrong address.
// - The server rejects Decline due to address mismatch
-TEST_F(DeclineTest, declineAddressMismatch) {
+TEST_F(DeclineTest, addressMismatch) {
acquireAndDecline("01:02:03:04:05:06", 1234,
"01:02:03:04:05:06", 1234,
false, SHOULD_FAIL);
// - Client acquires new lease using duid, iaid1
// - Client sends the DHCPDECLINE with duid, iaid2
// - The server rejects Decline due to IAID mismatch
-TEST_F(DeclineTest, declineIAIDMismatch) {
+TEST_F(DeclineTest, iaidMismatch) {
acquireAndDecline("01:02:03:04:05:06", 1234,
"01:02:03:04:05:06", 1235,
true, SHOULD_FAIL);
// - Client acquires new lease using duid1, iaid
// - Client sends the DHCPDECLINE using duid2, iaid
// - The server rejects the Decline due to DUID mismatch
-TEST_F(DeclineTest, declineDuidMismatch) {
+TEST_F(DeclineTest, duidMismatch) {
acquireAndDecline("01:02:03:04:05:06", 1234,
"01:02:03:04:05:07", 1234,
- true, SHOULD_PASS);
+ true, SHOULD_FAIL);
}
} // end of anonymous namespace
} else {
query->addOption(forced_server_id_);
}
- copyIAs(context_.response_, query);
- appendRequestedIAs(query);
+
+ generateIAFromLeases(query);
context_.query_ = query;
sendMsg(context_.query_);
}
}
+void
+Dhcp6Client::generateIAFromLeases(const Pkt6Ptr& query) {
+ /// @todo: add support for IAPREFIX here.
+
+ for (std::vector<Lease6>::const_iterator lease = config_.leases_.begin();
+ lease != config_.leases_.end(); ++lease) {
+ if (lease->type_ != Lease::TYPE_NA) {
+ continue;
+ }
+
+ Option6IAPtr ia(new Option6IA(D6O_IA_NA, lease->iaid_));
+
+ ia->addOption(Option6IAAddrPtr(new Option6IAAddr(D6O_IAADDR,
+ lease->addr_, lease->preferred_lft_, lease->valid_lft_)));
+ query->addOption(ia);
+ }
+}
void
Dhcp6Client::fastFwdTime(const uint32_t secs) {