Kea 3.0.0
isc::lease_query::LeaseQueryImpl6 Class Reference

Provides configuration and control flow for processing queries. More...

#include <lease_query_impl6.h>

Inheritance diagram for isc::lease_query::LeaseQueryImpl6:

Public Member Functions

 LeaseQueryImpl6 (const data::ConstElementPtr config)
 Constructor.
virtual ~LeaseQueryImpl6 ()
 Destructor.
void addPrefixLength (uint8_t prefix_len)
 Add a prefix to the list of prefix lengths.
void clearPrefixLengthList ()
 Empty the prefix length list.
const PrefixLengthListgetPrefixLengthList () const
 Fetch the prefix length list.
void populatePrefixLengthList (dhcp::SrvConfigPtr cfg)
 Populates the prefix length list from the given configuration.
virtual void processQuery (dhcp::PktPtr base_query) const
 Processes a single DHCPv6 client Lease Query.
virtual void send (const dhcp::Pkt6Ptr &response) const
 Wrapper around the call to IfaceMgr::send().
void sendResponse (const dhcp::Pkt6Ptr &response) const
 Sends a response to the requester.
Public Member Functions inherited from isc::lease_query::LeaseQueryImpl
 LeaseQueryImpl (uint16_t family, const isc::data::ConstElementPtr config)
 Constructor.
virtual ~LeaseQueryImpl ()
 Destructor.
uint16_t getFamily ()
 Returns the protocol family of the impl.
isc::asiolink::IOServicePtr getIOService ()
 Get the hook I/O service.
size_t getNumRequesters () const
 Returns the number of valid requester.
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 Public Member Functions

static dhcp::Pkt6Ptr buildReply (const dhcp::Option6StatusCodePtr &status, const dhcp::Pkt6Ptr &query, dhcp::Lease6Collection &leases)
 Creates a lease query reply packet.
static std::string dumpPrefixLengthList (const PrefixLengthList &prefix_lengths)
 Dump the given list of prefix lengths to a string.
static asiolink::IOAddress getPrefixFromAddress (const asiolink::IOAddress &address, const uint8_t prefix_length)
 Creates a prefix of a given length from an address.
static uint16_t getRelayOverhead (const dhcp::Pkt6::RelayInfo &relay, bool innermost)
 Calculates the packed size (in octets) of a given RelayInfo.
static dhcp::Pkt6Ptr initData (const dhcp::Pkt6Ptr &query)
 Creates the query data response.
static dhcp::Pkt6Ptr initDone (const dhcp::Pkt6Ptr &query)
 Creates the final query done response.
static dhcp::Pkt6Ptr initReply (const dhcp::Pkt6Ptr &query)
 Creates the initial query reply.
static std::string leaseQueryLabel (const dhcp::Pkt6Ptr &packet)
 Convenience method for generating per packet logging info.
static dhcp::OptionPtr makeClientOption (dhcp::Lease6Collection &leases)
 Constructs a client option based on a collection of leases.
static dhcp::OptionPtr makeClientOption (dhcp::Lease6Ptr lease)
 Constructs a client option based on a lease.
static dhcp::OptionPtr makeRelayOption (const dhcp::Lease6 &lease)
 Constructs a D6O_LQ_RELAY_DATA option from a lease user-context.
static dhcp::Option6StatusCodePtr makeStatusOption (const DHCPv6StatusCode &status_code, const std::string message="")
 Constructs a D6O_STATUS_CODE option.
static RelayInfoPtr parseRelayInfo (data::ConstElementPtr relay)
 Converts an Element::map into an Pkt6::RelayInfo instance.
static void parseRelayInfoList (data::ConstElementPtr relays, std::vector< RelayInfoPtr > &relay_infos)
 Converts an Element::list into a list of Pkt6::RelayInfo instances.
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 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::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 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::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 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::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 void testServerId (const dhcp::Pkt6Ptr &query)
 Validates the server-id of a received DHCPV6_LEASEQUERY.
static int upgradeHandler (hooks::CalloutHandle &handle)
 Upgrade extended information.

Public Attributes

bool build_prefix_lens_
 True if the prefix length should be gleaned from configured pools.
PrefixLengthList prefix_lens_
 List of PD prefix lengths to use when searching for leases by address.

Additional Inherited Members

Static Public Attributes inherited from isc::lease_query::LeaseQueryImpl
static const isc::data::SimpleKeywords LEASE_QUERY_KEYWORDS
 Keywords for Lease Query configuration.
static size_t PageSize = 100
 Page size to commands.
static bool terminated_ = false
 Terminated flag.

Detailed Description

Provides configuration and control flow for processing queries.

Definition at line 33 of file lease_query_impl6.h.

Constructor & Destructor Documentation

◆ LeaseQueryImpl6()

LeaseQueryImpl6::LeaseQueryImpl6 ( const data::ConstElementPtr config)

Constructor.

Parameters
configinput configuration

Definition at line 53 of file lease_query_impl6.cc.

References isc::lease_query::LeaseQueryImpl::LeaseQueryImpl(), addPrefixLength(), build_prefix_lens_, isc::dhcp::CfgMgr::getStagingCfg(), isc::dhcp::CfgMgr::instance(), isc::lease_query::BulkLeaseQueryService::instance(), Element::integer, isc_throw, Element::list, and prefix_lens_.

Here is the call graph for this function:

◆ ~LeaseQueryImpl6()

virtual isc::lease_query::LeaseQueryImpl6::~LeaseQueryImpl6 ( )
inlinevirtual

Destructor.

Definition at line 41 of file lease_query_impl6.h.

Member Function Documentation

◆ addPrefixLength()

void isc::lease_query::LeaseQueryImpl6::addPrefixLength ( uint8_t prefix_len)
inline

Add a prefix to the list of prefix lengths.

Parameters
prefix_lenprefix length value to add. Value must be greater than 0 and less than or equal to 128.

Definition at line 451 of file lease_query_impl6.h.

References prefix_lens_.

Referenced by LeaseQueryImpl6(), and populatePrefixLengthList().

◆ buildReply()

Pkt6Ptr LeaseQueryImpl6::buildReply ( const dhcp::Option6StatusCodePtr & status,
const dhcp::Pkt6Ptr & query,
dhcp::Lease6Collection & leases )
static

Creates a lease query reply packet.

Orchestrates the construction of a reply to lease query based on the status code, client query, and the list of active leases (if any).

Parameters
status(code and text) to send back in the reply.
queryclient lease query to which we are responding.
leaseslist of active leases (if any).
Returns
pointer the populated reply
Exceptions
Unexpectedif status is empty
Todo
RFC 5007 allows clients to request options via an for D6O_ORO option. We do not currently support that.

Definition at line 601 of file lease_query_impl6.cc.

References D6O_LQ_CLIENT_LINK, initReply(), isc_throw, makeClientOption(), makeRelayOption(), STATUS_MalformedQuery, STATUS_NotAllowed, STATUS_NotConfigured, STATUS_Success, and STATUS_UnknownQueryType.

Referenced by processQuery().

Here is the call graph for this function:

◆ clearPrefixLengthList()

void isc::lease_query::LeaseQueryImpl6::clearPrefixLengthList ( )
inline

Empty the prefix length list.

Definition at line 458 of file lease_query_impl6.h.

References prefix_lens_.

Referenced by populatePrefixLengthList().

◆ dumpPrefixLengthList()

std::string LeaseQueryImpl6::dumpPrefixLengthList ( const PrefixLengthList & prefix_lengths)
static

Dump the given list of prefix lengths to a string.

The list is output in descending order to reflect the order in which it is used.

Parameters
prefix_lengthslist to dump
Returns
a string contain the prefix length list in JSON format.

Definition at line 1185 of file lease_query_impl6.cc.

Referenced by populatePrefixLengthList().

◆ getPrefixFromAddress()

IOAddress LeaseQueryImpl6::getPrefixFromAddress ( const asiolink::IOAddress & address,
const uint8_t prefix_length )
static

Creates a prefix of a given length from an address.

Parameters
addressIPv6 address to derive prefix from
prefix_lengthlength of the prefix desired
Returns
the address with specified prefix length

Definition at line 190 of file lease_query_impl6.cc.

References isc::asiolink::IOAddress::fromBytes(), isc::asiolink::IOAddress::getFamily(), isc_throw, and isc::asiolink::IOAddress::toBytes().

Referenced by queryByIpAddress().

Here is the call graph for this function:

◆ getPrefixLengthList()

const PrefixLengthList & isc::lease_query::LeaseQueryImpl6::getPrefixLengthList ( ) const
inline

Fetch the prefix length list.

Returns
the prefix length list.

Definition at line 465 of file lease_query_impl6.h.

References prefix_lens_.

Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByIpAddress().

◆ getRelayOverhead()

uint16_t LeaseQueryImpl6::getRelayOverhead ( const dhcp::Pkt6::RelayInfo & relay,
bool innermost )
static

Calculates the packed size (in octets) of a given RelayInfo.

This function was largely borrowed from Pkt6.

Parameters
relayrelay whose size is desired
innermostindicates whether or not this is the relay closest to the client.
Returns
packed size of the relay.

Definition at line 957 of file lease_query_impl6.cc.

References isc::dhcp::Pkt6::DHCPV6_RELAY_HDR_LEN, isc::dhcp::Option::OPTION6_HDR_LEN, and isc::dhcp::Pkt6::RelayInfo::options_.

Referenced by makeRelayOption().

◆ initData()

◆ initDone()

Pkt6Ptr LeaseQueryImpl6::initDone ( const dhcp::Pkt6Ptr & query)
static

Creates the final query done response.

Creates the done packet.

Parameters
queryclient lease query to which we are responding
Returns
pointer to the newly constructed done packet

Definition at line 702 of file lease_query_impl6.cc.

References DHCPV6_LEASEQUERY_DONE.

Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByClientId(), isc::lease_query::BulkLeaseQuery6::bulkQueryByIpAddress(), isc::lease_query::BulkLeaseQuery6::bulkQueryByLinkAddressNext(), isc::lease_query::BulkLeaseQuery6::bulkQueryByRelayIdNext(), and isc::lease_query::BulkLeaseQuery6::bulkQueryByRemoteIdNext().

◆ initReply()

Pkt6Ptr LeaseQueryImpl6::initReply ( const dhcp::Pkt6Ptr & query)
static

Creates the initial query reply.

Creates the reply packet and populating basic reply values based on the client query.

Parameters
queryclient lease query to which we are responding
Returns
pointer to the newly constructed reply packet
Exceptions
Unexpectedif query does not contain a D6O_CLIENTID or if the server-id does not yet exist.

Definition at line 661 of file lease_query_impl6.cc.

References D6O_CLIENTID, D6O_SERVERID, DHCPV6_LEASEQUERY_REPLY, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc_throw, and isc::dhcp::Option::V6.

Referenced by buildReply(), isc::lease_query::BulkLeaseQuery6::bulkQueryByClientId(), isc::lease_query::BulkLeaseQuery6::bulkQueryByIpAddress(), isc::lease_query::BulkLeaseQuery6::bulkQueryByLinkAddress(), isc::lease_query::BulkLeaseQuery6::bulkQueryByRelayId(), isc::lease_query::BulkLeaseQuery6::bulkQueryByRemoteId(), and isc::lease_query::BulkLeaseQuery6::sendReply().

Here is the call graph for this function:

◆ leaseQueryLabel()

std::string LeaseQueryImpl6::leaseQueryLabel ( const dhcp::Pkt6Ptr & packet)
static

Convenience method for generating per packet logging info.

Parameters
packetDHCPv6 lease query packet (query or response)
Returns
the query label.

Definition at line 1117 of file lease_query_impl6.cc.

Referenced by buffer6_receive(), isc::lease_query::BulkLeaseQuery6::leaseQueryLabel(), and sendResponse().

◆ makeClientOption() [1/2]

OptionPtr LeaseQueryImpl6::makeClientOption ( dhcp::Lease6Collection & leases)
static

Constructs a client option based on a collection of leases.

Based on a collection of one or more active leases, sorted in descending order by CLTT (i.e. newest lease first), the function will either:

Create a D6O_LQ_CLIENT_LINK option with a list of the link addresses (i.e. subnet prefixes) for each unique link, when the leases in the collection are from more than one subnet. Create a D6O_CLIENT_DATA option with D6O_IAADDR and/or D6O_IAPREFIX options for each lease in the collection when those leases are all in the same subnet. This option will also contain a D6O_CLIENT_ID and a D6O_CLT_TIME option whose values are taken from the first lease in the collection. The valid and preferred lifetimes on each lease option will be reduced by the amount time elapsed since that lease's CLTT.

Parameters
leaseslist of active leases (must contain at least one lease)
Returns
Pointer to the newly created option
Exceptions
Unexpectedif passed an empty lease collection or if there is no option definition for D6O_CLIENT_DATA.

Definition at line 712 of file lease_query_impl6.cc.

References isc::dhcp::Lease::cltt_, isc::dhcp::LibDHCP::D6O_CLIENT_DATA_DEF(), D6O_CLIENTID, D6O_CLT_TIME, D6O_IAADDR, D6O_IAPREFIX, D6O_LQ_CLIENT_LINK, isc::dhcp::Lease6::duid_, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc_throw, isc::dhcp::Lease::TYPE_NA, and isc::dhcp::Option::V6.

Referenced by buildReply(), isc::lease_query::BulkLeaseQuery6::bulkQueryByClientId(), isc::lease_query::BulkLeaseQuery6::bulkQueryByIpAddress(), isc::lease_query::BulkLeaseQuery6::bulkQueryByLinkAddress(), isc::lease_query::BulkLeaseQuery6::bulkQueryByLinkAddressNext(), isc::lease_query::BulkLeaseQuery6::bulkQueryByRelayId(), isc::lease_query::BulkLeaseQuery6::bulkQueryByRelayIdNext(), isc::lease_query::BulkLeaseQuery6::bulkQueryByRemoteId(), and isc::lease_query::BulkLeaseQuery6::bulkQueryByRemoteIdNext().

Here is the call graph for this function:

◆ makeClientOption() [2/2]

OptionPtr LeaseQueryImpl6::makeClientOption ( dhcp::Lease6Ptr lease)
static

Constructs a client option based on a lease.

Create a D6O_CLIENT_DATA option with D6O_IAADDR and/or D6O_IAPREFIX options for the lease. This option will also contain a D6O_CLIENT_ID and a D6O_CLT_TIME option. The valid and preferred lifetimes will be reduced by the amount time elapsed since CLTT.

Parameters
leaseactive lease
Returns
Pointer to the newly created option
Exceptions
Unexpectedif there is no option definition for D6O_CLIENT_DATA.

Definition at line 803 of file lease_query_impl6.cc.

References isc::dhcp::LibDHCP::D6O_CLIENT_DATA_DEF(), D6O_CLIENTID, D6O_CLT_TIME, D6O_IAADDR, D6O_IAPREFIX, makeRelayOption(), isc::dhcp::Lease::TYPE_NA, and isc::dhcp::Option::V6.

Here is the call graph for this function:

◆ makeRelayOption()

OptionPtr LeaseQueryImpl6::makeRelayOption ( const dhcp::Lease6 & lease)
static

Constructs a D6O_LQ_RELAY_DATA option from a lease user-context.

When kea-dhcp6 is configured with store-extended-info enabled and it assigns or renews a lease at the behest of a relayed client packet, it stores the the list of Pkt6::RelayInfos from that client packet into the lease's user-context. If this function is passed a lease without this information it returns an empty OptionPtr.

If not, it parses the user-context into a list of Pkt6::RelayInfo structures. It then creates a new D6O_LQ_RELAY_OPTION and populates it's peer address field from the first RelayInfo in the list. It then uses the relay info list to construct a packed RELAY_FORW message into a buffer. This buffer is then added to the L6O_LQ_RELAY_OPTION as a D6O_RELAY_MSG option.

If the relay information for a lease is malformed and cannot be extracted and parsed correctly, an warning will be logged and an empty pointer returned. This allows a response to still be generated, albeit without the option.

Parameters
leasereference to the lease of interest
Returns
A pointer to newly constructed option or an empty pointer
Exceptions
Unexpectedif the lq-relay-data option definition is missing.

Definition at line 858 of file lease_query_impl6.cc.

References isc::dhcp::LibDHCP::D6O_LQ_RELAY_DATA_DEF(), D6O_RELAY_MSG, isc::lease_query::DHCP6_LEASE_QUERY_ERROR_GETTING_RELAY_INFO, DHCPV6_RELAY_FORW, isc::dhcp::Pkt6::DHCPV6_RELAY_HDR_LEN, isc::data::UserContext::getContext(), getRelayOverhead(), isc::util::OutputBuffer::getVector(), isc_throw, isc::lease_query::lease_query_logger, LOG_WARN, parseRelayInfoList(), isc::data::UserContext::toElement(), isc::dhcp::Lease6::toText(), isc::dhcp::Option::V6, isc::util::OutputBuffer::writeData(), isc::util::OutputBuffer::writeUint16(), and isc::util::OutputBuffer::writeUint8().

Referenced by buildReply(), and makeClientOption().

Here is the call graph for this function:

◆ makeStatusOption()

Option6StatusCodePtr LeaseQueryImpl6::makeStatusOption ( const DHCPv6StatusCode & status_code,
const std::string message = "" )
static

◆ parseRelayInfo()

RelayInfoPtr LeaseQueryImpl6::parseRelayInfo ( data::ConstElementPtr relay)
static

Converts an Element::map into an Pkt6::RelayInfo instance.

Parameters
relayan Element::map describing a relay
Returns
Pointer to the newly constructed Pkt6::RelayInfo
Exceptions
BadValueif the relay parameter is empty or not an Element::map, or the map content is invalid for a number of other reasons.

Definition at line 985 of file lease_query_impl6.cc.

References isc::util::str::decodeFormattedHexString(), DHCP6_OPTION_SPACE, isc_throw, Element::map, and isc::dhcp::LibDHCP::unpackOptions6().

Referenced by parseRelayInfoList().

Here is the call graph for this function:

◆ parseRelayInfoList()

void LeaseQueryImpl6::parseRelayInfoList ( data::ConstElementPtr relays,
std::vector< RelayInfoPtr > & relay_infos )
static

Converts an Element::list into a list of Pkt6::RelayInfo instances.

Parameters
relaysan Element::list of relays
[out]relay_infosa list into which to store the Pkt6::RelayInfo instances.
Exceptions
BadValueif the relay parameter is not an Element::list

Definition at line 972 of file lease_query_impl6.cc.

References isc::db::info, isc_throw, Element::list, and parseRelayInfo().

Referenced by makeRelayOption().

Here is the call graph for this function:

◆ populatePrefixLengthList()

void LeaseQueryImpl6::populatePrefixLengthList ( dhcp::SrvConfigPtr cfg)

Populates the prefix length list from the given configuration.

If the prefix length list has not been explicitly configured (i.e. build_prefix_lens_ is false), then the prefix length list is (re)populated from the PD pools in the given server configuration.

Parameters
cfgpointer the server configuration to use.

Definition at line 1164 of file lease_query_impl6.cc.

References addPrefixLength(), build_prefix_lens_, clearPrefixLengthList(), isc::log::DBGLVL_TRACE_BASIC, isc::lease_query::DHCP6_LEASE_QUERY_PREFIX_LENGTH_LIST, dumpPrefixLengthList(), isc::lease_query::lease_query_logger, LOG_DEBUG, prefix_lens_, and isc::dhcp::Lease::TYPE_PD.

Here is the call graph for this function:

◆ processQuery()

void LeaseQueryImpl6::processQuery ( dhcp::PktPtr base_query) const
virtual

Processes a single DHCPv6 client Lease Query.

  • Validates query content
  • Determines is the query is permitted
  • Queries matching lease(s)
  • Constructs the reply
  • Sends the reply
Parameters
base_queryDHCPv6 lease query to process.
Exceptions
BadValueif the query is invalid for a number reasons, including if it comes from an unauthorized requester.

Not sure this really possible.

Implements isc::lease_query::LeaseQueryImpl.

Definition at line 93 of file lease_query_impl6.cc.

References buildReply(), D6O_CLIENTID, D6O_IAADDR, D6O_LQ_QUERY, isc::asiolink::IOAddress::IPV6_ZERO_ADDRESS(), isc_throw, isc::lease_query::LeaseQueryImpl::isRequester(), isc::asiolink::IOAddress::isV6Zero(), LQ6QT_BY_ADDRESS, LQ6QT_BY_CLIENTID, makeStatusOption(), prefix_lens_, queryByClientId(), queryByIpAddress(), sendResponse(), STATUS_MalformedQuery, STATUS_UnknownQueryType, testServerId(), and isc::asiolink::IOAddress::toText().

Here is the call graph for this function:

◆ queryByClientId()

Option6StatusCodePtr LeaseQueryImpl6::queryByClientId ( const dhcp::DuidPtr & client_id,
const asiolink::IOAddress & link_addr,
dhcp::Lease6Collection & leases )
static

Queries for active leases matching a client id (i.e.

duid).

Given a client DUID and a link address, this function will return a list of matching leases, sorted in descending order by CLTT (i.e. newest first). A lease matches if it belongs to the client DUID, is active, and it belongs to the subnet whose range includes the link address if the link address specified is not ::.

Parameters
client_idclient DUID for which to search.
link_addraddress of the link to search,
[out]leasesa collection of leases containing the matching leases (if any).
Returns
Status (code and text) to send back in the reply.

Definition at line 268 of file lease_query_impl6.cc.

References CHECK_TERMINATED, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::LeaseMgr::getLeases6(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::asiolink::IOAddress::isV6Zero(), makeStatusOption(), isc::dhcp::Lease::STATE_DEFAULT, STATUS_NotConfigured, and STATUS_Success.

Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByClientId(), and processQuery().

Here is the call graph for this function:

◆ queryByIpAddress()

Option6StatusCodePtr LeaseQueryImpl6::queryByIpAddress ( const asiolink::IOAddress & iaaddr,
dhcp::Lease6Collection & leases,
const PrefixLengthList & prefix_lengths = PrefixLengthList() )
static

Queries for an active lease matching an ip address.

The lease store is first searched for IA_NA lease for the given address. If none are found and the list of prefix lengths is not empty, then the lease store is searched for IA_PD leases which match the given ip address masked with each prefix length. The prefix lengths are tested in descending order.

If no NA or PD leases are found, then the pools of each subnet are checked to to determine if the query address lies within them.

Parameters
iaaddrip address for which to search
[out]leasesa collection of leases containing the matching lease (if one)
prefix_lengthslist of prefix lengths to use when searching for PD leases containing iaaddr. The list is assumed to be in ascending order and is traversed in reverse.
Returns
Status (code and text) to send back in the reply.

Definition at line 221 of file lease_query_impl6.cc.

References CHECK_TERMINATED, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::LeaseMgr::getLease6(), getPrefixFromAddress(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), makeStatusOption(), isc::dhcp::Lease::STATE_DEFAULT, STATUS_NotConfigured, STATUS_Success, isc::dhcp::Lease::TYPE_NA, and isc::dhcp::Lease::TYPE_PD.

Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByIpAddress(), and processQuery().

Here is the call graph for this function:

◆ queryByLinkNext()

void LeaseQueryImpl6::queryByLinkNext ( asiolink::IOAddress & start_addr,
const size_t page_size,
dhcp::SubnetIDSet & links,
dhcp::Lease6Collection & leases )
static

Subsequent query for active leases of a given link.

Given a link address, this function will return an initial list of matching leases, sorted by address. A lease matches if it to the subnet whose range includes the link address. The start address is used to note progress: if it is not updated there is no more leases to retrieve, otherwise the method should be called again with the updated value to retrieve remaining leases.

Parameters
[in,out]start_addraddress to start from.
page_sizemaximum number of returned leases in this call.
linksset of subnet ids of the link to search.
[out]leasesa collection of leases containing the matching leases (if any).

Definition at line 548 of file lease_query_impl6.cc.

References CHECK_TERMINATED, isc::dhcp::LeaseMgr::getLeases6(), isc::dhcp::LeaseMgrFactory::instance(), isc::asiolink::IOAddress::IPV6_ZERO_ADDRESS(), and isc::dhcp::Lease::STATE_DEFAULT.

Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByLinkAddressNext().

Here is the call graph for this function:

◆ queryByLinkStart()

Option6StatusCodePtr LeaseQueryImpl6::queryByLinkStart ( asiolink::IOAddress & start_addr,
const size_t page_size,
const asiolink::IOAddress & link_addr,
dhcp::SubnetIDSet & links,
dhcp::Lease6Collection & leases )
static

Initial query for active leases of a given link.

Given a link address, this function will return an initial list of matching leases, sorted by address. A lease matches if it to the subnet whose range includes the link address.

Parameters
[out]start_addraddress to restart from.
page_sizemaximum number of returned leases in this call.
link_addraddress of the link to search.
[out]linksset of subnet ids of the link to search.
[out]leasesa collection of leases containing the matching leases (if any).
Returns
Status (code and text) to send back in the reply.

Definition at line 490 of file lease_query_impl6.cc.

References CHECK_TERMINATED, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::LeaseMgr::getLeases6(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::asiolink::IOAddress::IPV6_ZERO_ADDRESS(), isc::asiolink::IOAddress::isV6Zero(), makeStatusOption(), isc::dhcp::Lease::STATE_DEFAULT, STATUS_MalformedQuery, STATUS_NotConfigured, and STATUS_Success.

Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByLinkAddress().

Here is the call graph for this function:

◆ queryByRelayIdNext()

void LeaseQueryImpl6::queryByRelayIdNext ( const dhcp::DuidPtr & relay_id,
asiolink::IOAddress & start_addr,
const size_t page_size,
const dhcp::SubnetIDSet & links,
dhcp::Lease6Collection & leases )
static

Subsequent query for active leases matching a relay id (i.e.

duid).

Given a relay DUID, a link and a start address, this function will return a partial list of matching leases, sorted by address. A lease matches if it was relayed by the given relay, is active, and it belongs to the subnet whose range includes the link address if the specified link address is not ::. The start address is used to note progress: if it is not updated there is no more leases to retrieve, otherwise the method should be called again with the updated value to retrieve remaining leases.

Parameters
relay_idrelay DUID for which to search.
page_sizemaximum number of returned leases in this call.
[in,out]start_addraddress to start from.
linksset of subnet ids of the link to search.
[out]leasesa collection of leases containing the matching leases (if any).

Definition at line 363 of file lease_query_impl6.cc.

References CHECK_TERMINATED, isc::dhcp::LeaseMgr::getLeases6ByRelayId(), isc::dhcp::LeaseMgrFactory::instance(), and isc::dhcp::Lease::STATE_DEFAULT.

Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByRelayIdNext().

Here is the call graph for this function:

◆ queryByRelayIdStart()

Option6StatusCodePtr LeaseQueryImpl6::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 )
static

Initial query for active leases matching a relay id (i.e.

duid).

Given a relay DUID and a link address, this function will return an initial list of matching leases, sorted by address. A lease matches if it was relayed by the given relay, is active, and it belongs to the subnet whose range includes the link address if the specified link address is not ::.

Parameters
relay_idrelay DUID for which to search.
[out]start_addraddress to restart from.
page_sizemaximum number of returned leases in this call.
link_addraddress of the link to search.
[out]linksset of subnet ids of the link to search.
[out]leasesa collection of leases containing the matching leases (if any).
Returns
Status (code and text) to send back in the reply.

Definition at line 312 of file lease_query_impl6.cc.

References CHECK_TERMINATED, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::LeaseMgr::getLeases6ByRelayId(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::asiolink::IOAddress::IPV6_ZERO_ADDRESS(), isc::asiolink::IOAddress::isV6Zero(), makeStatusOption(), isc::dhcp::Lease::STATE_DEFAULT, STATUS_NotConfigured, and STATUS_Success.

Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByRelayId().

Here is the call graph for this function:

◆ queryByRemoteIdNext()

void LeaseQueryImpl6::queryByRemoteIdNext ( const dhcp::OptionBuffer & remote_id,
asiolink::IOAddress & start_addr,
const size_t page_size,
const dhcp::SubnetIDSet & links,
dhcp::Lease6Collection & leases )
static

Subsequent query for active leases matching a remote id.

Given a remote id, a link and a start address, this function will return a partial list of matching leases, sorted by address. A lease matches if it was remoteed by the given relay, is active, and it belongs to the subnet whose range includes the link address if the specified link address is not ::. The start address is used to note progress: if it is not updated there is no more leases to retrieve, otherwise the method should be called again with the updated value to retrieve remaining leases.

Parameters
remote_idremote id for which to search.
[in,out]start_addraddress to start from.
page_sizemaximum number of returned leases in this call.
linksset of subnet ids of the link to search.
[out]leasesa collection of leases containing the matching leases (if any).

Definition at line 452 of file lease_query_impl6.cc.

References CHECK_TERMINATED, isc::dhcp::LeaseMgr::getLeases6ByRemoteId(), isc::dhcp::LeaseMgrFactory::instance(), and isc::dhcp::Lease::STATE_DEFAULT.

Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByRemoteIdNext().

Here is the call graph for this function:

◆ queryByRemoteIdStart()

Option6StatusCodePtr LeaseQueryImpl6::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 )
static

Initial query for active leases matching a remote id.

Given a remote id and a link address, this function will return an initial list of matching leases, sorted by address. A lease matches if it was relayed by the given relay, is active, and it belongs to the subnet whose range includes the link address if the specified link address is not ::.

Parameters
remote_idremote id for which to search.
[out]start_addraddress to restart from.
page_sizemaximum number of returned leases in this call.
link_addraddress of the link to search.
[out]linksset of subnet ids of the link to search.
[out]leasesa collection of leases containing the matching leases (if any).
Returns
Status (code and text) to send back in the reply.

Definition at line 401 of file lease_query_impl6.cc.

References CHECK_TERMINATED, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::LeaseMgr::getLeases6ByRemoteId(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::asiolink::IOAddress::IPV6_ZERO_ADDRESS(), isc::asiolink::IOAddress::isV6Zero(), makeStatusOption(), isc::dhcp::Lease::STATE_DEFAULT, STATUS_NotConfigured, and STATUS_Success.

Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByRemoteId().

Here is the call graph for this function:

◆ send()

void LeaseQueryImpl6::send ( const dhcp::Pkt6Ptr & response) const
virtual

Wrapper around the call to IfaceMgr::send().

This function is virtual to facilitate unit testing. It allows test derivations to intervene and examine outbound packets.

Parameters
responseresponse packet to transmit

Definition at line 1105 of file lease_query_impl6.cc.

References isc::dhcp::IfaceMgr::instance(), and isc::dhcp::IfaceMgr::send().

Referenced by sendResponse().

Here is the call graph for this function:

◆ sendResponse()

void LeaseQueryImpl6::sendResponse ( const dhcp::Pkt6Ptr & response) const

Sends a response to the requester.

Packs the given response packet and then submits it to IfaceMgr for transmission.

Parameters
responseresponse packet to transmit

Definition at line 1074 of file lease_query_impl6.cc.

References isc::stats::StatsMgr::addValue(), isc::log::DBGLVL_TRACE_BASIC, isc::lease_query::DHCP6_LEASE_QUERY_PACKET_PACK_FAILED, isc::lease_query::DHCP6_LEASE_QUERY_REPLY_SEND_FAILED, isc::lease_query::DHCP6_LEASE_QUERY_REPLY_SENT, isc::stats::StatsMgr::instance(), isc::lease_query::lease_query_logger, leaseQueryLabel(), LOG_DEBUG, LOG_ERROR, and send().

Referenced by processQuery().

Here is the call graph for this function:

◆ testServerId()

void LeaseQueryImpl6::testServerId ( const dhcp::Pkt6Ptr & query)
static

Validates the server-id of a received DHCPV6_LEASEQUERY.

If the inbound query contains a D6O_SERVERID option, it's value is checked against the global server-id value used by the kea-dhcp6 server. If it is malformed or does not match the function will throw. Otherwise it will return. If the query does not contain the option, it simply returns.

Parameters
queryinbound DHCPV6_LEASEQUERY packet to check
Exceptions
BadValueif the query contained a malformed server-id or if the server-id does not match that of the kea-dhcp6 server.

Definition at line 1049 of file lease_query_impl6.cc.

References D6O_SERVERID, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), and isc_throw.

Referenced by isc::lease_query::BulkLeaseQuery6::init(), and processQuery().

Here is the call graph for this function:

◆ upgradeHandler()

int LeaseQueryImpl6::upgradeHandler ( hooks::CalloutHandle & handle)
static

Upgrade extended information.

Sanitize the extended information and (re)builds relay and remoted ID tables when enabled. Does nothing for the memfile backend.

Parameters
handleCallout handle used to retrieve a command and provide a response.

Definition at line 1136 of file lease_query_impl6.cc.

References isc::config::CONTROL_RESULT_ERROR, isc::config::CONTROL_RESULT_SUCCESS, isc::config::createAnswer(), isc::dhcp::LeaseMgrFactory::instance(), isc::lease_query::LeaseQueryImpl::PageSize, and isc::hooks::CalloutHandle::setArgument().

Here is the call graph for this function:

Member Data Documentation

◆ build_prefix_lens_

bool isc::lease_query::LeaseQueryImpl6::build_prefix_lens_

True if the prefix length should be gleaned from configured pools.

This is false, if the last has been configure explicitly.

Definition at line 495 of file lease_query_impl6.h.

Referenced by LeaseQueryImpl6(), and populatePrefixLengthList().

◆ prefix_lens_

PrefixLengthList isc::lease_query::LeaseQueryImpl6::prefix_lens_
mutable

List of PD prefix lengths to use when searching for leases by address.

Assumed to be in ascending order by value.

Definition at line 490 of file lease_query_impl6.h.

Referenced by LeaseQueryImpl6(), addPrefixLength(), clearPrefixLengthList(), getPrefixLengthList(), populatePrefixLengthList(), and processQuery().


The documentation for this class was generated from the following files: