![]() |
Kea 3.0.0
|
Provides configuration and control flow for processing queries. More...
#include <lease_query_impl6.h>
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 PrefixLengthList & | getPrefixLengthList () 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. |
Provides configuration and control flow for processing queries.
Definition at line 33 of file lease_query_impl6.h.
LeaseQueryImpl6::LeaseQueryImpl6 | ( | const data::ConstElementPtr | config | ) |
Constructor.
config | input 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_.
|
inlinevirtual |
Destructor.
Definition at line 41 of file lease_query_impl6.h.
|
inline |
Add a prefix to the list of prefix lengths.
prefix_len | prefix 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().
|
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).
status | (code and text) to send back in the reply. |
query | client lease query to which we are responding. |
leases | list of active leases (if any). |
Unexpected | if status is empty |
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().
|
inline |
Empty the prefix length list.
Definition at line 458 of file lease_query_impl6.h.
References prefix_lens_.
Referenced by populatePrefixLengthList().
|
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.
prefix_lengths | list to dump |
Definition at line 1185 of file lease_query_impl6.cc.
Referenced by populatePrefixLengthList().
|
static |
Creates a prefix of a given length from an address.
address | IPv6 address to derive prefix from |
prefix_length | length of the prefix desired |
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().
|
inline |
Fetch the prefix length list.
Definition at line 465 of file lease_query_impl6.h.
References prefix_lens_.
Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByIpAddress().
|
static |
Calculates the packed size (in octets) of a given RelayInfo.
This function was largely borrowed from Pkt6.
relay | relay whose size is desired |
innermost | indicates whether or not this is the relay closest to the client. |
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().
|
static |
Creates the query data response.
Creates a data packet.
query | client lease query to which we are responding |
Definition at line 692 of file lease_query_impl6.cc.
References DHCPV6_LEASEQUERY_DATA.
Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByClientId(), 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().
|
static |
Creates the final query done response.
Creates the done packet.
query | client lease query to which we are responding |
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().
|
static |
Creates the initial query reply.
Creates the reply packet and populating basic reply values based on the client query.
query | client lease query to which we are responding |
Unexpected | if 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().
|
static |
Convenience method for generating per packet logging info.
packet | DHCPv6 lease query packet (query or response) |
Definition at line 1117 of file lease_query_impl6.cc.
Referenced by buffer6_receive(), isc::lease_query::BulkLeaseQuery6::leaseQueryLabel(), and sendResponse().
|
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.
leases | list of active leases (must contain at least one lease) |
Unexpected | if 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().
|
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.
lease | active lease |
Unexpected | if 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.
|
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.
lease | reference to the lease of interest |
Unexpected | if 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().
|
static |
Constructs a D6O_STATUS_CODE option.
status_code | numeric status code |
message | status text message |
Definition at line 1110 of file lease_query_impl6.cc.
Referenced by isc::lease_query::BulkLeaseQuery6::bulkQueryByLinkAddress(), isc::lease_query::BulkLeaseQuery6::bulkQueryByRelayId(), isc::lease_query::BulkLeaseQuery6::bulkQueryByRemoteId(), isc::lease_query::BulkLeaseQuery6::init(), processQuery(), queryByClientId(), queryByIpAddress(), queryByLinkStart(), queryByRelayIdStart(), and queryByRemoteIdStart().
|
static |
Converts an Element::map into an Pkt6::RelayInfo instance.
relay | an Element::map describing a relay |
BadValue | if 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().
|
static |
Converts an Element::list into a list of Pkt6::RelayInfo instances.
relays | an Element::list of relays | |
[out] | relay_infos | a list into which to store the Pkt6::RelayInfo instances. |
BadValue | if 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().
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.
cfg | pointer 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.
|
virtual |
Processes a single DHCPv6 client Lease Query.
base_query | DHCPv6 lease query to process. |
BadValue | if 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().
|
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 ::.
client_id | client DUID for which to search. | |
link_addr | address of the link to search, | |
[out] | leases | a collection of leases containing the matching leases (if any). |
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().
|
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.
iaaddr | ip address for which to search | |
[out] | leases | a collection of leases containing the matching lease (if one) |
prefix_lengths | list 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. |
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().
|
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.
[in,out] | start_addr | address to start from. |
page_size | maximum number of returned leases in this call. | |
links | set of subnet ids of the link to search. | |
[out] | leases | a 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().
|
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.
[out] | start_addr | address to restart from. |
page_size | maximum number of returned leases in this call. | |
link_addr | address of the link to search. | |
[out] | links | set of subnet ids of the link to search. |
[out] | leases | a collection of leases containing the matching leases (if any). |
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().
|
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.
relay_id | relay DUID for which to search. | |
page_size | maximum number of returned leases in this call. | |
[in,out] | start_addr | address to start from. |
links | set of subnet ids of the link to search. | |
[out] | leases | a 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().
|
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 ::.
relay_id | relay DUID for which to search. | |
[out] | start_addr | address to restart from. |
page_size | maximum number of returned leases in this call. | |
link_addr | address of the link to search. | |
[out] | links | set of subnet ids of the link to search. |
[out] | leases | a collection of leases containing the matching leases (if any). |
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().
|
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.
remote_id | remote id for which to search. | |
[in,out] | start_addr | address to start from. |
page_size | maximum number of returned leases in this call. | |
links | set of subnet ids of the link to search. | |
[out] | leases | a 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().
|
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 ::.
remote_id | remote id for which to search. | |
[out] | start_addr | address to restart from. |
page_size | maximum number of returned leases in this call. | |
link_addr | address of the link to search. | |
[out] | links | set of subnet ids of the link to search. |
[out] | leases | a collection of leases containing the matching leases (if any). |
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().
|
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.
response | response 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().
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.
response | response 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().
|
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.
query | inbound DHCPV6_LEASEQUERY packet to check |
BadValue | if 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().
|
static |
Upgrade extended information.
Sanitize the extended information and (re)builds relay and remoted ID tables when enabled. Does nothing for the memfile backend.
handle | Callout 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().
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().
|
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().