27#include <boost/shared_ptr.hpp>
28#include <boost/pointer_cast.hpp>
40 Pkt6Ptr pkt = boost::dynamic_pointer_cast<Pkt6>(msg->getPkt());
55 query6_ = boost::dynamic_pointer_cast<Pkt6>(
query_->getQuery());
71 lq_option_ = boost::dynamic_pointer_cast<OptionCustom>
81 }
catch (
const std::exception& ex) {
92 query_iaaddr_ = boost::dynamic_pointer_cast<Option6IAAddr>(opt);
95 "missing D6O_IAADDR");
104 "missing D6O_CLIENTID");
110 }
catch (
const std::exception& ex) {
112 "malformed D6O_CLIENTID");
121 "missing D6O_RELAY_ID");
127 }
catch (
const std::exception& ex) {
129 "malformed D6O_RELAY_ID");
138 "missing D6O_REMOTE_ID");
143 "empty D6O_REMOTE_ID");
151 "undefined link address");
158 "unknown query-type");
203 if (leases.empty()) {
208 if (leases.size() > 1) {
217 reply->addOption(status);
240 if (leases.empty()) {
247 for (
auto const& lease : leases) {
255 reply->addOption(status);
284 "extended info tables are disabled");
296 if (leases.empty()) {
303 for (
auto const& lease : leases) {
311 reply->addOption(status);
325 boost::static_pointer_cast<BulkLeaseQuery6>(shared_from_this())));
351 for (
auto const& lease : leases) {
361 boost::static_pointer_cast<BulkLeaseQuery6>(shared_from_this())));
372 "extended info tables are disabled");
384 if (leases.empty()) {
391 for (
auto const& lease : leases) {
399 reply->addOption(status);
413 boost::static_pointer_cast<BulkLeaseQuery6>(shared_from_this())));
440 for (
auto const& lease : leases) {
450 boost::static_pointer_cast<BulkLeaseQuery6>(shared_from_this())));
460 "extended info tables are disabled");
471 if (leases.empty()) {
478 for (
auto const& lease : leases) {
486 reply->addOption(status);
500 boost::static_pointer_cast<BulkLeaseQuery6>(shared_from_this())));
522 for (
auto const& lease : leases) {
532 boost::static_pointer_cast<BulkLeaseQuery6>(shared_from_this())));
549 reply->addOption(status);
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown if a function is called in a prohibited way.
A generic exception that is thrown when an unexpected error condition occurs.
The IOAddress class represents an IP addresses (version agnostic)
Holds DUID (DHCPv6 Unique Identifier)
static TrackingLeaseMgr & instance()
Return current lease manager.
Holds a bulk lease query response packet.
asiolink::IOAddress start_addr_
The start address (for paged processing).
dhcp::SubnetIDSet links_
The links the link address (when not ::) belongs to.
void bulkQueryByRemoteIdNext()
Subsequent processing of a by remote id bulk query.
void bulkQueryByRelayIdNext()
Subsequent processing of a by relay id bulk query.
static void doBulkQueryByLinkAddressNext(BulkLeaseQuery6Ptr ptr)
Class/static subsequent processing of a by link address bulk query.
static std::string leaseQueryLabel(const BlqMsgPtr &msg)
Convenience method for generating per packet logging info.
static void doBulkQueryByRemoteIdNext(BulkLeaseQuery6Ptr ptr)
Class/static subsequent processing of a by remote id bulk query.
void bulkQueryByRemoteId()
Start processing of a by remote id bulk query.
void bulkQueryByRelayId()
Start processing of a by relay id bulk query.
virtual void send(dhcp::Pkt6Ptr response) const
Send a response.
dhcp::OptionPtr query_remote_id_
The remote id (for a by remote id bulk query).
dhcp::OptionCustomPtr lq_option_
The lease query option.
virtual void init()
Initialization.
virtual void sendReply(dhcp::OptionPtr status)
Send a final reply.
void bulkQueryByClientId()
Start processing of a by client id bulk query.
dhcp::DuidPtr query_client_id_
The query client id (for a by client id bulk query).
void bulkQueryByIpAddress()
Start processing of a by ip address bulk query.
void bulkQueryByLinkAddress()
Start processing of a by link address bulk query.
dhcp::Option6IAAddrPtr query_iaaddr_
The query ip address (for a by ip address bulk query).
dhcp::DuidPtr query_relay_id_
The query relay id (for a by relay id bulk query).
virtual void start()
Start processing.
dhcp::Pkt6Ptr query6_
The DHCPv6 query.
void bulkQueryByLinkAddressNext()
Subsequent processing of a by link address bulk query.
asiolink::IOAddress link_addr_
The link address.
size_t page_size_
The page size (for paged processing, taken from the MT Lease query manager or defaults to 10).
static void doBulkQueryByRelayIdNext(BulkLeaseQuery6Ptr ptr)
Class/static subsequent processing of a by relay id bulk query.
static BulkLeaseQueryServicePtr instance()
Returns a pointer to the sole instance of the BulkLeaseQueryService, can return null.
uint8_t query_type_
The query type.
virtual void setDone()
Set the done flag.
BlqPostCb post_
The post callback.
BlqQueryPtr query_
The query.
bool started_
The processing is in progress.
BlqPushToSendCb push_to_send_
The pushToSend callback.
Provides configuration and control flow for processing queries.
static void testServerId(const dhcp::Pkt6Ptr &query)
Validates the server-id of a received DHCPV6_LEASEQUERY.
static void queryByRelayIdNext(const dhcp::DuidPtr &relay_id, asiolink::IOAddress &start_addr, const size_t page_size, const dhcp::SubnetIDSet &links, dhcp::Lease6Collection &leases)
Subsequent query for active leases matching a relay id (i.e.
static dhcp::Pkt6Ptr initDone(const dhcp::Pkt6Ptr &query)
Creates the final query done response.
static dhcp::Option6StatusCodePtr queryByRemoteIdStart(const dhcp::OptionBuffer &remote_id, asiolink::IOAddress &start_addr, const size_t page_size, const asiolink::IOAddress &link_addr, dhcp::SubnetIDSet &links, dhcp::Lease6Collection &leases)
Initial query for active leases matching a remote id.
static dhcp::Option6StatusCodePtr queryByRelayIdStart(const dhcp::DuidPtr &relay_id, asiolink::IOAddress &start_addr, const size_t page_size, const asiolink::IOAddress &link_addr, dhcp::SubnetIDSet &links, dhcp::Lease6Collection &leases)
Initial query for active leases matching a relay id (i.e.
static dhcp::Option6StatusCodePtr makeStatusOption(const DHCPv6StatusCode &status_code, const std::string message="")
Constructs a D6O_STATUS_CODE option.
static dhcp::Option6StatusCodePtr queryByLinkStart(asiolink::IOAddress &start_addr, const size_t page_size, const asiolink::IOAddress &link_addr, dhcp::SubnetIDSet &links, dhcp::Lease6Collection &leases)
Initial query for active leases of a given link.
static dhcp::OptionPtr makeClientOption(dhcp::Lease6Collection &leases)
Constructs a client option based on a collection of leases.
const PrefixLengthList & getPrefixLengthList() const
Fetch the prefix length list.
static std::string leaseQueryLabel(const dhcp::Pkt6Ptr &packet)
Convenience method for generating per packet logging info.
static dhcp::Option6StatusCodePtr queryByIpAddress(const asiolink::IOAddress &iaaddr, dhcp::Lease6Collection &leases, const PrefixLengthList &prefix_lengths=PrefixLengthList())
Queries for an active lease matching an ip address.
static void queryByLinkNext(asiolink::IOAddress &start_addr, const size_t page_size, dhcp::SubnetIDSet &links, dhcp::Lease6Collection &leases)
Subsequent query for active leases of a given link.
static dhcp::Pkt6Ptr initReply(const dhcp::Pkt6Ptr &query)
Creates the initial query reply.
static dhcp::Option6StatusCodePtr queryByClientId(const dhcp::DuidPtr &client_id, const asiolink::IOAddress &link_addr, dhcp::Lease6Collection &leases)
Queries for active leases matching a client id (i.e.
static void queryByRemoteIdNext(const dhcp::OptionBuffer &remote_id, asiolink::IOAddress &start_addr, const size_t page_size, const dhcp::SubnetIDSet &links, dhcp::Lease6Collection &leases)
Subsequent query for active leases matching a remote id.
static dhcp::Pkt6Ptr initData(const dhcp::Pkt6Ptr &query)
Creates the query data response.
static const LeaseQueryImpl & getImpl()
Fetch the LeaseQueryImpl singleton.
Thrown on hook termination.
#define LQ6QT_BY_REMOTE_ID
@ STATUS_UnknownQueryType
#define LQ6QT_BY_RELAY_ID
#define LQ6QT_BY_CLIENTID
#define LQ6QT_BY_LINK_ADDRESS
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< DUID > DuidPtr
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
boost::shared_ptr< Option6StatusCode > Option6StatusCodePtr
Pointer to the isc::dhcp::Option6StatusCode.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
boost::shared_ptr< Option > OptionPtr
boost::shared_ptr< BlqResponse > BlqResponsePtr
Defines a shared pointer to an BlqResponse.
boost::shared_ptr< BlqMsg > BlqMsgPtr
Defines a shared pointer to an BlqMsg.
Defines the logger used by the top-level component of kea-lfc.