Kea 2.7.5
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 addAdditionalClass(const isc::dhcp::ClientClass& class_name);
356
358 const ClientClasses& getAdditionalClasses() const;
359
364
373 getClientClass(const Inheritance& inheritance = Inheritance::ALL) const {
374 return (getProperty<Network>(&Network::getClientClass, client_class_,
375 inheritance));
376 }
377
387
392 valid_ = valid;
393 }
394
399 return (getProperty<Network>(&Network::getT1, t1_, inheritance,
401 }
402
407 t1_ = t1;
408 }
409
414 return (getProperty<Network>(&Network::getT2, t2_, inheritance,
416 }
417
422 t2_ = t2;
423 }
424
430 return (getProperty<Network>(&Network::getReservationsGlobal,
432 inheritance,
434 }
435
439 void setReservationsGlobal(const util::Optional<bool>& reservations_global) {
440 reservations_global_ = reservations_global;
441 }
442
448 return (getProperty<Network>(&Network::getReservationsInSubnet,
450 inheritance,
452 }
453
457 void setReservationsInSubnet(const util::Optional<bool>& reservations_in_subnet) {
458 reservations_in_subnet_ = reservations_in_subnet;
459 }
460
466 return (getProperty<Network>(&Network::getReservationsOutOfPool,
468 inheritance,
470 }
471
475 void setReservationsOutOfPool(const util::Optional<bool>& reservations_out_of_pool) {
476 reservations_out_of_pool_ = reservations_out_of_pool;
477 }
478
481 return (cfg_option_);
482 }
483
487 return (cfg_option_);
488 }
489
495 return (getProperty<Network>(&Network::getCalculateTeeTimes,
497 inheritance,
499 }
500
504 void setCalculateTeeTimes(const util::Optional<bool>& calculate_tee_times) {
505 calculate_tee_times_ = calculate_tee_times;
506 }
507
512 getT1Percent(const Inheritance& inheritance = Inheritance::ALL) const {
513 return (getProperty<Network>(&Network::getT1Percent, t1_percent_,
514 inheritance, CfgGlobals::T1_PERCENT));
515 }
516
520 void setT1Percent(const util::Optional<double>& t1_percent) {
521 t1_percent_ = t1_percent;
522 }
523
528 getT2Percent(const Inheritance& inheritance = Inheritance::ALL) const {
529 return (getProperty<Network>(&Network::getT2Percent, t2_percent_,
530 inheritance, CfgGlobals::T2_PERCENT));
531 }
532
536 void setT2Percent(const util::Optional<double>& t2_percent) {
537 t2_percent_ = t2_percent;
538 }
539
544 getDdnsSendUpdates(const Inheritance& inheritance = Inheritance::ALL) const {
545 return (getProperty<Network>(&Network::getDdnsSendUpdates,
546 ddns_send_updates_, inheritance,
548 }
549
553 void setDdnsSendUpdates(const util::Optional<bool>& ddns_send_updates) {
554 ddns_send_updates_ = ddns_send_updates;
555 }
556
562 return (getProperty<Network>(&Network::getDdnsOverrideNoUpdate,
563 ddns_override_no_update_, inheritance,
565 }
566
570 void setDdnsOverrideNoUpdate(const util::Optional<bool>& ddns_override_no_update) {
571 ddns_override_no_update_ = ddns_override_no_update;
572 }
573
583
588 ddns_override_client_update) {
589 ddns_override_client_update_ = ddns_override_client_update;
590 }
591
597 // Inheritance for ddns-replace-client-name is a little different than for other
598 // parameters. The value at the global level is given as a string.
599 // Thus we call getProperty here without a global name to check if it
600 // is specified on network level only.
602 getProperty<Network>(&Network::getDdnsReplaceClientNameMode,
603 ddns_replace_client_name_mode_, inheritance);
604
605 // If it is not specified at network level we need this special
606 // case code to convert the global string value to an enum.
607 if (mode.unspecified() && (inheritance != Inheritance::NONE) &&
608 (inheritance != Inheritance::PARENT_NETWORK)) {
609 // Get global mode.
611 mode_label = getGlobalProperty(mode_label,
613 if (!mode_label.unspecified()) {
614 try {
615 // If the mode is globally configured, convert it to an enum.
616 return (D2ClientConfig::stringToReplaceClientNameMode(mode_label.get()));
617 } catch (...) {
618 // This should not really happen because the configuration
619 // parser should have already verified the globally configured
620 // mode. However, we want to be 100% sure that this
621 // method doesn't throw. Let's just return unspecified.
622 return (mode);
623 }
624 }
625 }
626 return (mode);
627 }
628
632 void
634 ddns_replace_client_name_mode) {
635 ddns_replace_client_name_mode_ = ddns_replace_client_name_mode;
636 }
637
643 return (getProperty<Network>(&Network::getDdnsGeneratedPrefix,
644 ddns_generated_prefix_, inheritance,
646 }
647
651 void setDdnsGeneratedPrefix(const util::Optional<std::string>& ddns_generated_prefix) {
652 ddns_generated_prefix_ = ddns_generated_prefix;
653 }
654
660 return (getProperty<Network>(&Network::getDdnsQualifyingSuffix,
661 ddns_qualifying_suffix_, inheritance,
663 }
664
668 void setDdnsQualifyingSuffix(const util::Optional<std::string>& ddns_qualifying_suffix) {
669 ddns_qualifying_suffix_ = ddns_qualifying_suffix;
670 }
671
676 getDdnsTtlPercent(const Inheritance& inheritance = Inheritance::ALL) const {
677 return (getProperty<Network>(&Network::getDdnsTtlPercent,
678 ddns_ttl_percent_, inheritance,
680 }
681
685 void setDdnsTtlPercent(const util::Optional<double>& ddns_ttl_percent) {
686 ddns_ttl_percent_ = ddns_ttl_percent;
687 }
688
691 getHostnameCharSet(const Inheritance& inheritance = Inheritance::ALL) const {
692 return (getProperty<Network>(&Network::getHostnameCharSet,
693 hostname_char_set_, inheritance,
695 }
696
700 void setHostnameCharSet(const util::Optional<std::string>& hostname_char_set) {
701 hostname_char_set_ = hostname_char_set;
702 }
703
711
716 hostname_char_replacement) {
717 hostname_char_replacement_ = hostname_char_replacement;
718 }
719
725 return (getProperty<Network>(&Network::getStoreExtendedInfo,
726 store_extended_info_, inheritance,
728 }
729
733 void setStoreExtendedInfo(const util::Optional<bool>& store_extended_info) {
734 store_extended_info_ = store_extended_info;
735 }
736
741 getCacheThreshold(const Inheritance& inheritance = Inheritance::ALL) const {
742 return (getProperty<Network>(&Network::getCacheThreshold,
743 cache_threshold_, inheritance,
745 }
746
750 void setCacheThreshold(const util::Optional<double>& cache_threshold) {
751 cache_threshold_ = cache_threshold;
752 }
753
758 getCacheMaxAge(const Inheritance& inheritance = Inheritance::ALL) const {
759 return (getProperty<Network>(&Network::getCacheMaxAge, cache_max_age_,
760 inheritance, CfgGlobals::CACHE_MAX_AGE));
761 }
762
766 void setCacheMaxAge(const util::Optional<uint32_t>& cache_max_age) {
767 cache_max_age_ = cache_max_age;
768 }
769
775 return (getProperty<Network>(&Network::getDdnsUpdateOnRenew,
776 ddns_update_on_renew_, inheritance,
778 }
779
783 void setDdnsUpdateOnRenew(const util::Optional<bool>& ddns_update_on_renew) {
784 ddns_update_on_renew_ = ddns_update_on_renew;
785 }
786
787
798
802 void setDdnsConflictResolutionMode(const util::Optional<std::string>& ddns_conflict_resolution_mode) {
803 ddns_conflict_resolution_mode_ = ddns_conflict_resolution_mode;
804 }
805
810 getAllocatorType(const Inheritance& inheritance = Inheritance::ALL) const {
811 return (getProperty<Network>(&Network::getAllocatorType,
813 inheritance,
815 }
816
824 void setAllocatorType(const util::Optional<std::string>& allocator_type) {
825 allocator_type_ = allocator_type;
826 }
827
836 return (getProperty<Network>(&Network::getDefaultAllocatorType,
838 inheritance));
839 }
840
844 void setDefaultAllocatorType(const std::string& allocator_type) {
845 default_allocator_type_ = allocator_type;
846 }
847
851 virtual data::ElementPtr toElement() const;
852
856 virtual std::string getLabel() const {
857 return ("base-network");
858 }
859
860protected:
861
869
896 template<typename ReturnType>
897 ReturnType getGlobalProperty(ReturnType property,
898 const int global_index,
899 const int min_index = -1,
900 const int max_index = -1) const {
901 unused(min_index, max_index);
902 if ((global_index >= 0) && fetch_globals_fn_) {
904 if (globals) {
905 data::ConstElementPtr global_param = globals->get(global_index);
906 if (global_param) {
907 // If there is a global parameter, convert it to the
908 // optional value of the given type and return.
910 }
911 }
912 }
913 return (property);
914 }
915
934 template<typename NumType>
936 const int global_index,
937 const int min_index = -1,
938 const int max_index = -1) const {
939
940 if ((global_index >= 0) && fetch_globals_fn_) {
942 if (globals) {
943 data::ConstElementPtr param = globals->get(global_index);
944 if (param) {
945 NumType def_value = static_cast<NumType>(param->intValue());
946 if ((min_index < 0) || (max_index < 0)) {
947 return (def_value);
948 } else {
949 NumType min_value = def_value;
950 NumType max_value = def_value;
951 data::ConstElementPtr min_param = globals->get(min_index);
952 if (min_param) {
953 min_value = static_cast<NumType>(min_param->intValue());
954 }
955 data::ConstElementPtr max_param = globals->get(max_index);
956 if (max_param) {
957 max_value = static_cast<NumType>(max_param->intValue());
958 }
959 return (isc::util::Triplet<NumType>(min_value, def_value, max_value));
960 }
961 }
962 }
963 }
964 return (property);
965 }
966
989 const int global_index,
990 const int min_index = -1,
991 const int max_index = -1) const;
992
1023 template<typename BaseType, typename ReturnType>
1024 ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance&) const,
1025 ReturnType property,
1026 const Inheritance& inheritance,
1027 const int global_index = -1,
1028 const int min_index = -1,
1029 const int max_index = -1) const {
1030
1031 // If no inheritance is to be used, return the value for this
1032 // network regardless if it is specified or not.
1033 if (inheritance == Inheritance::NONE) {
1034 return (property);
1035
1036 } else if (inheritance == Inheritance::PARENT_NETWORK) {
1037 ReturnType parent_property;
1038
1039 // Check if this instance has a parent network.
1040 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1041 if (parent) {
1042 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1043 }
1044 return (parent_property);
1045
1046 // If global value requested, return it.
1047 } else if (inheritance == Inheritance::GLOBAL) {
1048 return (getGlobalProperty(ReturnType(), global_index, min_index, max_index));
1049 }
1050
1051 // We use inheritance and the value is not specified on the network level.
1052 // Hence, we need to get the parent network specific value or global value.
1053 if (property.unspecified()) {
1054 // Check if this instance has a parent network.
1055 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1056 // If the parent network exists, let's fetch the parent specific
1057 // value.
1058 if (parent) {
1059 // We're using inheritance so ask for the parent specific network
1060 // and return it only if it is specified.
1061 auto parent_property = ((*parent).*MethodPointer)(inheritance);
1062 if (!parent_property.unspecified()) {
1063 return (parent_property);
1064 }
1065 }
1066
1067 // The value is not specified on network level. If the value
1068 // can be specified on global level and there is a callback
1069 // that returns the global values, try to find this parameter
1070 // at the global scope.
1071 return (getGlobalProperty(property, global_index, min_index, max_index));
1072 }
1073
1074 // We haven't found the value at any level, so return the unspecified.
1075 return (property);
1076 }
1077
1098 template<typename BaseType>
1099 OptionPtr
1100 getOptionProperty(OptionPtr(BaseType::*MethodPointer)(const Inheritance& inheritance) const,
1101 OptionPtr property,
1102 const Inheritance& inheritance) const {
1103 if (inheritance == Network::Inheritance::NONE) {
1104 return (property);
1105
1106 } else if (inheritance == Network::Inheritance::PARENT_NETWORK) {
1107 OptionPtr parent_property;
1108 // Check if this instance has a parent network.
1109 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1110 // If the parent network exists, let's fetch the parent specific
1111 // value.
1112 if (parent) {
1113 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1114 }
1115 return (parent_property);
1116
1117 } else if (inheritance == Network::Inheritance::GLOBAL) {
1118 return (OptionPtr());
1119 }
1120
1121 // We use inheritance and the value is not specified on the network level.
1122 // Hence, we need to get the parent network specific value.
1123 if (!property) {
1124 // Check if this instance has a parent network.
1125 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1126 if (parent) {
1127 // We're using inheritance so ask for the parent specific network
1128 // and return it only if it is specified.
1129 OptionPtr parent_property = (((*parent).*MethodPointer)(inheritance));
1130 if (parent_property) {
1131 return (parent_property);
1132 }
1133 }
1134 }
1135
1136 // We haven't found the value at any level, so return the unspecified.
1137 return (property);
1138 }
1139
1142
1147
1154
1161
1164
1167
1170
1173
1176
1183
1186
1189
1192
1195
1199
1203
1206
1209
1212
1215
1219
1223
1227
1230
1233
1236
1239
1242
1245
1251
1259
1263};
1264
1266class Network4 : public virtual Network {
1267public:
1268
1271 : Network(), match_client_id_(true, true), authoritative_(),
1272 siaddr_(), sname_(), filename_(), offer_lft_() {
1273 }
1274
1281 getMatchClientId(const Inheritance& inheritance = Inheritance::ALL) const {
1282 return (getProperty<Network4>(&Network4::getMatchClientId,
1283 match_client_id_,
1284 inheritance,
1285 CfgGlobals::MATCH_CLIENT_ID));
1286 }
1287
1294 match_client_id_ = match;
1295 }
1296
1304 getAuthoritative(const Inheritance& inheritance = Inheritance::ALL) const {
1305 return (getProperty<Network4>(&Network4::getAuthoritative,
1306 authoritative_, inheritance,
1307 CfgGlobals::AUTHORITATIVE));
1308 }
1309
1315 void setAuthoritative(const util::Optional<bool>& authoritative) {
1316 authoritative_ = authoritative;
1317 }
1318
1324 void setSiaddr(const util::Optional<asiolink::IOAddress>& siaddr);
1325
1330 getSiaddr(const Inheritance& inheritance = Inheritance::ALL) const {
1331 return (getProperty<Network4>(&Network4::getSiaddr, siaddr_,
1332 inheritance, CfgGlobals::NEXT_SERVER));
1333 }
1334
1338 void setSname(const util::Optional<std::string>& sname);
1339
1345 getSname(const Inheritance& inheritance = Inheritance::ALL) const {
1346 return (getProperty<Network4>(&Network4::getSname, sname_,
1347 inheritance,
1348 CfgGlobals::SERVER_HOSTNAME));
1349 }
1350
1354 void setFilename(const util::Optional<std::string>& filename);
1355
1361 getFilename(const Inheritance& inheritance = Inheritance::ALL) const {
1362 return (getProperty<Network4>(&Network4::getFilename, filename_,
1363 inheritance,
1364 CfgGlobals::BOOT_FILE_NAME));
1365 }
1366
1370 void setOfferLft(const util::Optional<uint32_t>& offer_lft) {
1371 offer_lft_ = offer_lft;
1372 }
1373
1379 getOfferLft(const Inheritance& inheritance = Inheritance::ALL) const {
1380 return (getProperty<Network4>(&Network4::getOfferLft, offer_lft_,
1381 inheritance,
1382 CfgGlobals::OFFER_LIFETIME));
1383 }
1384
1388 virtual data::ElementPtr toElement() const;
1389
1394 virtual asiolink::IOAddress getServerId() const;
1395
1396private:
1397
1400 util::Optional<bool> match_client_id_;
1401
1403 util::Optional<bool> authoritative_;
1404
1407
1410
1413
1415 util::Optional<uint32_t> offer_lft_;
1416};
1417
1419typedef boost::shared_ptr<Network4> Network4Ptr;
1420
1421class Network6;
1422
1424typedef boost::shared_ptr<Network6> Network6Ptr;
1425
1427class Network6 : public virtual Network {
1428public:
1429
1432 : Network(), preferred_(), interface_id_(), rapid_commit_(),
1433 default_pd_allocator_type_(){
1434 }
1435
1441 getPreferred(const Inheritance& inheritance = Inheritance::ALL) const {
1442 return (getProperty<Network6>(&Network6::getPreferred, preferred_,
1443 inheritance,
1444 CfgGlobals::PREFERRED_LIFETIME,
1445 CfgGlobals::MIN_PREFERRED_LIFETIME,
1446 CfgGlobals::MAX_PREFERRED_LIFETIME));
1447 }
1448
1453 preferred_ = preferred;
1454 }
1455
1460 OptionPtr getInterfaceId(const Inheritance& inheritance = Inheritance::ALL) const {
1461 return (getOptionProperty<Network6>(&Network6::getInterfaceId, interface_id_,
1462 inheritance));
1463 }
1464
1468 void setInterfaceId(const OptionPtr& ifaceid) {
1469 interface_id_ = ifaceid;
1470 }
1471
1480 getRapidCommit(const Inheritance& inheritance = Inheritance::ALL) const {
1481
1482 return (getProperty<Network6>(&Network6::getRapidCommit, rapid_commit_,
1483 inheritance));
1484 }
1485
1490 void setRapidCommit(const util::Optional<bool>& rapid_commit) {
1491 rapid_commit_ = rapid_commit;
1492 }
1493
1498 getPdAllocatorType(const Inheritance& inheritance = Inheritance::ALL) const {
1499 return (getProperty<Network6>(&Network6::getPdAllocatorType,
1500 pd_allocator_type_,
1501 inheritance,
1502 CfgGlobals::PD_ALLOCATOR));
1503 }
1504
1513 pd_allocator_type_ = allocator_type;
1514 }
1515
1523 getDefaultPdAllocatorType(const Inheritance& inheritance = Inheritance::ALL) const {
1524 return (getProperty<Network6>(&Network6::getDefaultPdAllocatorType,
1525 default_pd_allocator_type_,
1526 inheritance));
1527 }
1528
1532 void setDefaultPdAllocatorType(const std::string& allocator_type) {
1533 default_pd_allocator_type_ = allocator_type;
1534 }
1535
1539 virtual data::ElementPtr toElement() const;
1540
1541private:
1542
1545
1547 OptionPtr interface_id_;
1548
1554 util::Optional<bool> rapid_commit_;
1555
1557 util::Optional<std::string> pd_allocator_type_;
1558
1559 // @brief Default allocator type for prefix delegation.
1560 util::Optional<std::string> default_pd_allocator_type_;
1561};
1562
1563} // end of namespace isc::dhcp
1564} // end of namespace isc
1565
1566#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:372
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:1266
util::Optional< std::string > getFilename(const Inheritance &inheritance=Inheritance::ALL) const
Returns boot file name for this subnet.
Definition network.h:1361
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:1293
util::Optional< std::string > getSname(const Inheritance &inheritance=Inheritance::ALL) const
Returns server hostname for this network.
Definition network.h:1345
util::Optional< asiolink::IOAddress > getSiaddr(const Inheritance &inheritance=Inheritance::ALL) const
Returns siaddr for this network.
Definition network.h:1330
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:1315
util::Optional< uint32_t > getOfferLft(const Inheritance &inheritance=Inheritance::ALL) const
Returns offer lifetime for the network.
Definition network.h:1379
void setOfferLft(const util::Optional< uint32_t > &offer_lft)
Sets offer lifetime for the network.
Definition network.h:1370
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:1281
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:1304
Network4()
Constructor.
Definition network.h:1270
Specialization of the Network object for DHCPv6 case.
Definition network.h:1427
void setRapidCommit(const util::Optional< bool > &rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
Definition network.h:1490
void setDefaultPdAllocatorType(const std::string &allocator_type)
Sets a defalt allocator type for prefix delegation.
Definition network.h:1532
util::Optional< std::string > getDefaultPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type for prefix delegation.
Definition network.h:1523
isc::util::Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds)
Definition network.h:1441
void setPdAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type for prefix delegation.
Definition network.h:1512
Network6()
Constructor.
Definition network.h:1431
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:1480
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
Definition network.h:1468
void setPreferred(const isc::util::Triplet< uint32_t > &preferred)
Sets new preferred lifetime for a network.
Definition network.h:1452
OptionPtr getInterfaceId(const Inheritance &inheritance=Inheritance::ALL) const
Returns interface-id value (if specified)
Definition network.h:1460
util::Optional< std::string > getPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type for prefix delegation.
Definition network.h:1498
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:494
util::Optional< std::string > getDdnsQualifyingSuffix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-qualifying-suffix.
Definition network.h:659
isc::util::Triplet< uint32_t > t2_
a isc::util::Triplet (min/default/max) holding allowed rebind timer values
Definition network.h:1166
util::Optional< D2ClientConfig::ReplaceClientNameMode > getDdnsReplaceClientNameMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-replace-client-name-mode.
Definition network.h:596
void setT2(const isc::util::Triplet< uint32_t > &t2)
Sets new rebind timer for a network.
Definition network.h:421
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:1222
RelayInfo relay_
Relay information.
Definition network.h:1146
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:741
util::Optional< bool > reservations_out_of_pool_
Enables out-of-pool reservations optimization.
Definition network.h:1182
util::Optional< std::string > getHostnameCharReplacement(const Inheritance &inheritance=Inheritance::ALL) const
Return the invalid char replacement used to sanitize client hostnames.
Definition network.h:706
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
Definition network.h:1235
util::Optional< std::string > allocator_type_
Allocator used for IP address allocations.
Definition network.h:1244
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
Definition network.h:1185
void setAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type.
Definition network.h:824
void setDdnsReplaceClientNameMode(const util::Optional< D2ClientConfig::ReplaceClientNameMode > &ddns_replace_client_name_mode)
Sets new ddns-replace-client-name-mode.
Definition network.h:633
Network()
Constructor.
Definition network.h:213
const IOAddressList & getRelayAddresses() const
Returns the list of relay addresses from the network's relay info.
Definition network.cc:64
ClientClasses & getMutableAdditionalClasses()
Returns the mutable additional classes list.
Definition network.h:361
void setCacheMaxAge(const util::Optional< uint32_t > &cache_max_age)
Sets cache max for a network.
Definition network.h:766
ClientClasses additional_classes_
Additional classes.
Definition network.h:1160
util::Optional< double > getDdnsTtlPercent(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl-percent.
Definition network.h:676
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:750
void setT1Percent(const util::Optional< double > &t1_percent)
Sets new percentage for calculating T1 (renew timer).
Definition network.h:520
util::Optional< bool > reservations_global_
Enables global reservations.
Definition network.h:1172
util::Optional< bool > getDdnsOverrideClientUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-client-update.
Definition network.h:578
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:1205
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:1100
util::Optional< bool > reservations_in_subnet_
Enables subnet reservations.
Definition network.h:1175
util::Optional< std::string > getHostnameCharSet(const Inheritance &inheritance=Inheritance::ALL) const
Return the char set regexp used to sanitize client hostnames.
Definition network.h:691
FetchNetworkGlobalsFn getFetchGlobalsFn() const
Gets the optional callback function used to fetch globally configured parameters.
Definition network.h:866
void setReservationsInSubnet(const util::Optional< bool > &reservations_in_subnet)
Sets whether subnet reservations should be fetched.
Definition network.h:457
FetchNetworkGlobalsFn fetch_globals_fn_
Pointer to the optional callback used to fetch globally configured parameters inherited to the Networ...
Definition network.h:1262
void setStoreExtendedInfo(const util::Optional< bool > &store_extended_info)
Sets new store-extended-info.
Definition network.h:733
util::Optional< double > t2_percent_
Percentage of the lease lifetime to use when calculating T2 timer.
Definition network.h:1194
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:774
void setDdnsOverrideClientUpdate(const util::Optional< bool > &ddns_override_client_update)
Sets new ddns-override-client-update.
Definition network.h:587
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:1258
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:1024
isc::util::Triplet< uint32_t > getT1(const Inheritance &inheritance=Inheritance::ALL) const
Returns T1 (renew timer), expressed in seconds.
Definition network.h:398
util::Optional< bool > getReservationsGlobal(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether global reservations should be fetched.
Definition network.h:429
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
Definition network.h:1211
util::Optional< double > t1_percent_
Percentage of the lease lifetime to use when calculating T1 timer.
Definition network.h:1191
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:802
util::Optional< bool > getDdnsOverrideNoUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-no-update.
Definition network.h:561
util::Optional< ClientClass > client_class_
Optional definition of a client class.
Definition network.h:1153
util::Optional< std::string > getAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type.
Definition network.h:810
void setHostnameCharSet(const util::Optional< std::string > &hostname_char_set)
Sets new hostname-char-set.
Definition network.h:700
util::Optional< std::string > getDdnsGeneratedPrefix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-generated-prefix.
Definition network.h:642
util::Optional< bool > getDdnsSendUpdates(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-send-updates.
Definition network.h:544
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:475
util::Optional< std::string > hostname_char_set_
Regular expression describing invalid characters for client hostnames.
Definition network.h:1218
util::Optional< std::string > getDefaultAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type.
Definition network.h:835
util::Optional< std::string > getDdnsConflictResolutionMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ib-ddns-conflict-resolution-mode.
Definition network.h:792
void setDdnsGeneratedPrefix(const util::Optional< std::string > &ddns_generated_prefix)
Sets new ddns-generated-prefix.
Definition network.h:651
void setT1(const isc::util::Triplet< uint32_t > &t1)
Sets new renew timer for a network.
Definition network.h:406
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:528
void addAdditionalClass(const isc::dhcp::ClientClass &class_name)
Adds class class_name to the additional classes list.
Definition network.cc:85
util::Optional< std::string > iface_name_
Holds interface name for which this network is selected.
Definition network.h:1141
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:413
void setValid(const isc::util::Triplet< uint32_t > &valid)
Sets new valid lifetime for a network.
Definition network.h:391
virtual std::string getLabel() const
Generates an identifying label for logging.
Definition network.h:856
void setT2Percent(const util::Optional< double > &t2_percent)
Sets new percentage for calculating T2 (rebind timer).
Definition network.h:536
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:935
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
Definition network.h:1198
virtual ~Network()
Virtual destructor.
Definition network.h:229
util::Optional< std::string > ddns_conflict_resolution_mode_
DDNS conflict resolution mode.
Definition network.h:1238
util::Optional< bool > store_extended_info_
Should Kea store additional client query data (e.g.
Definition network.h:1226
isc::util::Triplet< uint32_t > valid_
a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
Definition network.h:1169
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this network.
Definition network.h:486
const ClientClasses & getAdditionalClasses() const
Returns the additional classes list.
Definition network.cc:92
util::Optional< bool > getReservationsOutOfPool(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether only out-of-pool reservations are allowed.
Definition network.h:465
util::Optional< bool > calculate_tee_times_
Enables calculation of T1 and T2 timers.
Definition network.h:1188
util::Optional< uint32_t > cache_max_age_
Value in seconds to use as cache maximal age.
Definition network.h:1232
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:897
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
Definition network.h:1202
void setCalculateTeeTimes(const util::Optional< bool > &calculate_tee_times)
Sets whether or not T1/T2 calculation is enabled.
Definition network.h:504
util::Optional< std::string > ddns_qualifying_suffix_
Suffix Kea should use when to qualify partial domain-names.
Definition network.h:1214
util::Optional< bool > getStoreExtendedInfo(const Inheritance &inheritance=Inheritance::ALL) const
Returns store-extended-info.
Definition network.h:724
void setDdnsOverrideNoUpdate(const util::Optional< bool > &ddns_override_no_update)
Sets new ddns-override-no-update.
Definition network.h:570
void setDefaultAllocatorType(const std::string &allocator_type)
Sets a defalt allocator type.
Definition network.h:844
util::Optional< bool > getReservationsInSubnet(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether subnet reservations should be fetched.
Definition network.h:447
void setHostnameCharReplacement(const util::Optional< std::string > &hostname_char_replacement)
Sets new hostname-char-replacement.
Definition network.h:715
util::Optional< uint32_t > getCacheMaxAge(const Inheritance &inheritance=Inheritance::ALL) const
Returns value in seconds to use as cache maximum age.
Definition network.h:758
void setReservationsGlobal(const util::Optional< bool > &reservations_global)
Sets whether global reservations should be fetched.
Definition network.h:439
util::Optional< double > getT1Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T1 (renew timer).
Definition network.h:512
void setDdnsSendUpdates(const util::Optional< bool > &ddns_send_updates)
Sets new ddns-send-updates.
Definition network.h:553
void setDdnsUpdateOnRenew(const util::Optional< bool > &ddns_update_on_renew)
Sets new ddns-update-on-renew.
Definition network.h:783
void setDdnsQualifyingSuffix(const util::Optional< std::string > &ddns_qualifying_suffix)
Sets new ddns-qualifying-suffix.
Definition network.h:668
util::Optional< double > ddns_ttl_percent_
Percentage of the lease lifetime to use for DNS TTL.
Definition network.h:1241
util::Optional< ClientClass > getClientClass(const Inheritance &inheritance=Inheritance::ALL) const
returns the client class
Definition network.h:373
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:685
util::Optional< D2ClientConfig::ReplaceClientNameMode > ddns_replace_client_name_mode_
How Kea should handle the domain-name supplied by the client.
Definition network.h:1208
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:381
util::Optional< std::string > default_allocator_type_
Default allocator type.
Definition network.h:1250
isc::util::Triplet< uint32_t > t1_
a isc::util::Triplet (min/default/max) holding allowed renew timer values
Definition network.h:1163
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this network.
Definition network.h:480
util::Optional< double > cache_threshold_
Percentage of the lease lifetime to use as cache threshold.
Definition network.h:1229
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:1419
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition cfg_option.h:832
boost::shared_ptr< Network6 > Network6Ptr
Pointer to the Network6 object.
Definition network.h:1424
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:835
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