Kea: lease_query_impl4.h Source File

| Kea 3.0.0

lease_query_impl4.h
Go to the documentation of this file.
1// Copyright (C) 2020-2025 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef LEASE_QUERY_IMPL4_H
8#define LEASE_QUERY_IMPL4_H
9
10#include <config.h>
11
12#include <dhcp/pkt4.h>
13#include <dhcpsrv/cfg_option.h>
14#include <dhcpsrv/lease.h>
15#include <dhcpsrv/subnet.h>
16#include <lease_query_impl.h>
17
18namespace isc {
19namespace lease_query {
20
22 class LeaseQueryImpl4 : public LeaseQueryImpl {
23public:
27 LeaseQueryImpl4(const data::ConstElementPtr config);
28
30 virtual ~LeaseQueryImpl4(){};
31
41 virtual void processQuery(dhcp::PktPtr base_query) const;
42
55 static dhcp::DHCPMessageType queryByIpAddress(const asiolink::IOAddress& ciaddr,
56 dhcp::Lease4Collection& leases);
57
70 static dhcp::DHCPMessageType queryByClientId(const dhcp::ClientIdPtr& client_id,
71 dhcp::Lease4Collection& leases);
72
85 static dhcp::DHCPMessageType queryByHWAddr(const dhcp::HWAddrPtr& hwaddr,
86 dhcp::Lease4Collection& leases);
87
95 static dhcp::Lease4Collection winnowLeases(const dhcp::Lease4Collection& leases);
96
107 static dhcp::Pkt4Ptr buildResponse(dhcp::DHCPMessageType response_type,
108 const dhcp::Pkt4Ptr& query,
109 const dhcp::Lease4Collection& leases);
110
120 static dhcp::Pkt4Ptr initResponse(dhcp::DHCPMessageType response_type,
121 const dhcp::Pkt4Ptr& query);
122
127 static void addAssociatedLeases(dhcp::Pkt4Ptr response,
128 const dhcp::Lease4Collection& leases);
129
144 static void addOptions(const dhcp::Pkt4Ptr& query, dhcp::Pkt4Ptr response,
145 const dhcp::Lease4Ptr& lease);
146
152 static void addLeaseTimes(dhcp::Pkt4Ptr response, const dhcp::Lease4Ptr& lease,
153 const dhcp::Subnet4Ptr& subnet);
154
159 static void addRelayAgentInfo(dhcp::Pkt4Ptr response, const dhcp::Lease4Ptr& lease);
160
164 static void sendResponse(const dhcp::Pkt4Ptr& response);
165
171 static std::string leaseQueryLabel(const dhcp::Pkt4Ptr& packet);
172
179 static bool acceptServerId(const dhcp::Pkt4Ptr& query,
180 dhcp::OptionPtr& server_id_opt);
181
205 static void buildCfgOptionList(dhcp::CfgOptionList& co_list,
206 const dhcp::Pkt4Ptr& query,
207 const dhcp::Lease4Ptr& lease = dhcp::Lease4Ptr(),
208 const dhcp::Subnet4Ptr& subnet = dhcp::Subnet4Ptr());
209
219 static void appendServerId(dhcp::Pkt4Ptr& response, dhcp::CfgOptionList& co_list);
220
228 static int upgradeHandler(hooks::CalloutHandle& handle);
229};
230
232 typedef boost::shared_ptr<LeaseQueryImpl4> LeaseQueryImpl4Ptr;
233
234} // end of namespace isc::lease_query
235} // end of namespace isc
236
237#endif // LEASE_QUERY_IMPL4_H
cfg_option.h
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic)
Definition io_address.h:45
isc::hooks::CalloutHandle
Per-packet callout handle.
Definition callout_handle.h:78
isc::lease_query::LeaseQueryImpl4::queryByIpAddress
static dhcp::DHCPMessageType queryByIpAddress(const asiolink::IOAddress &ciaddr, dhcp::Lease4Collection &leases)
Queries for an active lease matching an ip address.
Definition lease_query_impl4.cc:126
isc::lease_query::LeaseQueryImpl4::addOptions
static void addOptions(const dhcp::Pkt4Ptr &query, dhcp::Pkt4Ptr response, const dhcp::Lease4Ptr &lease)
Adds options to a query response.
Definition lease_query_impl4.cc:309
isc::lease_query::LeaseQueryImpl4::upgradeHandler
static int upgradeHandler(hooks::CalloutHandle &handle)
Upgrade extended information.
Definition lease_query_impl4.cc:711
isc::lease_query::LeaseQueryImpl4::sendResponse
static void sendResponse(const dhcp::Pkt4Ptr &response)
Packs and sends a query response.
Definition lease_query_impl4.cc:497
isc::lease_query::LeaseQueryImpl4::addLeaseTimes
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.
Definition lease_query_impl4.cc:342
isc::lease_query::LeaseQueryImpl4::LeaseQueryImpl4
LeaseQueryImpl4(const data::ConstElementPtr config)
Constructor.
Definition lease_query_impl4.cc:45
isc::lease_query::LeaseQueryImpl4::~LeaseQueryImpl4
virtual ~LeaseQueryImpl4()
Destructor.
Definition lease_query_impl4.h:30
isc::lease_query::LeaseQueryImpl4::processQuery
virtual void processQuery(dhcp::PktPtr base_query) const
Processes a single DHCPv4 client Lease Query.
Definition lease_query_impl4.cc:50
isc::lease_query::LeaseQueryImpl4::addAssociatedLeases
static void addAssociatedLeases(dhcp::Pkt4Ptr response, const dhcp::Lease4Collection &leases)
Adds associated leases to a query response.
Definition lease_query_impl4.cc:293
isc::lease_query::LeaseQueryImpl4::leaseQueryLabel
static std::string leaseQueryLabel(const dhcp::Pkt4Ptr &packet)
Convenience method for generating per packet logging info.
Definition lease_query_impl4.cc:465
isc::lease_query::LeaseQueryImpl4::winnowLeases
static dhcp::Lease4Collection winnowLeases(const dhcp::Lease4Collection &leases)
Creates a list of active leases from a list of leases.
Definition lease_query_impl4.cc:172
isc::lease_query::LeaseQueryImpl4::acceptServerId
static bool acceptServerId(const dhcp::Pkt4Ptr &query, dhcp::OptionPtr &server_id_opt)
Validates dhcp-server-identifier option in the inbound query (if one)
Definition lease_query_impl4.cc:544
isc::lease_query::LeaseQueryImpl4::queryByHWAddr
static dhcp::DHCPMessageType queryByHWAddr(const dhcp::HWAddrPtr &hwaddr, dhcp::Lease4Collection &leases)
Queries LeaseMgr for active leases matching a HW address.
Definition lease_query_impl4.cc:165
isc::lease_query::LeaseQueryImpl4::buildCfgOptionList
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.
Definition lease_query_impl4.cc:650
isc::lease_query::LeaseQueryImpl4::queryByClientId
static dhcp::DHCPMessageType queryByClientId(const dhcp::ClientIdPtr &client_id, dhcp::Lease4Collection &leases)
Queries LeaseMgr for active leases matching a client.
Definition lease_query_impl4.cc:158
isc::lease_query::LeaseQueryImpl4::appendServerId
static void appendServerId(dhcp::Pkt4Ptr &response, dhcp::CfgOptionList &co_list)
Adds dhcp-server-identifier option (54) to the response.
Definition lease_query_impl4.cc:626
isc::lease_query::LeaseQueryImpl4::addRelayAgentInfo
static void addRelayAgentInfo(dhcp::Pkt4Ptr response, const dhcp::Lease4Ptr &lease)
Adds relay-agent-info option to a query response.
Definition lease_query_impl4.cc:422
isc::lease_query::LeaseQueryImpl4::initResponse
static dhcp::Pkt4Ptr initResponse(dhcp::DHCPMessageType response_type, const dhcp::Pkt4Ptr &query)
Creates the initial query response.
Definition lease_query_impl4.cc:251
isc::lease_query::LeaseQueryImpl4::buildResponse
static dhcp::Pkt4Ptr buildResponse(dhcp::DHCPMessageType response_type, const dhcp::Pkt4Ptr &query, const dhcp::Lease4Collection &leases)
Creates a lease query response packet.
Definition lease_query_impl4.cc:190
isc::lease_query::LeaseQueryImpl::LeaseQueryImpl
LeaseQueryImpl(uint16_t family, const isc::data::ConstElementPtr config)
Constructor.
Definition lease_query_impl.cc:49
lease.h
lease_query_impl.h
isc::config
Definition command_interpreter.cc:23
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
isc::dhcp::PktPtr
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
Definition pkt.h:998
isc::dhcp::Subnet4Ptr
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
Definition subnet.h:461
isc::dhcp::Pkt4Ptr
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition pkt4.h:555
isc::dhcp::HWAddrPtr
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
Definition hwaddr.h:154
isc::dhcp::ClientIdPtr
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
Definition duid.h:216
isc::dhcp::DHCPMessageType
DHCPMessageType
Definition dhcp4.h:233
isc::dhcp::Lease4Collection
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
Definition lease.h:520
isc::dhcp::Lease4Ptr
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition lease.h:315
isc::dhcp::OptionPtr
boost::shared_ptr< Option > OptionPtr
Definition option.h:37
isc::dhcp::CfgOptionList
std::list< ConstCfgOptionPtr > CfgOptionList
Const pointer list.
Definition cfg_option.h:898
isc::lease_query
Definition blq_msg.h:15
isc::lease_query::LeaseQueryImpl4Ptr
boost::shared_ptr< LeaseQueryImpl4 > LeaseQueryImpl4Ptr
Defines a smart pointer to LeaseQueryImpl4 instance.
Definition lease_query_impl4.h:232
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
pkt4.h
subnet.h