Kea: sflq_cmds.cc Source File

| Kea 3.2.0-git

sflq_cmds.cc
Go to the documentation of this file.
1// Copyright (C) 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#include <config.h>
8#include <config/cmds_impl.h>
9#include <cc/data.h>
10#include <cc/simple_parser.h>
11#include <asiolink/io_address.h>
12#include <asiolink/addr_utilities.h>
13#include <database/db_exceptions.h>
14#include <dhcpsrv/lease_mgr.h>
15#include <dhcpsrv/lease_mgr_factory.h>
16#include <dhcpsrv/subnet_id.h>
17#include <hooks/hooks.h>
18#include <exceptions/exceptions.h>
19#include <lease_cmds_log.h>
20#include <sflq_cmds.h>
21#include <util/multi_threading_mgr.h>
22
23#include <string>
24#include <sstream>
25
26using namespace isc::dhcp;
27using namespace isc::data;
28using namespace isc::config;
29using namespace isc::asiolink;
30using namespace isc::hooks;
31using namespace isc::util;
32using namespace isc::log;
33using namespace std;
34
35namespace isc {
36namespace lease_cmds {
37
38int
39SflqCmdsImpl::sflqPool4RebuildHandler(CalloutHandle& handle) {
40 static const data::SimpleKeywords keywords =
41 {
42 { "start-address", Element::string },
43 { "end-address", Element::string },
44 };
45
46 static const data::SimpleRequiredKeywords required_keywords =
47 {
48 "start-address",
49 "end-address",
50 };
51
52 stringstream resp;
53 try {
54 extractCommand(handle);
55 if (!cmd_args_ || cmd_args_->getType() != Element::map) {
56 isc_throw(isc::BadValue, "no parameters specified for the command");
57 }
58
59 SimpleParser::checkRequired(required_keywords, cmd_args_);
60 SimpleParser::checkKeywords(keywords, cmd_args_);
61
62 // Fetch the command parameters.
63 IOAddress start_address(IOAddress::IPV4_ZERO_ADDRESS());
64 IOAddress end_address(IOAddress::IPV4_ZERO_ADDRESS());
65 extractRange(cmd_args_, AF_INET, start_address, end_address);
66
67 // Fetch pools by range.
68 auto pools = LeaseMgrFactory::instance().sflqPool4Get(start_address, end_address);
69
70 // Since get can return more than one, look for an exact match.
71 bool rebuilt = false;
72 for (auto const& pool : *pools ) {
73 if (pool->start_address_ == start_address && pool->end_address_ == end_address) {
74 // Found a match, rebuild it.
75 // Invoke the pool create function inside a CriticalSection. Rebuilding
76 // large pools can take a long time.
77 MultiThreadingCriticalSection cs;
78 LeaseMgrFactory::instance().sflqCreateFlqPool4(start_address, end_address,
79 pool->subnet_id_, true);
80 rebuilt = true;
81 break;
82 }
83 }
84
85 if (rebuilt){
86 auto response = createAnswer(CONTROL_RESULT_SUCCESS,
87 "SFLQ pool rebuilt.", cmd_args_);
88 setResponse(handle, response);
89 } else {
90 auto response = createAnswer(CONTROL_RESULT_EMPTY,
91 "SFLQ pool does not exist.", cmd_args_);
92 setResponse(handle, response);
93 }
94
95 LOG_DEBUG(lease_cmds_logger, LEASE_CMDS_DBG_COMMAND_DATA, SFLQ_POOL4_REBUILD)
96 .arg(cmd_args_->str())
97 .arg(rebuilt ? 1 : 0);
98
99 } catch (const std::exception& ex) {
100 LOG_ERROR(lease_cmds_logger, SFLQ_POOL4_REBUILD_FAILED)
101 .arg(cmd_args_ ? cmd_args_->str() : "<no args>")
102 .arg(ex.what());
103 setErrorResponse(handle, ex.what());
104 return (1);
105 }
106
107 return (0);
108}
109
110int
111SflqCmdsImpl::sflqPool4GetAllHandler(CalloutHandle& handle) {
112 return (sflqPoolGetAll(handle, AF_INET));
113}
114
115int
116SflqCmdsImpl::sflqPool4GetBySubnetHandler(CalloutHandle& handle) {
117 return (sflqPoolGetBySubnet(handle, AF_INET));
118}
119
120int
121SflqCmdsImpl::sflqPool4GetByRangeHandler(CalloutHandle& handle) {
122 return (sflqPoolGetByRange(handle, AF_INET));
123}
124
125int
126SflqCmdsImpl::sflqPool4DelHandler(CalloutHandle& handle) {
127 return (sflqPoolDel(handle, AF_INET));
128}
129
130int
131SflqCmdsImpl::sflqPool6RebuildHandler(CalloutHandle& handle) {
132 static const data::SimpleKeywords keywords =
133 {
134 { "start-address", Element::string },
135 { "end-address", Element::string },
136 };
137
138 static const data::SimpleRequiredKeywords required_keywords =
139 {
140 "start-address",
141 "end-address",
142 };
143
144 stringstream resp;
145 try {
146 extractCommand(handle);
147 if (!cmd_args_ || cmd_args_->getType() != Element::map) {
148 isc_throw(isc::BadValue, "no parameters specified for the command");
149 }
150
151 SimpleParser::checkRequired(required_keywords, cmd_args_);
152 SimpleParser::checkKeywords(keywords, cmd_args_);
153
154 // Fetch the command parameters.
155 IOAddress start_address(IOAddress::IPV6_ZERO_ADDRESS());
156 IOAddress end_address(IOAddress::IPV6_ZERO_ADDRESS());
157 extractRange(cmd_args_, AF_INET6, start_address, end_address);
158
159 // Fetch pools by range.
160 auto pools = LeaseMgrFactory::instance().sflqPool6Get(start_address, end_address);
161
162 // Since get can return more than one, look for an exact match.
163 bool rebuilt = false;
164 for (auto const& pool : *pools ) {
165 if (pool->start_address_ == start_address && pool->end_address_ == end_address) {
166 // Found a match, rebuild it.
167 // Invoke the pool create function inside a CriticalSection. Rebuilding
168 // large pools can take a long time.
169 MultiThreadingCriticalSection cs;
170 LeaseMgrFactory::instance().sflqCreateFlqPool6(start_address, end_address,
171 pool->lease_type_,
172 pool->delegated_len_,
173 pool->subnet_id_, true);
174 rebuilt = true;
175 break;
176 }
177 }
178
179 if (rebuilt){
180 auto response = createAnswer(CONTROL_RESULT_SUCCESS,
181 "SFLQ pool rebuilt.", cmd_args_);
182 setResponse(handle, response);
183 } else {
184 auto response = createAnswer(CONTROL_RESULT_EMPTY,
185 "SFLQ pool does not exist.", cmd_args_);
186 setResponse(handle, response);
187 }
188
189 LOG_DEBUG(lease_cmds_logger, LEASE_CMDS_DBG_COMMAND_DATA, SFLQ_POOL6_REBUILD)
190 .arg(cmd_args_->str())
191 .arg(rebuilt ? 1 : 0);
192 } catch (const std::exception& ex) {
193 LOG_ERROR(lease_cmds_logger, SFLQ_POOL6_REBUILD_FAILED)
194 .arg(cmd_args_ ? cmd_args_->str() : "<no args>")
195 .arg(ex.what());
196 setErrorResponse(handle, ex.what());
197 return (1);
198 }
199
200 return (0);
201}
202
203int
204SflqCmdsImpl::sflqPool6GetAllHandler(CalloutHandle& handle) {
205 return (sflqPoolGetAll(handle, AF_INET6));
206}
207
208int
209SflqCmdsImpl::sflqPool6GetBySubnetHandler(CalloutHandle& handle) {
210 return (sflqPoolGetBySubnet(handle, AF_INET6));
211}
212
213int
214SflqCmdsImpl::sflqPool6GetByRangeHandler(CalloutHandle& handle) {
215 return (sflqPoolGetByRange(handle, AF_INET6));
216}
217
218int
219SflqCmdsImpl::sflqPool6DelHandler(CalloutHandle& handle) {
220 return (sflqPoolDel(handle, AF_INET6));
221}
222
223int
224SflqCmdsImpl::sflqPoolGetAll(CalloutHandle& handle, uint16_t family) {
225 static const data::SimpleKeywords keywords;
226 try {
227 extractCommand(handle);
228 if (cmd_args_ && ((cmd_args_->getType() != Element::map) ||
229 (cmd_args_->mapValue().size()) > 0)) {
230 isc_throw(BadValue, "command does not take any arguments");
231 }
232
233 // Invoke the pool get function.
234 auto pools = (family == AF_INET ? LeaseMgrFactory::instance().sflqPool4GetAll()
235 : LeaseMgrFactory::instance().sflqPool6GetAll());
236
237 auto resp = buildGetResponse(pools);
238 setResponse(handle, resp);
239 LOG_DEBUG(lease_cmds_logger, LEASE_CMDS_DBG_COMMAND_DATA,
240 (family == AF_INET ? SFLQ_POOL4_GET_ALL : SFLQ_POOL6_GET_ALL))
241 .arg(pools->size());
242 } catch (const std::exception& ex) {
243 LOG_ERROR(lease_cmds_logger, (family == AF_INET ? SFLQ_POOL4_GET_ALL_FAILED
244 : SFLQ_POOL6_GET_ALL_FAILED))
245 .arg(cmd_args_ ? cmd_args_->str() : "<no args>")
246 .arg(ex.what());
247 setErrorResponse(handle, ex.what());
248 return (1);
249 }
250
251 return (0);
252}
253
254int
255SflqCmdsImpl::sflqPoolGetBySubnet(CalloutHandle& handle, uint16_t family) {
256 static const data::SimpleKeywords keywords =
257 {
258 { "subnet-id", Element::integer },
259 };
260
261 static const data::SimpleRequiredKeywords required_keywords =
262 {
263 "subnet-id",
264 };
265
266 try {
267 extractCommand(handle);
268 if (!cmd_args_ || cmd_args_->getType() != Element::map) {
269 isc_throw(isc::BadValue, "no parameters specified for the command");
270 }
271
272 SimpleParser::checkRequired(required_keywords, cmd_args_);
273 SimpleParser::checkKeywords(keywords, cmd_args_);
274
275 // Extract subnet-id.
276 int64_t subnet_id = SimpleParser::getInteger(cmd_args_, "subnet-id");
277 if ((subnet_id < 1) || (subnet_id >= SUBNET_ID_UNUSED)) {
278 isc_throw(isc::BadValue, "'subnet-id' " << subnet_id << " is invalid,"
279 " must be greater than zero and less than "
280 << SUBNET_ID_UNUSED);
281 }
282
283 // Invoke the pool get by subnet function.
284 auto pools = (family == AF_INET ? LeaseMgrFactory::instance().sflqPool4Get(subnet_id)
285 : LeaseMgrFactory::instance().sflqPool6Get(subnet_id));
286
287 auto resp = buildGetResponse(pools);
288 setResponse(handle, resp);
289 LOG_DEBUG(lease_cmds_logger, LEASE_CMDS_DBG_COMMAND_DATA,
290 (family == AF_INET ? SFLQ_POOL4_GET_BY_SUBNET : SFLQ_POOL6_GET_BY_SUBNET))
291 .arg(cmd_args_->str())
292 .arg(pools->size());
293 } catch (const std::exception& ex) {
294 LOG_ERROR(lease_cmds_logger, (family == AF_INET ? SFLQ_POOL4_GET_BY_SUBNET_FAILED
295 : SFLQ_POOL6_GET_BY_SUBNET_FAILED))
296 .arg(cmd_args_ ? cmd_args_->str() : "<no args>")
297 .arg(ex.what());
298 setErrorResponse(handle, ex.what());
299 return (1);
300 }
301
302 return (0);
303}
304
305int
306SflqCmdsImpl::sflqPoolGetByRange(CalloutHandle& handle, uint16_t family) {
307 static const data::SimpleKeywords keywords =
308 {
309 { "start-address", Element::string },
310 { "end-address", Element::string },
311 };
312
313 static const data::SimpleRequiredKeywords required_keywords =
314 {
315 "start-address",
316 "end-address",
317 };
318
319 try {
320 extractCommand(handle);
321 if (!cmd_args_ || cmd_args_->getType() != Element::map) {
322 isc_throw(isc::BadValue, "no parameters specified for the command");
323 }
324
325 SimpleParser::checkRequired(required_keywords, cmd_args_);
326 SimpleParser::checkKeywords(keywords, cmd_args_);
327
328 // Fetch the command parameters.
329 IOAddress start_address(IOAddress::IPV4_ZERO_ADDRESS());
330 IOAddress end_address(IOAddress::IPV4_ZERO_ADDRESS());
331 extractRange(cmd_args_, family, start_address, end_address);
332
333 // Invoke the pool get by subnet function.
334 auto pools = (family == AF_INET
335 ? LeaseMgrFactory::instance().sflqPool4Get(start_address, end_address)
336 : LeaseMgrFactory::instance().sflqPool6Get(start_address, end_address));
337
338 auto resp = buildGetResponse(pools);
339 setResponse(handle, resp);
340 LOG_DEBUG(lease_cmds_logger, LEASE_CMDS_DBG_COMMAND_DATA,
341 (family == AF_INET ? SFLQ_POOL4_GET_BY_RANGE : SFLQ_POOL6_GET_BY_RANGE))
342 .arg(cmd_args_->str())
343 .arg(pools->size());
344 } catch (const std::exception& ex) {
345 LOG_ERROR(lease_cmds_logger, (family == AF_INET ? SFLQ_POOL4_GET_BY_RANGE_FAILED
346 : SFLQ_POOL6_GET_BY_RANGE_FAILED))
347 .arg(cmd_args_ ? cmd_args_->str() : "<no args>")
348 .arg(ex.what());
349 setErrorResponse(handle, ex.what());
350 return (1);
351 }
352
353 return (0);
354}
355
356int
357SflqCmdsImpl::sflqPoolDel(CalloutHandle& handle, uint16_t family) {
358 static const data::SimpleKeywords keywords =
359 {
360 { "start-address", Element::string },
361 { "end-address", Element::string },
362 { "force", Element::boolean },
363 };
364
365 static const data::SimpleRequiredKeywords required_keywords =
366 {
367 "start-address",
368 "end-address",
369 };
370
371 try {
372 extractCommand(handle);
373 if (!cmd_args_ || cmd_args_->getType() != Element::map) {
374 isc_throw(isc::BadValue, "no parameters specified for the command");
375 }
376
377 SimpleParser::checkRequired(required_keywords, cmd_args_);
378 SimpleParser::checkKeywords(keywords, cmd_args_);
379
380 // Fetch the command parameters.
381 IOAddress start_address(IOAddress::IPV4_ZERO_ADDRESS());
382 IOAddress end_address(IOAddress::IPV4_ZERO_ADDRESS());
383 extractRange(cmd_args_, family, start_address, end_address);
384 bool force = extractBool(cmd_args_, "force", false);
385
386 // Invoke the pool get by subnet function.
387 bool deleted = (family == AF_INET
388 ? LeaseMgrFactory::instance().sflqPool4Del(start_address,
389 end_address, force)
390 : LeaseMgrFactory::instance().sflqPool6Del(start_address,
391 end_address, force));
392
393 if (deleted) {
394 auto response = createAnswer(CONTROL_RESULT_SUCCESS,
395 "SFLQ pool deleted", cmd_args_);
396 setResponse(handle, response);
397 } else {
398 auto response = createAnswer(CONTROL_RESULT_EMPTY,
399 "SFLQ pool does not exist", cmd_args_);
400 setResponse(handle, response);
401 }
402
403 LOG_DEBUG(lease_cmds_logger, LEASE_CMDS_DBG_COMMAND_DATA,
404 (family == AF_INET ? SFLQ_POOL4_DEL : SFLQ_POOL6_DEL))
405 .arg(cmd_args_->str())
406 .arg(deleted ? 1 : 0);
407 } catch (const std::exception& ex) {
408 LOG_ERROR(lease_cmds_logger, (family == AF_INET ? SFLQ_POOL4_DEL_FAILED
409 : SFLQ_POOL6_DEL_FAILED))
410 .arg(cmd_args_ ? cmd_args_->str() : "<no args>")
411 .arg(ex.what());
412 setErrorResponse(handle, ex.what());
413 return (1);
414 }
415
416 return (0);
417}
418
419 ConstElementPtr
420SflqCmdsImpl::buildGetResponse(SflqPoolInfoCollectionPtr pools) {
421 ElementPtr pools_json = Element::createList();
422 for (auto const& pool : *pools) {
423 pools_json->add(pool->toElement());
424 }
425
426 auto pool_cnt = pools_json->size();
427 stringstream resp_msg;
428 resp_msg << pool_cnt << " pool(s) found.";
429
430 ElementPtr args = Element::createMap();
431 args->set("pools", pools_json);
432
433 auto response = createAnswer(pool_cnt > 0 ?
434 CONTROL_RESULT_SUCCESS : CONTROL_RESULT_EMPTY,
435 resp_msg.str(), args);
436 return(response);
437}
438
439
440void
441SflqCmdsImpl::extractRange(ConstElementPtr& params, uint8_t family,
442 IOAddress& start_address, IOAddress& end_address) {
443 start_address = SimpleParser::getAddress(params, "start-address");
444 end_address = SimpleParser::getAddress(params, "end-address");
445 if (family == AF_INET) {
446 validateV4Range(start_address, end_address);
447 } else {
448 validateV6Range(start_address, end_address);
449 }
450}
451
452bool
453SflqCmdsImpl::extractBool(ConstElementPtr& params, const std::string& name,
454 bool default_value) {
455 auto tmp = params->get(name);
456 if (!tmp) {
457 return (default_value);
458 }
459
460 if (tmp->getType() != Element::boolean) {
461 isc_throw(BadValue, "'" << name << "' parameter is not boolean.");
462 }
463
464 return (tmp->boolValue());
465}
466
467 Lease::Type
468SflqCmdsImpl::extractLeaseType(ConstElementPtr& params, uint16_t family) {
469 auto tmp = SimpleParser::getString(params, "lease-type");
470 if (family == AF_INET) {
471 if (tmp == "V4" || tmp == "3") {
472 return (Lease::TYPE_V4);
473 }
474
475 isc_throw(BadValue, "invalid 'lease-type': " << tmp << " must be 'V4'");
476 }
477
478 if (tmp == "IA_NA" || tmp == "0") {
479 return (Lease::TYPE_NA);
480 } else if (tmp == "IA_PD" || tmp == "2") {
481 return (Lease::TYPE_PD);
482 }
483
484 isc_throw(BadValue, "invalid V6 'lease-type': "
485 << tmp << ", valid values are IA_NA and IA_PD");
486}
487
488SflqCmds::SflqCmds()
489 : sflq_impl_(new SflqCmdsImpl()) {
490}
491
492int
493SflqCmds::sflqPool4RebuildHandler(CalloutHandle& handle) {
494 return (sflq_impl_->sflqPool4RebuildHandler(handle));
495}
496
497int
498SflqCmds::sflqPool4GetAllHandler(CalloutHandle& handle) {
499 return (sflq_impl_->sflqPool4GetAllHandler(handle));
500}
501
502int
503SflqCmds::sflqPool4GetBySubnetHandler(CalloutHandle& handle) {
504 return (sflq_impl_->sflqPool4GetBySubnetHandler(handle));
505}
506
507int
508SflqCmds::sflqPool4GetByRangeHandler(CalloutHandle& handle) {
509 return (sflq_impl_->sflqPool4GetByRangeHandler(handle));
510}
511
512int
513SflqCmds::sflqPool4DelHandler(CalloutHandle& handle) {
514 return (sflq_impl_->sflqPool4DelHandler(handle));
515}
516
517int
518SflqCmds::sflqPool6RebuildHandler(CalloutHandle& handle) {
519 return (sflq_impl_->sflqPool6RebuildHandler(handle));
520}
521
522int
523SflqCmds::sflqPool6GetAllHandler(CalloutHandle& handle) {
524 return (sflq_impl_->sflqPool6GetAllHandler(handle));
525}
526
527int
528SflqCmds::sflqPool6GetBySubnetHandler(CalloutHandle& handle) {
529 return (sflq_impl_->sflqPool6GetBySubnetHandler(handle));
530}
531
532int
533SflqCmds::sflqPool6GetByRangeHandler(CalloutHandle& handle) {
534 return (sflq_impl_->sflqPool6GetByRangeHandler(handle));
535}
536
537int
538SflqCmds::sflqPool6DelHandler(CalloutHandle& handle) {
539 return (sflq_impl_->sflqPool6DelHandler(handle));
540}
541
542} // end of namespace lease_cmds
543} // end of namespace isc
addr_utilities.h
Element::map
@ map
Definition data.h:160
Element::integer
@ integer
Definition data.h:153
Element::boolean
@ boolean
Definition data.h:155
Element::string
@ string
Definition data.h:157
Element::createMap
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:354
Element::createList
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition data.cc:349
isc::BadValue
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Definition exceptions/exceptions.h:132
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:53
isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
Definition io_address.h:285
isc::asiolink::IOAddress::IPV6_ZERO_ADDRESS
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
Definition io_address.h:297
isc::config::CmdsImpl::setErrorResponse
void setErrorResponse(hooks::CalloutHandle &handle, const std::string &text, int status=CONTROL_RESULT_ERROR)
Set the callout argument "response" to indicate an error.
Definition cmds_impl.h:54
isc::config::CmdsImpl::cmd_args_
data::ConstElementPtr cmd_args_
Stores the command arguments extracted by a call to extractCommand.
Definition cmds_impl.h:72
isc::config::CmdsImpl::extractCommand
void extractCommand(hooks::CalloutHandle &handle)
Extracts the command name and arguments from a Callout handle.
Definition cmds_impl.h:29
isc::config::CmdsImpl::setResponse
void setResponse(hooks::CalloutHandle &handle, data::ConstElementPtr &response)
Set the callout argument "response" to the given response.
Definition cmds_impl.h:64
isc::data::SimpleParser::checkKeywords
static void checkKeywords(const SimpleKeywords &keywords, isc::data::ConstElementPtr scope)
Checks acceptable keywords with their expected type.
Definition lib/cc/simple_parser.cc:35
isc::data::SimpleParser::checkRequired
static void checkRequired(const SimpleRequiredKeywords &required, isc::data::ConstElementPtr scope)
Checks that all required keywords are present.
Definition lib/cc/simple_parser.cc:24
isc::data::SimpleParser::getAddress
static isc::asiolink::IOAddress getAddress(const ConstElementPtr &scope, const std::string &name)
Returns a IOAddress parameter from a scope.
Definition lib/cc/simple_parser.cc:125
isc::data::SimpleParser::getString
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
Definition lib/cc/simple_parser.cc:60
isc::data::SimpleParser::getInteger
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
Definition lib/cc/simple_parser.cc:77
isc::dhcp::LeaseMgrFactory::instance
static TrackingLeaseMgr & instance()
Return current lease manager.
Definition lease_mgr_factory.cc:148
isc::dhcp::LeaseMgr::sflqPool4Del
virtual bool sflqPool4Del(asiolink::IOAddress start_address, asiolink::IOAddress end_address, bool force=false)
Delete the SFLQ V4 pool that matches a start and end address.
Definition lease_mgr.cc:2026
isc::dhcp::LeaseMgr::sflqPool6Del
virtual bool sflqPool6Del(asiolink::IOAddress start_address, asiolink::IOAddress end_address, bool force=false)
Delete the SFLQ V6 pool that matches a start and end address.
Definition lease_mgr.cc:2046
isc::dhcp::LeaseMgr::sflqPool4Get
virtual SflqPoolInfoCollectionPtr sflqPool4Get(SubnetID subnet_id)
Fetch all SFLQ V4 pools belonging to a subnet.
Definition lease_mgr.cc:2016
isc::dhcp::LeaseMgr::sflqPool4GetAll
virtual SflqPoolInfoCollectionPtr sflqPool4GetAll()
Fetch all SFLQ V4 pools.
Definition lease_mgr.cc:2011
isc::dhcp::LeaseMgr::sflqCreateFlqPool4
virtual bool sflqCreateFlqPool4(asiolink::IOAddress start_address, asiolink::IOAddress end_address, SubnetID subnet_id, bool recreate=false)
Creates a v4 SFLQ Pool.
Definition lease_mgr.cc:1991
isc::dhcp::LeaseMgr::sflqPool6GetAll
virtual SflqPoolInfoCollectionPtr sflqPool6GetAll()
Fetch all SFLQ V6 pools.
Definition lease_mgr.cc:2031
isc::dhcp::LeaseMgr::sflqPool6Get
virtual SflqPoolInfoCollectionPtr sflqPool6Get(SubnetID subnet_id)
Fetch all SFLQ V6 pools belonging to a subnet.
Definition lease_mgr.cc:2036
isc::dhcp::LeaseMgr::sflqCreateFlqPool6
virtual bool sflqCreateFlqPool6(asiolink::IOAddress start_address, asiolink::IOAddress end_address, Lease::Type lease_type, uint8_t delegated_len, SubnetID subnet_id, bool recreate=false)
Calls stored procedure to create an SFLQ pool for v6.
Definition lease_mgr.cc:2001
isc::hooks::CalloutHandle
Per-packet callout handle.
Definition callout_handle.h:78
isc::lease_cmds::SflqCmdsImpl
Implements the logic for processing commands pertaining to SFLQ pools and data.
Definition sflq_cmds.h:26
isc::lease_cmds::SflqCmdsImpl::sflqPool6DelHandler
int sflqPool6DelHandler(hooks::CalloutHandle &handle)
Delete the SFLQ V6 pool that matches a start and end address.
Definition sflq_cmds.cc:219
isc::lease_cmds::SflqCmdsImpl::extractBool
static bool extractBool(data::ConstElementPtr &params, const std::string &name, bool default_value=false)
Extracts a boolean from given parameters map.
Definition sflq_cmds.cc:453
isc::lease_cmds::SflqCmdsImpl::extractLeaseType
static dhcp::Lease::Type extractLeaseType(data::ConstElementPtr &params, uint16_t family)
Extracts 'lease-type' from given parameters map.
Definition sflq_cmds.cc:468
isc::lease_cmds::SflqCmdsImpl::buildGetResponse
static data::ConstElementPtr buildGetResponse(dhcp::SflqPoolInfoCollectionPtr pools)
Creates a success response from a list of SqlPoolInfos.
Definition sflq_cmds.cc:420
isc::lease_cmds::SflqCmdsImpl::sflqPool6RebuildHandler
int sflqPool6RebuildHandler(hooks::CalloutHandle &handle)
The 'sflq-pool6-rebuild' command handler.
Definition sflq_cmds.cc:131
isc::lease_cmds::SflqCmdsImpl::sflqPool6GetBySubnetHandler
int sflqPool6GetBySubnetHandler(hooks::CalloutHandle &handle)
The 'sflq-pool6-by-subnet' command handler.
Definition sflq_cmds.cc:209
isc::lease_cmds::SflqCmdsImpl::extractRange
static void extractRange(data::ConstElementPtr &params, uint8_t family, asiolink::IOAddress &start_address, asiolink::IOAddress &end_address)
Extracts an ip address range from given parameters map.
Definition sflq_cmds.cc:441
isc::lease_cmds::SflqCmdsImpl::sflqPool4GetByRangeHandler
int sflqPool4GetByRangeHandler(hooks::CalloutHandle &handle)
Handles a 'sflq-pool4-by-range' command.
Definition sflq_cmds.cc:121
isc::lease_cmds::SflqCmdsImpl::sflqPool4GetAllHandler
int sflqPool4GetAllHandler(hooks::CalloutHandle &handle)
The 'sflq-pool4-get-all' command handler.
Definition sflq_cmds.cc:111
isc::lease_cmds::SflqCmdsImpl::sflqPool4RebuildHandler
int sflqPool4RebuildHandler(hooks::CalloutHandle &handle)
The 'sflq-pool4-rebuild' command handler.
Definition sflq_cmds.cc:39
isc::lease_cmds::SflqCmdsImpl::sflqPool4GetBySubnetHandler
int sflqPool4GetBySubnetHandler(hooks::CalloutHandle &handle)
The 'sflq-pool4-by-subnet' command handler.
Definition sflq_cmds.cc:116
isc::lease_cmds::SflqCmdsImpl::sflqPool6GetByRangeHandler
int sflqPool6GetByRangeHandler(hooks::CalloutHandle &handle)
Handles a 'sflq-pool6-by-range' command.
Definition sflq_cmds.cc:214
isc::lease_cmds::SflqCmdsImpl::sflqPool6GetAllHandler
int sflqPool6GetAllHandler(hooks::CalloutHandle &handle)
The 'sflq-pool6-get-all' command handler.
Definition sflq_cmds.cc:204
isc::lease_cmds::SflqCmdsImpl::sflqPool4DelHandler
int sflqPool4DelHandler(hooks::CalloutHandle &handle)
Delete the SFLQ V4 pool that matches a start and end address.
Definition sflq_cmds.cc:126
isc::lease_cmds::SflqCmds::sflqPool4DelHandler
int sflqPool4DelHandler(hooks::CalloutHandle &handle)
Delete the SFLQ V4 pool that matches a start and end address.
Definition sflq_cmds.cc:513
isc::lease_cmds::SflqCmds::sflqPool4GetBySubnetHandler
int sflqPool4GetBySubnetHandler(hooks::CalloutHandle &handle)
The 'sflq-pool4-get-by-subnet' command handler.
Definition sflq_cmds.cc:503
isc::lease_cmds::SflqCmds::sflqPool6RebuildHandler
int sflqPool6RebuildHandler(hooks::CalloutHandle &handle)
The 'sflq-pool6-rebuild' command handler.
Definition sflq_cmds.cc:518
isc::lease_cmds::SflqCmds::sflqPool6GetAllHandler
int sflqPool6GetAllHandler(hooks::CalloutHandle &handle)
The 'sflq-pool6-get-all' command handler.
Definition sflq_cmds.cc:523
isc::lease_cmds::SflqCmds::sflqPool4GetByRangeHandler
int sflqPool4GetByRangeHandler(hooks::CalloutHandle &handle)
Handles a 'sflq-pool4-by-range' command.
Definition sflq_cmds.cc:508
isc::lease_cmds::SflqCmds::sflqPool4GetAllHandler
int sflqPool4GetAllHandler(hooks::CalloutHandle &handle)
The 'sflq-pool4-get-all' command handler.
Definition sflq_cmds.cc:498
isc::lease_cmds::SflqCmds::sflqPool6GetByRangeHandler
int sflqPool6GetByRangeHandler(hooks::CalloutHandle &handle)
Handles a 'sflq-pool6-by-range' command.
Definition sflq_cmds.cc:533
isc::lease_cmds::SflqCmds::sflqPool6DelHandler
int sflqPool6DelHandler(hooks::CalloutHandle &handle)
Delete the SFLQ V6 pool that matches a start and end address.
Definition sflq_cmds.cc:538
isc::lease_cmds::SflqCmds::sflqPool6GetBySubnetHandler
int sflqPool6GetBySubnetHandler(hooks::CalloutHandle &handle)
The 'sflq-pool6-get-by-subnet' command handler.
Definition sflq_cmds.cc:528
isc::lease_cmds::SflqCmds::SflqCmds
SflqCmds()
Constructor.
Definition sflq_cmds.cc:488
isc::lease_cmds::SflqCmds::sflqPool4RebuildHandler
int sflqPool4RebuildHandler(hooks::CalloutHandle &handle)
sflq-pool4-rebuild handler.
Definition sflq_cmds.cc:493
isc::util::MultiThreadingCriticalSection
RAII class creating a critical section.
Definition multi_threading_mgr.h:374
cmds_impl.h
data.h
db_exceptions.h
exceptions.h
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
hooks.h
io_address.h
lease_cmds_log.h
SFLQ_POOL6_GET_BY_RANGE_FAILED
const isc::log::MessageID SFLQ_POOL6_GET_BY_RANGE_FAILED
SFLQ_POOL4_REBUILD
const isc::log::MessageID SFLQ_POOL4_REBUILD
SFLQ_POOL4_GET_BY_SUBNET_FAILED
const isc::log::MessageID SFLQ_POOL4_GET_BY_SUBNET_FAILED
SFLQ_POOL4_GET_ALL
const isc::log::MessageID SFLQ_POOL4_GET_ALL
SFLQ_POOL4_DEL_FAILED
const isc::log::MessageID SFLQ_POOL4_DEL_FAILED
SFLQ_POOL6_GET_ALL
const isc::log::MessageID SFLQ_POOL6_GET_ALL
SFLQ_POOL6_GET_BY_RANGE
const isc::log::MessageID SFLQ_POOL6_GET_BY_RANGE
SFLQ_POOL4_GET_BY_RANGE_FAILED
const isc::log::MessageID SFLQ_POOL4_GET_BY_RANGE_FAILED
SFLQ_POOL6_DEL_FAILED
const isc::log::MessageID SFLQ_POOL6_DEL_FAILED
SFLQ_POOL6_DEL
const isc::log::MessageID SFLQ_POOL6_DEL
SFLQ_POOL4_GET_ALL_FAILED
const isc::log::MessageID SFLQ_POOL4_GET_ALL_FAILED
SFLQ_POOL4_REBUILD_FAILED
const isc::log::MessageID SFLQ_POOL4_REBUILD_FAILED
SFLQ_POOL6_GET_BY_SUBNET_FAILED
const isc::log::MessageID SFLQ_POOL6_GET_BY_SUBNET_FAILED
SFLQ_POOL4_GET_BY_RANGE
const isc::log::MessageID SFLQ_POOL4_GET_BY_RANGE
SFLQ_POOL4_GET_BY_SUBNET
const isc::log::MessageID SFLQ_POOL4_GET_BY_SUBNET
SFLQ_POOL6_REBUILD
const isc::log::MessageID SFLQ_POOL6_REBUILD
SFLQ_POOL6_GET_BY_SUBNET
const isc::log::MessageID SFLQ_POOL6_GET_BY_SUBNET
SFLQ_POOL4_DEL
const isc::log::MessageID SFLQ_POOL4_DEL
SFLQ_POOL6_REBUILD_FAILED
const isc::log::MessageID SFLQ_POOL6_REBUILD_FAILED
SFLQ_POOL6_GET_ALL_FAILED
const isc::log::MessageID SFLQ_POOL6_GET_ALL_FAILED
lease_mgr.h
An abstract API for lease database.
lease_mgr_factory.h
simple_parser.h
LOG_ERROR
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition macros.h:32
LOG_DEBUG
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
Definition macros.h:14
multi_threading_mgr.h
isc::asiolink
Definition addr_utilities.cc:170
isc::asiolink::validateV4Range
void validateV4Range(const IOAddress &start_address, const IOAddress &end_address)
Ensures address pair are both v4 and start <= end.
Definition addr_utilities.cc:414
isc::asiolink::validateV6Range
void validateV6Range(const IOAddress &start_address, const IOAddress &end_address)
Ensures address pair are both v6 and start <= end.
Definition addr_utilities.cc:422
isc::config
Definition command_interpreter.cc:23
isc::config::CONTROL_RESULT_EMPTY
const int CONTROL_RESULT_EMPTY
Status code indicating that the specified command was completed correctly, but failed to produce any ...
Definition command_interpreter.h:53
isc::config::createAnswer
ConstElementPtr createAnswer()
Creates a standard config/command level success answer message (i.e.
Definition command_interpreter.cc:54
isc::config::CONTROL_RESULT_SUCCESS
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
Definition command_interpreter.h:42
isc::data
Definition base_stamped_element.cc:12
isc::data::SimpleRequiredKeywords
std::vector< std::string > SimpleRequiredKeywords
This specifies all required keywords.
Definition lib/cc/simple_parser.h:33
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
isc::data::SimpleKeywords
std::map< std::string, isc::data::Element::types > SimpleKeywords
This specifies all accepted keywords with their types.
Definition lib/cc/simple_parser.h:36
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::SflqPoolInfoCollectionPtr
boost::shared_ptr< SflqPoolInfoCollection > SflqPoolInfoCollectionPtr
Definition lease_mgr.h:262
isc::hooks
Definition callout_handle.cc:21
isc::lease_cmds
Definition binding_variables.cc:21
isc::lease_cmds::LEASE_CMDS_DBG_COMMAND_DATA
const int LEASE_CMDS_DBG_COMMAND_DATA
Logging level used to log successful commands.
Definition lease_cmds_log.h:18
isc::lease_cmds::lease_cmds_logger
isc::log::Logger lease_cmds_logger("lease-cmds-hooks")
Definition lease_cmds_log.h:20
isc::log
Definition buffer_appender_impl.cc:17
isc::util
Definition time_utils.cc:43
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
sflq_cmds.h
isc::dhcp::Lease::Type
Type
Type of lease or pool.
Definition lease.h:46
isc::dhcp::Lease::TYPE_PD
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
Definition lease.h:49
isc::dhcp::Lease::TYPE_V4
@ TYPE_V4
IPv4 lease.
Definition lease.h:50
isc::dhcp::Lease::TYPE_NA
@ TYPE_NA
the lease contains non-temporary IPv6 address
Definition lease.h:47
subnet_id.h