// Subnet 2
subnet = subnets->selectSubnet(IOAddress("192.0.2.1"));
ASSERT_TRUE(subnet);
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET, subnet->getHostReservationMode());
+ EXPECT_EQ(Network::HR_OUT_OF_POOL, subnet->getHostReservationMode());
// Subnet 3
subnet = subnets->selectSubnet(IOAddress("192.0.3.1"));
// Subnet 2
subnet = subnets->selectSubnet(IOAddress("192.0.2.1"));
ASSERT_TRUE(subnet);
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET, subnet->getHostReservationMode());
+ EXPECT_EQ(Network::HR_OUT_OF_POOL, subnet->getHostReservationMode());
// Subnet 3
subnet = subnets->selectSubnet(IOAddress("192.0.3.1"));
// Subnet 7
subnet = subnets->selectSubnet(IOAddress("192.0.7.1"));
ASSERT_TRUE(subnet);
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET|Network::HR_GLOBAL,
+ EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_GLOBAL,
subnet->getHostReservationMode());
}
subnet->setFetchGlobalsFn([]() -> ConstElementPtr {
return (CfgMgr::instance().getStagingCfg()->getConfiguredGlobals());
});
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET, subnet->getHostReservationMode());
+ EXPECT_EQ(Network::HR_OUT_OF_POOL, subnet->getHostReservationMode());
}
/// The goal of this test is to verify that Host Reservation modes can be
subnet->setFetchGlobalsFn([]() -> ConstElementPtr {
return (CfgMgr::instance().getStagingCfg()->getConfiguredGlobals());
});
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET, subnet->getHostReservationMode());
+ EXPECT_EQ(Network::HR_OUT_OF_POOL, subnet->getHostReservationMode());
}
/// Check that the decline-probation-period has a default value when not
EXPECT_EQ("foo", s->getSname().get());
EXPECT_EQ("bar", s->getFilename().get());
EXPECT_TRUE(s->hasRelayAddress(IOAddress("5.6.7.8")));
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET, s->getHostReservationMode());
+ EXPECT_EQ(Network::HR_OUT_OF_POOL, s->getHostReservationMode());
// For the second subnet, the renew-timer should be 100, because it
// was specified explicitly. Other parameters a derived
// Subnet 2
subnet = subnets->selectSubnet(IOAddress("2001:db8:2::1"));
ASSERT_TRUE(subnet);
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET, subnet->getHostReservationMode());
+ EXPECT_EQ(Network::HR_OUT_OF_POOL, subnet->getHostReservationMode());
// Subnet 3
subnet = subnets->selectSubnet(IOAddress("2001:db8:3::1"));
// Subnet 2
subnet = subnets->selectSubnet(IOAddress("2001:db8:2::1"));
ASSERT_TRUE(subnet);
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET, subnet->getHostReservationMode());
+ EXPECT_EQ(Network::HR_OUT_OF_POOL, subnet->getHostReservationMode());
// Subnet 3
subnet = subnets->selectSubnet(IOAddress("2001:db8:3::1"));
// Subnet 7
subnet = subnets->selectSubnet(IOAddress("2001:db8:7::1"));
ASSERT_TRUE(subnet);
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET|Network::HR_GLOBAL,
+ EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_GLOBAL,
subnet->getHostReservationMode());
}
// Subnet 2
subnet = subnets->selectSubnet(IOAddress("2001:db8:2::1"));
ASSERT_TRUE(subnet);
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET, subnet->getHostReservationMode());
+ EXPECT_EQ(Network::HR_OUT_OF_POOL, subnet->getHostReservationMode());
}
/// The goal of this test is to verify that Host Reservation modes can be
// Subnet 2
subnet = subnets->selectSubnet(IOAddress("2001:db8:2::1"));
ASSERT_TRUE(subnet);
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET, subnet->getHostReservationMode());
+ EXPECT_EQ(Network::HR_OUT_OF_POOL, subnet->getHostReservationMode());
}
/// The goal of this test is to verify that configuration can include
EXPECT_TRUE(iface_id2.equals(s->getInterfaceId()));
EXPECT_TRUE(s->hasRelayAddress(IOAddress("2222::2")));
EXPECT_TRUE(s->getRapidCommit());
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET, s->getHostReservationMode());
+ EXPECT_EQ(Network::HR_OUT_OF_POOL, s->getHostReservationMode());
EXPECT_TRUE(s->getStoreExtendedInfo());
// Ok, now check the second shared subnet.
}
// First check for reservation when it is the choice.
- if (check_reservation_first && ((hr_mode & Network::HR_IN_SUBNET) &&
- !(hr_mode & Network::HR_OUT_OF_POOL))) {
+ if (check_reservation_first && ((hr_mode & Network::HR_IN_SUBNET_FLAG) &&
+ !(hr_mode & Network::HR_OUT_OF_POOL_FLAG))) {
auto hosts = getIPv6Resrv(subnet->getID(), candidate);
if (!hosts.empty()) {
// Don't allocate.
/// In-pool reservations: Check if this address is reserved for someone
/// else. There is no need to check for whom it is reserved, because if
/// it has been reserved for us we would have already allocated a lease.
- if (!check_reservation_first && (hr_mode & Network::HR_IN_SUBNET) &&
- !(hr_mode & Network::HR_OUT_OF_POOL)) {
+ if (!check_reservation_first && (hr_mode & Network::HR_IN_SUBNET_FLAG) &&
+ !(hr_mode & Network::HR_OUT_OF_POOL_FLAG)) {
auto hosts = getIPv6Resrv(subnet->getID(), candidate);
if (!hosts.empty()) {
// Don't allocate.
// allocation attempts.
} else if (existing->expired()) {
// Make sure it's not reserved.
- if (!check_reservation_first && (hr_mode & Network::HR_IN_SUBNET) &&
- !(hr_mode & Network::HR_OUT_OF_POOL)) {
+ if (!check_reservation_first && (hr_mode & Network::HR_IN_SUBNET_FLAG) &&
+ !(hr_mode & Network::HR_OUT_OF_POOL_FLAG)) {
auto hosts = getIPv6Resrv(subnet->getID(), candidate);
if (!hosts.empty()) {
// Don't allocate.
/// @return true if the address is reserved for another client.
bool
addressReserved(const IOAddress& address, const AllocEngine::ClientContext4& ctx) {
- bool in_subnet = (ctx.subnet_->getHostReservationMode() & Network::HR_IN_SUBNET);
- bool out_of_pool = (ctx.subnet_->getHostReservationMode() & Network::HR_OUT_OF_POOL);
+ bool in_subnet = (ctx.subnet_->getHostReservationMode() & Network::HR_IN_SUBNET_FLAG);
+ bool out_of_pool = (ctx.subnet_->getHostReservationMode() & Network::HR_OUT_OF_POOL_FLAG);
if (ctx.subnet_ && ((in_subnet && !out_of_pool) ||
(out_of_pool && (!ctx.subnet_->inPool(Lease::TYPE_V4, address))))) {
// The global parameter ip-reservations-unique controls whether it is allowed
}
auto host = ctx.hosts_.find(subnet->getID());
- bool in_subnet = (subnet->getHostReservationMode() & Network::HR_IN_SUBNET);
- bool out_of_pool = (subnet->getHostReservationMode() & Network::HR_OUT_OF_POOL);
+ bool in_subnet = (subnet->getHostReservationMode() & Network::HR_IN_SUBNET_FLAG);
+ bool out_of_pool = (subnet->getHostReservationMode() & Network::HR_OUT_OF_POOL_FLAG);
if (host != ctx.hosts_.end()) {
auto reservation = host->second->getIPv4Reservation();
if (!reservation.isV4Zero() &&
namespace dhcp {
const uint8_t Network::HR_DISABLED = 0;
-const uint8_t Network::HR_OUT_OF_POOL = 1 << 0;
-const uint8_t Network::HR_IN_SUBNET = 1 << 1;
-const uint8_t Network::HR_GLOBAL = 1 << 2;
+const uint8_t Network::HR_OUT_OF_POOL_FLAG = 1 << 0;
+const uint8_t Network::HR_IN_SUBNET_FLAG = 1 << 1;
+const uint8_t Network::HR_GLOBAL_FLAG = 1 << 2;
+const uint8_t Network::HR_OUT_OF_POOL = HR_OUT_OF_POOL_FLAG | HR_IN_SUBNET_FLAG;
+const uint8_t Network::HR_IN_SUBNET = HR_IN_SUBNET_FLAG;
+const uint8_t Network::HR_GLOBAL = HR_GLOBAL_FLAG;
const uint8_t Network::HR_ALL = Network::HR_IN_SUBNET;
void
(hr_mode_name.compare("off") == 0) ) {
return (Network::HR_DISABLED);
} else if (hr_mode_name.compare("out-of-pool") == 0) {
- return (Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET);
+ return (Network::HR_OUT_OF_POOL);
} else if (hr_mode_name.compare("global") == 0) {
return (Network::HR_GLOBAL);
} else if (hr_mode_name.compare("all") == 0) {
if (hrmode & Network::HR_GLOBAL) {
hr_global = true;
}
- if (hrmode & Network::HR_IN_SUBNET) {
+ if (hrmode & Network::HR_IN_SUBNET_FLAG) {
hr_in_subnet = true;
}
- if (hrmode & Network::HR_OUT_OF_POOL) {
+ if (hrmode & Network::HR_OUT_OF_POOL_FLAG) {
hr_out_of_pool = true;
}
if (hrmode == Network::HR_DISABLED) {
}
if (hr_out_of_pool) {
map->set("reservations-out-of-pool", Element::create(true));
- map->set("reservations-in-subnet", Element::create(true));
}
}
}
/// are allowed.
static const uint8_t HR_DISABLED; // value: 0
+ /// The out-of-pool reservations flag.
+ static const uint8_t HR_OUT_OF_POOL_FLAG; // value: 1 << 0
+
+ /// The in-subnet flag.
+ static const uint8_t HR_IN_SUBNET_FLAG; // value: 1 << 1
+
+ /// The global flag.
+ static const uint8_t HR_GLOBAL_FLAG; // value: 1 << 2
+
/// Only out-of-pool reservations is allowed. This mode allows AllocEngine
/// to skip reservation checks for dynamically allocated addressed.
- /// When this is set, HR_IN_SUBNET is always enabled as well as there can
- /// can be no reservations that are out-of-pool but not in-subnet.
- static const uint8_t HR_OUT_OF_POOL; // value: 1 << 0
+ /// When this is set, both HR_OUT_OF_POOL_FLAG and HR_IN_SUBNET_FLAG are
+ /// enabled as there can can be no reservations that are out-of-pool but not
+ /// in-subnet.
+ static const uint8_t HR_OUT_OF_POOL; // value: HR_OUT_OF_POOL_FLAG | HR_IN_SUBNET_FLAG
/// The in-subnet mode which also allows in-pool reservations.
/// This is equivalent to HR_ALL flag.
- static const uint8_t HR_IN_SUBNET; // value: 1 << 1
+ static const uint8_t HR_IN_SUBNET; // value: HR_IN_SUBNET_FLAG
/// Only global reservations are allowed. This mode instructs AllocEngine
/// to only look at global reservations.
- static const uint8_t HR_GLOBAL; // value: 1 << 2
+ static const uint8_t HR_GLOBAL; // value: HR_GLOBAL_FLAG
/// Both out-of-pool and in-pool reservations are allowed. This is the most
/// flexible mode, where sysadmin have biggest liberty. However, there is a
"reservations-out-of-pool");
if (!hr_mode_out_of_pool.unspecified()) {
if (hr_mode_out_of_pool.get()) {
- flags |= Network::HR_IN_SUBNET | Network::HR_OUT_OF_POOL;
+ flags |= Network::HR_OUT_OF_POOL;
}
found = true;
}
if (elem) {
bool value = elem->boolValue();
if (value) {
- flags |= Network::HR_IN_SUBNET | Network::HR_OUT_OF_POOL;
+ flags |= Network::HR_OUT_OF_POOL;
force_true = true;
}
}
TEST_F(NetworkTest, hrModeFromString) {
EXPECT_EQ(Network::HR_DISABLED, Network::hrModeFromString("off"));
EXPECT_EQ(Network::HR_DISABLED, Network::hrModeFromString("disabled"));
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET, Network::hrModeFromString("out-of-pool"));
+ EXPECT_EQ(Network::HR_OUT_OF_POOL, Network::hrModeFromString("out-of-pool"));
EXPECT_EQ(Network::HR_GLOBAL, Network::hrModeFromString("global"));
EXPECT_EQ(Network::HR_ALL, Network::hrModeFromString("all"));
EXPECT_THROW(Network::hrModeFromString("bogus"), isc::BadValue);
" \"reservations-in-subnet\": true, \n"
" \"reservations-out-of-pool\": true \n"
"} \n",
- static_cast<uint8_t>(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET)
+ static_cast<uint8_t>(Network::HR_OUT_OF_POOL)
},
{
"reservation modes out-of-pool enabled specifying in-subnet and out-of-pool",
" \"reservations-in-subnet\": true, \n"
" \"reservations-out-of-pool\": true \n"
"} \n",
- static_cast<uint8_t>(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET)
+ static_cast<uint8_t>(Network::HR_OUT_OF_POOL)
},
{
"reservation modes out-of-pool enabled specifying only out-of-pool",
"{ \n"
" \"reservations-out-of-pool\": true \n"
"} \n",
- static_cast<uint8_t>(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET)
+ static_cast<uint8_t>(Network::HR_OUT_OF_POOL)
},
{
"reservation modes global and out-of-pool enabled specifying all parameters",
" \"reservations-in-subnet\": true, \n"
" \"reservations-out-of-pool\": true \n"
"} \n",
- static_cast<uint8_t>(Network::HR_GLOBAL|Network::HR_IN_SUBNET|Network::HR_OUT_OF_POOL)
+ static_cast<uint8_t>(Network::HR_OUT_OF_POOL|Network::HR_GLOBAL)
},
{
"reservation modes global and out-of-pool enabled specifying global and out-of-pool",
" \"reservations-global\": true, \n"
" \"reservations-out-of-pool\": true \n"
"} \n",
- static_cast<uint8_t>(Network::HR_GLOBAL|Network::HR_IN_SUBNET|Network::HR_OUT_OF_POOL)
+ static_cast<uint8_t>(Network::HR_OUT_OF_POOL|Network::HR_GLOBAL)
}
};
EXPECT_EQ("/dev/null", network->getFilename().get());
EXPECT_EQ("10.0.0.1", network->getSiaddr().get().toText());
EXPECT_EQ("example.org", network->getSname().get());
- EXPECT_EQ(Network::HR_OUT_OF_POOL|Network::HR_IN_SUBNET, network->getHostReservationMode());
+ EXPECT_EQ(Network::HR_OUT_OF_POOL, network->getHostReservationMode());
EXPECT_TRUE(network->getDdnsSendUpdates().get());
EXPECT_TRUE(network->getDdnsOverrideNoUpdate().get());
EXPECT_TRUE(network->getDdnsOverrideClientUpdate().get());