Kea 3.1.1
lease_query_impl.h
Go to the documentation of this file.
1// Copyright (C) 2020-2025 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef LEASE_QUERY_IMPL_H
8#define LEASE_QUERY_IMPL_H
9
11#include <asiolink/io_address.h>
12#include <asiolink/io_service.h>
13#include <dhcp/pkt.h>
14#include <cc/data.h>
15#include <cc/simple_parser.h>
16
17#include <boost/functional/hash.hpp>
18#include <unordered_set>
19
20namespace isc {
21namespace lease_query {
22
25public:
26 QueryTerminated(const char* file, size_t line, const char* what) :
27 isc::Exception(file, line, what) {
28 }
29};
30
31#define CHECK_TERMINATED \
32 if (LeaseQueryImpl::terminated_) { \
33 isc_throw(isc::lease_query::QueryTerminated, "terminated"); \
34 }
35
38public:
42 AddressList(uint16_t family)
43 : family_(family) { };
44
52 void insert(const isc::asiolink::IOAddress& address);
53
60 bool contains(const isc::asiolink::IOAddress& address) const;
61
63 size_t size() const {
64 return (addresses_.size());
65 }
66
68 uint16_t getFamily() {
69 return (family_);
70 }
71
72private:
74 uint16_t family_;
75
77 std::unordered_set<asiolink::IOAddress, boost::hash<asiolink::IOAddress> > addresses_;
78};
79
81class LeaseQueryImpl : public boost::noncopyable {
82public:
87 LeaseQueryImpl(uint16_t family, const isc::data::ConstElementPtr config);
88
90 virtual ~LeaseQueryImpl();
91
97 bool isRequester(const isc::asiolink::IOAddress& address) const;
98
100 size_t getNumRequesters() const {
101 return (address_list_.size());
102 }
103
114 virtual void processQuery(isc::dhcp::PktPtr base_query) const = 0;
115
118
120 uint16_t getFamily() {
121 return (address_list_.getFamily());
122 }
123
128 return (io_service_);
129 }
130
135 io_service_ = io_service;
136 }
137
139 static bool terminated_;
140
142 static size_t PageSize;
143
144private:
145
147 isc::asiolink::IOServicePtr io_service_;
148
150 AddressList address_list_;
151};
152
154typedef boost::shared_ptr<LeaseQueryImpl> LeaseQueryImplPtr;
155
156} // end of namespace isc::lease_query
157} // end of namespace isc
158
159#endif // LEASE_QUERY_IMPL_H
This is a base class for exceptions thrown from the DNS library module.
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Manages a unique list of IP addresses.
size_t size() const
Returns the number of addresses in the list.
bool contains(const isc::asiolink::IOAddress &address) const
Checks if an address is present in the list.
AddressList(uint16_t family)
Constructor.
uint16_t getFamily()
Returns the protocol family of the address list.
void insert(const isc::asiolink::IOAddress &address)
Inserts an address into the list.
virtual void processQuery(isc::dhcp::PktPtr base_query) const =0
Processes a single client Lease Query.
uint16_t getFamily()
Returns the protocol family of the impl.
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.
size_t getNumRequesters() const
Returns the number of valid requester.
isc::asiolink::IOServicePtr getIOService()
Get the hook I/O service.
bool isRequester(const isc::asiolink::IOAddress &address) const
Checks if the given address belongs to a valid requester.
void setIOService(isc::asiolink::IOServicePtr io_service)
Set the hook I/O service.
static size_t PageSize
Page size to commands.
QueryTerminated(const char *file, size_t line, const char *what)
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
std::map< std::string, isc::data::Element::types > SimpleKeywords
This specifies all accepted keywords with their types.
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
Definition pkt.h:999
boost::shared_ptr< LeaseQueryImpl > LeaseQueryImplPtr
Defines a smart pointer to LeaseQueryImpl instance.
Defines the logger used by the top-level component of kea-lfc.