Kea 3.3.3
bulk_lease_query4.h
Go to the documentation of this file.
1// Copyright (C) 2023-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 BULK_LEASE_QUERY4_H
8#define BULK_LEASE_QUERY4_H
9
10#include <config.h>
11
12#include <dhcp/dhcp4.h>
13#include <dhcpsrv/lease.h>
16
17#include <cstdint>
18
19namespace isc {
20namespace lease_query {
21
30
32std::string getStatusCodeName(BLQStatusCode status);
33
45
47std::string getStateName(BLQStates state);
48
50#ifndef DHO_VSS
51#define DHO_VSS 221
52#endif
53
55class BulkLeaseQuery4;
56
58typedef boost::shared_ptr<BulkLeaseQuery4> BulkLeaseQuery4Ptr;
59
62public:
63
72 const BlqPostCb& post,
73 const BlqPushToSendCb& push_to_send,
74 const BlqQueryCompleteCb& query_complete)
75 : BulkLeaseQuery(query, post, push_to_send, query_complete),
76 query4_(),
77 start_addr_(asiolink::IOAddress::IPV4_ZERO_ADDRESS()),
78 page_size_(10),
79 query_mask_(0),
83 sent_(0) {
84 init();
85 }
86
88 virtual ~BulkLeaseQuery4() {
89 }
90
94 static std::string leaseQueryLabel(const BlqMsgPtr& msg);
95
101 virtual void init();
102
104 virtual void start();
105
108 return (query4_);
109 }
110
113 return (start_addr_);
114 }
115
117 size_t getPageSize() const {
118 return (page_size_);
119 }
120
121protected:
123 void bulkQueryByClientId();
124
126 void bulkQueryByHWAddr();
127
129 void bulkQueryByRelayId();
130
132 void bulkQueryByRemoteId();
133
138 if (!ptr) {
139 // Should not happen.
140 return;
141 }
142 ptr->bulkQueryByRelayId();
143 }
144
149 if (!ptr) {
150 // Should not happen.
151 return;
152 }
153 ptr->bulkQueryByRemoteId();
154 }
155
159 virtual void send(dhcp::Pkt4Ptr response);
160
165 virtual void sendDone(BLQStatusCode status,
166 const std::string& message = "");
167
171 virtual void sendActive(const dhcp::Lease4Ptr& lease);
172
174 uint8_t getQueryMask() const {
175 return (query_mask_);
176 }
177
182 return (query_client_id_);
183 }
184
189 return (query_hwaddr_);
190 }
191
196 return (query_relay_id_);
197 }
198
203 return (query_remote_id_);
204 }
205
208
211
215
222 uint8_t query_mask_;
223
226
229
232
235
238
241
243 size_t sent_;
244};
245
246} // end of namespace isc::lease_query
247} // end of namespace isc
248
249#endif // BULK_LEASE_QUERY4_H
dhcp::HWAddrPtr query_hwaddr_
The query hardware address (for a by hardware address bulk query).
void bulkQueryByClientId()
Start processing of a by client id bulk query.
uint8_t getQueryMask() const
Get the query mask.
size_t sent_
Sent response counter.
virtual void start()
Start processing.
dhcp::OptionPtr getQueryRelayId() const
Get the query relay id for a by relay id bulk query.
time_t query_start_time_
The query start time.
time_t query_end_time_
The query end time.
virtual void send(dhcp::Pkt4Ptr response)
Send a response.
size_t getPageSize() const
Get the page size.
static std::string leaseQueryLabel(const BlqMsgPtr &msg)
Convenience method for generating per packet logging info.
static void doBulkQueryByRemoteId(BulkLeaseQuery4Ptr ptr)
Class/static subsequent processing of a by remote id bulk query.
void bulkQueryByRelayId()
Start processing of a by relay id bulk query.
dhcp::HWAddrPtr getQueryHWAddr() const
Get the query hardware address for a by hardware address bulk query.
dhcp::OptionPtr query_client_id_
The query client id (for a by client id bulk query).
BulkLeaseQuery4(BlqQueryPtr query, const BlqPostCb &post, const BlqPushToSendCb &push_to_send, const BlqQueryCompleteCb &query_complete)
Constructor.
asiolink::IOAddress start_addr_
The start address (for paged processing).
void bulkQueryByHWAddr()
Start processing of a by harware address bulk query.
size_t page_size_
The page size (for paged processing, taken from the MT Lease query manager or defaults to 10).
dhcp::OptionPtr query_remote_id_
The remote id (for a by remote id bulk query).
dhcp::OptionPtr getQueryClientId() const
Get the query client id for a by client id bulk query.
virtual void sendDone(BLQStatusCode status, const std::string &message="")
Send a DHCPLEASEQUERYDONE message.
dhcp::OptionPtr query_relay_id_
The query relay id (for a by relay id bulk query).
dhcp::Pkt4Ptr getQuery4() const
Get the DHCPv4 query.
static void doBulkQueryByRelayId(BulkLeaseQuery4Ptr ptr)
Class/static subsequent processing of a by relay id bulk query.
asiolink::IOAddress getStartAddress() const
Get the current start address.
dhcp::Pkt4Ptr query4_
The DHCPv4 query.
void bulkQueryByRemoteId()
Start processing of a by remote id bulk query.
virtual void sendActive(const dhcp::Lease4Ptr &lease)
Send a DHCPLEASEACTIVE message.
virtual void init()
Initialization.
dhcp::OptionPtr getQueryRemoteId() const
Get the query remote id for a by remote id bulk query.
BulkLeaseQuery(BlqQueryPtr query, const BlqPostCb &post, const BlqPushToSendCb &push_to_send, const BlqQueryCompleteCb &query_complete)
Constructor.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition pkt4.h:556
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
Definition hwaddr.h:166
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition lease.h:343
boost::shared_ptr< Option > OptionPtr
Definition option.h:38
std::string getStateName(BLQStates state)
Return the name of the state.
std::string getStatusCodeName(BLQStatusCode status)
Return the name of the status code.
std::function< void(const BlqPostCbArg &)> BlqPostCb
Type of BLQ post callback.
std::function< void(Xid)> BlqQueryCompleteCb
Type of BLQ queryComplete callback.
boost::shared_ptr< BulkLeaseQuery4 > BulkLeaseQuery4Ptr
Defines a shared pointer to a BulkLeaseQuery4 object.
BLQStatusCode
Status Codes.
boost::shared_ptr< BlqQuery > BlqQueryPtr
Defines a shared pointer to an BlqQuery.
Definition blq_msg.h:116
boost::shared_ptr< BlqMsg > BlqMsgPtr
Defines a shared pointer to an BlqMsg.
Definition blq_msg.h:93
std::function< bool(BlqResponsePtr)> BlqPushToSendCb
Type of BLQ pushToSend callback.
Defines the logger used by the top-level component of kea-lfc.