72 for (
auto const& pool : *pools ) {
73 if (pool->start_address_ == start_address && pool->end_address_ == end_address) {
79 pool->subnet_id_,
true);
97 .arg(rebuilt ? 1 : 0);
99 }
catch (
const std::exception& ex) {
112 return (sflqPoolGetAll(handle, AF_INET));
117 return (sflqPoolGetBySubnet(handle, AF_INET));
122 return (sflqPoolGetByRange(handle, AF_INET));
127 return (sflqPoolDel(handle, AF_INET));
163 bool rebuilt =
false;
164 for (
auto const& pool : *pools ) {
165 if (pool->start_address_ == start_address && pool->end_address_ == end_address) {
172 pool->delegated_len_,
173 pool->subnet_id_,
true);
191 .arg(rebuilt ? 1 : 0);
192 }
catch (
const std::exception& ex) {
205 return (sflqPoolGetAll(handle, AF_INET6));
210 return (sflqPoolGetBySubnet(handle, AF_INET6));
215 return (sflqPoolGetByRange(handle, AF_INET6));
220 return (sflqPoolDel(handle, AF_INET6));
224SflqCmdsImpl::sflqPoolGetAll(
CalloutHandle& handle, uint16_t family) {
242 }
catch (
const std::exception& ex) {
255SflqCmdsImpl::sflqPoolGetBySubnet(CalloutHandle& handle, uint16_t family) {
269 isc_throw(isc::BadValue,
"no parameters specified for the command");
277 if ((subnet_id < 1) || (subnet_id >= SUBNET_ID_UNUSED)) {
278 isc_throw(isc::BadValue,
"'subnet-id' " << subnet_id <<
" is invalid,"
279 " must be greater than zero and less than "
280 << SUBNET_ID_UNUSED);
293 }
catch (
const std::exception& ex) {
306SflqCmdsImpl::sflqPoolGetByRange(CalloutHandle& handle, uint16_t family) {
322 isc_throw(isc::BadValue,
"no parameters specified for the command");
334 auto pools = (family == AF_INET
344 }
catch (
const std::exception& ex) {
357SflqCmdsImpl::sflqPoolDel(CalloutHandle& handle, uint16_t family) {
374 isc_throw(isc::BadValue,
"no parameters specified for the command");
387 bool deleted = (family == AF_INET
391 end_address, force));
406 .arg(deleted ? 1 : 0);
407 }
catch (
const std::exception& ex) {
422 for (
auto const& pool : *pools) {
423 pools_json->add(pool->toElement());
426 auto pool_cnt = pools_json->size();
427 stringstream resp_msg;
428 resp_msg << pool_cnt <<
" pool(s) found.";
431 args->set(
"pools", pools_json);
435 resp_msg.str(), args);
445 if (family == AF_INET) {
454 bool default_value) {
455 auto tmp = params->get(name);
457 return (default_value);
464 return (tmp->boolValue());
470 if (family == AF_INET) {
471 if (tmp ==
"V4" || tmp ==
"3") {
478 if (tmp ==
"IA_NA" || tmp ==
"0") {
480 }
else if (tmp ==
"IA_PD" || tmp ==
"2") {
485 << tmp <<
", valid values are IA_NA and IA_PD");
494 return (sflq_impl_->sflqPool4RebuildHandler(handle));
499 return (sflq_impl_->sflqPool4GetAllHandler(handle));
504 return (sflq_impl_->sflqPool4GetBySubnetHandler(handle));
509 return (sflq_impl_->sflqPool4GetByRangeHandler(handle));
514 return (sflq_impl_->sflqPool4DelHandler(handle));
519 return (sflq_impl_->sflqPool6RebuildHandler(handle));
524 return (sflq_impl_->sflqPool6GetAllHandler(handle));
529 return (sflq_impl_->sflqPool6GetBySubnetHandler(handle));
534 return (sflq_impl_->sflqPool6GetByRangeHandler(handle));
539 return (sflq_impl_->sflqPool6DelHandler(handle));
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
The IOAddress class represents an IP addresses (version agnostic).
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
void setErrorResponse(hooks::CalloutHandle &handle, const std::string &text, int status=CONTROL_RESULT_ERROR)
Set the callout argument "response" to indicate an error.
data::ConstElementPtr cmd_args_
Stores the command arguments extracted by a call to extractCommand.
void extractCommand(hooks::CalloutHandle &handle)
Extracts the command name and arguments from a Callout handle.
void setResponse(hooks::CalloutHandle &handle, data::ConstElementPtr &response)
Set the callout argument "response" to the given response.
static void checkKeywords(const SimpleKeywords &keywords, isc::data::ConstElementPtr scope)
Checks acceptable keywords with their expected type.
static void checkRequired(const SimpleRequiredKeywords &required, isc::data::ConstElementPtr scope)
Checks that all required keywords are present.
static isc::asiolink::IOAddress getAddress(const ConstElementPtr &scope, const std::string &name)
Returns a IOAddress parameter from a scope.
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
static TrackingLeaseMgr & instance()
Return current lease manager.
virtual bool sflqPool4Del(asiolink::IOAddress start_address, asiolink::IOAddress end_address, bool force=false)
Delete the SFLQ V4 pool that matches a start and end address.
virtual bool sflqPool6Del(asiolink::IOAddress start_address, asiolink::IOAddress end_address, bool force=false)
Delete the SFLQ V6 pool that matches a start and end address.
virtual SflqPoolInfoCollectionPtr sflqPool4Get(SubnetID subnet_id)
Fetch all SFLQ V4 pools belonging to a subnet.
virtual SflqPoolInfoCollectionPtr sflqPool4GetAll()
Fetch all SFLQ V4 pools.
virtual bool sflqCreateFlqPool4(asiolink::IOAddress start_address, asiolink::IOAddress end_address, SubnetID subnet_id, bool recreate=false)
Creates a v4 SFLQ Pool.
virtual SflqPoolInfoCollectionPtr sflqPool6GetAll()
Fetch all SFLQ V6 pools.
virtual SflqPoolInfoCollectionPtr sflqPool6Get(SubnetID subnet_id)
Fetch all SFLQ V6 pools belonging to a subnet.
virtual bool sflqCreateFlqPool6(asiolink::IOAddress start_address, asiolink::IOAddress end_address, Lease::Type lease_type, uint8_t delegated_len, SubnetID subnet_id, bool recreate=false)
Calls stored procedure to create an SFLQ pool for v6.
Per-packet callout handle.
Implements the logic for processing commands pertaining to SFLQ pools and data.
int sflqPool6DelHandler(hooks::CalloutHandle &handle)
Delete the SFLQ V6 pool that matches a start and end address.
static bool extractBool(data::ConstElementPtr ¶ms, const std::string &name, bool default_value=false)
Extracts a boolean from given parameters map.
static dhcp::Lease::Type extractLeaseType(data::ConstElementPtr ¶ms, uint16_t family)
Extracts 'lease-type' from given parameters map.
static data::ConstElementPtr buildGetResponse(dhcp::SflqPoolInfoCollectionPtr pools)
Creates a success response from a list of SqlPoolInfos.
int sflqPool6RebuildHandler(hooks::CalloutHandle &handle)
The 'sflq-pool6-rebuild' command handler.
int sflqPool6GetBySubnetHandler(hooks::CalloutHandle &handle)
The 'sflq-pool6-by-subnet' command handler.
static void extractRange(data::ConstElementPtr ¶ms, uint8_t family, asiolink::IOAddress &start_address, asiolink::IOAddress &end_address)
Extracts an ip address range from given parameters map.
int sflqPool4GetByRangeHandler(hooks::CalloutHandle &handle)
Handles a 'sflq-pool4-by-range' command.
int sflqPool4GetAllHandler(hooks::CalloutHandle &handle)
The 'sflq-pool4-get-all' command handler.
int sflqPool4RebuildHandler(hooks::CalloutHandle &handle)
The 'sflq-pool4-rebuild' command handler.
int sflqPool4GetBySubnetHandler(hooks::CalloutHandle &handle)
The 'sflq-pool4-by-subnet' command handler.
int sflqPool6GetByRangeHandler(hooks::CalloutHandle &handle)
Handles a 'sflq-pool6-by-range' command.
int sflqPool6GetAllHandler(hooks::CalloutHandle &handle)
The 'sflq-pool6-get-all' command handler.
int sflqPool4DelHandler(hooks::CalloutHandle &handle)
Delete the SFLQ V4 pool that matches a start and end address.
int sflqPool4DelHandler(hooks::CalloutHandle &handle)
Delete the SFLQ V4 pool that matches a start and end address.
int sflqPool4GetBySubnetHandler(hooks::CalloutHandle &handle)
The 'sflq-pool4-get-by-subnet' command handler.
int sflqPool6RebuildHandler(hooks::CalloutHandle &handle)
The 'sflq-pool6-rebuild' command handler.
int sflqPool6GetAllHandler(hooks::CalloutHandle &handle)
The 'sflq-pool6-get-all' command handler.
int sflqPool4GetByRangeHandler(hooks::CalloutHandle &handle)
Handles a 'sflq-pool4-by-range' command.
int sflqPool4GetAllHandler(hooks::CalloutHandle &handle)
The 'sflq-pool4-get-all' command handler.
int sflqPool6GetByRangeHandler(hooks::CalloutHandle &handle)
Handles a 'sflq-pool6-by-range' command.
int sflqPool6DelHandler(hooks::CalloutHandle &handle)
Delete the SFLQ V6 pool that matches a start and end address.
int sflqPool6GetBySubnetHandler(hooks::CalloutHandle &handle)
The 'sflq-pool6-get-by-subnet' command handler.
int sflqPool4RebuildHandler(hooks::CalloutHandle &handle)
sflq-pool4-rebuild handler.
RAII class creating a critical section.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
const isc::log::MessageID SFLQ_POOL6_GET_BY_RANGE_FAILED
const isc::log::MessageID SFLQ_POOL4_REBUILD
const isc::log::MessageID SFLQ_POOL4_GET_BY_SUBNET_FAILED
const isc::log::MessageID SFLQ_POOL4_GET_ALL
const isc::log::MessageID SFLQ_POOL4_DEL_FAILED
const isc::log::MessageID SFLQ_POOL6_GET_ALL
const isc::log::MessageID SFLQ_POOL6_GET_BY_RANGE
const isc::log::MessageID SFLQ_POOL4_GET_BY_RANGE_FAILED
const isc::log::MessageID SFLQ_POOL6_DEL_FAILED
const isc::log::MessageID SFLQ_POOL6_DEL
const isc::log::MessageID SFLQ_POOL4_GET_ALL_FAILED
const isc::log::MessageID SFLQ_POOL4_REBUILD_FAILED
const isc::log::MessageID SFLQ_POOL6_GET_BY_SUBNET_FAILED
const isc::log::MessageID SFLQ_POOL4_GET_BY_RANGE
const isc::log::MessageID SFLQ_POOL4_GET_BY_SUBNET
const isc::log::MessageID SFLQ_POOL6_REBUILD
const isc::log::MessageID SFLQ_POOL6_GET_BY_SUBNET
const isc::log::MessageID SFLQ_POOL4_DEL
const isc::log::MessageID SFLQ_POOL6_REBUILD_FAILED
const isc::log::MessageID SFLQ_POOL6_GET_ALL_FAILED
An abstract API for lease database.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
void validateV4Range(const IOAddress &start_address, const IOAddress &end_address)
Ensures address pair are both v4 and start <= end.
void validateV6Range(const IOAddress &start_address, const IOAddress &end_address)
Ensures address pair are both v6 and start <= end.
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
ConstElementPtr createAnswer()
Creates a standard config/command level success answer message (i.e.
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
std::vector< std::string > SimpleRequiredKeywords
This specifies all required keywords.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
std::map< std::string, isc::data::Element::types > SimpleKeywords
This specifies all accepted keywords with their types.
boost::shared_ptr< SflqPoolInfoCollection > SflqPoolInfoCollectionPtr
const int LEASE_CMDS_DBG_COMMAND_DATA
Logging level used to log successful commands.
isc::log::Logger lease_cmds_logger("lease-cmds-hooks")
Defines the logger used by the top-level component of kea-lfc.
Type
Type of lease or pool.
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
@ TYPE_NA
the lease contains non-temporary IPv6 address