Kea 2.7.4
network.h
Go to the documentation of this file.
1// Copyright (C) 2017-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#ifndef NETWORK_H
8#define NETWORK_H
9
10#include <cc/cfg_to_element.h>
11#include <cc/data.h>
12#include <cc/element_value.h>
13#include <cc/stamped_element.h>
14#include <cc/user_context.h>
15#include <dhcp/classify.h>
16#include <dhcp/option.h>
17#include <dhcpsrv/cfg_globals.h>
18#include <dhcpsrv/cfg_option.h>
19#include <dhcpsrv/cfg_4o6.h>
21#include <util/triplet.h>
22#include <util/optional.h>
23
24#include <boost/multi_index/hashed_index.hpp>
25#include <boost/multi_index/identity.hpp>
26#include <boost/multi_index/indexed_by.hpp>
27#include <boost/multi_index/sequenced_index.hpp>
28#include <boost/multi_index_container.hpp>
29#include <boost/shared_ptr.hpp>
30#include <boost/weak_ptr.hpp>
31
32#include <cstdint>
33#include <functional>
34#include <string>
35
37namespace {
38template <typename... Args>
39inline void unused(Args const& ...) {}
40} // end of anonymous namespace
41
42namespace isc {
43namespace dhcp {
44
47
50
52typedef boost::multi_index_container<
53 // Multi index container holds IO addresses.
55 // Indexes.
56 boost::multi_index::indexed_by<
57 // First and default index allows for in order iteration.
58 boost::multi_index::sequenced<
59 boost::multi_index::tag<IOAddressListListTag>
60 >,
61 // Second index allows for checking existence.
62 boost::multi_index::hashed_unique<
63 boost::multi_index::tag<IOAddressListSetTag>,
64 boost::multi_index::identity<asiolink::IOAddress>
65 >
66 >
68
69// @brief Forward declaration of the Network class.
70class Network;
71
73typedef boost::shared_ptr<Network> NetworkPtr;
74
76typedef boost::weak_ptr<Network> WeakNetworkPtr;
77
80typedef std::function<ConstCfgGlobalsPtr()> FetchNetworkGlobalsFn;
81
152class Network : public virtual isc::data::StampedElement,
153 public virtual isc::data::UserContext,
155public:
162 class RelayInfo {
163 public:
164
169 void addAddress(const asiolink::IOAddress& addr);
170
174 const IOAddressList& getAddresses() const;
175
179 bool hasAddresses() const;
180
184 bool containsAddress(const asiolink::IOAddress& addr) const;
185
186 private:
188 IOAddressList addresses_;
189 };
190
202 enum class Inheritance {
203 NONE,
205 GLOBAL,
206 ALL
207 };
208
210 typedef boost::shared_ptr<Network::RelayInfo> RelayInfoPtr;
211
225
229 virtual ~Network() { };
230
236 fetch_globals_fn_ = fetch_globals_fn;
237 }
238
243 bool hasFetchGlobalsFn() const {
244 return (static_cast<bool>(fetch_globals_fn_));
245 }
246
256 void setIface(const util::Optional<std::string>& iface_name) {
257 if (iface_name.empty()) {
259 } else {
260 iface_name_ = iface_name;
261 }
262 }
263
270 getIface(const Inheritance& inheritance = Inheritance::ALL) const {
271 return (getProperty<Network>(&Network::getIface, iface_name_,
272 inheritance));
273 };
274
294 void setRelayInfo(const RelayInfo& relay) {
295 relay_ = relay;
296 }
297
304 const RelayInfo& getRelayInfo() const {
305 return (relay_);
306 }
307
312 void addRelayAddress(const asiolink::IOAddress& addr);
313
317 const IOAddressList& getRelayAddresses() const;
318
322 bool hasRelays() const;
323
328 bool hasRelayAddress(const asiolink::IOAddress& address) const;
329
344 virtual bool
345 clientSupported(const isc::dhcp::ClientClasses& client_classes) const;
346
350 void allowClientClass(const isc::dhcp::ClientClass& class_name);
351
355 void requireClientClass(const isc::dhcp::ClientClass& class_name);
356
358 const ClientClasses& getRequiredClasses() const;
359
368 getClientClass(const Inheritance& inheritance = Inheritance::ALL) const {
369 return (getProperty<Network>(&Network::getClientClass, client_class_,
370 inheritance));
371 }
372
382
387 valid_ = valid;
388 }
389
394 return (getProperty<Network>(&Network::getT1, t1_, inheritance,
396 }
397
402 t1_ = t1;
403 }
404
409 return (getProperty<Network>(&Network::getT2, t2_, inheritance,
411 }
412
417 t2_ = t2;
418 }
419
425 return (getProperty<Network>(&Network::getReservationsGlobal,
427 inheritance,
429 }
430
434 void setReservationsGlobal(const util::Optional<bool>& reservations_global) {
435 reservations_global_ = reservations_global;
436 }
437
443 return (getProperty<Network>(&Network::getReservationsInSubnet,
445 inheritance,
447 }
448
452 void setReservationsInSubnet(const util::Optional<bool>& reservations_in_subnet) {
453 reservations_in_subnet_ = reservations_in_subnet;
454 }
455
461 return (getProperty<Network>(&Network::getReservationsOutOfPool,
463 inheritance,
465 }
466
470 void setReservationsOutOfPool(const util::Optional<bool>& reservations_out_of_pool) {
471 reservations_out_of_pool_ = reservations_out_of_pool;
472 }
473
476 return (cfg_option_);
477 }
478
482 return (cfg_option_);
483 }
484
490 return (getProperty<Network>(&Network::getCalculateTeeTimes,
492 inheritance,
494 }
495
499 void setCalculateTeeTimes(const util::Optional<bool>& calculate_tee_times) {
500 calculate_tee_times_ = calculate_tee_times;
501 }
502
507 getT1Percent(const Inheritance& inheritance = Inheritance::ALL) const {
508 return (getProperty<Network>(&Network::getT1Percent, t1_percent_,
509 inheritance, CfgGlobals::T1_PERCENT));
510 }
511
515 void setT1Percent(const util::Optional<double>& t1_percent) {
516 t1_percent_ = t1_percent;
517 }
518
523 getT2Percent(const Inheritance& inheritance = Inheritance::ALL) const {
524 return (getProperty<Network>(&Network::getT2Percent, t2_percent_,
525 inheritance, CfgGlobals::T2_PERCENT));
526 }
527
531 void setT2Percent(const util::Optional<double>& t2_percent) {
532 t2_percent_ = t2_percent;
533 }
534
539 getDdnsSendUpdates(const Inheritance& inheritance = Inheritance::ALL) const {
540 return (getProperty<Network>(&Network::getDdnsSendUpdates,
541 ddns_send_updates_, inheritance,
543 }
544
548 void setDdnsSendUpdates(const util::Optional<bool>& ddns_send_updates) {
549 ddns_send_updates_ = ddns_send_updates;
550 }
551
557 return (getProperty<Network>(&Network::getDdnsOverrideNoUpdate,
558 ddns_override_no_update_, inheritance,
560 }
561
565 void setDdnsOverrideNoUpdate(const util::Optional<bool>& ddns_override_no_update) {
566 ddns_override_no_update_ = ddns_override_no_update;
567 }
568
578
583 ddns_override_client_update) {
584 ddns_override_client_update_ = ddns_override_client_update;
585 }
586
592 // Inheritance for ddns-replace-client-name is a little different than for other
593 // parameters. The value at the global level is given as a string.
594 // Thus we call getProperty here without a global name to check if it
595 // is specified on network level only.
597 getProperty<Network>(&Network::getDdnsReplaceClientNameMode,
598 ddns_replace_client_name_mode_, inheritance);
599
600 // If it is not specified at network level we need this special
601 // case code to convert the global string value to an enum.
602 if (mode.unspecified() && (inheritance != Inheritance::NONE) &&
603 (inheritance != Inheritance::PARENT_NETWORK)) {
604 // Get global mode.
606 mode_label = getGlobalProperty(mode_label,
608 if (!mode_label.unspecified()) {
609 try {
610 // If the mode is globally configured, convert it to an enum.
611 return (D2ClientConfig::stringToReplaceClientNameMode(mode_label.get()));
612 } catch (...) {
613 // This should not really happen because the configuration
614 // parser should have already verified the globally configured
615 // mode. However, we want to be 100% sure that this
616 // method doesn't throw. Let's just return unspecified.
617 return (mode);
618 }
619 }
620 }
621 return (mode);
622 }
623
627 void
629 ddns_replace_client_name_mode) {
630 ddns_replace_client_name_mode_ = ddns_replace_client_name_mode;
631 }
632
638 return (getProperty<Network>(&Network::getDdnsGeneratedPrefix,
639 ddns_generated_prefix_, inheritance,
641 }
642
646 void setDdnsGeneratedPrefix(const util::Optional<std::string>& ddns_generated_prefix) {
647 ddns_generated_prefix_ = ddns_generated_prefix;
648 }
649
655 return (getProperty<Network>(&Network::getDdnsQualifyingSuffix,
656 ddns_qualifying_suffix_, inheritance,
658 }
659
663 void setDdnsQualifyingSuffix(const util::Optional<std::string>& ddns_qualifying_suffix) {
664 ddns_qualifying_suffix_ = ddns_qualifying_suffix;
665 }
666
671 getDdnsTtlPercent(const Inheritance& inheritance = Inheritance::ALL) const {
672 return (getProperty<Network>(&Network::getDdnsTtlPercent,
673 ddns_ttl_percent_, inheritance,
675 }
676
680 void setDdnsTtlPercent(const util::Optional<double>& ddns_ttl_percent) {
681 ddns_ttl_percent_ = ddns_ttl_percent;
682 }
683
686 getHostnameCharSet(const Inheritance& inheritance = Inheritance::ALL) const {
687 return (getProperty<Network>(&Network::getHostnameCharSet,
688 hostname_char_set_, inheritance,
690 }
691
695 void setHostnameCharSet(const util::Optional<std::string>& hostname_char_set) {
696 hostname_char_set_ = hostname_char_set;
697 }
698
706
711 hostname_char_replacement) {
712 hostname_char_replacement_ = hostname_char_replacement;
713 }
714
720 return (getProperty<Network>(&Network::getStoreExtendedInfo,
721 store_extended_info_, inheritance,
723 }
724
728 void setStoreExtendedInfo(const util::Optional<bool>& store_extended_info) {
729 store_extended_info_ = store_extended_info;
730 }
731
736 getCacheThreshold(const Inheritance& inheritance = Inheritance::ALL) const {
737 return (getProperty<Network>(&Network::getCacheThreshold,
738 cache_threshold_, inheritance,
740 }
741
745 void setCacheThreshold(const util::Optional<double>& cache_threshold) {
746 cache_threshold_ = cache_threshold;
747 }
748
753 getCacheMaxAge(const Inheritance& inheritance = Inheritance::ALL) const {
754 return (getProperty<Network>(&Network::getCacheMaxAge, cache_max_age_,
755 inheritance, CfgGlobals::CACHE_MAX_AGE));
756 }
757
761 void setCacheMaxAge(const util::Optional<uint32_t>& cache_max_age) {
762 cache_max_age_ = cache_max_age;
763 }
764
770 return (getProperty<Network>(&Network::getDdnsUpdateOnRenew,
771 ddns_update_on_renew_, inheritance,
773 }
774
778 void setDdnsUpdateOnRenew(const util::Optional<bool>& ddns_update_on_renew) {
779 ddns_update_on_renew_ = ddns_update_on_renew;
780 }
781
782
793
797 void setDdnsConflictResolutionMode(const util::Optional<std::string>& ddns_conflict_resolution_mode) {
798 ddns_conflict_resolution_mode_ = ddns_conflict_resolution_mode;
799 }
800
805 getAllocatorType(const Inheritance& inheritance = Inheritance::ALL) const {
806 return (getProperty<Network>(&Network::getAllocatorType,
808 inheritance,
810 }
811
819 void setAllocatorType(const util::Optional<std::string>& allocator_type) {
820 allocator_type_ = allocator_type;
821 }
822
831 return (getProperty<Network>(&Network::getDefaultAllocatorType,
833 inheritance));
834 }
835
839 void setDefaultAllocatorType(const std::string& allocator_type) {
840 default_allocator_type_ = allocator_type;
841 }
842
846 virtual data::ElementPtr toElement() const;
847
851 virtual std::string getLabel() const {
852 return ("base-network");
853 }
854
855protected:
856
864
891 template<typename ReturnType>
892 ReturnType getGlobalProperty(ReturnType property,
893 const int global_index,
894 const int min_index = -1,
895 const int max_index = -1) const {
896 unused(min_index, max_index);
897 if ((global_index >= 0) && fetch_globals_fn_) {
899 if (globals) {
900 data::ConstElementPtr global_param = globals->get(global_index);
901 if (global_param) {
902 // If there is a global parameter, convert it to the
903 // optional value of the given type and return.
905 }
906 }
907 }
908 return (property);
909 }
910
929 template<typename NumType>
931 const int global_index,
932 const int min_index = -1,
933 const int max_index = -1) const {
934
935 if ((global_index >= 0) && fetch_globals_fn_) {
937 if (globals) {
938 data::ConstElementPtr param = globals->get(global_index);
939 if (param) {
940 NumType def_value = static_cast<NumType>(param->intValue());
941 if ((min_index < 0) || (max_index < 0)) {
942 return (def_value);
943 } else {
944 NumType min_value = def_value;
945 NumType max_value = def_value;
946 data::ConstElementPtr min_param = globals->get(min_index);
947 if (min_param) {
948 min_value = static_cast<NumType>(min_param->intValue());
949 }
950 data::ConstElementPtr max_param = globals->get(max_index);
951 if (max_param) {
952 max_value = static_cast<NumType>(max_param->intValue());
953 }
954 return (isc::util::Triplet<NumType>(min_value, def_value, max_value));
955 }
956 }
957 }
958 }
959 return (property);
960 }
961
984 const int global_index,
985 const int min_index = -1,
986 const int max_index = -1) const;
987
1018 template<typename BaseType, typename ReturnType>
1019 ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance&) const,
1020 ReturnType property,
1021 const Inheritance& inheritance,
1022 const int global_index = -1,
1023 const int min_index = -1,
1024 const int max_index = -1) const {
1025
1026 // If no inheritance is to be used, return the value for this
1027 // network regardless if it is specified or not.
1028 if (inheritance == Inheritance::NONE) {
1029 return (property);
1030
1031 } else if (inheritance == Inheritance::PARENT_NETWORK) {
1032 ReturnType parent_property;
1033
1034 // Check if this instance has a parent network.
1035 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1036 if (parent) {
1037 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1038 }
1039 return (parent_property);
1040
1041 // If global value requested, return it.
1042 } else if (inheritance == Inheritance::GLOBAL) {
1043 return (getGlobalProperty(ReturnType(), global_index, min_index, max_index));
1044 }
1045
1046 // We use inheritance and the value is not specified on the network level.
1047 // Hence, we need to get the parent network specific value or global value.
1048 if (property.unspecified()) {
1049 // Check if this instance has a parent network.
1050 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1051 // If the parent network exists, let's fetch the parent specific
1052 // value.
1053 if (parent) {
1054 // We're using inheritance so ask for the parent specific network
1055 // and return it only if it is specified.
1056 auto parent_property = ((*parent).*MethodPointer)(inheritance);
1057 if (!parent_property.unspecified()) {
1058 return (parent_property);
1059 }
1060 }
1061
1062 // The value is not specified on network level. If the value
1063 // can be specified on global level and there is a callback
1064 // that returns the global values, try to find this parameter
1065 // at the global scope.
1066 return (getGlobalProperty(property, global_index, min_index, max_index));
1067 }
1068
1069 // We haven't found the value at any level, so return the unspecified.
1070 return (property);
1071 }
1072
1093 template<typename BaseType>
1094 OptionPtr
1095 getOptionProperty(OptionPtr(BaseType::*MethodPointer)(const Inheritance& inheritance) const,
1096 OptionPtr property,
1097 const Inheritance& inheritance) const {
1098 if (inheritance == Network::Inheritance::NONE) {
1099 return (property);
1100
1101 } else if (inheritance == Network::Inheritance::PARENT_NETWORK) {
1102 OptionPtr parent_property;
1103 // Check if this instance has a parent network.
1104 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1105 // If the parent network exists, let's fetch the parent specific
1106 // value.
1107 if (parent) {
1108 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1109 }
1110 return (parent_property);
1111
1112 } else if (inheritance == Network::Inheritance::GLOBAL) {
1113 return (OptionPtr());
1114 }
1115
1116 // We use inheritance and the value is not specified on the network level.
1117 // Hence, we need to get the parent network specific value.
1118 if (!property) {
1119 // Check if this instance has a parent network.
1120 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1121 if (parent) {
1122 // We're using inheritance so ask for the parent specific network
1123 // and return it only if it is specified.
1124 OptionPtr parent_property = (((*parent).*MethodPointer)(inheritance));
1125 if (parent_property) {
1126 return (parent_property);
1127 }
1128 }
1129 }
1130
1131 // We haven't found the value at any level, so return the unspecified.
1132 return (property);
1133 }
1134
1137
1142
1149
1155
1158
1161
1164
1167
1170
1177
1180
1183
1186
1189
1193
1197
1200
1203
1206
1209
1213
1217
1221
1224
1227
1230
1233
1236
1239
1245
1253
1257};
1258
1260class Network4 : public virtual Network {
1261public:
1262
1265 : Network(), match_client_id_(true, true), authoritative_(),
1266 siaddr_(), sname_(), filename_(), offer_lft_() {
1267 }
1268
1275 getMatchClientId(const Inheritance& inheritance = Inheritance::ALL) const {
1276 return (getProperty<Network4>(&Network4::getMatchClientId,
1277 match_client_id_,
1278 inheritance,
1279 CfgGlobals::MATCH_CLIENT_ID));
1280 }
1281
1288 match_client_id_ = match;
1289 }
1290
1298 getAuthoritative(const Inheritance& inheritance = Inheritance::ALL) const {
1299 return (getProperty<Network4>(&Network4::getAuthoritative,
1300 authoritative_, inheritance,
1301 CfgGlobals::AUTHORITATIVE));
1302 }
1303
1309 void setAuthoritative(const util::Optional<bool>& authoritative) {
1310 authoritative_ = authoritative;
1311 }
1312
1318 void setSiaddr(const util::Optional<asiolink::IOAddress>& siaddr);
1319
1324 getSiaddr(const Inheritance& inheritance = Inheritance::ALL) const {
1325 return (getProperty<Network4>(&Network4::getSiaddr, siaddr_,
1326 inheritance, CfgGlobals::NEXT_SERVER));
1327 }
1328
1332 void setSname(const util::Optional<std::string>& sname);
1333
1339 getSname(const Inheritance& inheritance = Inheritance::ALL) const {
1340 return (getProperty<Network4>(&Network4::getSname, sname_,
1341 inheritance,
1342 CfgGlobals::SERVER_HOSTNAME));
1343 }
1344
1348 void setFilename(const util::Optional<std::string>& filename);
1349
1355 getFilename(const Inheritance& inheritance = Inheritance::ALL) const {
1356 return (getProperty<Network4>(&Network4::getFilename, filename_,
1357 inheritance,
1358 CfgGlobals::BOOT_FILE_NAME));
1359 }
1360
1364 void setOfferLft(const util::Optional<uint32_t>& offer_lft) {
1365 offer_lft_ = offer_lft;
1366 }
1367
1373 getOfferLft(const Inheritance& inheritance = Inheritance::ALL) const {
1374 return (getProperty<Network4>(&Network4::getOfferLft, offer_lft_,
1375 inheritance,
1376 CfgGlobals::OFFER_LIFETIME));
1377 }
1378
1382 virtual data::ElementPtr toElement() const;
1383
1388 virtual asiolink::IOAddress getServerId() const;
1389
1390private:
1391
1394 util::Optional<bool> match_client_id_;
1395
1397 util::Optional<bool> authoritative_;
1398
1401
1404
1407
1409 util::Optional<uint32_t> offer_lft_;
1410};
1411
1413typedef boost::shared_ptr<Network4> Network4Ptr;
1414
1415class Network6;
1416
1418typedef boost::shared_ptr<Network6> Network6Ptr;
1419
1421class Network6 : public virtual Network {
1422public:
1423
1426 : Network(), preferred_(), interface_id_(), rapid_commit_(),
1427 default_pd_allocator_type_(){
1428 }
1429
1435 getPreferred(const Inheritance& inheritance = Inheritance::ALL) const {
1436 return (getProperty<Network6>(&Network6::getPreferred, preferred_,
1437 inheritance,
1438 CfgGlobals::PREFERRED_LIFETIME,
1439 CfgGlobals::MIN_PREFERRED_LIFETIME,
1440 CfgGlobals::MAX_PREFERRED_LIFETIME));
1441 }
1442
1447 preferred_ = preferred;
1448 }
1449
1454 OptionPtr getInterfaceId(const Inheritance& inheritance = Inheritance::ALL) const {
1455 return (getOptionProperty<Network6>(&Network6::getInterfaceId, interface_id_,
1456 inheritance));
1457 }
1458
1462 void setInterfaceId(const OptionPtr& ifaceid) {
1463 interface_id_ = ifaceid;
1464 }
1465
1474 getRapidCommit(const Inheritance& inheritance = Inheritance::ALL) const {
1475
1476 return (getProperty<Network6>(&Network6::getRapidCommit, rapid_commit_,
1477 inheritance));
1478 }
1479
1484 void setRapidCommit(const util::Optional<bool>& rapid_commit) {
1485 rapid_commit_ = rapid_commit;
1486 };
1487
1492 getPdAllocatorType(const Inheritance& inheritance = Inheritance::ALL) const {
1493 return (getProperty<Network6>(&Network6::getPdAllocatorType,
1494 pd_allocator_type_,
1495 inheritance,
1496 CfgGlobals::PD_ALLOCATOR));
1497 }
1498
1507 pd_allocator_type_ = allocator_type;
1508 }
1509
1517 getDefaultPdAllocatorType(const Inheritance& inheritance = Inheritance::ALL) const {
1518 return (getProperty<Network6>(&Network6::getDefaultPdAllocatorType,
1519 default_pd_allocator_type_,
1520 inheritance));
1521 }
1522
1526 void setDefaultPdAllocatorType(const std::string& allocator_type) {
1527 default_pd_allocator_type_ = allocator_type;
1528 }
1529
1533 virtual data::ElementPtr toElement() const;
1534
1535private:
1536
1539
1541 OptionPtr interface_id_;
1542
1548 util::Optional<bool> rapid_commit_;
1549
1551 util::Optional<std::string> pd_allocator_type_;
1552
1553 // @brief Default allocator type for prefix delegation.
1554 util::Optional<std::string> default_pd_allocator_type_;
1555};
1556
1557} // end of namespace isc::dhcp
1558} // end of namespace isc
1559
1560#endif // NETWORK_H
if(!(yy_init))
Defines elements for storing the names of client classes.
Template class for converting a value encapsulated in the Element object into a simple type.
This class represents configuration element which is associated with database identifier,...
Represents option data configuration for the DHCP server.
Definition cfg_option.h:352
Container for storing client class names.
Definition classify.h:108
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
Specialization of the Network object for DHCPv4 case.
Definition network.h:1260
util::Optional< std::string > getFilename(const Inheritance &inheritance=Inheritance::ALL) const
Returns boot file name for this subnet.
Definition network.h:1355
void setMatchClientId(const util::Optional< bool > &match)
Sets the flag indicating if the client identifier should be used to identify the client's lease.
Definition network.h:1287
util::Optional< std::string > getSname(const Inheritance &inheritance=Inheritance::ALL) const
Returns server hostname for this network.
Definition network.h:1339
util::Optional< asiolink::IOAddress > getSiaddr(const Inheritance &inheritance=Inheritance::ALL) const
Returns siaddr for this network.
Definition network.h:1324
void setAuthoritative(const util::Optional< bool > &authoritative)
Sets the flag indicating if requests for unknown IP addresses should be rejected with DHCPNAK instead...
Definition network.h:1309
util::Optional< uint32_t > getOfferLft(const Inheritance &inheritance=Inheritance::ALL) const
Returns offer lifetime for the network.
Definition network.h:1373
void setOfferLft(const util::Optional< uint32_t > &offer_lft)
Sets offer lifetime for the network.
Definition network.h:1364
util::Optional< bool > getMatchClientId(const Inheritance &inheritance=Inheritance::ALL) const
Returns the flag indicating if the client identifiers should be used to identify the client's lease.
Definition network.h:1275
util::Optional< bool > getAuthoritative(const Inheritance &inheritance=Inheritance::ALL) const
Returns the flag indicating if requests for unknown IP addresses should be rejected with DHCPNAK inst...
Definition network.h:1298
Network4()
Constructor.
Definition network.h:1264
Specialization of the Network object for DHCPv6 case.
Definition network.h:1421
void setRapidCommit(const util::Optional< bool > &rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
Definition network.h:1484
void setDefaultPdAllocatorType(const std::string &allocator_type)
Sets a defalt allocator type for prefix delegation.
Definition network.h:1526
util::Optional< std::string > getDefaultPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type for prefix delegation.
Definition network.h:1517
isc::util::Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds)
Definition network.h:1435
void setPdAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type for prefix delegation.
Definition network.h:1506
Network6()
Constructor.
Definition network.h:1425
util::Optional< bool > getRapidCommit(const Inheritance &inheritance=Inheritance::ALL) const
Returns boolean value indicating that the Rapid Commit option is supported or unsupported for the sub...
Definition network.h:1474
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
Definition network.h:1462
void setPreferred(const isc::util::Triplet< uint32_t > &preferred)
Sets new preferred lifetime for a network.
Definition network.h:1446
OptionPtr getInterfaceId(const Inheritance &inheritance=Inheritance::ALL) const
Returns interface-id value (if specified)
Definition network.h:1454
util::Optional< std::string > getPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type for prefix delegation.
Definition network.h:1492
Holds optional information about relay.
Definition network.h:162
const IOAddressList & getAddresses() const
Returns const reference to the list of addresses.
Definition network.cc:44
void addAddress(const asiolink::IOAddress &addr)
Adds an address to the list of addresses.
Definition network.cc:23
bool containsAddress(const asiolink::IOAddress &addr) const
Checks the address list for the given address.
Definition network.cc:38
bool hasAddresses() const
Indicates whether or not the address list has entries.
Definition network.cc:33
Common interface representing a network to which the DHCP clients are connected.
Definition network.h:154
virtual bool clientSupported(const isc::dhcp::ClientClasses &client_classes) const
Checks whether this network supports client that belongs to specified classes.
Definition network.cc:69
util::Optional< bool > getCalculateTeeTimes(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether or not T1/T2 calculation is enabled.
Definition network.h:489
util::Optional< std::string > getDdnsQualifyingSuffix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-qualifying-suffix.
Definition network.h:654
isc::util::Triplet< uint32_t > t2_
a isc::util::Triplet (min/default/max) holding allowed rebind timer values
Definition network.h:1160
util::Optional< D2ClientConfig::ReplaceClientNameMode > getDdnsReplaceClientNameMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-replace-client-name-mode.
Definition network.h:591
void setT2(const isc::util::Triplet< uint32_t > &t2)
Sets new rebind timer for a network.
Definition network.h:416
void addRelayAddress(const asiolink::IOAddress &addr)
Adds an address to the list addresses in the network's relay info.
Definition network.cc:49
util::Optional< std::string > hostname_char_replacement_
A string to replace invalid characters when scrubbing hostnames.
Definition network.h:1216
RelayInfo relay_
Relay information.
Definition network.h:1141
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
Definition network.h:210
util::Optional< double > getCacheThreshold(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use as cache threshold.
Definition network.h:736
util::Optional< bool > reservations_out_of_pool_
Enables out-of-pool reservations optimization.
Definition network.h:1176
util::Optional< std::string > getHostnameCharReplacement(const Inheritance &inheritance=Inheritance::ALL) const
Return the invalid char replacement used to sanitize client hostnames.
Definition network.h:701
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
Definition network.h:1229
util::Optional< std::string > allocator_type_
Allocator used for IP address allocations.
Definition network.h:1238
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
Definition network.h:1179
void setAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type.
Definition network.h:819
void setDdnsReplaceClientNameMode(const util::Optional< D2ClientConfig::ReplaceClientNameMode > &ddns_replace_client_name_mode)
Sets new ddns-replace-client-name-mode.
Definition network.h:628
Network()
Constructor.
Definition network.h:213
void requireClientClass(const isc::dhcp::ClientClass &class_name)
Adds class class_name to classes required to be evaluated.
Definition network.cc:85
const IOAddressList & getRelayAddresses() const
Returns the list of relay addresses from the network's relay info.
Definition network.cc:64
void setCacheMaxAge(const util::Optional< uint32_t > &cache_max_age)
Sets cache max for a network.
Definition network.h:761
util::Optional< double > getDdnsTtlPercent(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl-percent.
Definition network.h:671
void allowClientClass(const isc::dhcp::ClientClass &class_name)
Sets the supported class to class class_name.
Definition network.cc:80
Inheritance
Inheritance "mode" used when fetching an optional Network parameter.
Definition network.h:202
void setCacheThreshold(const util::Optional< double > &cache_threshold)
Sets cache threshold for a network.
Definition network.h:745
void setT1Percent(const util::Optional< double > &t1_percent)
Sets new percentage for calculating T1 (renew timer).
Definition network.h:515
util::Optional< bool > reservations_global_
Enables global reservations.
Definition network.h:1166
util::Optional< bool > getDdnsOverrideClientUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-client-update.
Definition network.h:573
bool hasFetchGlobalsFn() const
Checks if the network is associated with a function used to fetch globally configured parameters.
Definition network.h:243
util::Optional< bool > ddns_override_client_update_
Should Kea perform updates, even if client requested delegation.
Definition network.h:1199
OptionPtr getOptionProperty(OptionPtr(BaseType::*MethodPointer)(const Inheritance &inheritance) const, OptionPtr property, const Inheritance &inheritance) const
Returns option pointer associated with a network using inheritance.
Definition network.h:1095
util::Optional< bool > reservations_in_subnet_
Enables subnet reservations.
Definition network.h:1169
util::Optional< std::string > getHostnameCharSet(const Inheritance &inheritance=Inheritance::ALL) const
Return the char set regexp used to sanitize client hostnames.
Definition network.h:686
FetchNetworkGlobalsFn getFetchGlobalsFn() const
Gets the optional callback function used to fetch globally configured parameters.
Definition network.h:861
void setReservationsInSubnet(const util::Optional< bool > &reservations_in_subnet)
Sets whether subnet reservations should be fetched.
Definition network.h:452
FetchNetworkGlobalsFn fetch_globals_fn_
Pointer to the optional callback used to fetch globally configured parameters inherited to the Networ...
Definition network.h:1256
void setStoreExtendedInfo(const util::Optional< bool > &store_extended_info)
Sets new store-extended-info.
Definition network.h:728
util::Optional< double > t2_percent_
Percentage of the lease lifetime to use when calculating T2 timer.
Definition network.h:1188
void setIface(const util::Optional< std::string > &iface_name)
Sets local name of the interface for which this network is selected.
Definition network.h:256
util::Optional< bool > getDdnsUpdateOnRenew(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-update-on-renew.
Definition network.h:769
void setDdnsOverrideClientUpdate(const util::Optional< bool > &ddns_override_client_update)
Sets new ddns-override-client-update.
Definition network.h:582
const RelayInfo & getRelayInfo() const
Returns const reference to relay information.
Definition network.h:304
WeakNetworkPtr parent_network_
Pointer to another network that this network belongs to.
Definition network.h:1252
ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance &) const, ReturnType property, const Inheritance &inheritance, const int global_index=-1, const int min_index=-1, const int max_index=-1) const
Returns a value associated with a network using inheritance.
Definition network.h:1019
isc::util::Triplet< uint32_t > getT1(const Inheritance &inheritance=Inheritance::ALL) const
Returns T1 (renew timer), expressed in seconds.
Definition network.h:393
util::Optional< bool > getReservationsGlobal(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether global reservations should be fetched.
Definition network.h:424
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
Definition network.h:1205
util::Optional< double > t1_percent_
Percentage of the lease lifetime to use when calculating T1 timer.
Definition network.h:1185
bool hasRelays() const
Indicates if network's relay info has relay addresses.
Definition network.cc:54
void setDdnsConflictResolutionMode(const util::Optional< std::string > &ddns_conflict_resolution_mode)
Sets new ib-ddns-conflict-resolution-mode.
Definition network.h:797
util::Optional< bool > getDdnsOverrideNoUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-no-update.
Definition network.h:556
util::Optional< ClientClass > client_class_
Optional definition of a client class.
Definition network.h:1148
util::Optional< std::string > getAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type.
Definition network.h:805
void setHostnameCharSet(const util::Optional< std::string > &hostname_char_set)
Sets new hostname-char-set.
Definition network.h:695
util::Optional< std::string > getDdnsGeneratedPrefix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-generated-prefix.
Definition network.h:637
util::Optional< bool > getDdnsSendUpdates(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-send-updates.
Definition network.h:539
virtual data::ElementPtr toElement() const
Unparses network object.
Definition network.cc:117
void setReservationsOutOfPool(const util::Optional< bool > &reservations_out_of_pool)
Sets whether only out-of-pool reservations are allowed.
Definition network.h:470
util::Optional< std::string > hostname_char_set_
Regular expression describing invalid characters for client hostnames.
Definition network.h:1212
util::Optional< std::string > getDefaultAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type.
Definition network.h:830
util::Optional< std::string > getDdnsConflictResolutionMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ib-ddns-conflict-resolution-mode.
Definition network.h:787
void setDdnsGeneratedPrefix(const util::Optional< std::string > &ddns_generated_prefix)
Sets new ddns-generated-prefix.
Definition network.h:646
void setT1(const isc::util::Triplet< uint32_t > &t1)
Sets new renew timer for a network.
Definition network.h:401
bool hasRelayAddress(const asiolink::IOAddress &address) const
Tests if the network's relay info contains the given address.
Definition network.cc:59
util::Optional< double > getT2Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T2 (rebind timer).
Definition network.h:523
util::Optional< std::string > iface_name_
Holds interface name for which this network is selected.
Definition network.h:1136
void setFetchGlobalsFn(FetchNetworkGlobalsFn fetch_globals_fn)
Sets the optional callback function used to fetch globally configured parameters.
Definition network.h:235
isc::util::Triplet< uint32_t > getT2(const Inheritance &inheritance=Inheritance::ALL) const
Returns T2 (rebind timer), expressed in seconds.
Definition network.h:408
void setValid(const isc::util::Triplet< uint32_t > &valid)
Sets new valid lifetime for a network.
Definition network.h:386
virtual std::string getLabel() const
Generates an identifying label for logging.
Definition network.h:851
void setT2Percent(const util::Optional< double > &t2_percent)
Sets new percentage for calculating T2 (rebind timer).
Definition network.h:531
isc::util::Triplet< NumType > getGlobalProperty(isc::util::Triplet< NumType > property, const int global_index, const int min_index=-1, const int max_index=-1) const
The getGlobalProperty specialization for isc::util::Triplet<T>.
Definition network.h:930
const ClientClasses & getRequiredClasses() const
Returns classes which are required to be evaluated.
Definition network.cc:92
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
Definition network.h:1192
virtual ~Network()
Virtual destructor.
Definition network.h:229
util::Optional< std::string > ddns_conflict_resolution_mode_
DDNS conflict resolution mode.
Definition network.h:1232
util::Optional< bool > store_extended_info_
Should Kea store additional client query data (e.g.
Definition network.h:1220
isc::util::Triplet< uint32_t > valid_
a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
Definition network.h:1163
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this network.
Definition network.h:481
util::Optional< bool > getReservationsOutOfPool(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether only out-of-pool reservations are allowed.
Definition network.h:460
util::Optional< bool > calculate_tee_times_
Enables calculation of T1 and T2 timers.
Definition network.h:1182
util::Optional< uint32_t > cache_max_age_
Value in seconds to use as cache maximal age.
Definition network.h:1226
ReturnType getGlobalProperty(ReturnType property, const int global_index, const int min_index=-1, const int max_index=-1) const
Returns a value of global configuration parameter with a given index.
Definition network.h:892
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
Definition network.h:1196
void setCalculateTeeTimes(const util::Optional< bool > &calculate_tee_times)
Sets whether or not T1/T2 calculation is enabled.
Definition network.h:499
util::Optional< std::string > ddns_qualifying_suffix_
Suffix Kea should use when to qualify partial domain-names.
Definition network.h:1208
ClientClasses required_classes_
Required classes.
Definition network.h:1154
util::Optional< bool > getStoreExtendedInfo(const Inheritance &inheritance=Inheritance::ALL) const
Returns store-extended-info.
Definition network.h:719
void setDdnsOverrideNoUpdate(const util::Optional< bool > &ddns_override_no_update)
Sets new ddns-override-no-update.
Definition network.h:565
void setDefaultAllocatorType(const std::string &allocator_type)
Sets a defalt allocator type.
Definition network.h:839
util::Optional< bool > getReservationsInSubnet(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether subnet reservations should be fetched.
Definition network.h:442
void setHostnameCharReplacement(const util::Optional< std::string > &hostname_char_replacement)
Sets new hostname-char-replacement.
Definition network.h:710
util::Optional< uint32_t > getCacheMaxAge(const Inheritance &inheritance=Inheritance::ALL) const
Returns value in seconds to use as cache maximum age.
Definition network.h:753
void setReservationsGlobal(const util::Optional< bool > &reservations_global)
Sets whether global reservations should be fetched.
Definition network.h:434
util::Optional< double > getT1Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T1 (renew timer).
Definition network.h:507
void setDdnsSendUpdates(const util::Optional< bool > &ddns_send_updates)
Sets new ddns-send-updates.
Definition network.h:548
void setDdnsUpdateOnRenew(const util::Optional< bool > &ddns_update_on_renew)
Sets new ddns-update-on-renew.
Definition network.h:778
void setDdnsQualifyingSuffix(const util::Optional< std::string > &ddns_qualifying_suffix)
Sets new ddns-qualifying-suffix.
Definition network.h:663
util::Optional< double > ddns_ttl_percent_
Percentage of the lease lifetime to use for DNS TTL.
Definition network.h:1235
util::Optional< ClientClass > getClientClass(const Inheritance &inheritance=Inheritance::ALL) const
returns the client class
Definition network.h:368
util::Optional< std::string > getIface(const Inheritance &inheritance=Inheritance::ALL) const
Returns name of the local interface for which this network is selected.
Definition network.h:270
void setDdnsTtlPercent(const util::Optional< double > &ddns_ttl_percent)
Sets new ddns-ttl-percent.
Definition network.h:680
util::Optional< D2ClientConfig::ReplaceClientNameMode > ddns_replace_client_name_mode_
How Kea should handle the domain-name supplied by the client.
Definition network.h:1202
void setRelayInfo(const RelayInfo &relay)
Sets information about relay.
Definition network.h:294
isc::util::Triplet< uint32_t > getValid(const Inheritance &inheritance=Inheritance::ALL) const
Return valid-lifetime for addresses in that prefix.
Definition network.h:376
util::Optional< std::string > default_allocator_type_
Default allocator type.
Definition network.h:1244
isc::util::Triplet< uint32_t > t1_
a isc::util::Triplet (min/default/max) holding allowed renew timer values
Definition network.h:1157
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this network.
Definition network.h:475
util::Optional< double > cache_threshold_
Percentage of the lease lifetime to use as cache threshold.
Definition network.h:1223
A template representing an optional value.
Definition optional.h:36
This template specifies a parameter value.
Definition triplet.h:37
Defines the D2ClientConfig class.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
std::string ClientClass
Defines a single class name.
Definition classify.h:42
boost::shared_ptr< const CfgGlobals > ConstCfgGlobalsPtr
Const shared pointer to a CfgGlobals instance.
boost::shared_ptr< Network4 > Network4Ptr
Pointer to the Network4 object.
Definition network.h:1413
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition cfg_option.h:803
boost::shared_ptr< Network6 > Network6Ptr
Pointer to the Network6 object.
Definition network.h:1418
std::function< ConstCfgGlobalsPtr()> FetchNetworkGlobalsFn
Callback function for D2ClientConfig that retrieves globally configured parameters.
boost::weak_ptr< Network > WeakNetworkPtr
Weak pointer to the Network object.
Definition network.h:76
boost::multi_index_container< asiolink::IOAddress, boost::multi_index::indexed_by< boost::multi_index::sequenced< boost::multi_index::tag< IOAddressListListTag > >, boost::multi_index::hashed_unique< boost::multi_index::tag< IOAddressListSetTag >, boost::multi_index::identity< asiolink::IOAddress > > > > IOAddressList
List of IO addresses.
Definition network.h:67
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
Definition network.h:73
boost::shared_ptr< Option > OptionPtr
Definition option.h:37
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
Definition cfg_option.h:806
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.
Base class for user context.
Tag for the list of IO addresses as a list.
Definition network.h:46
Tag for the list of IO addresses as a set.
Definition network.h:49