Kea 2.7.5
lease_mgr.cc
Go to the documentation of this file.
1// Copyright (C) 2012-2024 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
9#include <dhcp/libdhcp++.h>
10#include <dhcp/option_custom.h>
11#include <dhcpsrv/cfgmgr.h>
12#include <dhcpsrv/dhcpsrv_log.h>
13#include <dhcpsrv/lease_mgr.h>
15#include <stats/stats_mgr.h>
16#include <util/encode/encode.h>
17#include <util/str.h>
18
19#include <boost/algorithm/string.hpp>
20
21#include <algorithm>
22#include <iostream>
23#include <iterator>
24#include <limits>
25#include <map>
26#include <sstream>
27#include <string>
28
29#include <time.h>
30
31using namespace isc::asiolink;
32using namespace isc::data;
33using namespace isc::db;
34using namespace isc::dhcp;
35using namespace isc::util;
36using namespace std;
37
38namespace isc {
39namespace dhcp {
40
41LeasePageSize::LeasePageSize(const size_t page_size)
42 : page_size_(page_size) {
43
44 if (page_size_ == 0) {
45 isc_throw(OutOfRange, "page size of retrieved leases must not be 0");
46 }
47
48 if (page_size_ > std::numeric_limits<uint32_t>::max()) {
49 isc_throw(OutOfRange, "page size of retrieved leases must not be greater than "
50 << std::numeric_limits<uint32_t>::max());
51 }
52}
53
56 uint32_t iaid, SubnetID subnet_id) const {
57 Lease6Collection col = getLeases6(type, duid, iaid, subnet_id);
58
59 if (col.size() > 1) {
60 isc_throw(MultipleRecords, "More than one lease found for type "
61 << static_cast<int>(type) << ", duid "
62 << duid.toText() << ", iaid " << iaid
63 << " and subnet-id " << subnet_id);
64 }
65 if (col.empty()) {
66 return (Lease6Ptr());
67 }
68 return (*col.begin());
69}
70
71void
73 using namespace stats;
74
75 StatsMgr& stats_mgr = StatsMgr::instance();
76
78 if (!query) {
80 return;
81 }
82
83 // Zero out the global stats.
84 // Cumulative counters ("reclaimed-declined-addresses", "reclaimed-leases",
85 // "cumulative-assigned-addresses") never get zeroed.
86 int64_t zero = 0;
87 stats_mgr.setValue("declined-addresses", zero);
88
89 // Create if it does not exit reclaimed declined leases global stats.
90 if (!stats_mgr.getObservation("reclaimed-declined-addresses")) {
91 stats_mgr.setValue("reclaimed-declined-addresses", zero);
92 }
93
94 // Create if it does not exit reclaimed leases global stats.
95 if (!stats_mgr.getObservation("reclaimed-leases")) {
96 stats_mgr.setValue("reclaimed-leases", zero);
97 }
98
99 // Create if it does not exit cumulative global stats.
100 if (!stats_mgr.getObservation("cumulative-assigned-addresses")) {
101 stats_mgr.setValue("cumulative-assigned-addresses", zero);
102 }
103
104 // Clear subnet level stats. This ensures we don't end up with corner
105 // cases that leave stale values in place.
106 const Subnet4Collection* subnets =
107 CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
108
109 for (auto const& subnet : *subnets) {
110 SubnetID subnet_id = subnet->getID();
111 stats_mgr.setValue(StatsMgr::generateName("subnet", subnet_id,
112 "assigned-addresses"),
113 zero);
114
115 stats_mgr.setValue(StatsMgr::generateName("subnet", subnet_id,
116 "declined-addresses"),
117 zero);
118
119 const std::string name_rec_dec(StatsMgr::generateName("subnet", subnet_id,
120 "reclaimed-declined-addresses"));
121 if (!stats_mgr.getObservation(name_rec_dec)) {
122 stats_mgr.setValue(name_rec_dec, zero);
123 }
124
125 const std::string name_rec(StatsMgr::generateName("subnet", subnet_id,
126 "reclaimed-leases"));
127 if (!stats_mgr.getObservation(name_rec)) {
128 stats_mgr.setValue(name_rec, zero);
129 }
130
131 for (auto const& pool : subnet->getPools(Lease::TYPE_V4)) {
132 const std::string name_aa(StatsMgr::generateName("subnet", subnet_id,
133 StatsMgr::generateName("pool", pool->getID(),
134 "assigned-addresses")));
135 if (!stats_mgr.getObservation(name_aa)) {
136 stats_mgr.setValue(name_aa, zero);
137 }
138
139 const std::string& name_da(StatsMgr::generateName("subnet", subnet_id,
140 StatsMgr::generateName("pool", pool->getID(),
141 "declined-addresses")));
142 if (!stats_mgr.getObservation(name_da)) {
143 stats_mgr.setValue(name_da, zero);
144 }
145
146 const std::string& pname_rec_dec(StatsMgr::generateName("subnet", subnet_id,
147 StatsMgr::generateName("pool", pool->getID(),
148 "reclaimed-declined-addresses")));
149 if (!stats_mgr.getObservation(pname_rec_dec)) {
150 stats_mgr.setValue(pname_rec_dec, zero);
151 }
152
153 const std::string& pname_rec(StatsMgr::generateName("subnet", subnet_id,
154 StatsMgr::generateName("pool", pool->getID(),
155 "reclaimed-leases")));
156 if (!stats_mgr.getObservation(pname_rec)) {
157 stats_mgr.setValue(pname_rec, zero);
158 }
159 }
160 }
161
162 // Get counts per state per subnet. Iterate over the result set
163 // updating the subnet and global values.
164 LeaseStatsRow row;
165 while (query->getNextRow(row)) {
166 if (row.lease_state_ == Lease::STATE_DEFAULT) {
167 // Add to subnet level value.
168 stats_mgr.addValue(StatsMgr::generateName("subnet", row.subnet_id_,
169 "assigned-addresses"),
170 row.state_count_);
171 } else if (row.lease_state_ == Lease::STATE_DECLINED) {
172 // Set subnet level value.
173 stats_mgr.setValue(StatsMgr::generateName("subnet", row.subnet_id_,
174 "declined-addresses"),
175 row.state_count_);
176
177 // Add to the global value.
178 stats_mgr.addValue("declined-addresses", row.state_count_);
179
180 // Add to subnet level value.
181 // Declined leases also count as assigned.
182 stats_mgr.addValue(StatsMgr::generateName("subnet", row.subnet_id_,
183 "assigned-addresses"),
184 row.state_count_);
185 }
186 }
187
189 if (!query) {
191 return;
192 }
193
194 // Get counts per state per subnet and pool. Iterate over the result set
195 // updating the subnet and pool and global values.
196 while (query->getNextRow(row)) {
197 if (row.lease_state_ == Lease::STATE_DEFAULT) {
198 // Add to subnet and pool level value.
199 stats_mgr.addValue(StatsMgr::generateName("subnet", row.subnet_id_,
200 StatsMgr::generateName("pool", row.pool_id_,
201 "assigned-addresses")),
202 row.state_count_);
203 } else if (row.lease_state_ == Lease::STATE_DECLINED) {
204 // Set subnet and pool level value.
205 stats_mgr.setValue(StatsMgr::generateName("subnet", row.subnet_id_,
206 StatsMgr::generateName("pool", row.pool_id_,
207 "declined-addresses")),
208 row.state_count_);
209
210 // Add to subnet and pool level value.
211 // Declined leases also count as assigned.
212 stats_mgr.addValue(StatsMgr::generateName("subnet", row.subnet_id_,
213 StatsMgr::generateName("pool", row.pool_id_,
214 "assigned-addresses")),
215 row.state_count_);
216 }
217 }
218}
219
221 : first_subnet_id_(0), last_subnet_id_(0), select_mode_(select_mode) {
222 if (select_mode != ALL_SUBNETS && select_mode != ALL_SUBNET_POOLS) {
223 isc_throw(BadValue, "LeaseStatsQuery: mode must be either ALL_SUBNETS or ALL_SUBNET_POOLS");
224 }
225}
226
228 : first_subnet_id_(subnet_id), last_subnet_id_(0),
229 select_mode_(SINGLE_SUBNET) {
230
231 if (first_subnet_id_ == 0) {
232 isc_throw(BadValue, "LeaseStatsQuery: subnet_id_ must be > 0");
233 }
234}
235
237 const SubnetID& last_subnet_id)
238 : first_subnet_id_(first_subnet_id), last_subnet_id_(last_subnet_id),
239 select_mode_(SUBNET_RANGE) {
240
241 if (first_subnet_id_ == 0) {
242 isc_throw(BadValue, "LeaseStatsQuery: first_subnet_id_ must be > 0");
243 }
244
245 if (last_subnet_id_ == 0) {
246 isc_throw(BadValue, "LeaseStatsQuery: last_subnet_id_ must be > 0");
247 }
248
251 "LeaseStatsQuery: last_subnet_id_must be > first_subnet_id_");
252 }
253}
254
259
264
267 return(LeaseStatsQueryPtr());
268}
269
272 const SubnetID& /* last_subnet_id */) {
273 return(LeaseStatsQueryPtr());
274}
275
276bool
278 return (false);
279}
280
281void
283 using namespace stats;
284
285 StatsMgr& stats_mgr = StatsMgr::instance();
286
288 if (!query) {
290 return;
291 }
292
293 // Zero out the global stats.
294 // Cumulative counters ("reclaimed-declined-addresses", "reclaimed-leases",
295 // "cumulative-assigned-nas", "cumulative-assigned-pds") never get zeroed.
296 int64_t zero = 0;
297 stats_mgr.setValue("declined-addresses", zero);
298
299 if (!stats_mgr.getObservation("reclaimed-declined-addresses")) {
300 stats_mgr.setValue("reclaimed-declined-addresses", zero);
301 }
302
303 if (!stats_mgr.getObservation("reclaimed-leases")) {
304 stats_mgr.setValue("reclaimed-leases", zero);
305 }
306
307 // Create if it does not exit cumulative nas global stats.
308 if (!stats_mgr.getObservation("cumulative-assigned-nas")) {
309 stats_mgr.setValue("cumulative-assigned-nas", zero);
310 }
311
312 // Create if it does not exit cumulative pds global stats.
313 if (!stats_mgr.getObservation("cumulative-assigned-pds")) {
314 stats_mgr.setValue("cumulative-assigned-pds", zero);
315 }
316
317 // Clear subnet level stats. This ensures we don't end up with corner
318 // cases that leave stale values in place.
319 const Subnet6Collection* subnets =
320 CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
321
322 for (auto const& subnet : *subnets) {
323 SubnetID subnet_id = subnet->getID();
324 stats_mgr.setValue(StatsMgr::generateName("subnet", subnet_id,
325 "assigned-nas"),
326 zero);
327
328 stats_mgr.setValue(StatsMgr::generateName("subnet", subnet_id,
329 "assigned-pds"),
330 zero);
331
332 stats_mgr.setValue(StatsMgr::generateName("subnet", subnet_id,
333 "declined-addresses"),
334 zero);
335
336 if (!stats_mgr.getObservation(
337 StatsMgr::generateName("subnet", subnet_id,
338 "reclaimed-declined-addresses"))) {
339 stats_mgr.setValue(
340 StatsMgr::generateName("subnet", subnet_id,
341 "reclaimed-declined-addresses"),
342 zero);
343 }
344
345 if (!stats_mgr.getObservation(
346 StatsMgr::generateName("subnet", subnet_id,
347 "reclaimed-leases"))) {
348 stats_mgr.setValue(
349 StatsMgr::generateName("subnet", subnet_id,
350 "reclaimed-leases"),
351 zero);
352 }
353
354 for (auto const& pool : subnet->getPools(Lease::TYPE_NA)) {
355 const std::string& name_anas(StatsMgr::generateName("subnet", subnet_id,
356 StatsMgr::generateName("pool", pool->getID(),
357 "assigned-nas")));
358 if (!stats_mgr.getObservation(name_anas)) {
359 stats_mgr.setValue(name_anas, zero);
360 }
361
362 const std::string& name_da(StatsMgr::generateName("subnet", subnet_id,
363 StatsMgr::generateName("pool", pool->getID(),
364 "declined-addresses")));
365 if (!stats_mgr.getObservation(name_da)) {
366 stats_mgr.setValue(name_da, zero);
367 }
368
369 const std::string name_rec_dec(StatsMgr::generateName("subnet", subnet_id,
370 StatsMgr::generateName("pool", pool->getID(),
371 "reclaimed-declined-addresses")));
372 if (!stats_mgr.getObservation(name_rec_dec)) {
373 stats_mgr.setValue(name_rec_dec, zero);
374 }
375
376 const std::string& name_rec(StatsMgr::generateName("subnet", subnet_id,
377 StatsMgr::generateName("pool", pool->getID(),
378 "reclaimed-leases")));
379 if (!stats_mgr.getObservation(name_rec)) {
380 stats_mgr.setValue(name_rec, zero);
381 }
382 }
383
384 for (auto const& pool : subnet->getPools(Lease::TYPE_PD)) {
385 const std::string& name_apds(StatsMgr::generateName("subnet", subnet_id,
386 StatsMgr::generateName("pd-pool", pool->getID(),
387 "assigned-pds")));
388 if (!stats_mgr.getObservation(name_apds)) {
389 stats_mgr.setValue(name_apds, zero);
390 }
391
392 const std::string& name_rec(StatsMgr::generateName("subnet", subnet_id,
393 StatsMgr::generateName("pd-pool", pool->getID(),
394 "reclaimed-leases")));
395 if (!stats_mgr.getObservation(name_rec)) {
396 stats_mgr.setValue(name_rec, zero);
397 }
398 }
399 }
400
401 // Get counts per state per subnet. Iterate over the result set
402 // updating the subnet and global values.
403 LeaseStatsRow row;
404 while (query->getNextRow(row)) {
405 switch(row.lease_type_) {
406 case Lease::TYPE_NA:
407 if (row.lease_state_ == Lease::STATE_DEFAULT) {
408 // Add to subnet level value.
409 stats_mgr.addValue(StatsMgr::generateName("subnet", row.subnet_id_,
410 "assigned-nas"),
411 row.state_count_);
412 } else if (row.lease_state_ == Lease::STATE_DECLINED) {
413 // Set subnet level value.
414 stats_mgr.setValue(StatsMgr::generateName("subnet", row.subnet_id_,
415 "declined-addresses"),
416 row.state_count_);
417
418 // Add to the global value.
419 stats_mgr.addValue("declined-addresses", row.state_count_);
420
421 // Add to subnet level value.
422 // Declined leases also count as assigned.
423 stats_mgr.addValue(StatsMgr::generateName("subnet", row.subnet_id_,
424 "assigned-nas"),
425 row.state_count_);
426 }
427 break;
428
429 case Lease::TYPE_PD:
430 if (row.lease_state_ == Lease::STATE_DEFAULT) {
431 // Set subnet level value.
432 stats_mgr.setValue(StatsMgr::generateName("subnet", row.subnet_id_,
433 "assigned-pds"),
434 row.state_count_);
435 }
436 break;
437
438 default:
439 // We don't support TYPE_TAs yet
440 break;
441 }
442 }
443
445 if (!query) {
447 return;
448 }
449
450 // Get counts per state per subnet and pool. Iterate over the result set
451 // updating the subnet and pool and global values.
452 while (query->getNextRow(row)) {
453 switch(row.lease_type_) {
454 case Lease::TYPE_NA:
455 if (row.lease_state_ == Lease::STATE_DEFAULT) {
456 // Add to subnet and pool level value.
457 stats_mgr.addValue(StatsMgr::generateName("subnet", row.subnet_id_,
458 StatsMgr::generateName("pool", row.pool_id_,
459 "assigned-nas")),
460 row.state_count_);
461 } else if (row.lease_state_ == Lease::STATE_DECLINED) {
462 // Set subnet and pool level value.
463 stats_mgr.setValue(StatsMgr::generateName("subnet", row.subnet_id_,
464 StatsMgr::generateName("pool", row.pool_id_,
465 "declined-addresses")),
466 row.state_count_);
467
468 // Add to subnet and pool level value.
469 // Declined leases also count as assigned.
470 stats_mgr.addValue(StatsMgr::generateName("subnet", row.subnet_id_,
471 StatsMgr::generateName("pool", row.pool_id_,
472 "assigned-nas")),
473 row.state_count_);
474 }
475 break;
476
477 case Lease::TYPE_PD:
478 if (row.lease_state_ == Lease::STATE_DEFAULT) {
479 // Set subnet and pool level value.
480 stats_mgr.setValue(StatsMgr::generateName("subnet", row.subnet_id_,
481 StatsMgr::generateName("pd-pool", row.pool_id_,
482 "assigned-pds")),
483 row.state_count_);
484 }
485 break;
486
487 default:
488 // We don't support TYPE_TAs yet
489 break;
490 }
491 }
492}
493
498
503
506 return(LeaseStatsQueryPtr());
507}
508
511 const SubnetID& /* last_subnet_id */) {
512 return(LeaseStatsQueryPtr());
513}
514
515std::string
517 isc_throw(NotImplemented, "LeaseMgr::getDBVersion() called");
518}
519
520void
522 std::string extended_info_tables;
523 try {
524 extended_info_tables = parameters.at("extended-info-tables");
525 } catch (const exception&) {
526 extended_info_tables = "false";
527 }
528 // If extended_info_tables is 'true' we will enable them.
529 if (extended_info_tables == "true") {
531 }
532}
533
534bool
538
539 bool changed = false;
540 if (!lease) {
541 return (changed);
542 }
543
545 return (changed);
546 }
547
548 ConstElementPtr user_context = lease->getContext();
549 if (!user_context) {
550 return (changed);
551 }
552
554 ConstElementPtr extended_info;
555 ElementPtr mutable_user_context;
556 ElementPtr mutable_isc;
557 string verifying = "";
558 bool removed_extended_info = false;
559
560 try {
561 verifying = "user context";
562 if (user_context->getType() != Element::map) {
563 isc_throw(BadValue, "user context is not a map");
564 }
565 if (user_context->empty()) {
566 changed = true;
567 lease->setContext(ConstElementPtr());
568 return (changed);
569 }
570
571 verifying = "isc";
572 isc = user_context->get("ISC");
573 if (!isc) {
574 return (changed);
575 }
576 mutable_user_context =
577 boost::const_pointer_cast<Element>(user_context);
578 if (!mutable_user_context) {
579 // Should not happen...
580 mutable_user_context = copy(user_context, 0);
581 lease->setContext(mutable_user_context);
582 }
583
584 if (isc->getType() != Element::map) {
585 isc_throw(BadValue, "ISC entry is not a map");
586 }
587 if (isc->empty()) {
588 changed = true;
589 mutable_user_context->remove("ISC");
590 if (mutable_user_context->empty()) {
591 lease->setContext(ConstElementPtr());
592 }
593 return (changed);
594 }
595
596 verifying = "relay-agent-info";
597 extended_info = isc->get("relay-agent-info");
598 if (!extended_info) {
599 return (changed);
600 }
601 mutable_isc = boost::const_pointer_cast<Element>(isc);
602 if (!mutable_isc) {
603 // Should not happen...
604 mutable_isc = copy(isc, 0);
605 mutable_user_context->set("ISC", mutable_isc);
606 }
607
608 if (extended_info->getType() == Element::string) {
609 // Upgrade
610 changed = true;
611 ElementPtr upgraded = Element::createMap();
612 upgraded->set("sub-options", extended_info);
613 mutable_isc->set("relay-agent-info", upgraded);
614
615 // Try to decode sub-options.
616 verifying = "rai";
617 string rai_hex = extended_info->stringValue();
618 vector<uint8_t> rai_data;
619 str::decodeFormattedHexString(rai_hex, rai_data);
620 OptionCustomPtr rai(new OptionCustom(rai_def, Option::V4, rai_data));
621 if (!rai) {
622 isc_throw(BadValue, "can't create RAI option");
623 }
624
625 OptionPtr remote_id = rai->getOption(RAI_OPTION_REMOTE_ID);
626 if (remote_id) {
627 vector<uint8_t> bytes = remote_id->toBinary();
628 if (bytes.size() > 0) {
629 upgraded->set("remote-id",
631 }
632 }
633
634 OptionPtr relay_id = rai->getOption(RAI_OPTION_RELAY_ID);
635 if (relay_id) {
636 vector<uint8_t> bytes = relay_id->toBinary(false);
637 if (bytes.size() > 0) {
638 upgraded->set("relay-id",
640 }
641 }
642
645 .arg(lease->addr_.toText());
646 return (changed);
647 } else if (extended_info->getType() != Element::map) {
648 mutable_isc->remove("relay-agent-info");
649 removed_extended_info = true;
650 isc_throw(BadValue, "relay-agent-info is not a map or a string");
651 }
652
654 return (changed);
655 }
656
657 // Try to decode sub-options.
658 ConstElementPtr sub_options = extended_info->get("sub-options");
659 if (sub_options) {
660 verifying = "sub-options";
661 if (sub_options->getType() != Element::string) {
662 mutable_isc->remove("relay-agent-info");
663 removed_extended_info = true;
664 isc_throw(BadValue, "sub-options is not a string");
665 }
666 string rai_hex = sub_options->stringValue();
667 vector<uint8_t> rai_data;
668 str::decodeFormattedHexString(rai_hex, rai_data);
669 }
670
671 ConstElementPtr remote_id = extended_info->get("remote-id");
672 if (remote_id) {
673 verifying = "remote-id";
674 if (remote_id->getType() != Element::string) {
675 mutable_isc->remove("relay-agent-info");
676 removed_extended_info = true;
677 isc_throw(BadValue, "remote-id is not a string");
678 }
679 string remote_id_hex = remote_id->stringValue();
680 vector<uint8_t> remote_id_data;
681 encode::decodeHex(remote_id_hex, remote_id_data);
682 if (remote_id_data.empty()) {
683 mutable_isc->remove("relay-agent-info");
684 removed_extended_info = true;
685 isc_throw(BadValue, "remote-id is empty");
686 }
687 }
688
689 ConstElementPtr relay_id = extended_info->get("relay-id");
690 if (relay_id) {
691 verifying = "relay-id";
692 if (relay_id->getType() != Element::string) {
693 mutable_isc->remove("relay-agent-info");
694 removed_extended_info = true;
695 isc_throw(BadValue, "relay-id is not a string");
696 }
697 string relay_id_hex = relay_id->stringValue();
698 vector<uint8_t> relay_id_data;
699 encode::decodeHex(relay_id_hex, relay_id_data);
700 if (relay_id_data.empty()) {
701 mutable_isc->remove("relay-agent-info");
702 removed_extended_info = true;
703 isc_throw(BadValue, "relay-id is empty");
704 }
705 }
706
708 return (changed);
709 }
710
711 verifying = "relay-agent-info";
712 for (auto const& elem : extended_info->mapValue()) {
713 if ((elem.first != "sub-options") &&
714 (elem.first != "remote-id") &&
715 (elem.first != "relay-id") &&
716 (elem.first != "comment")) {
717 mutable_isc->remove("relay-agent-info");
718 removed_extended_info = true;
719 isc_throw(BadValue, "spurious '" << elem.first <<
720 "' entry in relay-agent-info");
721 }
722 }
723
724 return (changed);
725 } catch (const exception& ex) {
726 ostringstream err;
727 err << "in " << verifying << " a problem was found: " << ex.what();
729 .arg(lease->addr_.toText())
730 .arg(err.str());
731
732 changed = true;
733 if (verifying == "user context") {
734 lease->setContext(ConstElementPtr());
735 } else if (verifying == "isc") {
736 mutable_user_context->remove("ISC");
737 if (mutable_user_context->empty()) {
738 lease->setContext(ConstElementPtr());
739 }
740 } else {
741 if (!removed_extended_info) {
742 mutable_isc->remove("relay-agent-info");
743 }
744 if (mutable_isc->empty()) {
745 mutable_user_context->remove("ISC");
746 if (mutable_user_context->empty()) {
747 lease->setContext(ConstElementPtr());
748 }
749 }
750 }
751 return (changed);
752 }
753}
754
755bool
758 bool changed = false;
759 if (!lease) {
760 return (changed);
761 }
762
764 return (changed);
765 }
766
767 ConstElementPtr user_context = lease->getContext();
768 if (!user_context) {
769 return (changed);
770 }
771
773 ConstElementPtr relay_info;
774 ElementPtr mutable_user_context;
775 ElementPtr mutable_isc;
776 string verifying = "";
777 bool removed_relay_info = false;
778 bool upgraded = false;
779 bool have_both = false;
780 int i = -1;
781
782 try {
783 verifying = "user context";
784 if (user_context->getType() != Element::map) {
785 isc_throw(BadValue, "user context is not a map");
786 }
787 if (user_context->empty()) {
788 changed = true;
789 lease->setContext(ConstElementPtr());
790 return (changed);
791 }
792
793 verifying = "isc";
794 isc = user_context->get("ISC");
795 if (!isc) {
796 return (changed);
797 }
798 mutable_user_context =
799 boost::const_pointer_cast<Element>(user_context);
800 if (!mutable_user_context) {
801 // Should not happen...
802 mutable_user_context = copy(user_context, 0);
803 lease->setContext(mutable_user_context);
804 }
805
806 if (isc->getType() != Element::map) {
807 isc_throw(BadValue, "ISC entry is not a map");
808 }
809 if (isc->empty()) {
810 changed = true;
811 mutable_user_context->remove("ISC");
812 if (mutable_user_context->empty()) {
813 lease->setContext(ConstElementPtr());
814 }
815 return (changed);
816 }
817 mutable_isc = boost::const_pointer_cast<Element>(isc);
818 if (!mutable_isc) {
819 // Should not happen...
820 mutable_isc = copy(isc, 0);
821 mutable_user_context->set("ISC", mutable_isc);
822 }
823
824 relay_info = mutable_isc->get("relays");
825 if (relay_info && isc->contains("relay-info")) {
826 changed = true;
827 mutable_isc->remove("relays");
828 have_both = true;
829 relay_info.reset();
830 }
831 if (relay_info) {
832 // Upgrade
833 changed = true;
834 upgraded = true;
835 verifying = "relays";
836 mutable_isc->set("relay-info", relay_info);
837 mutable_isc->remove("relays");
838
839 if (relay_info->getType() != Element::list) {
840 mutable_isc->remove("relay-info");
841 removed_relay_info = true;
842 isc_throw(BadValue, "relays is not a list");
843 }
844 if (relay_info->empty()) {
845 mutable_isc->remove("relay-info");
846 removed_relay_info = true;
847 isc_throw(BadValue, "relays is empty");
848 }
849
850 verifying = "relay";
851 for (i = 0; i < relay_info->size(); ++i) {
852 ElementPtr relay = relay_info->getNonConst(i);
853 if (!relay) {
854 mutable_isc->remove("relay-info");
855 removed_relay_info = true;
856 isc_throw(BadValue, "null relay#" << i);
857 }
858 if (relay->getType() != Element::map) {
859 mutable_isc->remove("relay-info");
860 removed_relay_info = true;
861 isc_throw(BadValue, "relay#" << i << " is not a map");
862 }
863
864 // Try to decode options.
865 ConstElementPtr options = relay->get("options");
866 if (!options) {
867 continue;
868 }
869
870 verifying = "options";
871 if (options->getType() != Element::string) {
872 mutable_isc->remove("relay-info");
873 removed_relay_info = true;
874 isc_throw(BadValue, "options is not a string");
875 }
876 string options_hex = options->stringValue();
877 vector<uint8_t> options_data;
878 str::decodeFormattedHexString(options_hex, options_data);
879 OptionCollection opts;
880 LibDHCP::unpackOptions6(options_data, DHCP6_OPTION_SPACE, opts);
881
882 auto remote_id_it = opts.find(D6O_REMOTE_ID);
883 if (remote_id_it != opts.end()) {
884 OptionPtr remote_id = remote_id_it->second;
885 if (remote_id) {
886 vector<uint8_t> bytes = remote_id->toBinary();
887 if (bytes.size() > 0) {
888 relay->set("remote-id",
890 }
891 }
892 }
893
894 auto relay_id_it = opts.find(D6O_RELAY_ID);
895 if (relay_id_it != opts.end()) {
896 OptionPtr relay_id = relay_id_it->second;
897 if (relay_id) {
898 vector<uint8_t> bytes = relay_id->toBinary(false);
899 if (bytes.size() > 0) {
900 relay->set("relay-id",
902 }
903 }
904 }
905 }
906 }
907
908 verifying = (upgraded ? "relays" : "relay-info");
909 i = -1;
910 relay_info = mutable_isc->get("relay-info");
911 if (!relay_info) {
912 return (changed);
913 }
914 if (!upgraded && (relay_info->getType() != Element::list)) {
915 mutable_isc->remove("relay-info");
916 removed_relay_info = true;
917 isc_throw(BadValue, "relay-info is not a list");
918 }
919 if (!upgraded && relay_info->empty()) {
920 mutable_isc->remove("relay-info");
921 removed_relay_info = true;
922 isc_throw(BadValue, "relay-info is empty");
923 }
924
925 verifying = "relay";
926 for (i = 0; i < relay_info->size(); ++i) {
927 ElementPtr relay = relay_info->getNonConst(i);
928 if (!upgraded && !relay) {
929 mutable_isc->remove("relay-info");
930 removed_relay_info = true;
931 isc_throw(BadValue, "null relay#" << i);
932 }
933 if (!upgraded && (relay->getType() != Element::map)) {
934 mutable_isc->remove("relay-info");
935 removed_relay_info = true;
936 isc_throw(BadValue, "relay#" << i << " is not a map");
937 }
938
939 ConstElementPtr options = relay->get("options");
940 if (!upgraded && options) {
941 // Try to decode options.
942 verifying = "options";
943 if (options->getType() != Element::string) {
944 mutable_isc->remove("relay-info");
945 removed_relay_info = true;
946 isc_throw(BadValue, "options is not a string");
947 }
948 string options_hex = options->stringValue();
949 vector<uint8_t> options_data;
950 str::decodeFormattedHexString(options_hex, options_data);
951 OptionCollection opts;
952 LibDHCP::unpackOptions6(options_data, DHCP6_OPTION_SPACE, opts);
953 }
955 continue;
956 }
957
958 verifying = "link";
959 ConstElementPtr link_addr = relay->get("link");
960 if (!link_addr) {
961 mutable_isc->remove("relay-info");
962 removed_relay_info = true;
963 isc_throw(BadValue, "no link");
964 }
965 if (link_addr->getType() != Element::string) {
966 mutable_isc->remove("relay-info");
967 removed_relay_info = true;
968 isc_throw(BadValue, "link is not a string");
969 }
970 IOAddress laddr(link_addr->stringValue());
971 if (!laddr.isV6()) {
972 mutable_isc->remove("relay-info");
973 removed_relay_info = true;
974 isc_throw(BadValue, "link is not an IPv6 address");
975 }
976
977 ConstElementPtr remote_id = relay->get("remote-id");
978 if (!upgraded && remote_id) {
979 verifying = "remote-id";
980 if (remote_id->getType() != Element::string) {
981 mutable_isc->remove("relay-info");
982 removed_relay_info = true;
983 isc_throw(BadValue, "remote-id is not a string");
984 }
985 string remote_id_hex = remote_id->stringValue();
986 vector<uint8_t> remote_id_data;
987 encode::decodeHex(remote_id_hex, remote_id_data);
988 if (remote_id_data.empty()) {
989 mutable_isc->remove("relay-info");
990 removed_relay_info = true;
991 isc_throw(BadValue, "remote-id is empty");
992 }
993 }
994
995 ConstElementPtr relay_id = relay->get("relay-id");
996 if (!upgraded && relay_id) {
997 verifying = "relay-id";
998 if (relay_id->getType() != Element::string) {
999 mutable_isc->remove("relay-info");
1000 removed_relay_info = true;
1001 isc_throw(BadValue, "relay-id is not a string");
1002 }
1003 string relay_id_hex = relay_id->stringValue();
1004 vector<uint8_t> relay_id_data;
1005 encode::decodeHex(relay_id_hex, relay_id_data);
1006 if (relay_id_data.empty()) {
1007 mutable_isc->remove("relay-info");
1008 removed_relay_info = true;
1009 isc_throw(BadValue, "relay-id is empty");
1010 }
1011 }
1012
1014 continue;
1015 }
1016
1017 verifying = "peer";
1018 ConstElementPtr peer_addr = relay->get("peer");
1019 if (!peer_addr) {
1020 mutable_isc->remove("relay-info");
1021 removed_relay_info = true;
1022 isc_throw(BadValue, "no peer");
1023 }
1024 if (peer_addr->getType() != Element::string) {
1025 mutable_isc->remove("relay-info");
1026 removed_relay_info = true;
1027 isc_throw(BadValue, "peer is not a string");
1028 }
1029 IOAddress paddr(peer_addr->stringValue());
1030 if (!paddr.isV6()) {
1031 mutable_isc->remove("relay-info");
1032 removed_relay_info = true;
1033 isc_throw(BadValue, "peer is not an IPv6 address");
1034 }
1035
1036 verifying = "hop";
1037 ConstElementPtr hop = relay->get("hop");
1038 if (!hop) {
1039 mutable_isc->remove("relay-info");
1040 removed_relay_info = true;
1041 isc_throw(BadValue, "no hop");
1042 }
1043 if (hop->getType() != Element::integer) {
1044 mutable_isc->remove("relay-info");
1045 removed_relay_info = true;
1046 isc_throw(BadValue, "hop is not an integer");
1047 }
1048
1049 verifying = (upgraded ? "relays" : "relay-info");
1050 for (auto const& elem : relay->mapValue()) {
1051 if ((elem.first != "hop") &&
1052 (elem.first != "link") &&
1053 (elem.first != "peer") &&
1054 (elem.first != "options") &&
1055 (elem.first != "remote-id") &&
1056 (elem.first != "relay-id") &&
1057 (elem.first != "comment")) {
1058 mutable_isc->remove("relay-info");
1059 removed_relay_info = true;
1060 isc_throw(BadValue, "spurious '" << elem.first << "' entry");
1061 }
1062 }
1063 }
1064
1065 if (upgraded) {
1068 .arg(lease->addr_.toText());
1069 }
1070
1071 return (changed);
1072 } catch (const exception& ex) {
1073 ostringstream err;
1074 err << "in " << verifying;
1075 if (i >= 0) {
1076 err << " [relay#" << i << "]";
1077 }
1078 err << " a problem was found: " << ex.what();
1080 .arg(lease->addr_.toText())
1081 .arg(err.str());
1082
1083 changed = true;
1084 have_both = !have_both;
1085 if (verifying == "user context") {
1086 lease->setContext(ConstElementPtr());
1087 } else if (verifying == "isc") {
1088 mutable_user_context->remove("ISC");
1089 if (mutable_user_context->empty()) {
1090 lease->setContext(ConstElementPtr());
1091 }
1092 } else {
1093 if (!removed_relay_info) {
1094 mutable_isc->remove("relay-info");
1095 }
1096 if (mutable_isc->empty()) {
1097 mutable_user_context->remove("ISC");
1098 if (mutable_user_context->empty()) {
1099 lease->setContext(ConstElementPtr());
1100 }
1101 }
1102 }
1103 return (changed);
1104 }
1105}
1106
1107void
1109 bool ignore_errors) {
1110 if (!lease) {
1111 return;
1112 }
1113
1114 ConstElementPtr user_context = lease->getContext();
1115 if (!user_context) {
1116 return;
1117 }
1118 if (user_context->getType() != Element::map) {
1119 if (ignore_errors) {
1120 return;
1121 }
1122 isc_throw(BadValue, "user context is not a map");
1123 }
1124 if (user_context->empty()) {
1125 return;
1126 }
1127
1128 ConstElementPtr isc = user_context->get("ISC");
1129 if (!isc) {
1130 return;
1131 }
1132 if (isc->getType() != Element::map) {
1133 if (ignore_errors) {
1134 return;
1135 }
1136 isc_throw(BadValue, "ISC entry is not a map");
1137 }
1138 if (isc->empty()) {
1139 return;
1140 }
1141
1142 ConstElementPtr extended_info = isc->get("relay-agent-info");
1143 if (!extended_info) {
1144 return;
1145 }
1146 if (extended_info->getType() != Element::map) {
1147 if (ignore_errors) {
1148 return;
1149 }
1150 isc_throw(BadValue, "relay-agent-info is not a map");
1151 }
1152 if (extended_info->empty()) {
1153 return;
1154 }
1155
1156 ConstElementPtr relay_id = extended_info->get("relay-id");
1157 if (relay_id) {
1158 if (relay_id->getType() == Element::string) {
1159 vector<uint8_t> bytes;
1160 try {
1161 encode::decodeHex(relay_id->stringValue(), bytes);
1162 } catch (...) {
1163 // Decode failed
1164 if (!ignore_errors) {
1165 throw;
1166 }
1167 }
1168 lease->relay_id_ = bytes;
1169 } else if (!ignore_errors) {
1170 isc_throw(BadValue, "relay-id entry is not a string");
1171 }
1172 }
1173
1174 ConstElementPtr remote_id = extended_info->get("remote-id");
1175 if (remote_id) {
1176 if (remote_id->getType() == Element::string) {
1177 vector<uint8_t> bytes;
1178 try {
1179 encode::decodeHex(remote_id->stringValue(), bytes);
1180 } catch (...) {
1181 // Decode failed
1182 if (!ignore_errors) {
1183 throw;
1184 }
1185 }
1186 lease->remote_id_ = bytes;
1187 } else if (!ignore_errors) {
1188 isc_throw(BadValue, "remote-id entry is not a string");
1189 }
1190 }
1191}
1192
1193bool
1195
1196 bool added = false;
1197 if (!lease) {
1198 return (added);
1199 }
1200
1201 ConstElementPtr user_context = lease->getContext();
1202 if (!user_context || (user_context->getType() != Element::map) ||
1203 user_context->empty()) {
1204 return (added);
1205 }
1206
1207 ConstElementPtr isc = user_context->get("ISC");
1208 if (!isc || (isc->getType() != Element::map) || isc->empty()) {
1209 return (added);
1210 }
1211
1212 ConstElementPtr relay_info = isc->get("relay-info");
1213 if (!relay_info || (relay_info->getType() != Element::list) ||
1214 relay_info->empty()) {
1215 return (added);
1216 }
1217
1218 for (int i = 0; i < relay_info->size(); ++i) {
1219 ConstElementPtr relay = relay_info->get(i);
1220 if (!relay || (relay->getType() != Element::map) || relay->empty()) {
1221 continue;
1222 }
1223 try {
1224 ConstElementPtr relay_id = relay->get("relay-id");
1225 if (relay_id) {
1226 string relay_id_hex = relay_id->stringValue();
1227 vector<uint8_t> relay_id_data;
1228 encode::decodeHex(relay_id_hex, relay_id_data);
1229 if (relay_id_data.empty()) {
1230 continue;
1231 }
1232 addRelayId6(lease->addr_, relay_id_data);
1233 added = true;
1234 }
1235
1236 ConstElementPtr remote_id = relay->get("remote-id");
1237 if (remote_id) {
1238 string remote_id_hex = remote_id->stringValue();
1239 vector<uint8_t> remote_id_data;
1240 encode::decodeHex(remote_id_hex, remote_id_data);
1241 if (remote_id_data.empty()) {
1242 continue;
1243 }
1244 addRemoteId6(lease->addr_, remote_id_data);
1245 added = true;
1246 }
1247 } catch (const exception&) {
1248 continue;
1249 }
1250 }
1251 return (added);
1252}
1253
1254size_t
1256 return (0);
1257}
1258
1259size_t
1261 return (0);
1262}
1263
1264} // namespace isc::dhcp
1265} // namespace isc
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown when a function is not implemented.
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
static ElementPtr create(const Position &pos=ZERO_POSITION())
Definition data.cc:249
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:304
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
Multiple lease records found where one expected.
ExtendedInfoSanity
Values for extended info sanity checks done for leases.
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition cfgmgr.cc:25
Holds DUID (DHCPv6 Unique Identifier)
Definition duid.h:142
std::string toText() const
Returns textual representation of the identifier (e.g.
Definition duid.h:88
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
Definition lease_mgr.cc:505
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query for all subnets and pools.
Definition lease_mgr.cc:500
virtual Lease6Collection getLeases6() const =0
Returns all IPv6 leases.
void recountLeaseStats6()
Recalculates per-subnet and global stats for IPv6 leases.
Definition lease_mgr.cc:282
void setExtendedInfoTablesEnabled(const bool enabled)
Modifies the setting whether the lease6 extended info tables are enabled.
Definition lease_mgr.h:1018
virtual size_t byRelayId6size() const
Return the by-relay-id table size.
static bool upgradeLease6ExtendedInfo(const Lease6Ptr &lease, CfgConsistency::ExtendedInfoSanity check=CfgConsistency::EXTENDED_INFO_CHECK_FIX)
Upgrade a V6 lease user context to the new extended info entry.
Definition lease_mgr.cc:756
virtual size_t byRemoteId6size() const
Return the by-remote-id table size.
virtual void addRelayId6(const isc::asiolink::IOAddress &lease_addr, const std::vector< uint8_t > &relay_id)=0
Add lease6 extended info into by-relay-id table.
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
Definition lease_mgr.cc:271
void recountLeaseStats4()
Recalculates per-subnet and global stats for IPv4 leases.
Definition lease_mgr.cc:72
static std::string getDBVersion()
Class method to return extended version info This class method must be redeclared and redefined in de...
Definition lease_mgr.cc:516
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
Definition lease_mgr.cc:510
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
Definition lease_mgr.cc:266
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const =0
Returns existing IPv6 lease for a given IPv6 address.
virtual LeaseStatsQueryPtr startLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query for all subnets.
Definition lease_mgr.cc:256
static void extractLease4ExtendedInfo(const Lease4Ptr &lease, bool ignore_errors=true)
Extract relay and remote identifiers from the extended info.
static bool upgradeLease4ExtendedInfo(const Lease4Ptr &lease, CfgConsistency::ExtendedInfoSanity check=CfgConsistency::EXTENDED_INFO_CHECK_FIX)
The following queries are used to fulfill Bulk Lease Query queries.
Definition lease_mgr.cc:535
virtual void addRemoteId6(const isc::asiolink::IOAddress &lease_addr, const std::vector< uint8_t > &remote_id)=0
Add lease6 extended info into by-remote-id table.
virtual LeaseStatsQueryPtr startPoolLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query for all subnets and pools.
Definition lease_mgr.cc:261
virtual bool addExtendedInfo6(const Lease6Ptr &lease)
Extract extended info from a lease6 and add it into tables.
virtual LeaseStatsQueryPtr startLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query for all subnets.
Definition lease_mgr.cc:495
const size_t page_size_
Holds page size.
Definition lease_mgr.h:56
LeasePageSize(const size_t page_size)
Constructor.
Definition lease_mgr.cc:41
LeaseStatsQuery(const SelectMode &select_mode=ALL_SUBNETS)
Constructor to query statistics for all subnets.
Definition lease_mgr.cc:220
SubnetID first_subnet_id_
First (or only) subnet_id in the selection criteria.
Definition lease_mgr.h:222
SubnetID last_subnet_id_
Last subnet_id in the selection criteria when a range is given.
Definition lease_mgr.h:225
virtual bool getNextRow(LeaseStatsRow &row)
Fetches the next row of data.
Definition lease_mgr.cc:277
SelectMode
Defines the types of selection criteria supported.
Definition lease_mgr.h:152
static const OptionDefinition & DHO_DHCP_AGENT_OPTIONS_DEF()
Get definition of DHO_DHCP_AGENT_OPTIONS option.
static size_t unpackOptions6(const OptionBuffer &buf, const std::string &option_space, isc::dhcp::OptionCollection &options, size_t *relay_msg_offset=0, size_t *relay_msg_len=0)
Parses provided buffer as DHCPv6 options and creates Option objects.
Definition libdhcp++.cc:317
Option with defined data fields represented as buffers that can be accessed using data field index.
Base class representing a DHCP option definition.
@ D6O_REMOTE_ID
Definition dhcp6.h:57
@ D6O_RELAY_ID
Definition dhcp6.h:73
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
An abstract API for lease database.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition macros.h:32
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
Definition macros.h:14
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
Definition data.cc:1420
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
Definition dhcpsrv_log.h:56
const isc::log::MessageID DHCPSRV_LEASE6_EXTENDED_INFO_UPGRADED
boost::shared_ptr< OptionCustom > OptionCustomPtr
A pointer to the OptionCustom object.
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
Definition lease.h:508
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
Definition lease.h:673
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
Definition lease_mgr.h:233
boost::multi_index_container< Subnet6Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > > > Subnet6Collection
A collection of Subnet6 objects.
Definition subnet.h:937
std::multimap< unsigned int, OptionPtr > OptionCollection
A collection of DHCP (v4 or v6) options.
Definition option.h:40
boost::multi_index_container< Subnet4Ptr, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress, &Network4::getServerId > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetModificationTimeIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > > > > Subnet4Collection
A collection of Subnet4 objects.
Definition subnet.h:866
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition subnet_id.h:25
@ RAI_OPTION_RELAY_ID
Definition dhcp4.h:276
@ RAI_OPTION_REMOTE_ID
Definition dhcp4.h:266
const isc::log::MessageID DHCPSRV_LEASE4_EXTENDED_INFO_SANITY_FAIL
const isc::log::MessageID DHCPSRV_LEASE4_EXTENDED_INFO_UPGRADED
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
Definition lease.h:295
const int DHCPSRV_DBG_TRACE
DHCP server library logging levels.
Definition dhcpsrv_log.h:26
boost::shared_ptr< Option > OptionPtr
Definition option.h:37
const isc::log::MessageID DHCPSRV_LEASE6_EXTENDED_INFO_SANITY_FAIL
void decodeHex(const string &encoded_str, vector< uint8_t > &output)
Decode a base16 encoded string into binary data.
Definition encode.cc:367
string encodeHex(const vector< uint8_t > &binary)
Encode binary data in the base16 format.
Definition encode.cc:361
void decodeFormattedHexString(const string &hex_string, vector< uint8_t > &binary)
Converts a formatted string of hexadecimal digits into a vector.
Definition str.cc:212
Defines the logger used by the top-level component of kea-lfc.
#define DHCP6_OPTION_SPACE
Contains a single row of lease statistical data.
Definition lease_mgr.h:64
static const uint32_t STATE_DEFAULT
A lease in the default state.
Definition lease.h:69
static const uint32_t STATE_DECLINED
Declined lease.
Definition lease.h:72
Type
Type of lease or pool.
Definition lease.h:46
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
Definition lease.h:49
@ TYPE_V4
IPv4 lease.
Definition lease.h:50
@ TYPE_NA
the lease contains non-temporary IPv6 address
Definition lease.h:47