![]() |
Kea 3.1.5
|
Provides configuration and for processing DHCPv4 lease queries. More...
#include <lease_query_impl4.h>
Inheritance diagram for isc::lease_query::LeaseQueryImpl4:Public Member Functions | |
| LeaseQueryImpl4 (const data::ConstElementPtr config) | |
| Constructor. | |
| virtual | ~LeaseQueryImpl4 () |
| Destructor. | |
| virtual void | processQuery (isc::dhcp::PktPtr base_query, bool &invalid) const |
| Processes a single DHCPv4 client Lease Query. | |
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 | getNumRequesterPools () const |
| Returns the number of valid requester pools. | |
| 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 bool | acceptServerId (const dhcp::Pkt4Ptr &query, dhcp::OptionPtr &server_id_opt) |
| Validates dhcp-server-identifier option in the inbound query (if one) | |
| static void | addAssociatedLeases (dhcp::Pkt4Ptr response, const dhcp::Lease4Collection &leases) |
| Adds associated leases to a query response. | |
| 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 void | addOptions (const dhcp::Pkt4Ptr &query, dhcp::Pkt4Ptr response, const dhcp::Lease4Ptr &lease) |
| Adds options to a query response. | |
| static void | addRelayAgentInfo (dhcp::Pkt4Ptr response, const dhcp::Lease4Ptr &lease) |
| Adds relay-agent-info option to a query response. | |
| static void | appendServerId (dhcp::Pkt4Ptr &response, dhcp::CfgOptionList &co_list) |
| Adds dhcp-server-identifier option (54) to the response. | |
| static void | buildCfgOptionList (dhcp::CfgOptionList &co_list, const dhcp::Pkt4Ptr &query, const dhcp::Lease4Ptr &lease=dhcp::Lease4Ptr(), const dhcp::Subnet4Ptr &subnet=dhcp::Subnet4Ptr()) |
| Constructs a list of configured option sets for a given lease and it's subnet. | |
| static dhcp::Pkt4Ptr | buildResponse (dhcp::DHCPMessageType response_type, const dhcp::Pkt4Ptr &query, const dhcp::Lease4Collection &leases) |
| Creates a lease query response packet. | |
| static dhcp::Pkt4Ptr | initResponse (dhcp::DHCPMessageType response_type, const dhcp::Pkt4Ptr &query) |
| Creates the initial query response. | |
| static std::string | leaseQueryLabel (const dhcp::Pkt4Ptr &packet) |
| Convenience method for generating per packet logging info. | |
| static dhcp::DHCPMessageType | queryByClientId (const dhcp::ClientIdPtr &client_id, dhcp::Lease4Collection &leases) |
| Queries LeaseMgr for active leases matching a client. | |
| static dhcp::DHCPMessageType | queryByHWAddr (const dhcp::HWAddrPtr &hwaddr, dhcp::Lease4Collection &leases) |
| Queries LeaseMgr for active leases matching a HW address. | |
| static dhcp::DHCPMessageType | queryByIpAddress (const asiolink::IOAddress &ciaddr, dhcp::Lease4Collection &leases) |
| Queries for an active lease matching an ip address. | |
| static void | sendResponse (const dhcp::Pkt4Ptr &response) |
| Packs and sends a query response. | |
| static int | upgradeHandler (hooks::CalloutHandle &handle) |
| Upgrade extended information. | |
| static dhcp::Lease4Collection | winnowLeases (const dhcp::Lease4Collection &leases) |
| Creates a list of active leases from a list of leases. | |
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 for processing DHCPv4 lease queries.
Definition at line 22 of file lease_query_impl4.h.
| LeaseQueryImpl4::LeaseQueryImpl4 | ( | const data::ConstElementPtr | config | ) |
Constructor.
| config | input configuration |
Definition at line 45 of file lease_query_impl4.cc.
References isc::lease_query::LeaseQueryImpl::LeaseQueryImpl().
Here is the call graph for this function:
|
inlinevirtual |
Destructor.
Definition at line 30 of file lease_query_impl4.h.
|
static |
Validates dhcp-server-identifier option in the inbound query (if one)
| query | client lease query which server identifier is to be checked. | |
| [out] | server_id_opt | copy of the dhcp-server-identifier in the query |
Definition at line 555 of file lease_query_impl4.cc.
References isc::stats::StatsMgr::addValue(), DHCP4_OPTION_SPACE, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc::dhcp::IfaceMgr::instance(), isc::stats::StatsMgr::instance(), isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS(), and isc::asiolink::IOAddress::isV4().
Referenced by processQuery().
Here is the call graph for this function:
|
static |
Adds associated leases to a query response.
| response | query response to which to add |
| leases | list of active leases (if any) |
Definition at line 304 of file lease_query_impl4.cc.
References isc::dhcp::DHO_ASSOCIATED_IP.
Referenced by buildResponse().
|
static |
Adds life time, T1, and T2 options to a query response.
| response | query response to which to add |
| lease | newest active lease. |
| subnet | lease's subnet |
Definition at line 353 of file lease_query_impl4.cc.
References isc::dhcp::DHO_CLIENT_LAST_TRANSACTION_TIME, isc::dhcp::DHO_DHCP_LEASE_TIME, isc::dhcp::DHO_DHCP_REBINDING_TIME, isc::dhcp::DHO_DHCP_RENEWAL_TIME, isc::dhcp::Lease::INFINITY_LFT, and isc::dhcp::Option::V4.
Referenced by addOptions(), and isc::lease_query::BulkLeaseQuery4::sendActive().
|
static |
Adds options to a query response.
Adds the following options to the reponse (regardless of PRL):
| query | used to get associated client classes |
| response | query response to which to add |
| lease | newest active lease. |
Definition at line 320 of file lease_query_impl4.cc.
References addLeaseTimes(), addRelayAgentInfo(), appendServerId(), buildCfgOptionList(), isc::dhcp::DHO_DHCP_CLIENT_IDENTIFIER, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc_throw, and isc::dhcp::Option::V4.
Referenced by buildResponse().
Here is the call graph for this function:
|
static |
Adds relay-agent-info option to a query response.
| response | query response to which to add |
| lease | newest active lease |
Definition at line 433 of file lease_query_impl4.cc.
References isc::util::str::decodeFormattedHexString(), isc::dhcp::DHO_DHCP_AGENT_OPTIONS, isc_throw, Element::map, isc::data::UserContext::toElement(), and isc::dhcp::Option::V4.
Referenced by addOptions(), and isc::lease_query::BulkLeaseQuery4::sendActive().
Here is the call graph for this function:
|
static |
Adds dhcp-server-identifier option (54) to the response.
If the response packet does not already contain the option it, will be added either from a configured value in co_list (if one) or constructed from the response's local address.
| response | packet to which the option should be added |
| co_list | List of configured option sets in which to search for the option. The sets should be in the list in the order of precedence. |
Definition at line 650 of file lease_query_impl4.cc.
References DHCP4_OPTION_SPACE, isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::dhcp::LibDHCP::DHO_DHCP_SERVER_IDENTIFIER_DEF(), isc::dhcp::OptionDescriptor::option_, and isc::dhcp::Option::V4.
Referenced by addOptions(), and buildResponse().
Here is the call graph for this function:
|
static |
Constructs a list of configured option sets for a given lease and it's subnet.
When lease and subnet are not provided the list will only contain the set of globally configured options. When they are provided the list will contain option sets in the following order:
| [out] | co_list | list to populate |
| lease | lease to use for matching options | |
| subnet | to use for matching options | |
| query | to get associated client classes |
| Unexpected | if lease is provided but subnet is not. |
Definition at line 674 of file lease_query_impl4.cc.
References isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::CfgMgr::instance(), isc_throw, and isc::dhcp::Lease::TYPE_V4.
Referenced by addOptions(), and buildResponse().
Here is the call graph for this function:
|
static |
Creates a lease query response packet.
Orchestrates the construction of a response to lease query based on the response_type and list of active leases.
| response_type | Message type of the response |
| query | client lease query to which we are responding. |
| leases | list of active leases (if any). |
Definition at line 201 of file lease_query_impl4.cc.
References addAssociatedLeases(), addOptions(), appendServerId(), buildCfgOptionList(), isc::dhcp::DHCPLEASEACTIVE, isc::dhcp::DHCPLEASEUNASSIGNED, isc::dhcp::DHCPLEASEUNKNOWN, isc::dhcp::DHO_DHCP_CLIENT_IDENTIFIER, initResponse(), and isc_throw.
Referenced by processQuery().
Here is the call graph for this function:
|
static |
Creates the initial query response.
Creates the response packet and populating basic response values based on query attributes.
| response_type | Message type of the response |
| query | client lease query to which we are responding |
Definition at line 262 of file lease_query_impl4.cc.
References isc::dhcp::DHO_DHCP_SERVER_IDENTIFIER, isc::dhcp::IfaceMgr::getSocket(), isc::dhcp::IfaceMgr::instance(), and isc::asiolink::IOAddress::isV4Bcast().
Referenced by buildResponse().
Here is the call graph for this function:
|
static |
Convenience method for generating per packet logging info.
| packet | DHCPv4 lease query packet (query or response) |
Definition at line 476 of file lease_query_impl4.cc.
References isc::dhcp::DHO_DHCP_CLIENT_IDENTIFIER, and isc::dhcp::IdentifierType< min_size, max_size >::toText().
Referenced by buffer4_receive(), isc::lease_query::BulkLeaseQuery4::leaseQueryLabel(), and sendResponse().
Here is the call graph for this function:
|
virtual |
Processes a single DHCPv4 client Lease Query.
| base_query | DHCPv4 lease query to process. |
| invalid | Reference to a flag set to true when the query is invalid (used to detect unexpected exceptions). |
Send the response if we have one
Implements isc::lease_query::LeaseQueryImpl.
Definition at line 50 of file lease_query_impl4.cc.
References acceptServerId(), isc::stats::StatsMgr::addValue(), buildResponse(), isc::dhcp::DHO_DHCP_CLIENT_IDENTIFIER, isc::stats::StatsMgr::instance(), isc_throw, isc::lease_query::LeaseQueryImpl::isRequester(), isc::asiolink::IOAddress::isV4Zero(), queryByClientId(), queryByHWAddr(), queryByIpAddress(), sendResponse(), and isc::asiolink::IOAddress::toText().
Here is the call graph for this function:
|
static |
Queries LeaseMgr for active leases matching a client.
| client_id | client id for which to search | |
| [out] | leases | a collection of leases containing the matching leases (if one). The newest (by CLTT) will be the first lease in the collection. |
Definition at line 169 of file lease_query_impl4.cc.
References isc::dhcp::DHCPLEASEACTIVE, isc::dhcp::DHCPLEASEUNKNOWN, isc::dhcp::LeaseMgrFactory::instance(), and winnowLeases().
Referenced by processQuery().
Here is the call graph for this function:
|
static |
Queries LeaseMgr for active leases matching a HW address.
| hwaddr | Hardware address for which to search | |
| [out] | leases | a collection of leases containing the matching leases (if one). The newest (by CLTT) will be the first lease in the collection. |
Definition at line 176 of file lease_query_impl4.cc.
References isc::dhcp::DHCPLEASEACTIVE, isc::dhcp::DHCPLEASEUNKNOWN, isc::dhcp::LeaseMgrFactory::instance(), and winnowLeases().
Referenced by processQuery().
Here is the call graph for this function:
|
static |
Queries for an active lease matching an ip address.
| ciaddr | ip address for which to search | |
| [out] | leases | a collection of leases containing the matching lease (if one) |
Definition at line 137 of file lease_query_impl4.cc.
References isc::dhcp::DHCPLEASEACTIVE, isc::dhcp::DHCPLEASEUNASSIGNED, isc::dhcp::DHCPLEASEUNKNOWN, isc::dhcp::CfgMgr::getCurrentCfg(), isc::dhcp::LeaseMgr::getLease4(), isc::dhcp::CfgMgr::instance(), isc::dhcp::LeaseMgrFactory::instance(), isc::dhcp::Lease::STATE_DEFAULT, and isc::dhcp::Lease::TYPE_V4.
Referenced by processQuery().
Here is the call graph for this function:
|
static |
Packs and sends a query response.
| response | query response to send |
Definition at line 508 of file lease_query_impl4.cc.
References isc::stats::StatsMgr::addValue(), isc::log::DBGLVL_TRACE_BASIC, isc::lease_query::DHCP4_LEASE_QUERY_PACKET_PACK_FAILED, isc::lease_query::DHCP4_LEASE_QUERY_RESPONSE_SENT, isc::lease_query::DHCP4_LEASE_QUERY_SEND_FAILED, isc::dhcp::DHCPLEASEACTIVE, isc::dhcp::DHCPLEASEUNASSIGNED, isc::dhcp::DHCPLEASEUNKNOWN, isc::dhcp::IfaceMgr::instance(), isc::stats::StatsMgr::instance(), isc::lease_query::lease_query_logger, leaseQueryLabel(), LOG_DEBUG, LOG_ERROR, and isc::dhcp::IfaceMgr::send().
Referenced by processQuery().
Here is the call graph for this function:
|
static |
Upgrade extended information.
Sanitize the extended information and fills relay and remoted IDs SQL new columns. Does nothing for the memfile backend.
| handle | Callout handle used to retrieve a command and provide a response. |
Definition at line 735 of file lease_query_impl4.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:
|
static |
Creates a list of active leases from a list of leases.
The new list will contain active leases ordered from newest to oldest by CLTT.
| leases | input list of leases. |
Definition at line 183 of file lease_query_impl4.cc.
References isc::dhcp::Lease::STATE_DEFAULT.
Referenced by queryByClientId(), and queryByHWAddr().