subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24,
unspecified,
unspecified,
- valid_lft);
+ valid_lft,
+ subnet_->getID());
pool_ = Pool4Ptr(new Pool4(IOAddress("192.0.2.100"),
IOAddress("192.0.2.110")));
subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24,
unspecified,
unspecified,
- valid_lft);
+ valid_lft,
+ subnet_->getID());
pool_ = Pool4Ptr(new Pool4(IOAddress("192.0.2.100"),
IOAddress("192.0.2.110")));
subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24,
unspecified,
unspecified,
- valid_lft);
+ valid_lft,
+ subnet_->getID());
pool_ = Pool4Ptr(new Pool4(IOAddress("192.0.2.100"),
IOAddress("192.0.2.110")));
subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24,
Triplet<uint32_t>(),
Triplet<uint32_t>(),
- 3000);
+ 3000,
+ subnet_->getID());
pool_ = Pool4Ptr(new Pool4(IOAddress("192.0.2.100"),
IOAddress("192.0.2.110")));
subnet_->addPool(pool_);
// Wipe any existing statistics
isc::stats::StatsMgr::instance().removeAll();
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1000, 2000, 3000);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"),
+ 24, 1000, 2000, 3000, SubnetID(1));
pool_ = Pool4Ptr(new Pool4(IOAddress("192.0.2.100"), IOAddress("192.0.2.110")));
subnet_->addPool(pool_);
TEST_F(Dhcpv6SrvTest, selectSubnetAddr) {
NakedDhcpv6Srv srv(0);
- auto subnet1 = Subnet6::create(IOAddress("2001:db8:1::"), 48, 1, 2, 3, 4);
- auto subnet2 = Subnet6::create(IOAddress("2001:db8:2::"), 48, 1, 2, 3, 4);
- auto subnet3 = Subnet6::create(IOAddress("2001:db8:3::"), 48, 1, 2, 3, 4);
+ auto subnet1 = Subnet6::create(IOAddress("2001:db8:1::"),
+ 48, 1, 2, 3, 4, SubnetID(10));
+ auto subnet2 = Subnet6::create(IOAddress("2001:db8:2::"),
+ 48, 1, 2, 3, 4, SubnetID(20));
+ auto subnet3 = Subnet6::create(IOAddress("2001:db8:3::"),
+ 48, 1, 2, 3, 4, SubnetID(30));
// CASE 1: We have only one subnet defined and we received local traffic.
// The only available subnet used to be picked, but not anymore
TEST_F(Dhcpv6SrvTest, selectSubnetIface) {
NakedDhcpv6Srv srv(0);
- auto subnet1 = Subnet6::create(IOAddress("2001:db8:1::"), 48, 1, 2, 3, 4);
- auto subnet2 = Subnet6::create(IOAddress("2001:db8:2::"), 48, 1, 2, 3, 4);
- auto subnet3 = Subnet6::create(IOAddress("2001:db8:3::"), 48, 1, 2, 3, 4);
+ auto subnet1 = Subnet6::create(IOAddress("2001:db8:1::"),
+ 48, 1, 2, 3, 4, SubnetID(10));
+ auto subnet2 = Subnet6::create(IOAddress("2001:db8:2::"),
+ 48, 1, 2, 3, 4, SubnetID(20));
+ auto subnet3 = Subnet6::create(IOAddress("2001:db8:3::"),
+ 48, 1, 2, 3, 4, SubnetID(30));
subnet1->setIface("eth0");
subnet3->setIface("wifi1");
TEST_F(Dhcpv6SrvTest, selectSubnetRelayLinkaddr) {
NakedDhcpv6Srv srv(0);
- auto subnet1 = Subnet6::create(IOAddress("2001:db8:1::"), 48, 1, 2, 3, 4);
- auto subnet2 = Subnet6::create(IOAddress("2001:db8:2::"), 48, 1, 2, 3, 4);
- auto subnet3 = Subnet6::create(IOAddress("2001:db8:3::"), 48, 1, 2, 3, 4);
+ auto subnet1 = Subnet6::create(IOAddress("2001:db8:1::"),
+ 48, 1, 2, 3, 4, SubnetID(10));
+ auto subnet2 = Subnet6::create(IOAddress("2001:db8:2::"),
+ 48, 1, 2, 3, 4, SubnetID(20));
+ auto subnet3 = Subnet6::create(IOAddress("2001:db8:3::"),
+ 48, 1, 2, 3, 4, SubnetID(30));
Pkt6::RelayInfo relay;
relay.linkaddr_ = IOAddress("2001:db8:2::1234");
TEST_F(Dhcpv6SrvTest, selectSubnetRelayInterfaceId) {
NakedDhcpv6Srv srv(0);
- auto subnet1 = Subnet6::create(IOAddress("2001:db8:1::"), 48, 1, 2, 3, 4);
- auto subnet2 = Subnet6::create(IOAddress("2001:db8:2::"), 48, 1, 2, 3, 4);
- auto subnet3 = Subnet6::create(IOAddress("2001:db8:3::"), 48, 1, 2, 3, 4);
+ auto subnet1 = Subnet6::create(IOAddress("2001:db8:1::"),
+ 48, 1, 2, 3, 4, SubnetID(10));
+ auto subnet2 = Subnet6::create(IOAddress("2001:db8:2::"),
+ 48, 1, 2, 3, 4, SubnetID(20));
+ auto subnet3 = Subnet6::create(IOAddress("2001:db8:3::"),
+ 48, 1, 2, 3, 4, SubnetID(30));
subnet1->setInterfaceId(generateInterfaceId("relay1"));
subnet2->setInterfaceId(generateInterfaceId("relay2"));
Dhcpv6SrvTest::Dhcpv6SrvTest()
: NakedDhcpv6SrvTest(), srv_(0), multi_threading_(false) {
subnet_ = Subnet6::create(isc::asiolink::IOAddress("2001:db8:1::"),
- 48, 1000, 2000, 3000, 4000);
+ 48, 1000, 2000, 3000, 4000, SubnetID(1));
subnet_->setIface("eth0");
pool_ = isc::dhcp::Pool6Ptr(new isc::dhcp::Pool6(isc::dhcp::Lease::TYPE_NA,
// and then be reused.
if (expire_before_renew) {
CfgMgr::instance().clear();
- subnet_ = Subnet6::create(IOAddress("2001:db8:1:1::"),
- 48, 1000, 2000, 3000, 4000);
+ subnet_ = Subnet6::create(IOAddress("2001:db8:1:1::"), 48,
+ 1000, 2000, 3000, 4000, subnet_->getID());
subnet_->setIface("eth0");
pool_.reset(new Pool6(Lease::TYPE_NA, existing, existing));
subnet_->addPool(pool_);
// exactly one address. This address will be handed out to the
// client, will get expired and then be reused.
CfgMgr::instance().clear();
- subnet_ = Subnet6::create(IOAddress("2001:db8:1:1::"), 56, 1, 2, 3, 4);
+ subnet_ = Subnet6::create(IOAddress("2001:db8:1:1::"),
+ 56, 1, 2, 3, 4, SubnetID(10));
subnet_->setIface("eth0");
subnet_->setDdnsSendUpdates(true);
/// @param t1 renewal timer (in seconds)
/// @param t2 rebind timer (in seconds)
/// @param valid_lifetime preferred lifetime of leases (in seconds)
- /// @param id arbitrary subnet id, default value of 0 triggers
- /// autogeneration of subnet id
+ /// @param id arbitrary subnet id, no default value
Subnet4(const isc::asiolink::IOAddress& prefix, uint8_t length,
const util::Triplet<uint32_t>& t1,
const util::Triplet<uint32_t>& t2,
const util::Triplet<uint32_t>& valid_lifetime,
- const SubnetID id = 0);
+ const SubnetID id);
/// @brief Factory function creating an instance of the @c Subnet4.
///
/// @param t1 renewal timer (in seconds)
/// @param t2 rebind timer (in seconds)
/// @param valid_lifetime preferred lifetime of leases (in seconds)
- /// @param id arbitrary subnet id, default value of 0 triggers
- /// autogeneration of subnet id
+ /// @param id arbitrary subnet id, no default value
///
/// @return Pointer to the @c Subnet4 instance.
static Subnet4Ptr
const util::Triplet<uint32_t>& t1,
const util::Triplet<uint32_t>& t2,
const util::Triplet<uint32_t>& valid_lifetime,
- const SubnetID id = 0);
+ const SubnetID id);
/// @brief Returns next subnet within shared network.
///
/// @param t2 rebind timer (in seconds)
/// @param preferred_lifetime preferred lifetime of leases (in seconds)
/// @param valid_lifetime preferred lifetime of leases (in seconds)
- /// @param id arbitrary subnet id, default value of 0 triggers
+ /// @param id arbitrary subnet id, no default value
/// autogeneration of subnet id
Subnet6(const isc::asiolink::IOAddress& prefix, uint8_t length,
const util::Triplet<uint32_t>& t1,
const util::Triplet<uint32_t>& t2,
const util::Triplet<uint32_t>& preferred_lifetime,
const util::Triplet<uint32_t>& valid_lifetime,
- const SubnetID id = 0);
+ const SubnetID id);
/// @brief Factory function creating an instance of the @c Subnet4.
///
/// @param t2 rebind timer (in seconds)
/// @param preferred_lifetime preferred lifetime of leases (in seconds)
/// @param valid_lifetime preferred lifetime of leases (in seconds)
- /// @param id arbitrary subnet id, default value of 0 triggers
- /// autogeneration of subnet id
+ /// @param id arbitrary subnet id, no default value
///
/// @return Pointer to the @c Subnet6 instance.
static Subnet6Ptr
const util::Triplet<uint32_t>& t2,
const util::Triplet<uint32_t>& preferred_lifetime,
const util::Triplet<uint32_t>& valid_lifetime,
- const SubnetID id = 0);
+ const SubnetID id);
/// @brief Returns next subnet within shared network.
///
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
// Allocations without HW address are not allowed
AllocEngine::ClientContext4 ctx2(subnet_, clientid_, HWAddrPtr(),
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
// Allocations without client-id are allowed
clientid_.reset();
cfg_mgr.clear();
// Create configuration similar to other tests, but with a single address pool
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(addr, addr)); // just a single address
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets4()->add(subnet_);
cfg_mgr.clear();
// Create configuration similar to other tests, but with a single address pool
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(addr, addr)); // just a single address
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets4()->add(subnet_);
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(1, getStatistics("v4-allocation-fail", 2));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 2));
- EXPECT_EQ(1, getStatistics("v4-allocation-fail-subnet", 2));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 2));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 2));
+ EXPECT_EQ(1, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(1, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
}
/// @brief This test class is dedicated to testing shared networks
// Create two subnets, each with a single address pool. The first subnet
// has only one address in its address pool to make it easier to simulate
// address exhaustion.
- subnet1_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(1));
- subnet2_ = Subnet4::create(IOAddress("10.1.2.0"), 24, 1, 2, 3, SubnetID(2));
+ subnet1_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(10));
+ subnet2_ = Subnet4::create(IOAddress("10.1.2.0"), 24, 1, 2, 3, SubnetID(20));
pool1_.reset(new Pool4(IOAddress("192.0.2.17"), IOAddress("192.0.2.17")));
pool2_.reset(new Pool4(IOAddress("10.1.2.5"), IOAddress("10.1.2.100")));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(1, getStatistics("v4-allocation-fail", 1));
- EXPECT_EQ(1, getStatistics("v4-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 1));
+ EXPECT_EQ(1, getStatistics("v4-allocation-fail", subnet1_->getID()));
+ EXPECT_EQ(1, getStatistics("v4-allocation-fail-shared-network", subnet1_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", subnet1_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet1_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet1_->getID()));
}
// This test verifies that the server can offer an address from a
cfg_mgr.clear();
// Create configuration similar to other tests, but with a single address pool
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(addr, addr)); // just a single address
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets4()->add(subnet_);
IOAddress addr("192.0.2.15");
CfgMgr& cfg_mgr = CfgMgr::instance();
cfg_mgr.clear();
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(addr, addr)); // just a single address
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets4()->add(subnet_);
IOAddress addr("192.0.2.15");
CfgMgr& cfg_mgr = CfgMgr::instance();
cfg_mgr.clear();
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(addr, addr)); // just a single address
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets4()->add(subnet_);
IOAddress addr("192.0.2.15");
CfgMgr& cfg_mgr = CfgMgr::instance();
cfg_mgr.clear();
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(addr, addr)); // just a single address
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets4()->add(subnet_);
IOAddress addr("192.0.2.15");
CfgMgr& cfg_mgr = CfgMgr::instance();
cfg_mgr.clear();
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(addr, addr)); // just a single address
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets4()->add(subnet_);
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
// Now simulate the DHCPDISCOVER case when the provided address is
// treated as a hint. The engine should return a lease for a
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
// Now, request a correct address. The client should obtain it.
AllocEngine::ClientContext4 ctx2(subnet_, clientid_, hwaddr_,
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
// Make sure that the allocation engine didn't modify the lease of the
// client A.
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
from_mgr = LeaseMgrFactory::instance().getLease4(lease->addr_);
ASSERT_TRUE(from_mgr);
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
// Repeat the test, but this time ask for the address that the client
// has allocated.
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
}
// This test checks that the behavior of the allocation engine in the following
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
// Client A tries to renew the lease. The renewal should fail because
// server detects that Client A doesn't have reservation for this
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
// Client A returns to DHCPDISCOVER and should be offered a lease.
// The offered lease address must be different than the one the
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
// The same client should get a different lease than requested if
// if is sending a DHCPDISCOVER (fake allocation is true).
EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes"));
- EXPECT_EQ(1, getStatistics("v4-allocation-fail", 2));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", 2));
- EXPECT_EQ(1, getStatistics("v4-allocation-fail-subnet", 2));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", 2));
- EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", 2));
+ EXPECT_EQ(1, getStatistics("v4-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(1, getStatistics("v4-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v4-allocation-fail-classes", subnet_->getID()));
// Now, let's remove the reservation.
initSubnet(IOAddress("192.0.2.100"), IOAddress("192.0.2.100"));
cfg_mgr.clear();
// Configure a larger subnet with a /24 pool.
- subnet_ = Subnet4::create(IOAddress("10.0.0.0"), 8, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("10.0.0.0"), 8, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(IOAddress("10.0.1.0"), IOAddress("10.0.1.255")));
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets4()->add(subnet_);
cfg_mgr.clear();
// Configure a larger subnet with a /24 pool.
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(IOAddress("192.0.2.0"),
IOAddress("192.0.2.255")));
subnet_->addPool(pool_);
cfg_mgr.clear();
// Configure a larger subnet with a /24 pool.
- subnet_ = Subnet4::create(IOAddress("10.0.0.0"), 8, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("10.0.0.0"), 8, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(IOAddress("10.0.1.0"), IOAddress("10.0.1.255")));
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets4()->add(subnet_);
cfg_mgr.clear();
// Configure a larger subnet with a /24 pool.
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(IOAddress("192.0.2.0"),
IOAddress("192.0.2.255")));
subnet_->addPool(pool_);
cfg_mgr.clear();
// Configure a smaller subnet with a /25 pool.
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 25, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 25, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(IOAddress("192.0.2.0"),
IOAddress("192.0.2.127")));
subnet_->addPool(pool_);
cfg_mgr.clear();
// Configure a smaller subnet with a /25 pool.
- subnet_ = Subnet4::create(IOAddress("192.0.2.128"), 25, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.128"), 25, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(IOAddress("192.0.2.128"),
IOAddress("192.0.2.255")));
subnet_->addPool(pool_);
cfg_mgr.clear();
// Configure a larger subnet with a /24 pool.
- subnet_ = Subnet4::create(IOAddress("10.0.0.0"), 8, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("10.0.0.0"), 8, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(IOAddress("10.0.1.0"), IOAddress("10.0.1.255")));
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets4()->add(subnet_);
cfg_mgr.clear();
// Configure a larger subnet with a /24 pool.
- subnet_ = Subnet4::create(IOAddress("10.0.0.0"), 8, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("10.0.0.0"), 8, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(IOAddress("10.0.1.0"), IOAddress("10.0.1.255")));
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets4()->add(subnet_);
cfg_mgr.clear();
// Create configuration similar to other tests, but with a single address pool
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(addr, addr)); // just a single address
subnet_->addPool(pool_);
cfg_mgr.clear();
// Create configuration similar to other tests, but with a single address pool
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 300);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 300, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(addr, addr)); // just a single address
subnet_->addPool(pool_);
cfg_mgr.clear();
// Create configuration similar to other tests, but with a single address pool
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(10));
pool_ = Pool4Ptr(new Pool4(addr, addr)); // just a single address
subnet_->addPool(pool_);
EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", subnet_->getID()));
// Allocations without DUID are not allowed either
AllocEngine::ClientContext6 ctx2(subnet_, DuidPtr(), false, false, "", false,
EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", subnet_->getID()));
}
// This test checks if really small pools are working
cfg_mgr.clear(); // Get rid of the default test configuration
// Create configuration similar to other tests, but with a single address pool
- subnet_ = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ subnet_ = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4, SubnetID(10));
pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, addr, addr)); // just a single address
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets6()->add(subnet_);
EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes"));
- EXPECT_EQ(1, getStatistics("v6-allocation-fail", 2));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", 2));
- EXPECT_EQ(1, getStatistics("v6-allocation-fail-subnet", 2));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", 2));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", 2));
+ EXPECT_EQ(1, getStatistics("v6-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(1, getStatistics("v6-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", subnet_->getID()));
}
// This test checks if an expired lease can be reused in SOLICIT (fake allocation)
cfg_mgr.clear(); // Get rid of the default test configuration
// Create configuration similar to other tests, but with a single address pool
- subnet_ = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ subnet_ = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4, SubnetID(10));
pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, addr, addr)); // just a single address
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets6()->add(subnet_);
EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes"));
- EXPECT_EQ(failure, getStatistics("v6-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", 1));
- EXPECT_EQ(failure, getStatistics("v6-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", 1));
+ EXPECT_EQ(failure, getStatistics("v6-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(failure, getStatistics("v6-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", subnet_->getID()));
} else {
success++;
std::cout << "Alloc for client " << (int)i << " succeeded:"
EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", subnet_->getID()));
// Let's fix this and break it in a different way.
ctx.subnet_ = subnet_;
EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes"));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", 1));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", subnet_->getID()));
}
// Checks whether an address can be renewed (simple case, no reservation tricks)
AllocEngine engine(0);
// Configure 2001:db8::/32 subnet
- subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4);
+ subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(10));
// Configure the NA pool of /48. So there are 2^80 addresses there. Make
// sure that we still can handle cases where number of available addresses
EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes"));
- EXPECT_EQ(1, getStatistics("v6-allocation-fail", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", 1));
- EXPECT_EQ(1, getStatistics("v6-allocation-fail-subnet", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", 1));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", 1));
+ EXPECT_EQ(1, getStatistics("v6-allocation-fail", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-shared-network", subnet_->getID()));
+ EXPECT_EQ(1, getStatistics("v6-allocation-fail-subnet", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", subnet_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", subnet_->getID()));
// This time, lets allow more attempts, and expect that the allocation will
// be successful.
cfg_mgr.clear(); // Get rid of the default test configuration
// Create configuration similar to other tests, but with a single address pool
- subnet_ = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ subnet_ = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4, SubnetID(10));
pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, addr, addr)); // just a single address
subnet_->addPool(pool_);
cfg_mgr.getStagingCfg()->getCfgSubnets6()->add(subnet_);
SharedNetworkAlloc6Test()
:engine_(0) {
- subnet1_ = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
- subnet2_ = Subnet6::create(IOAddress("2001:db8:2::"), 56, 1, 2, 3, 4);
+ subnet1_ = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4, SubnetID(10));
+ subnet2_ = Subnet6::create(IOAddress("2001:db8:2::"), 56, 1, 2, 3, 4, SubnetID(20));
pool1_.reset(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"),
IOAddress("2001:db8:1::1")));
pool2_.reset(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:2::"),
EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools"));
EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes"));
- EXPECT_EQ(1, getStatistics("v6-allocation-fail", 3));
- EXPECT_EQ(1, getStatistics("v6-allocation-fail-shared-network", 3));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-subnet", 3));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", 3));
- EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", 3));
+ EXPECT_EQ(1, getStatistics("v6-allocation-fail", subnet2_->getID()));
+ EXPECT_EQ(1, getStatistics("v6-allocation-fail-shared-network", subnet2_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-subnet", subnet2_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-no-pools", subnet2_->getID()));
+ EXPECT_EQ(0, getStatistics("v6-allocation-fail-classes", subnet2_->getID()));
}
// Verifies that client with a hostname reservation can
}
AllocEngine6Test::AllocEngine6Test() {
- Subnet::resetSubnetID();
+ // No longer used but this means too that tests relied far too much on it.
+ //Subnet::resetSubnetID();
+
CfgMgr::instance().clear();
// This lease mgr needs to exist to before configuration commits.
const uint8_t pd_delegated_length) {
CfgMgr& cfg_mgr = CfgMgr::instance();
- subnet_ = Subnet6::create(subnet, 56, 100, 200, 300, 400);
+ static SubnetID id(1);
+ subnet_ = Subnet6::create(subnet, 56, 100, 200, 300, 400, id++);
pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, pool_start, pool_end));
subnet_->addPool(pool_);
const asiolink::IOAddress& pool_end) {
CfgMgr& cfg_mgr = CfgMgr::instance();
- subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ static SubnetID id(1);
+ subnet_ = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3, id++);
pool_ = Pool4Ptr(new Pool4(pool_start, pool_end));
subnet_->addPool(pool_);
}
AllocEngine4Test::AllocEngine4Test() {
- Subnet::resetSubnetID();
+ // No longer used but this means too that tests relied far too much on it.
+ //Subnet::resetSubnetID();
+
CfgMgr::instance().clear();
// This lease mgr needs to exist to before configuration commits.
CfgSubnets4 cfg;
// Create 3 subnets.
- Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"), 26, 1, 2, 3));
- Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"), 26, 1, 2, 3));
- Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3));
+ Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"),
+ 26, 1, 2, 3, SubnetID(1)));
+ Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"),
+ 26, 1, 2, 3, SubnetID(2)));
+ Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"),
+ 26, 1, 2, 3, SubnetID(3)));
// Make sure that initially the subnets don't exist.
SubnetSelector selector;
CfgSubnets4 cfg;
// Create 3 subnets.
- Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"), 26, 1, 2, 3));
- Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"), 26, 1, 2, 3));
- Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3));
+ Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"),
+ 26, 1, 2, 3, SubnetID(1)));
+ Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"),
+ 26, 1, 2, 3, SubnetID(2)));
+ Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"),
+ 26, 1, 2, 3, SubnetID(3)));
// No interface defined for subnet1
subnet2->setIface("lo");
subnet3->setIface("eth1");
CfgSubnets4 cfg;
// Create 3 subnets.
- Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"), 26, 1, 2, 3));
- Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"), 26, 1, 2, 3));
- Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3));
+ Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"),
+ 26, 1, 2, 3, SubnetID(1)));
+ Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"),
+ 26, 1, 2, 3, SubnetID(2)));
+ Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"),
+ 26, 1, 2, 3, SubnetID(3)));
// Add them to the configuration.
cfg.add(subnet1);
CfgSubnets4 cfg;
// Create 3 subnets.
- Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"), 26, 1, 2, 3));
- Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"), 26, 1, 2, 3));
- Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3));
+ Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"),
+ 26, 1, 2, 3, SubnetID(1)));
+ Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"),
+ 26, 1, 2, 3, SubnetID(2)));
+ Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"),
+ 26, 1, 2, 3, SubnetID(3)));
// Add them to the configuration.
cfg.add(subnet1);
CfgSubnets4 cfg;
// Create 3 subnets.
- Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"), 26, 1, 2, 3));
- Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"), 26, 1, 2, 3));
- Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3));
+ Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"),
+ 26, 1, 2, 3, SubnetID(1)));
+ Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"),
+ 26, 1, 2, 3, SubnetID(2)));
+ Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"),
+ 26, 1, 2, 3, SubnetID(3)));
// Add them to the configuration.
cfg.add(subnet1);
CfgSubnets4 cfg;
// Create 3 subnets.
- Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"), 26, 1, 2, 3));
- Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"), 26, 1, 2, 3));
- Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3));
+ Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"),
+ 26, 1, 2, 3, SubnetID(1)));
+ Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"),
+ 26, 1, 2, 3, SubnetID(2)));
+ Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"),
+ 26, 1, 2, 3, SubnetID(3)));
// Add them to the configuration.
cfg.add(subnet1);
CfgSubnets4 cfg;
// Create 3 subnets.
- Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"), 26, 1, 2, 3));
- Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"), 26, 1, 2, 3));
- Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3));
+ Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"),
+ 26, 1, 2, 3, SubnetID(1)));
+ Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"),
+ 26, 1, 2, 3, SubnetID(2)));
+ Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"),
+ 26, 1, 2, 3, SubnetID(3)));
// Add them to the configuration.
cfg.add(subnet1);
CfgSubnets4 cfg;
// Create 3 subnets.
- Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"), 26, 1, 2, 3));
- Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"), 26, 1, 2, 3));
- Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3));
+ Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"),
+ 26, 1, 2, 3, SubnetID(1)));
+ Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"),
+ 26, 1, 2, 3, SubnetID(2)));
+ Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"),
+ 26, 1, 2, 3, SubnetID(3)));
// Add them to the configuration.
cfg.add(subnet1);
CfgSubnets4 cfg;
// Create 3 subnets.
- Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"), 26, 1, 2, 3));
- Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"), 26, 1, 2, 3));
- Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3));
+ Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"),
+ 26, 1, 2, 3, SubnetID(1)));
+ Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"),
+ 26, 1, 2, 3, SubnetID(2)));
+ Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"),
+ 26, 1, 2, 3, SubnetID(3)));
// Make sure that initially the subnets don't exist.
SubnetSelector selector;
EXPECT_FALSE(cfg.selectSubnet(selector));
// Configure first subnet which address on eth0 corresponds to.
- Subnet4Ptr subnet1(new Subnet4(IOAddress("10.0.0.1"), 24, 1, 2, 3));
+ Subnet4Ptr subnet1(new Subnet4(IOAddress("10.0.0.1"),
+ 24, 1, 2, 3, SubnetID(1)));
cfg.add(subnet1);
// The address on eth0 should match the existing subnet.
EXPECT_FALSE(cfg.selectSubnet(selector));
// Configure a second subnet.
- Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.1"), 24, 1, 2, 3));
+ Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.1"),
+ 24, 1, 2, 3, SubnetID(2)));
cfg.add(subnet2);
// There should be match between eth0 and subnet1 and between eth1 and
CfgSubnets6 cfg;
// Create 3 subnets.
- Subnet6Ptr subnet1(new Subnet6(IOAddress("2001:db8:1::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet2(new Subnet6(IOAddress("2001:db8:2::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet3(new Subnet6(IOAddress("2001:db8:3::"), 48, 1, 2, 3, 4));
+ Subnet6Ptr subnet1(new Subnet6(IOAddress("2001:db8:1::"),
+ 48, 1, 2, 3, 4, SubnetID(1)));
+ Subnet6Ptr subnet2(new Subnet6(IOAddress("2001:db8:2::"),
+ 48, 1, 2, 3, 4, SubnetID(2)));
+ Subnet6Ptr subnet3(new Subnet6(IOAddress("2001:db8:3::"),
+ 48, 1, 2, 3, 4, SubnetID(3)));
ASSERT_NO_THROW(cfg.add(subnet1));
ASSERT_NO_THROW(cfg.add(subnet2));
CfgSubnets6 cfg;
// Let's configure 3 subnets
- Subnet6Ptr subnet1(new Subnet6(IOAddress("2001:db8:1::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet2(new Subnet6(IOAddress("2001:db8:2::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet3(new Subnet6(IOAddress("2001:db8:3::"), 48, 1, 2, 3, 4));
+ Subnet6Ptr subnet1(new Subnet6(IOAddress("2001:db8:1::"),
+ 48, 1, 2, 3, 4, SubnetID(1)));
+ Subnet6Ptr subnet2(new Subnet6(IOAddress("2001:db8:2::"),
+ 48, 1, 2, 3, 4, SubnetID(2)));
+ Subnet6Ptr subnet3(new Subnet6(IOAddress("2001:db8:3::"),
+ 48, 1, 2, 3, 4, SubnetID(3)));
cfg.add(subnet1);
cfg.add(subnet2);
cfg.add(subnet3);
SharedNetwork6Ptr network3(new SharedNetwork6("net3"));
// Let's configure 3 subnets
- Subnet6Ptr subnet1(new Subnet6(IOAddress("2001:db8:1::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet2(new Subnet6(IOAddress("2001:db8:2::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet3(new Subnet6(IOAddress("2001:db8:3::"), 48, 1, 2, 3, 4));
+ Subnet6Ptr subnet1(new Subnet6(IOAddress("2001:db8:1::"),
+ 48, 1, 2, 3, 4, SubnetID(1)));
+ Subnet6Ptr subnet2(new Subnet6(IOAddress("2001:db8:2::"),
+ 48, 1, 2, 3, 4, SubnetID(2)));
+ Subnet6Ptr subnet3(new Subnet6(IOAddress("2001:db8:3::"),
+ 48, 1, 2, 3, 4, SubnetID(3)));
// Allow subnet class of clients to use the subnets.
subnet1->allowClientClass("subnet");
CfgSubnets6 cfg;
// Let's create 3 subnets.
- Subnet6Ptr subnet1(new Subnet6(IOAddress("2000::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet2(new Subnet6(IOAddress("3000::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet3(new Subnet6(IOAddress("4000::"), 48, 1, 2, 3, 4));
+ Subnet6Ptr subnet1(new Subnet6(IOAddress("2000::"),
+ 48, 1, 2, 3, 4, SubnetID(1)));
+ Subnet6Ptr subnet2(new Subnet6(IOAddress("3000::"),
+ 48, 1, 2, 3, 4, SubnetID(2)));
+ Subnet6Ptr subnet3(new Subnet6(IOAddress("4000::"),
+ 48, 1, 2, 3, 4, SubnetID(3)));
subnet1->setIface("foo");
subnet2->setIface("bar");
subnet3->setIface("foobar");
CfgSubnets6 cfg;
// Create 3 subnets.
- Subnet6Ptr subnet1(new Subnet6(IOAddress("2000::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet2(new Subnet6(IOAddress("3000::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet3(new Subnet6(IOAddress("4000::"), 48, 1, 2, 3, 4));
+ Subnet6Ptr subnet1(new Subnet6(IOAddress("2000::"),
+ 48, 1, 2, 3, 4, SubnetID(1)));
+ Subnet6Ptr subnet2(new Subnet6(IOAddress("3000::"),
+ 48, 1, 2, 3, 4, SubnetID(2)));
+ Subnet6Ptr subnet3(new Subnet6(IOAddress("4000::"),
+ 48, 1, 2, 3, 4, SubnetID(3)));
// Create Interface-id options used in subnets 1,2, and 3
OptionPtr ifaceid1 = generateInterfaceId("relay1.eth0");
CfgSubnets6 cfg;
// Let's configure 3 subnets
- Subnet6Ptr subnet1(new Subnet6(IOAddress("2000::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet2(new Subnet6(IOAddress("3000::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet3(new Subnet6(IOAddress("4000::"), 48, 1, 2, 3, 4));
+ Subnet6Ptr subnet1(new Subnet6(IOAddress("2000::"),
+ 48, 1, 2, 3, 4, SubnetID(1)));
+ Subnet6Ptr subnet2(new Subnet6(IOAddress("3000::"),
+ 48, 1, 2, 3, 4, SubnetID(2)));
+ Subnet6Ptr subnet3(new Subnet6(IOAddress("4000::"),
+ 48, 1, 2, 3, 4, SubnetID(3)));
cfg.add(subnet1);
cfg.add(subnet2);
cfg.add(subnet3);
TEST(CfgSubnets6Test, selectSubnetByInterfaceNameAndClassify) {
CfgSubnets6 cfg;
- Subnet6Ptr subnet1(new Subnet6(IOAddress("2000::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet2(new Subnet6(IOAddress("3000::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet3(new Subnet6(IOAddress("4000::"), 48, 1, 2, 3, 4));
+ Subnet6Ptr subnet1(new Subnet6(IOAddress("2000::"),
+ 48, 1, 2, 3, 4, SubnetID(1)));
+ Subnet6Ptr subnet2(new Subnet6(IOAddress("3000::"),
+ 48, 1, 2, 3, 4, SubnetID(2)));
+ Subnet6Ptr subnet3(new Subnet6(IOAddress("4000::"),
+ 48, 1, 2, 3, 4, SubnetID(3)));
subnet1->setIface("foo");
subnet2->setIface("bar");
subnet3->setIface("foobar");
TEST(CfgSubnets6Test, selectSubnetByInterfaceIdAndClassify) {
CfgSubnets6 cfg;
- Subnet6Ptr subnet1(new Subnet6(IOAddress("2000::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet2(new Subnet6(IOAddress("3000::"), 48, 1, 2, 3, 4));
- Subnet6Ptr subnet3(new Subnet6(IOAddress("4000::"), 48, 1, 2, 3, 4));
+ Subnet6Ptr subnet1(new Subnet6(IOAddress("2000::"),
+ 48, 1, 2, 3, 4, SubnetID(1)));
+ Subnet6Ptr subnet2(new Subnet6(IOAddress("3000::"),
+ 48, 1, 2, 3, 4, SubnetID(2)));
+ Subnet6Ptr subnet3(new Subnet6(IOAddress("4000::"),
+ 48, 1, 2, 3, 4, SubnetID(3)));
// interface-id options used in subnets 1,2, and 3
OptionPtr ifaceid1 = generateInterfaceId("relay1.eth0");
IOAddress last("192.0.2.255");
- auto subnet(boost::make_shared<Subnet4>(IOAddress("192.0.2.0"), 24, 1, 2, 3));
+ auto subnet(boost::make_shared<Subnet4>(IOAddress("192.0.2.0"),
+ 24, 1, 2, 3, SubnetID(1)));
auto state = SubnetIterativeAllocationState::create(subnet);
// Check initial conditions (all should be set to the last address in range)
IOAddress last("192.0.2.255");
- auto subnet(boost::make_shared<Subnet4>(IOAddress("192.0.2.0"), 24, 1, 2, 3));
+ auto subnet(boost::make_shared<Subnet4>(IOAddress("192.0.2.0"),
+ 24, 1, 2, 3, SubnetID(1)));
auto state = SubnetIterativeAllocationState::create(subnet);
// Check initial conditions (all should be set to the last address in range)
IOAddress last("2001:db8:1::ffff:ffff:ffff:ffff");
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 64, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 64, 1, 2, 3, 4, SubnetID(1));
auto state_na = boost::dynamic_pointer_cast<SubnetIterativeAllocationState>
(subnet->getAllocationState(Lease::TYPE_NA));
auto state_ta = boost::dynamic_pointer_cast<SubnetIterativeAllocationState>
IOAddress last("2001:db8:1::ffff:ffff:ffff:ffff");
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 64, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 64, 1, 2, 3, 4, SubnetID(1));
auto state_na = boost::dynamic_pointer_cast<SubnetIterativeAllocationState>
(subnet->getAllocationState(Lease::TYPE_NA));
auto state_ta = boost::dynamic_pointer_cast<SubnetIterativeAllocationState>
// This test verifies that the allocator picks delegated prefixes from several
// pools.
TEST_F(IterativeAllocatorTest6, prefixStep) {
- subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4);
+ subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"), 56, 60));
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 48));
// This test verifies that the allocator picks delegated prefixes from several
// pools.
TEST_F(IterativeAllocatorTest6, prefixStepPreferLower) {
- subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4);
+ subnet_ = Subnet6::create(IOAddress("2001:db8::"),
+ 32, 1, 2, 3, 4, SubnetID(1));
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"), 56, 60));
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 48));
// This test verifies that the allocator picks delegated prefixes from several
// pools.
TEST_F(IterativeAllocatorTest6, prefixStepPreferEqual) {
- subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4);
+ subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"), 56, 60));
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 48));
// This test verifies that the allocator picks delegated prefixes from several
// pools.
TEST_F(IterativeAllocatorTest6, prefixStepPreferHigher) {
- subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4);
+ subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"), 56, 60));
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 48));
// This test verifies that the allocator picks delegated prefixes from the pools
// with class guards.
TEST_F(IterativeAllocatorTest6, prefixStepInClass) {
- subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4);
+ subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"), 56, 60));
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 48));
// This test verifies that the allocator omits pools with non-matching client classes.
TEST_F(IterativeAllocatorTest6, prefixStepOutClass) {
- subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4);
+ subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"), 56, 60));
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 48));
/// @brief Implementation of the method creating DHCPv6 lease instance.
virtual void initLease() {
- Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8:1::"), 64, 100, 200, 300, 400));
+ Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8:1::"), 64, 100, 200, 300, 400, SubnetID(1)));
// Normally, this would be set via defaults
subnet->setDdnsUseConflictResolution(true);
/// @brief Implementation of the method creating DHCPv4 lease instance.
virtual void initLease() {
- Subnet4Ptr subnet(new Subnet4(IOAddress("192.0.2.0"), 24, 1, 2, 3));
+ Subnet4Ptr subnet(new Subnet4(IOAddress("192.0.2.0"), 24, 1, 2, 3, SubnetID(1)));
// Normally, this would be set via defaults
subnet->setDdnsUseConflictResolution(true);
}
}
-
} // end of anonymous namespace
// 0, 1, 2 etc.
Subnet4Ptr subnet(new Subnet4(IOAddress(0xC0000000 | (i << 2)),
24, def_triplet, def_triplet,
- 4000));
+ 4000, SubnetID(100 + i)));
test_subnets4_.insert(subnet);
}
// Create IPv6 subnets.
// 2001:db8:2::0 etc.
++prefix_bytes[5];
prefix = IOAddress::fromBytes(prefix.getFamily(), &prefix_bytes[0]);
- Subnet6Ptr subnet(new Subnet6(prefix, 64, 1000, 2000, 3000, 4000));
+ Subnet6Ptr subnet(new Subnet6(prefix, 64, 1000, 2000, 3000, 4000,
+ SubnetID(200 + i)));
test_subnets6_.insert(subnet);
}
EXPECT_NO_THROW(Subnet4 subnet1(IOAddress("192.0.2.2"), 16,
1, 2, 3, 10));
- EXPECT_THROW(Subnet4 subnet2(IOAddress("192.0.2.0"), 33, 1, 2, 3),
+ EXPECT_THROW(Subnet4 subnet2(IOAddress("192.0.2.0"),
+ 33, 1, 2, 3, SubnetID(2)),
BadValue); // invalid prefix length
- EXPECT_THROW(Subnet4 subnet3(IOAddress("2001:db8::1"), 24, 1, 2, 3),
+ EXPECT_THROW(Subnet4 subnet3(IOAddress("2001:db8::1"),
+ 24, 1, 2, 3, SubnetID(3)),
BadValue); // IPv6 addresses are not allowed in Subnet4
}
Triplet<uint32_t> t1;
Triplet<uint32_t> t2;
Triplet<uint32_t> valid_lft;
- Subnet4 subnet(IOAddress("192.0.2.0"), 24, t1, t2, valid_lft);
+ Subnet4 subnet(IOAddress("192.0.2.0"), 24,
+ t1, t2, valid_lft, SubnetID(10));
EXPECT_TRUE(subnet.getIface().unspecified());
EXPECT_TRUE(subnet.getIface().empty());
EXPECT_EQ(0, subnet.getOfferLft().get());
}
-// Checks that the subnet id can be either autogenerated or set to an
-// arbitrary value through the constructor.
-TEST(Subnet4Test, subnetID) {
- // Create subnet and don't specify id, so as it is autogenerated.
- auto subnet = Subnet4::create(IOAddress("192.0.2.0"), 24, 1000, 2000,
- 3000);
- SubnetID id0 = subnet->getID();
-
- // Create another subnet and let id be autogenerated.
- subnet.reset(new Subnet4(IOAddress("192.0.3.0"), 24, 1000, 2000,
- 3000));
- SubnetID id1 = subnet->getID();
-
- // The autogenerated ids must not be equal.
- EXPECT_NE(id0, id1);
-
- // Create third subnet but this time select an arbitrary id. The id
- // we use the one of the second subnet. That way we ensure that the
- // subnet id we provide via constructor is used and it is not
- // autogenerated - if it was autogenerated we would get id other
- // than id1 because id1 has already been used.
- subnet = Subnet4::create(IOAddress("192.0.4.0"), 24, 1000, 2000, 3000, id1);
- EXPECT_EQ(id1, subnet->getID());
-}
-
TEST(Subnet4Test, inRange) {
- Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000);
+ Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000, SubnetID(1));
EXPECT_EQ(1000, subnet.getT1().get());
EXPECT_EQ(2000, subnet.getT2().get());
// Checks whether the relay list is empty by default
// and basic operations function
TEST(Subnet4Test, relay) {
- Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000);
+ Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000, SubnetID(1));
// Should be empty.
EXPECT_FALSE(subnet.hasRelays());
// Checks whether siaddr field can be set and retrieved correctly.
TEST(Subnet4Test, siaddr) {
- Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000);
+ Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000, SubnetID(1));
// Check if the default is 0.0.0.0
EXPECT_EQ("0.0.0.0", subnet.getSiaddr().get().toText());
// Checks whether server-hostname field can be set and retrieved correctly.
TEST(Subnet4Test, serverHostname) {
- Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000);
+ Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000, SubnetID(1));
// Check if the default is empty
EXPECT_TRUE(subnet.getSname().empty());
// Checks whether boot-file-name field can be set and retrieved correctly.
TEST(Subnet4Test, bootFileName) {
- Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000);
+ Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000, SubnetID(1));
// Check if the default is empty
EXPECT_TRUE(subnet.getFilename().empty());
// Checks if the match-client-id flag can be set and retrieved.
TEST(Subnet4Test, matchClientId) {
- Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000);
+ Subnet4 subnet(IOAddress("192.0.2.1"), 24, 1000, 2000, 3000, SubnetID(1));
// By default the flag should be set to true.
EXPECT_TRUE(subnet.getMatchClientId());
// Checks that it is possible to add and retrieve multiple pools.
TEST(Subnet4Test, pool4InSubnet4) {
- auto subnet = Subnet4::create(IOAddress("192.1.2.0"), 24, 1, 2, 3);
+ auto subnet = Subnet4::create(IOAddress("192.1.2.0"),
+ 24, 1, 2, 3, SubnetID(1));
PoolPtr pool1(new Pool4(IOAddress("192.1.2.0"), 25));
PoolPtr pool2(new Pool4(IOAddress("192.1.2.128"), 26));
TEST(Subnet4Test, getCapacity) {
// There's one /24 pool.
- auto subnet = Subnet4::create(IOAddress("192.1.2.0"), 24, 1, 2, 3);
+ auto subnet = Subnet4::create(IOAddress("192.1.2.0"),
+ 24, 1, 2, 3, SubnetID(1));
// There are no pools defined, so the total number of available addrs is 0.
EXPECT_EQ(0, subnet->getPoolCapacity(Lease::TYPE_V4));
// Checks that it is not allowed to add invalid pools.
TEST(Subnet4Test, pool4Checks) {
- auto subnet = Subnet4::create(IOAddress("192.0.2.0"), 8, 1, 2, 3);
+ auto subnet = Subnet4::create(IOAddress("192.0.2.0"),
+ 8, 1, 2, 3, SubnetID(1));
// this one is in subnet
Pool4Ptr pool1(new Pool4(IOAddress("192.254.0.0"), 16));
// information about allowed client class (a single class).
TEST(Subnet4Test, clientClass) {
// Create the V4 subnet.
- auto subnet = Subnet4::create(IOAddress("192.0.2.0"), 8, 1, 2, 3);
+ auto subnet = Subnet4::create(IOAddress("192.0.2.0"),
+ 8, 1, 2, 3, SubnetID(1));
// This client does not belong to any class.
isc::dhcp::ClientClasses no_class;
TEST(Subnet4Test, addInvalidOption) {
// Create the V4 subnet.
- auto subnet = Subnet4::create(IOAddress("192.0.2.0"), 8, 1, 2, 3);
+ auto subnet = Subnet4::create(IOAddress("192.0.2.0"),
+ 8, 1, 2, 3, SubnetID(1));
// Create NULL pointer option. Attempt to add NULL option
// should result in exception.
// This test verifies that inRange() and inPool() methods work properly.
TEST(Subnet4Test, inRangeinPool) {
- auto subnet = Subnet4::create(IOAddress("192.0.0.0"), 8, 1, 2, 3);
+ auto subnet = Subnet4::create(IOAddress("192.0.0.0"),
+ 8, 1, 2, 3, SubnetID(1));
// this one is in subnet
Pool4Ptr pool1(new Pool4(IOAddress("192.2.0.0"), 16));
// This test checks if the toText() method returns text representation
TEST(Subnet4Test, toText) {
- auto subnet = Subnet4::create(IOAddress("192.0.2.0"), 24, 1, 2, 3);
+ auto subnet = Subnet4::create(IOAddress("192.0.2.0"),
+ 24, 1, 2, 3, SubnetID(1));
EXPECT_EQ("192.0.2.0/24", subnet->toText());
}
// This test checks if the get() method returns proper parameters
TEST(Subnet4Test, get) {
- auto subnet = Subnet4::create(IOAddress("192.0.2.0"), 28, 1, 2, 3);
+ auto subnet = Subnet4::create(IOAddress("192.0.2.0"),
+ 28, 1, 2, 3, SubnetID(1));
EXPECT_EQ("192.0.2.0", subnet->get().first.toText());
EXPECT_EQ(28, subnet->get().second);
}
// is working properly.
TEST(Subnet4Test, PoolType) {
- auto subnet = Subnet4::create(IOAddress("192.2.0.0"), 16, 1, 2, 3);
+ auto subnet = Subnet4::create(IOAddress("192.2.0.0"),
+ 16, 1, 2, 3, SubnetID(1));
PoolPtr pool1(new Pool4(IOAddress("192.2.1.0"), 24));
PoolPtr pool2(new Pool4(IOAddress("192.2.2.0"), 24));
// called.
TEST(Subnet4Test, getServerId) {
// Initially, the subnet has no server identifier.
- Subnet4 subnet(IOAddress("192.2.0.0"), 16, 1, 2, 3);
+ Subnet4 subnet(IOAddress("192.2.0.0"), 16, 1, 2, 3, SubnetID(1));
EXPECT_TRUE(subnet.getServerId().isV4Zero());
// Add server identifier.
// states are instantiated for a subnet.
TEST(Subnet4Test, createAllocatorsIterative) {
// Create a subnet.
- auto subnet = Subnet4::create(IOAddress("192.2.0.0"), 16, 1, 2, 3);
+ auto subnet = Subnet4::create(IOAddress("192.2.0.0"),
+ 16, 1, 2, 3, SubnetID(1));
ASSERT_TRUE(subnet);
// Create a pool.
auto pool = boost::make_shared<Pool4>(IOAddress("192.2.0.0"), 16);
// states are instantiated for a subnet.
TEST(Subnet4Test, createAllocatorsRandom) {
// Create a subnet.
- auto subnet = Subnet4::create(IOAddress("192.2.0.0"), 16, 1, 2, 3);
+ auto subnet = Subnet4::create(IOAddress("192.2.0.0"),
+ 16, 1, 2, 3, SubnetID(1));
ASSERT_TRUE(subnet);
// Create a pool.
auto pool = boost::make_shared<Pool4>(IOAddress("192.2.0.0"), 16);
// states are instantiated for a subnet.
TEST(Subnet4Test, createAllocatorsFreeLeaseQueue) {
// Create a subnet.
- auto subnet = Subnet4::create(IOAddress("192.2.0.0"), 16, 1, 2, 3);
+ auto subnet = Subnet4::create(IOAddress("192.2.0.0"),
+ 16, 1, 2, 3, SubnetID(1));
ASSERT_TRUE(subnet);
// Create a pool.
auto pool = boost::make_shared<Pool4>(IOAddress("192.2.0.0"), 16);
TEST(Subnet6Test, constructor) {
EXPECT_NO_THROW(Subnet6 subnet1(IOAddress("2001:db8:1::"), 64,
- 1, 2, 3, 4));
+ 1, 2, 3, 4, SubnetID(1)));
- EXPECT_THROW(Subnet6 subnet2(IOAddress("2001:db8:1::"), 129, 1, 2, 3, 4),
+ EXPECT_THROW(Subnet6 subnet2(IOAddress("2001:db8:1::"),
+ 129, 1, 2, 3, 4, SubnetID(2)),
BadValue); // invalid prefix length
- EXPECT_THROW(Subnet6 subnet3(IOAddress("192.168.0.0"), 32, 1, 2, 3, 4),
+ EXPECT_THROW(Subnet6 subnet3(IOAddress("192.168.0.0"),
+ 32, 1, 2, 3, 4, SubnetID(3)),
BadValue); // IPv4 addresses are not allowed in Subnet6
}
Triplet<uint32_t> preferred_lft;
Triplet<uint32_t> valid_lft;
Subnet6 subnet(IOAddress("2001:db8:1::"), 64, t1, t2, preferred_lft,
- valid_lft);
+ valid_lft, SubnetID(1));
EXPECT_TRUE(subnet.getIface().unspecified());
EXPECT_TRUE(subnet.getIface().empty());
EXPECT_FALSE(subnet.getDdnsUpdateOnRenew().get());
}
-// Checks that the subnet id can be either autogenerated or set to an
-// arbitrary value through the constructor.
-TEST(Subnet6Test, subnetID) {
- // Create subnet and don't specify id, so as it is autogenerated.
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 64, 1000, 2000,
- 3000, 4000);
- SubnetID id0 = subnet->getID();
-
- // Create another subnet and let id be autogenerated.
- subnet.reset(new Subnet6(IOAddress("2001:db8:2::"), 64, 1000, 2000,
- 3000, 4000));
- SubnetID id1 = subnet->getID();
-
- // The autogenerated ids must not be equal.
- EXPECT_NE(id0, id1);
-
- // Create third subnet but this time select an arbitrary id. The id
- // we use us the one of second subnet. That way we ensure that the
- // subnet id we provide via constructor is used and it is not
- // autogenerated - if it was autogenerated we would get id other
- // than id1 because id1 has already been used.
- subnet.reset(new Subnet6(IOAddress("2001:db8:3::"), 64, 1000, 2000,
- 3000, 4000, id1));
- EXPECT_EQ(id1, subnet->getID());
-}
-
TEST(Subnet6Test, inRange) {
- Subnet6 subnet(IOAddress("2001:db8:1::"), 64, 1000, 2000, 3000, 4000);
+ Subnet6 subnet(IOAddress("2001:db8:1::"),
+ 64, 1000, 2000, 3000, 4000, SubnetID(1));
EXPECT_EQ(1000, subnet.getT1().get());
EXPECT_EQ(2000, subnet.getT2().get());
// Checks whether the relay list is empty by default
// and basic operations function
TEST(Subnet6Test, relay) {
- Subnet6 subnet(IOAddress("2001:db8:1::"), 64, 1000, 2000, 3000, 4000);
+ Subnet6 subnet(IOAddress("2001:db8:1::"),
+ 64, 1000, 2000, 3000, 4000, SubnetID(1));
// Should be empty.
EXPECT_FALSE(subnet.hasRelays());
// calculated properly.
TEST(Subnet6Test, Pool6getCapacity) {
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
// There's 2^16 = 65536 addresses in this one.
PoolPtr pool1(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:1::"), 112));
// calculated properly.
TEST(Subnet6Test, Pool6PdgetPoolCapacity) {
- auto subnet = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8::"),
+ 32, 1, 2, 3, 4, SubnetID(1));
// There's 2^16 = 65536 addresses in this one.
PoolPtr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 64));
TEST(Subnet6Test, Pool6InSubnet6) {
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
PoolPtr pool1(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:1::"), 64));
PoolPtr pool2(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:2::"), 64));
// Check if Subnet6 supports different types of pools properly.
TEST(Subnet6Test, poolTypes) {
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
PoolPtr pool1(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:1::"), 64));
PoolPtr pool2(new Pool6(Lease::TYPE_TA, IOAddress("2001:db8:1:2::"), 64));
// information about allowed client class (a single class).
TEST(Subnet6Test, clientClass) {
// Create the V6 subnet.
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
// This client does not belong to any class.
isc::dhcp::ClientClasses no_class;
// Checks that it is not allowed to add invalid pools.
TEST(Subnet6Test, pool6Checks) {
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
// this one is in subnet
Pool6Ptr pool1(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:1::"), 64));
TEST(Subnet6Test, addOptions) {
// Create as subnet to add options to it.
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
// Differentiate options by their codes (100-109)
for (uint16_t code = 100; code < 110; ++code) {
TEST(Subnet6Test, addNonUniqueOptions) {
// Create as subnet to add options to it.
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
// Create a set of options with non-unique codes.
for (int i = 0; i < 2; ++i) {
TEST(Subnet6Test, addPersistentOption) {
// Create as subnet to add options to it.
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
// Add 10 options to the subnet with option codes 100 - 109.
for (uint16_t code = 100; code < 110; ++code) {
}
TEST(Subnet6Test, getOptions) {
- auto subnet = Subnet6::create(IOAddress("2001:db8::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
// Add 10 options to a "dhcp6" option space in the subnet.
for (uint16_t code = 100; code < 110; ++code) {
TEST(Subnet6Test, addVendorOption) {
// Create as subnet to add options to it.
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
// Differentiate options by their codes (100-109)
for (uint16_t code = 100; code < 110; ++code) {
// This test verifies that inRange() and inPool() methods work properly.
TEST(Subnet6Test, inRangeinPool) {
- auto subnet = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8::"),
+ 32, 1, 2, 3, 4, SubnetID(1));
// this one is in subnet
Pool6Ptr pool1(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8::10"),
// This test verifies that inRange() and inPool() methods work properly
// for prefixes too.
TEST(Subnet6Test, PdinRangeinPool) {
- auto subnet = Subnet6::create(IOAddress("2001:db8::"), 64, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8::"),
+ 64, 1, 2, 3, 4, SubnetID(1));
// this one is in subnet
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"),
// This test checks if the toText() method returns text representation
TEST(Subnet6Test, toText) {
- Subnet6 subnet(IOAddress("2001:db8::"), 32, 1, 2, 3, 4);
+ Subnet6 subnet(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
EXPECT_EQ("2001:db8::/32", subnet.toText());
}
// This test checks if the get() method returns proper parameters
TEST(Subnet6Test, get) {
- Subnet6 subnet(IOAddress("2001:db8::"), 32, 1, 2, 3, 4);
+ Subnet6 subnet(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
EXPECT_EQ("2001:db8::", subnet.get().first.toText());
EXPECT_EQ(32, subnet.get().second);
}
// This trivial test checks if interface name is stored properly
// in Subnet6 objects.
TEST(Subnet6Test, iface) {
- Subnet6 subnet(IOAddress("2001:db8::"), 32, 1, 2, 3, 4);
+ Subnet6 subnet(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
EXPECT_TRUE(subnet.getIface().empty());
// later retrieved for a subnet6 object.
TEST(Subnet6Test, interfaceId) {
// Create as subnet to add options to it.
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
EXPECT_FALSE(subnet->getInterfaceId());
// disabled for a subnet. It also checks that the Rapid Commit
// support is disabled by default.
TEST(Subnet6Test, rapidCommit) {
- Subnet6 subnet(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ Subnet6 subnet(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
// By default, the RC should be disabled.
EXPECT_FALSE(subnet.getRapidCommit());
// states are instantiated for a subnet.
TEST(Subnet6Test, createAllocatorsIterative) {
// Create a subnet.
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
ASSERT_TRUE(subnet);
// NA pool.
auto pool = boost::make_shared<Pool6>(Lease::TYPE_NA, IOAddress("2001:db8:1:1::"), 112);
// states are instantiated for a subnet.
TEST(Subnet6Test, createAllocatorsRandom) {
// Create a subnet.
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
ASSERT_TRUE(subnet);
// NA pool.
auto pool = boost::make_shared<Pool6>(Lease::TYPE_NA, IOAddress("2001:db8:1:1::"), 112);
// states are instantiated for a subnet.
TEST(Subnet6Test, createAllocatorsFreeLeaseQueue) {
// Create a subnet.
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
ASSERT_TRUE(subnet);
// NA pool.
auto pool = boost::make_shared<Pool6>(Lease::TYPE_NA, IOAddress("2001:db8:1:1::"), 112);
// Test that it is not allowed to use the FLQ allocator for the address pools.
TEST(Subnet6Test, createAllocatorsFreeLeaseQueueNotAllowed) {
- auto subnet = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
+ auto subnet = Subnet6::create(IOAddress("2001:db8:1::"),
+ 56, 1, 2, 3, 4, SubnetID(1));
ASSERT_TRUE(subnet);
subnet->setAllocatorType("flq");
EXPECT_EQ("2001:db8:2::/64", subnet->toText());
}
-};
+}