23#include <boost/shared_ptr.hpp>
24#include <boost/pointer_cast.hpp>
40 return (
"UnspecFail");
42 return (
"QueryTerminated");
44 return (
"MalformedQuery");
46 return (
"NotAllowed");
48 return (
"(unknown status code)");
70 return (
"TRANSITIONING");
72 return (
"(unknown state)");
78 Pkt4Ptr pkt = boost::dynamic_pointer_cast<Pkt4>(msg->getPkt());
93 query4_ = boost::dynamic_pointer_cast<Pkt4>(
query_->getQuery());
100 if (!
query4_->getCiaddr().isV4Zero()) {
104 if (!
query4_->getYiaddr().isV4Zero()) {
108 if (!
query4_->getSiaddr().isV4Zero()) {
156 boost::dynamic_pointer_cast<OptionInt<uint32_t>>(opt);
170 boost::dynamic_pointer_cast<OptionInt<uint32_t>>(opt);
198 "query for all configured addresses is not supported");
256 for (
auto const& lease : leases) {
261 if (lease->expired()) {
292 for (
auto const& lease : leases) {
297 if (lease->expired()) {
337 if (leases.empty()) {
346 for (
auto const& lease : leases) {
351 if (lease->expired()) {
361 boost::static_pointer_cast<BulkLeaseQuery4>(shared_from_this())));
383 if (leases.empty()) {
392 for (
auto const& lease : leases) {
397 if (lease->expired()) {
407 boost::static_pointer_cast<BulkLeaseQuery4>(shared_from_this())));
422 opt->writeAddress(srv->getLeaseQueryIp());
423 response->addOption(opt);
446 opt->writeInteger(
static_cast<uint8_t
>(status), 0);
447 opt->writeString(message, 1);
448 done->addOption(opt);
467 ->getCfgSubnets4()->getSubnet(lease->subnet_id_);
477 active->setCiaddr(lease->addr_);
480 if (lease->hwaddr_) {
481 active->setHWAddr(lease->hwaddr_);
487 if (lease->client_id_) {
489 lease->client_id_->getClientId()));
490 active->addOption(opt);
495 active->addOption(opt);
std::string getStateName(BLQStates state)
std::string getStatusCodeName(BLQStatusCode status)
#define DHO_VSS
Virtual Subnet Selection Option code point (RFC 6607 and 6926).
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.
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
Holds Client identifier or client IPv4 address.
static TrackingLeaseMgr & instance()
Return current lease manager.
virtual Lease4Collection getLeases4ByRemoteId(const OptionBuffer &remote_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size, const time_t &qry_start_time=0, const time_t &qry_end_time=0)=0
Returns existing IPv4 leases with a given remote-id.
virtual Lease4Collection getLeases4ByRelayId(const OptionBuffer &relay_id, const asiolink::IOAddress &lower_bound_address, const LeasePageSize &page_size, const time_t &qry_start_time=0, const time_t &qry_end_time=0)=0
Returns existing IPv4 leases with a given relay-id.
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const =0
Returns an IPv4 lease for specified IPv4 address.
Wraps value holding size of the page with leases.
static const OptionDefinition & DHO_DHCP_SERVER_IDENTIFIER_DEF()
Get definition of DHO_DHCP_SERVER_IDENTIFIER option.
static const OptionDefinition & DHO_STATUS_CODE_DEF()
Get definition of DHO_STATUS_CODE option.
Option with defined data fields represented as buffers that can be accessed using data field index.
Base class representing a DHCP option definition.
Represents DHCPv4 packet.
Holds a bulk lease query response packet.
dhcp::HWAddrPtr query_hwaddr_
The query hardware address (for a by hardware address bulk query).
void bulkQueryByClientId()
Start processing of a by client id bulk query.
size_t sent_
Sent response counter.
virtual void start()
Start processing.
time_t query_start_time_
The query start time.
time_t query_end_time_
The query end time.
virtual void send(dhcp::Pkt4Ptr response)
Send a response.
static std::string leaseQueryLabel(const BlqMsgPtr &msg)
Convenience method for generating per packet logging info.
static void doBulkQueryByRemoteId(BulkLeaseQuery4Ptr ptr)
Class/static subsequent processing of a by remote id bulk query.
void bulkQueryByRelayId()
Start processing of a by relay id bulk query.
dhcp::OptionPtr query_client_id_
The query client id (for a by client id bulk query).
asiolink::IOAddress start_addr_
The start address (for paged processing).
void bulkQueryByHWAddr()
Start processing of a by harware address bulk query.
size_t page_size_
The page size (for paged processing, taken from the MT Lease query manager or defaults to 10).
uint8_t query_mask_
The query mask.
dhcp::OptionPtr query_remote_id_
The remote id (for a by remote id bulk query).
virtual void sendDone(BLQStatusCode status, const std::string &message="")
Send a DHCPLEASEQUERYDONE message.
dhcp::OptionPtr query_relay_id_
The query relay id (for a by relay id bulk query).
static void doBulkQueryByRelayId(BulkLeaseQuery4Ptr ptr)
Class/static subsequent processing of a by relay id bulk query.
dhcp::Pkt4Ptr query4_
The DHCPv4 query.
void bulkQueryByRemoteId()
Start processing of a by remote id bulk query.
virtual void sendActive(const dhcp::Lease4Ptr &lease)
Send a DHCPLEASEACTIVE message.
virtual void init()
Initialization.
static BulkLeaseQueryServicePtr instance()
Returns a pointer to the sole instance of the BulkLeaseQueryService, can return null.
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.
static void addLeaseTimes(dhcp::Pkt4Ptr response, const dhcp::Lease4Ptr &lease, const dhcp::Subnet4Ptr &subnet)
Adds life time, T1, and T2 options to a query response.
static std::string leaseQueryLabel(const dhcp::Pkt4Ptr &packet)
Convenience method for generating per packet logging info.
static void addRelayAgentInfo(dhcp::Pkt4Ptr response, const dhcp::Lease4Ptr &lease)
Adds relay-agent-info option to a query response.
Thrown on hook termination.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
OptionInt< uint32_t > OptionUint32
boost::shared_ptr< OptionUint32 > OptionUint32Ptr
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
@ DHO_DHCP_CLIENT_IDENTIFIER
boost::shared_ptr< OptionCustom > OptionCustomPtr
A pointer to the OptionCustom object.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
boost::shared_ptr< Option > OptionPtr
@ BLQ_STATE_TRANSITIONING
boost::shared_ptr< BlqResponse > BlqResponsePtr
Defines a shared pointer to an BlqResponse.
BLQStatusCode
Status Codes.
@ BLQ_STATUS_QueryTerminated
@ BLQ_STATUS_MalformedQuery
boost::shared_ptr< BlqMsg > BlqMsgPtr
Defines a shared pointer to an BlqMsg.
Defines the logger used by the top-level component of kea-lfc.
Hardware type that represents information from DHCPv4 packet.
static const uint32_t STATE_DEFAULT
A lease in the default state.