Kea: lease_query_impl4.h Source File

| Kea 3.2.0-git

lease_query_impl4.h
Go to the documentation of this file.
1// Copyright (C) 2020-2026 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
43 virtual void processQuery(isc::dhcp::PktPtr base_query,
44 bool& invalid) const;
45
58 static dhcp::DHCPMessageType queryByIpAddress(const asiolink::IOAddress& ciaddr,
59 dhcp::Lease4Collection& leases);
60
73 static dhcp::DHCPMessageType queryByClientId(const dhcp::ClientIdPtr& client_id,
74 dhcp::Lease4Collection& leases);
75
88 static dhcp::DHCPMessageType queryByHWAddr(const dhcp::HWAddrPtr& hwaddr,
89 dhcp::Lease4Collection& leases);
90
98 static dhcp::Lease4Collection winnowLeases(const dhcp::Lease4Collection& leases);
99
110 static dhcp::Pkt4Ptr buildResponse(dhcp::DHCPMessageType response_type,
111 const dhcp::Pkt4Ptr& query,
112 const dhcp::Lease4Collection& leases);
113
123 static dhcp::Pkt4Ptr initResponse(dhcp::DHCPMessageType response_type,
124 const dhcp::Pkt4Ptr& query);
125
130 static void addAssociatedLeases(dhcp::Pkt4Ptr response,
131 const dhcp::Lease4Collection& leases);
132
147 static void addOptions(const dhcp::Pkt4Ptr& query, dhcp::Pkt4Ptr response,
148 const dhcp::Lease4Ptr& lease);
149
155 static void addLeaseTimes(dhcp::Pkt4Ptr response, const dhcp::Lease4Ptr& lease,
156 const dhcp::Subnet4Ptr& subnet);
157
162 static void addRelayAgentInfo(dhcp::Pkt4Ptr response, const dhcp::Lease4Ptr& lease);
163
167 static void sendResponse(const dhcp::Pkt4Ptr& response);
168
174 static std::string leaseQueryLabel(const dhcp::Pkt4Ptr& packet);
175
182 static bool acceptServerId(const dhcp::Pkt4Ptr& query,
183 dhcp::OptionPtr& server_id_opt);
184
208 static void buildCfgOptionList(dhcp::CfgOptionList& co_list,
209 const dhcp::Pkt4Ptr& query,
210 const dhcp::Lease4Ptr& lease = dhcp::Lease4Ptr(),
211 const dhcp::Subnet4Ptr& subnet = dhcp::Subnet4Ptr());
212
222 static void appendServerId(dhcp::Pkt4Ptr& response, dhcp::CfgOptionList& co_list);
223
231 static int upgradeHandler(hooks::CalloutHandle& handle);
232};
233
235 typedef boost::shared_ptr<LeaseQueryImpl4> LeaseQueryImpl4Ptr;
236
237} // end of namespace isc::lease_query
238} // end of namespace isc
239
240#endif // LEASE_QUERY_IMPL4_H
cfg_option.h
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:53
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:137
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:320
isc::lease_query::LeaseQueryImpl4::upgradeHandler
static int upgradeHandler(hooks::CalloutHandle &handle)
Upgrade extended information.
Definition lease_query_impl4.cc:735
isc::lease_query::LeaseQueryImpl4::sendResponse
static void sendResponse(const dhcp::Pkt4Ptr &response)
Packs and sends a query response.
Definition lease_query_impl4.cc:508
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:353
isc::lease_query::LeaseQueryImpl4::LeaseQueryImpl4
LeaseQueryImpl4(const data::ConstElementPtr config)
Constructor.
Definition lease_query_impl4.cc:45
isc::lease_query::LeaseQueryImpl4::processQuery
virtual void processQuery(isc::dhcp::PktPtr base_query, bool &invalid) const
Processes a single DHCPv4 client Lease Query.
Definition lease_query_impl4.cc:50
isc::lease_query::LeaseQueryImpl4::~LeaseQueryImpl4
virtual ~LeaseQueryImpl4()
Destructor.
Definition lease_query_impl4.h:30
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:304
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:476
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:183
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:555
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:176
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:674
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:169
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:650
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:433
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:262
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:201
isc::lease_query::LeaseQueryImpl::LeaseQueryImpl
LeaseQueryImpl(uint16_t family, const isc::data::ConstElementPtr config)
Constructor.
Definition lease_query_impl.cc:81
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:30
isc::dhcp::PktPtr
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
Definition pkt.h:999
isc::dhcp::Subnet4Ptr
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
Definition subnet.h:458
isc::dhcp::Pkt4Ptr
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition pkt4.h:556
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:979
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:235
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
pkt4.h
subnet.h