Kea 3.1.1
bulk_lease_query4.h
Go to the documentation of this file.
1// Copyright (C) 2023-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 BULK_LEASE_QUERY4_H
8#define BULK_LEASE_QUERY4_H
9
10#include <config.h>
11
12#include <lease_query_impl.h>
13#include <bulk_lease_query.h>
14#include <dhcp/dhcp4.h>
15#include <dhcpsrv/lease.h>
16
17namespace isc {
18namespace lease_query {
19
28
30std::string getStatusCodeName(BLQStatusCode status);
31
43
45std::string getStateName(BLQStates state);
46
48#ifndef DHO_VSS
49#define DHO_VSS 221
50#endif
51
53class BulkLeaseQuery4;
54
56typedef boost::shared_ptr<BulkLeaseQuery4> BulkLeaseQuery4Ptr;
57
60public:
61
70 const BlqPostCb& post,
71 const BlqPushToSendCb& push_to_send,
72 const BlqQueryCompleteCb& query_complete)
73 : BulkLeaseQuery(query, post, push_to_send, query_complete),
74 query4_(),
75 start_addr_(asiolink::IOAddress::IPV4_ZERO_ADDRESS()),
76 page_size_(10),
77 query_mask_(0),
81 sent_(0) {
82 init();
83 }
84
86 virtual ~BulkLeaseQuery4() {
87 }
88
92 static std::string leaseQueryLabel(const BlqMsgPtr& msg);
93
99 virtual void init();
100
102 virtual void start();
103
106 return (query4_);
107 }
108
111 return (start_addr_);
112 }
113
115 size_t getPageSize() const {
116 return (page_size_);
117 }
118
119protected:
121 void bulkQueryByClientId();
122
124 void bulkQueryByHWAddr();
125
127 void bulkQueryByRelayId();
128
130 void bulkQueryByRemoteId();
131
136 if (!ptr) {
137 // Should not happen.
138 return;
139 }
140 ptr->bulkQueryByRelayId();
141 }
142
147 if (!ptr) {
148 // Should not happen.
149 return;
150 }
151 ptr->bulkQueryByRemoteId();
152 }
153
157 virtual void send(dhcp::Pkt4Ptr response);
158
163 virtual void sendDone(BLQStatusCode status,
164 const std::string& message = "");
165
169 virtual void sendActive(const dhcp::Lease4Ptr& lease);
170
172 uint8_t getQueryMask() const {
173 return (query_mask_);
174 }
175
180 return (query_client_id_);
181 }
182
187 return (query_hwaddr_);
188 }
189
194 return (query_relay_id_);
195 }
196
201 return (query_remote_id_);
202 }
203
206
209
213
220 uint8_t query_mask_;
221
224
227
230
233
236
239
241 size_t sent_;
242};
243
244} // end of namespace isc::lease_query
245} // end of namespace isc
246
247#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:154
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition lease.h:315
boost::shared_ptr< Option > OptionPtr
Definition option.h:37
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.
boost::shared_ptr< BlqQuery > BlqQueryPtr
Defines a shared pointer to an BlqQuery.
Definition blq_msg.h:116
BLQStatusCode
Status Codes.
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.