Kea 2.7.6
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
226
230 virtual ~Network() { }
231
237 fetch_globals_fn_ = fetch_globals_fn;
238 }
239
244 bool hasFetchGlobalsFn() const {
245 return (static_cast<bool>(fetch_globals_fn_));
246 }
247
257 void setIface(const util::Optional<std::string>& iface_name) {
258 if (iface_name.empty()) {
260 } else {
261 iface_name_ = iface_name;
262 }
263 }
264
271 getIface(const Inheritance& inheritance = Inheritance::ALL) const {
273 inheritance));
274 }
275
295 void setRelayInfo(const RelayInfo& relay) {
296 relay_ = relay;
297 }
298
305 const RelayInfo& getRelayInfo() const {
306 return (relay_);
307 }
308
313 void addRelayAddress(const asiolink::IOAddress& addr);
314
318 const IOAddressList& getRelayAddresses() const;
319
323 bool hasRelays() const;
324
329 bool hasRelayAddress(const asiolink::IOAddress& address) const;
330
342 virtual bool
343 clientSupported(const isc::dhcp::ClientClasses& client_classes) const;
344
348 void allowClientClass(const isc::dhcp::ClientClass& class_name);
349
352 return (client_classes_);
353 }
354
359
363 void addAdditionalClass(const isc::dhcp::ClientClass& class_name);
364
367 return (additional_classes_);
368 }
369
374
384
389 valid_ = valid;
390 }
391
399
404 t1_ = t1;
405 }
406
414
419 t2_ = t2;
420 }
421
432
436 void setReservationsGlobal(const util::Optional<bool>& reservations_global) {
437 reservations_global_ = reservations_global;
438 }
439
450
454 void setReservationsInSubnet(const util::Optional<bool>& reservations_in_subnet) {
455 reservations_in_subnet_ = reservations_in_subnet;
456 }
457
468
472 void setReservationsOutOfPool(const util::Optional<bool>& reservations_out_of_pool) {
473 reservations_out_of_pool_ = reservations_out_of_pool;
474 }
475
478 return (cfg_option_);
479 }
480
484 return (cfg_option_);
485 }
486
497
501 void setCalculateTeeTimes(const util::Optional<bool>& calculate_tee_times) {
502 calculate_tee_times_ = calculate_tee_times;
503 }
504
509 getT1Percent(const Inheritance& inheritance = Inheritance::ALL) const {
511 inheritance, CfgGlobals::T1_PERCENT));
512 }
513
517 void setT1Percent(const util::Optional<double>& t1_percent) {
518 t1_percent_ = t1_percent;
519 }
520
525 getT2Percent(const Inheritance& inheritance = Inheritance::ALL) const {
527 inheritance, CfgGlobals::T2_PERCENT));
528 }
529
533 void setT2Percent(const util::Optional<double>& t2_percent) {
534 t2_percent_ = t2_percent;
535 }
536
546
550 void setDdnsSendUpdates(const util::Optional<bool>& ddns_send_updates) {
551 ddns_send_updates_ = ddns_send_updates;
552 }
553
563
567 void setDdnsOverrideNoUpdate(const util::Optional<bool>& ddns_override_no_update) {
568 ddns_override_no_update_ = ddns_override_no_update;
569 }
570
580
585 ddns_override_client_update) {
586 ddns_override_client_update_ = ddns_override_client_update;
587 }
588
594 // Inheritance for ddns-replace-client-name is a little different than for other
595 // parameters. The value at the global level is given as a string.
596 // Thus we call getProperty here without a global name to check if it
597 // is specified on network level only.
600 ddns_replace_client_name_mode_, inheritance);
601
602 // If it is not specified at network level we need this special
603 // case code to convert the global string value to an enum.
604 if (mode.unspecified() && (inheritance != Inheritance::NONE) &&
605 (inheritance != Inheritance::PARENT_NETWORK)) {
606 // Get global mode.
608 mode_label = getGlobalProperty(mode_label,
610 if (!mode_label.unspecified()) {
611 try {
612 // If the mode is globally configured, convert it to an enum.
614 } catch (...) {
615 // This should not really happen because the configuration
616 // parser should have already verified the globally configured
617 // mode. However, we want to be 100% sure that this
618 // method doesn't throw. Let's just return unspecified.
619 return (mode);
620 }
621 }
622 }
623 return (mode);
624 }
625
629 void
631 ddns_replace_client_name_mode) {
632 ddns_replace_client_name_mode_ = ddns_replace_client_name_mode;
633 }
634
644
648 void setDdnsGeneratedPrefix(const util::Optional<std::string>& ddns_generated_prefix) {
649 ddns_generated_prefix_ = ddns_generated_prefix;
650 }
651
661
665 void setDdnsQualifyingSuffix(const util::Optional<std::string>& ddns_qualifying_suffix) {
666 ddns_qualifying_suffix_ = ddns_qualifying_suffix;
667 }
668
678
682 void setDdnsTtlPercent(const util::Optional<double>& ddns_ttl_percent) {
683 ddns_ttl_percent_ = ddns_ttl_percent;
684 }
685
686
691 getDdnsTtl(const Inheritance& inheritance = Inheritance::ALL) const {
693 ddns_ttl_, inheritance,
695 }
696
700 void setDdnsTtl(const util::Optional<uint32_t>& ddns_ttl) {
701 ddns_ttl_ = ddns_ttl;
702 }
703
704
709 getDdnsTtlMin(const Inheritance& inheritance = Inheritance::ALL) const {
711 ddns_ttl_min_, inheritance,
713 }
714
718 void setDdnsTtlMin(const util::Optional<uint32_t>& ddns_ttl_min) {
719 ddns_ttl_min_ = ddns_ttl_min;
720 }
721
726 getDdnsTtlMax(const Inheritance& inheritance = Inheritance::ALL) const {
728 ddns_ttl_max_, inheritance,
730 }
731
735 void setDdnsTtlMax(const util::Optional<uint32_t>& ddns_ttl_max) {
736 ddns_ttl_max_ = ddns_ttl_max;
737 }
738
746
750 void setHostnameCharSet(const util::Optional<std::string>& hostname_char_set) {
751 hostname_char_set_ = hostname_char_set;
752 }
753
761
766 hostname_char_replacement) {
767 hostname_char_replacement_ = hostname_char_replacement;
768 }
769
779
783 void setStoreExtendedInfo(const util::Optional<bool>& store_extended_info) {
784 store_extended_info_ = store_extended_info;
785 }
786
796
800 void setCacheThreshold(const util::Optional<double>& cache_threshold) {
801 cache_threshold_ = cache_threshold;
802 }
803
812
816 void setCacheMaxAge(const util::Optional<uint32_t>& cache_max_age) {
817 cache_max_age_ = cache_max_age;
818 }
819
829
833 void setDdnsUpdateOnRenew(const util::Optional<bool>& ddns_update_on_renew) {
834 ddns_update_on_renew_ = ddns_update_on_renew;
835 }
836
837
848
852 void setDdnsConflictResolutionMode(const util::Optional<std::string>& ddns_conflict_resolution_mode) {
853 ddns_conflict_resolution_mode_ = ddns_conflict_resolution_mode;
854 }
855
860 getAllocatorType(const Inheritance& inheritance = Inheritance::ALL) const {
863 inheritance,
865 }
866
874 void setAllocatorType(const util::Optional<std::string>& allocator_type) {
875 allocator_type_ = allocator_type;
876 }
877
890
894 void setDefaultAllocatorType(const std::string& allocator_type) {
895 default_allocator_type_ = allocator_type;
896 }
897
901 virtual data::ElementPtr toElement() const;
902
906 virtual std::string getLabel() const {
907 return ("base-network");
908 }
909
910protected:
911
919
946 template<typename ReturnType>
947 ReturnType getGlobalProperty(ReturnType property,
948 const int global_index,
949 const int min_index = -1,
950 const int max_index = -1) const {
951 unused(min_index, max_index);
952 if ((global_index >= 0) && fetch_globals_fn_) {
954 if (globals) {
955 data::ConstElementPtr global_param = globals->get(global_index);
956 if (global_param) {
957 // If there is a global parameter, convert it to the
958 // optional value of the given type and return.
960 }
961 }
962 }
963 return (property);
964 }
965
984 template<typename NumType>
986 const int global_index,
987 const int min_index = -1,
988 const int max_index = -1) const {
989
990 if ((global_index >= 0) && fetch_globals_fn_) {
992 if (globals) {
993 data::ConstElementPtr param = globals->get(global_index);
994 if (param) {
995 NumType def_value = static_cast<NumType>(param->intValue());
996 if ((min_index < 0) || (max_index < 0)) {
997 return (def_value);
998 } else {
999 NumType min_value = def_value;
1000 NumType max_value = def_value;
1001 data::ConstElementPtr min_param = globals->get(min_index);
1002 if (min_param) {
1003 min_value = static_cast<NumType>(min_param->intValue());
1004 }
1005 data::ConstElementPtr max_param = globals->get(max_index);
1006 if (max_param) {
1007 max_value = static_cast<NumType>(max_param->intValue());
1008 }
1009 return (isc::util::Triplet<NumType>(min_value, def_value, max_value));
1010 }
1011 }
1012 }
1013 }
1014 return (property);
1015 }
1016
1039 const int global_index,
1040 const int min_index = -1,
1041 const int max_index = -1) const;
1042
1073 template<typename BaseType, typename ReturnType>
1074 ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance&) const,
1075 ReturnType property,
1076 const Inheritance& inheritance,
1077 const int global_index = -1,
1078 const int min_index = -1,
1079 const int max_index = -1) const {
1080
1081 // If no inheritance is to be used, return the value for this
1082 // network regardless if it is specified or not.
1083 if (inheritance == Inheritance::NONE) {
1084 return (property);
1085
1086 } else if (inheritance == Inheritance::PARENT_NETWORK) {
1087 ReturnType parent_property;
1088
1089 // Check if this instance has a parent network.
1090 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1091 if (parent) {
1092 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1093 }
1094 return (parent_property);
1095
1096 // If global value requested, return it.
1097 } else if (inheritance == Inheritance::GLOBAL) {
1098 return (getGlobalProperty(ReturnType(), global_index, min_index, max_index));
1099 }
1100
1101 // We use inheritance and the value is not specified on the network level.
1102 // Hence, we need to get the parent network specific value or global value.
1103 if (property.unspecified()) {
1104 // Check if this instance has a parent network.
1105 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1106 // If the parent network exists, let's fetch the parent specific
1107 // value.
1108 if (parent) {
1109 // We're using inheritance so ask for the parent specific network
1110 // and return it only if it is specified.
1111 auto parent_property = ((*parent).*MethodPointer)(inheritance);
1112 if (!parent_property.unspecified()) {
1113 return (parent_property);
1114 }
1115 }
1116
1117 // The value is not specified on network level. If the value
1118 // can be specified on global level and there is a callback
1119 // that returns the global values, try to find this parameter
1120 // at the global scope.
1121 return (getGlobalProperty(property, global_index, min_index, max_index));
1122 }
1123
1124 // We haven't found the value at any level, so return the unspecified.
1125 return (property);
1126 }
1127
1148 template<typename BaseType>
1149 OptionPtr
1150 getOptionProperty(OptionPtr(BaseType::*MethodPointer)(const Inheritance& inheritance) const,
1151 OptionPtr property,
1152 const Inheritance& inheritance) const {
1153 if (inheritance == Network::Inheritance::NONE) {
1154 return (property);
1155
1156 } else if (inheritance == Network::Inheritance::PARENT_NETWORK) {
1157 OptionPtr parent_property;
1158 // Check if this instance has a parent network.
1159 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1160 // If the parent network exists, let's fetch the parent specific
1161 // value.
1162 if (parent) {
1163 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1164 }
1165 return (parent_property);
1166
1167 } else if (inheritance == Network::Inheritance::GLOBAL) {
1168 return (OptionPtr());
1169 }
1170
1171 // We use inheritance and the value is not specified on the network level.
1172 // Hence, we need to get the parent network specific value.
1173 if (!property) {
1174 // Check if this instance has a parent network.
1175 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1176 if (parent) {
1177 // We're using inheritance so ask for the parent specific network
1178 // and return it only if it is specified.
1179 OptionPtr parent_property = (((*parent).*MethodPointer)(inheritance));
1180 if (parent_property) {
1181 return (parent_property);
1182 }
1183 }
1184 }
1185
1186 // We haven't found the value at any level, so return the unspecified.
1187 return (property);
1188 }
1189
1192
1197
1205
1212
1215
1218
1221
1224
1227
1234
1237
1240
1243
1246
1250
1254
1257
1260
1263
1266
1270
1274
1278
1281
1284
1287
1290
1293
1296
1299
1302
1305
1311
1319
1323};
1324
1326class Network4 : public virtual Network {
1327public:
1328
1331 : Network(), match_client_id_(true, true), authoritative_(),
1332 siaddr_(), sname_(), filename_(), offer_lft_() {
1333 }
1334
1341 getMatchClientId(const Inheritance& inheritance = Inheritance::ALL) const {
1343 match_client_id_,
1344 inheritance,
1346 }
1347
1354 match_client_id_ = match;
1355 }
1356
1364 getAuthoritative(const Inheritance& inheritance = Inheritance::ALL) const {
1366 authoritative_, inheritance,
1368 }
1369
1375 void setAuthoritative(const util::Optional<bool>& authoritative) {
1376 authoritative_ = authoritative;
1377 }
1378
1385
1390 getSiaddr(const Inheritance& inheritance = Inheritance::ALL) const {
1392 inheritance, CfgGlobals::NEXT_SERVER));
1393 }
1394
1398 void setSname(const util::Optional<std::string>& sname);
1399
1405 getSname(const Inheritance& inheritance = Inheritance::ALL) const {
1407 inheritance,
1409 }
1410
1414 void setFilename(const util::Optional<std::string>& filename);
1415
1421 getFilename(const Inheritance& inheritance = Inheritance::ALL) const {
1422 return (getProperty<Network4>(&Network4::getFilename, filename_,
1423 inheritance,
1425 }
1426
1430 void setOfferLft(const util::Optional<uint32_t>& offer_lft) {
1431 offer_lft_ = offer_lft;
1432 }
1433
1439 getOfferLft(const Inheritance& inheritance = Inheritance::ALL) const {
1440 return (getProperty<Network4>(&Network4::getOfferLft, offer_lft_,
1441 inheritance,
1443 }
1444
1448 virtual data::ElementPtr toElement() const;
1449
1454 virtual asiolink::IOAddress getServerId() const;
1455
1456private:
1457
1460 util::Optional<bool> match_client_id_;
1461
1463 util::Optional<bool> authoritative_;
1464
1467
1470
1473
1475 util::Optional<uint32_t> offer_lft_;
1476};
1477
1479typedef boost::shared_ptr<Network4> Network4Ptr;
1480
1481class Network6;
1482
1484typedef boost::shared_ptr<Network6> Network6Ptr;
1485
1487class Network6 : public virtual Network {
1488public:
1489
1492 : Network(), preferred_(), interface_id_(), rapid_commit_(),
1493 default_pd_allocator_type_(){
1494 }
1495
1508
1513 preferred_ = preferred;
1514 }
1515
1522 inheritance));
1523 }
1524
1528 void setInterfaceId(const OptionPtr& ifaceid) {
1529 interface_id_ = ifaceid;
1530 }
1531
1540 getRapidCommit(const Inheritance& inheritance = Inheritance::ALL) const {
1541
1542 return (getProperty<Network6>(&Network6::getRapidCommit, rapid_commit_,
1543 inheritance));
1544 }
1545
1550 void setRapidCommit(const util::Optional<bool>& rapid_commit) {
1551 rapid_commit_ = rapid_commit;
1552 }
1553
1560 pd_allocator_type_,
1561 inheritance,
1563 }
1564
1573 pd_allocator_type_ = allocator_type;
1574 }
1575
1585 default_pd_allocator_type_,
1586 inheritance));
1587 }
1588
1592 void setDefaultPdAllocatorType(const std::string& allocator_type) {
1593 default_pd_allocator_type_ = allocator_type;
1594 }
1595
1599 virtual data::ElementPtr toElement() const;
1600
1601private:
1602
1605
1607 OptionPtr interface_id_;
1608
1614 util::Optional<bool> rapid_commit_;
1615
1617 util::Optional<std::string> pd_allocator_type_;
1618
1619 // @brief Default allocator type for prefix delegation.
1620 util::Optional<std::string> default_pd_allocator_type_;
1621};
1622
1623} // end of namespace isc::dhcp
1624} // end of namespace isc
1625
1626#endif // NETWORK_H
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:109
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:1326
util::Optional< std::string > getFilename(const Inheritance &inheritance=Inheritance::ALL) const
Returns boot file name for this subnet.
Definition network.h:1421
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:1353
util::Optional< std::string > getSname(const Inheritance &inheritance=Inheritance::ALL) const
Returns server hostname for this network.
Definition network.h:1405
util::Optional< asiolink::IOAddress > getSiaddr(const Inheritance &inheritance=Inheritance::ALL) const
Returns siaddr for this network.
Definition network.h:1390
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:1375
void setSiaddr(const util::Optional< asiolink::IOAddress > &siaddr)
Sets siaddr for the network.
Definition network.cc:283
util::Optional< uint32_t > getOfferLft(const Inheritance &inheritance=Inheritance::ALL) const
Returns offer lifetime for the network.
Definition network.h:1439
void setOfferLft(const util::Optional< uint32_t > &offer_lft)
Sets offer lifetime for the network.
Definition network.h:1430
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:1341
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:1364
void setFilename(const util::Optional< std::string > &filename)
Sets boot file name for the network.
Definition network.cc:297
virtual asiolink::IOAddress getServerId() const
Returns binary representation of the dhcp-server-identifier option (54).
Definition network.cc:339
Network4()
Constructor.
Definition network.h:1330
virtual data::ElementPtr toElement() const
Unparses network object.
Definition network.cc:302
void setSname(const util::Optional< std::string > &sname)
Sets server hostname for the network.
Definition network.cc:292
Specialization of the Network object for DHCPv6 case.
Definition network.h:1487
void setRapidCommit(const util::Optional< bool > &rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
Definition network.h:1550
void setDefaultPdAllocatorType(const std::string &allocator_type)
Sets a defalt allocator type for prefix delegation.
Definition network.h:1592
util::Optional< std::string > getDefaultPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type for prefix delegation.
Definition network.h:1583
isc::util::Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds)
Definition network.h:1501
void setPdAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type for prefix delegation.
Definition network.h:1572
Network6()
Constructor.
Definition network.h:1491
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:1540
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
Definition network.h:1528
void setPreferred(const isc::util::Triplet< uint32_t > &preferred)
Sets new preferred lifetime for a network.
Definition network.h:1512
virtual data::ElementPtr toElement() const
Unparses network object.
Definition network.cc:354
OptionPtr getInterfaceId(const Inheritance &inheritance=Inheritance::ALL) const
Returns interface-id value (if specified)
Definition network.h:1520
util::Optional< std::string > getPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type for prefix delegation.
Definition network.h:1558
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 a client that belongs to the 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:491
util::Optional< std::string > getDdnsQualifyingSuffix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-qualifying-suffix.
Definition network.h:656
isc::util::Triplet< uint32_t > t2_
a isc::util::Triplet (min/default/max) holding allowed rebind timer values
Definition network.h:1217
util::Optional< D2ClientConfig::ReplaceClientNameMode > getDdnsReplaceClientNameMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-replace-client-name-mode.
Definition network.h:593
void setT2(const isc::util::Triplet< uint32_t > &t2)
Sets new rebind timer for a network.
Definition network.h:418
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:1273
RelayInfo relay_
Relay information.
Definition network.h:1196
util::Optional< double > getCacheThreshold(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use as cache threshold.
Definition network.h:791
util::Optional< bool > reservations_out_of_pool_
Enables out-of-pool reservations optimization.
Definition network.h:1233
util::Optional< std::string > getHostnameCharReplacement(const Inheritance &inheritance=Inheritance::ALL) const
Return the invalid char replacement used to sanitize client hostnames.
Definition network.h:756
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
Definition network.h:1286
util::Optional< std::string > allocator_type_
Allocator used for IP address allocations.
Definition network.h:1304
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
Definition network.h:1236
void setAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type.
Definition network.h:874
void setDdnsReplaceClientNameMode(const util::Optional< D2ClientConfig::ReplaceClientNameMode > &ddns_replace_client_name_mode)
Sets new ddns-replace-client-name-mode.
Definition network.h:630
Network()
Constructor.
Definition network.h:213
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
Definition network.h:210
void setDdnsTtlMin(const util::Optional< uint32_t > &ddns_ttl_min)
Sets new ddns-ttl-min.
Definition network.h:718
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:371
void setCacheMaxAge(const util::Optional< uint32_t > &cache_max_age)
Sets cache max for a network.
Definition network.h:816
ClientClasses additional_classes_
Additional classes.
Definition network.h:1211
util::Optional< double > getDdnsTtlPercent(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl-percent.
Definition network.h:673
void allowClientClass(const isc::dhcp::ClientClass &class_name)
Adds class clas_name to the allowed client classes list.
Definition network.cc:79
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:800
void setT1Percent(const util::Optional< double > &t1_percent)
Sets new percentage for calculating T1 (renew timer).
Definition network.h:517
util::Optional< bool > reservations_global_
Enables global reservations.
Definition network.h:1223
util::Optional< bool > getDdnsOverrideClientUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-client-update.
Definition network.h:575
bool hasFetchGlobalsFn() const
Checks if the network is associated with a function used to fetch globally configured parameters.
Definition network.h:244
util::Optional< bool > ddns_override_client_update_
Should Kea perform updates, even if client requested delegation.
Definition network.h:1256
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:1150
void setDdnsTtlMax(const util::Optional< uint32_t > &ddns_ttl_max)
Sets new ddns-ttl-max.
Definition network.h:735
util::Optional< bool > reservations_in_subnet_
Enables subnet reservations.
Definition network.h:1226
util::Optional< std::string > getHostnameCharSet(const Inheritance &inheritance=Inheritance::ALL) const
Return the char set regexp used to sanitize client hostnames.
Definition network.h:741
FetchNetworkGlobalsFn getFetchGlobalsFn() const
Gets the optional callback function used to fetch globally configured parameters.
Definition network.h:916
void setReservationsInSubnet(const util::Optional< bool > &reservations_in_subnet)
Sets whether subnet reservations should be fetched.
Definition network.h:454
FetchNetworkGlobalsFn fetch_globals_fn_
Pointer to the optional callback used to fetch globally configured parameters inherited to the Networ...
Definition network.h:1322
void setStoreExtendedInfo(const util::Optional< bool > &store_extended_info)
Sets new store-extended-info.
Definition network.h:783
util::Optional< double > t2_percent_
Percentage of the lease lifetime to use when calculating T2 timer.
Definition network.h:1245
void setIface(const util::Optional< std::string > &iface_name)
Sets local name of the interface for which this network is selected.
Definition network.h:257
util::Optional< bool > getDdnsUpdateOnRenew(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-update-on-renew.
Definition network.h:824
util::Optional< uint32_t > getDdnsTtlMax(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl-max.
Definition network.h:726
ClientClasses client_classes_
List of client classes allowed to use this network.
Definition network.h:1204
void setDdnsOverrideClientUpdate(const util::Optional< bool > &ddns_override_client_update)
Sets new ddns-override-client-update.
Definition network.h:584
const ClientClasses & getClientClasses() const
Returns the list of allowed client classes.
Definition network.h:351
const RelayInfo & getRelayInfo() const
Returns const reference to relay information.
Definition network.h:305
WeakNetworkPtr parent_network_
Pointer to another network that this network belongs to.
Definition network.h:1318
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:1074
isc::util::Triplet< uint32_t > getT1(const Inheritance &inheritance=Inheritance::ALL) const
Returns T1 (renew timer), expressed in seconds.
Definition network.h:395
util::Optional< bool > getReservationsGlobal(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether global reservations should be fetched.
Definition network.h:426
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
Definition network.h:1262
util::Optional< double > t1_percent_
Percentage of the lease lifetime to use when calculating T1 timer.
Definition network.h:1242
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:852
util::Optional< uint32_t > ddns_ttl_min_
Minimum value to use for DNS TTL.
Definition network.h:1298
util::Optional< bool > getDdnsOverrideNoUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-no-update.
Definition network.h:558
util::Optional< std::string > getAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type.
Definition network.h:860
void setHostnameCharSet(const util::Optional< std::string > &hostname_char_set)
Sets new hostname-char-set.
Definition network.h:750
util::Optional< std::string > getDdnsGeneratedPrefix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-generated-prefix.
Definition network.h:639
void setDdnsTtl(const util::Optional< uint32_t > &ddns_ttl)
Sets new ddns-ttl.
Definition network.h:700
util::Optional< bool > getDdnsSendUpdates(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-send-updates.
Definition network.h:541
virtual data::ElementPtr toElement() const
Unparses network object.
Definition network.cc:113
void setReservationsOutOfPool(const util::Optional< bool > &reservations_out_of_pool)
Sets whether only out-of-pool reservations are allowed.
Definition network.h:472
util::Optional< std::string > hostname_char_set_
Regular expression describing invalid characters for client hostnames.
Definition network.h:1269
util::Optional< std::string > getDefaultAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type.
Definition network.h:885
util::Optional< std::string > getDdnsConflictResolutionMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ib-ddns-conflict-resolution-mode.
Definition network.h:842
void setDdnsGeneratedPrefix(const util::Optional< std::string > &ddns_generated_prefix)
Sets new ddns-generated-prefix.
Definition network.h:648
void setT1(const isc::util::Triplet< uint32_t > &t1)
Sets new renew timer for a network.
Definition network.h:403
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:525
util::Optional< uint32_t > getDdnsTtl(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl.
Definition network.h:691
void addAdditionalClass(const isc::dhcp::ClientClass &class_name)
Adds class class_name to the additional classes list.
Definition network.cc:86
util::Optional< std::string > iface_name_
Holds interface name for which this network is selected.
Definition network.h:1191
void setFetchGlobalsFn(FetchNetworkGlobalsFn fetch_globals_fn)
Sets the optional callback function used to fetch globally configured parameters.
Definition network.h:236
isc::util::Triplet< uint32_t > getT2(const Inheritance &inheritance=Inheritance::ALL) const
Returns T2 (rebind timer), expressed in seconds.
Definition network.h:410
void setValid(const isc::util::Triplet< uint32_t > &valid)
Sets new valid lifetime for a network.
Definition network.h:388
virtual std::string getLabel() const
Generates an identifying label for logging.
Definition network.h:906
void setT2Percent(const util::Optional< double > &t2_percent)
Sets new percentage for calculating T2 (rebind timer).
Definition network.h:533
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:985
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
Definition network.h:1249
virtual ~Network()
Virtual destructor.
Definition network.h:230
util::Optional< std::string > ddns_conflict_resolution_mode_
DDNS conflict resolution mode.
Definition network.h:1289
util::Optional< bool > store_extended_info_
Should Kea store additional client query data (e.g.
Definition network.h:1277
isc::util::Triplet< uint32_t > valid_
a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
Definition network.h:1220
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this network.
Definition network.h:483
const ClientClasses & getAdditionalClasses() const
Returns the additional classes list.
Definition network.h:366
util::Optional< bool > getReservationsOutOfPool(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether only out-of-pool reservations are allowed.
Definition network.h:462
util::Optional< bool > calculate_tee_times_
Enables calculation of T1 and T2 timers.
Definition network.h:1239
util::Optional< uint32_t > cache_max_age_
Value in seconds to use as cache maximal age.
Definition network.h:1283
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:947
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
Definition network.h:1253
void setCalculateTeeTimes(const util::Optional< bool > &calculate_tee_times)
Sets whether or not T1/T2 calculation is enabled.
Definition network.h:501
util::Optional< std::string > ddns_qualifying_suffix_
Suffix Kea should use when to qualify partial domain-names.
Definition network.h:1265
util::Optional< bool > getStoreExtendedInfo(const Inheritance &inheritance=Inheritance::ALL) const
Returns store-extended-info.
Definition network.h:774
void setDdnsOverrideNoUpdate(const util::Optional< bool > &ddns_override_no_update)
Sets new ddns-override-no-update.
Definition network.h:567
void setDefaultAllocatorType(const std::string &allocator_type)
Sets a defalt allocator type.
Definition network.h:894
util::Optional< bool > getReservationsInSubnet(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether subnet reservations should be fetched.
Definition network.h:444
void setHostnameCharReplacement(const util::Optional< std::string > &hostname_char_replacement)
Sets new hostname-char-replacement.
Definition network.h:765
util::Optional< uint32_t > getCacheMaxAge(const Inheritance &inheritance=Inheritance::ALL) const
Returns value in seconds to use as cache maximum age.
Definition network.h:808
void setReservationsGlobal(const util::Optional< bool > &reservations_global)
Sets whether global reservations should be fetched.
Definition network.h:436
util::Optional< double > getT1Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T1 (renew timer).
Definition network.h:509
util::Optional< uint32_t > ddns_ttl_max_
Maximum value to use for DNS TTL.
Definition network.h:1301
void setDdnsSendUpdates(const util::Optional< bool > &ddns_send_updates)
Sets new ddns-send-updates.
Definition network.h:550
void setDdnsUpdateOnRenew(const util::Optional< bool > &ddns_update_on_renew)
Sets new ddns-update-on-renew.
Definition network.h:833
void setDdnsQualifyingSuffix(const util::Optional< std::string > &ddns_qualifying_suffix)
Sets new ddns-qualifying-suffix.
Definition network.h:665
util::Optional< double > ddns_ttl_percent_
Percentage of the lease lifetime to use for DNS TTL.
Definition network.h:1292
util::Optional< uint32_t > ddns_ttl_
Explicit value to use for DNS TTL.
Definition network.h:1295
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:271
void setDdnsTtlPercent(const util::Optional< double > &ddns_ttl_percent)
Sets new ddns-ttl-percent.
Definition network.h:682
ClientClasses & getMutableClientClasses()
Returns the mutable list of allowed client classes.
Definition network.h:356
util::Optional< D2ClientConfig::ReplaceClientNameMode > ddns_replace_client_name_mode_
How Kea should handle the domain-name supplied by the client.
Definition network.h:1259
void setRelayInfo(const RelayInfo &relay)
Sets information about relay.
Definition network.h:295
isc::util::Triplet< uint32_t > getValid(const Inheritance &inheritance=Inheritance::ALL) const
Return valid-lifetime for addresses in that prefix.
Definition network.h:378
util::Optional< std::string > default_allocator_type_
Default allocator type.
Definition network.h:1310
isc::util::Triplet< uint32_t > t1_
a isc::util::Triplet (min/default/max) holding allowed renew timer values
Definition network.h:1214
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this network.
Definition network.h:477
util::Optional< double > cache_threshold_
Percentage of the lease lifetime to use as cache threshold.
Definition network.h:1280
util::Optional< uint32_t > getDdnsTtlMin(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl-min.
Definition network.h:709
A template representing an optional value.
Definition optional.h:36
T get() const
Retrieves the encapsulated value.
Definition optional.h:114
bool empty() const
Checks if the encapsulated value is empty.
Definition optional.h:153
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
Definition optional.h:136
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:43
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:1479
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:1484
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