26 static_cast<void>(addresses_.insert(address));
37 return (addresses_.count(address));
49 if (pools_.find(pool) != pools_.end()) {
63 for (
auto pool : pools_) {
64 if (pool->inRange(address)) {
83 : io_service_(new
IOService()), address_list_(family), pool_set_(family) {
86 isc_throw(BadValue,
"Lease Query config is empty or not a map");
89 parserRequesters(
config->get(
"requesters"));
98 io_service_->stopAndPoll();
103 if (!requesters || (requesters->getType() !=
Element::list)) {
105 "'requesters' address list is missing or not a list");
108 for (
auto const& address_elem : requesters->listValue()) {
109 auto entry_txt = address_elem->stringValue();
111 size_t pos = entry_txt.find(
"/");
112 if (pos == std::string::npos) {
115 address_list_.
insert(address);
116 }
catch (
const std::exception& ex) {
118 << address_elem->stringValue()
119 <<
"' is invalid: " << ex.what());
123 IOAddress prefix = IOAddress(entry_txt.substr(0, pos));
126 auto len_txt = entry_txt.substr(pos + 1);
127 int prefix_len = boost::lexical_cast<int>(len_txt);
128 if ((prefix_len < std::numeric_limits<uint8_t>::min()) ||
129 (prefix_len > std::numeric_limits<uint8_t>::max())) {
132 << len_txt <<
" is out of range");
135 pool_set_.insert(prefix, prefix_len);
136 }
catch (
const std::exception& ex) {
138 "'requesters' CIDR entry '" << entry_txt
139 <<
"' is invalid: " << ex.what());
144 if (address_list_.size() == 0 && pool_set_.size() == 0) {
145 isc_throw(BadValue,
"'requesters' list cannot be empty");
151 if (address_list_.contains(address)) {
155 return (pool_set_.contains(address));
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)
short getFamily() const
Returns the address family.
The IOService class is a wrapper for the ASIO io_context class.
static Pool4Ptr create(const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
Factory function for creating an instance of the Pool4.
static Pool6Ptr create(Lease::Type type, const isc::asiolink::IOAddress &first, const isc::asiolink::IOAddress &last)
Factory function for creating an instance of the Pool6.
bool contains(const isc::asiolink::IOAddress &address) const
Checks if an address is present in the list.
void insert(const isc::asiolink::IOAddress &address)
Inserts an address into the list.
static void create(LeaseQueryImpl *impl, isc::data::ConstElementPtr advanced)
Create a new instance of the BulkLeaseQueryService.
static bool terminated_
Terminated flag.
LeaseQueryImpl(uint16_t family, const isc::data::ConstElementPtr config)
Constructor.
static const isc::data::SimpleKeywords LEASE_QUERY_KEYWORDS
Keywords for Lease Query configuration.
bool isRequester(const isc::asiolink::IOAddress &address) const
Checks if the given address belongs to a valid requester.
static size_t PageSize
Page size to commands.
virtual ~LeaseQueryImpl()
Destructor.
uint16_t getFamily() const
Returns the protocol family of the address set.
void insert(const isc::asiolink::IOAddress &prefix, uint8_t prefix_len)
Inserts an pool into the set.
bool contains(const isc::asiolink::IOAddress &address) const
Checks if an address is present in the set.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
std::map< std::string, isc::data::Element::types > SimpleKeywords
This specifies all accepted keywords with their types.
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
Defines the logger used by the top-level component of kea-lfc.
@ TYPE_NA
the lease contains non-temporary IPv6 address