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,
154 public virtual isc::data::CfgToElement {
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
847
851 void setDdnsConflictResolutionMode(const util::Optional<std::string>& ddns_conflict_resolution_mode) {
852 ddns_conflict_resolution_mode_ = ddns_conflict_resolution_mode;
853 }
854
859 getAllocatorType(const Inheritance& inheritance = Inheritance::ALL) const {
862 inheritance,
864 }
865
873 void setAllocatorType(const util::Optional<std::string>& allocator_type) {
874 allocator_type_ = allocator_type;
875 }
876
889
893 void setDefaultAllocatorType(const std::string& allocator_type) {
894 default_allocator_type_ = allocator_type;
895 }
896
900 virtual data::ElementPtr toElement() const;
901
905 virtual std::string getLabel() const {
906 return ("base-network");
907 }
908
909protected:
910
918
945 template<typename ReturnType>
946 ReturnType getGlobalProperty(ReturnType property,
947 const int global_index,
948 const int min_index = -1,
949 const int max_index = -1) const {
950 unused(min_index, max_index);
951 if ((global_index >= 0) && fetch_globals_fn_) {
953 if (globals) {
954 data::ConstElementPtr global_param = globals->get(global_index);
955 if (global_param) {
956 // If there is a global parameter, convert it to the
957 // optional value of the given type and return.
959 }
960 }
961 }
962 return (property);
963 }
964
983 template<typename NumType>
985 const int global_index,
986 const int min_index = -1,
987 const int max_index = -1) const {
988
989 if ((global_index >= 0) && fetch_globals_fn_) {
991 if (globals) {
992 data::ConstElementPtr param = globals->get(global_index);
993 if (param) {
994 NumType def_value = static_cast<NumType>(param->intValue());
995 if ((min_index < 0) || (max_index < 0)) {
996 return (def_value);
997 } else {
998 NumType min_value = def_value;
999 NumType max_value = def_value;
1000 data::ConstElementPtr min_param = globals->get(min_index);
1001 if (min_param) {
1002 min_value = static_cast<NumType>(min_param->intValue());
1003 }
1004 data::ConstElementPtr max_param = globals->get(max_index);
1005 if (max_param) {
1006 max_value = static_cast<NumType>(max_param->intValue());
1007 }
1008 return (isc::util::Triplet<NumType>(min_value, def_value, max_value));
1009 }
1010 }
1011 }
1012 }
1013 return (property);
1014 }
1015
1038 const int global_index,
1039 const int min_index = -1,
1040 const int max_index = -1) const;
1041
1072 template<typename BaseType, typename ReturnType>
1073 ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance&) const,
1074 ReturnType property,
1075 const Inheritance& inheritance,
1076 const int global_index = -1,
1077 const int min_index = -1,
1078 const int max_index = -1) const {
1079
1080 // If no inheritance is to be used, return the value for this
1081 // network regardless if it is specified or not.
1082 if (inheritance == Inheritance::NONE) {
1083 return (property);
1084
1085 } else if (inheritance == Inheritance::PARENT_NETWORK) {
1086 ReturnType parent_property;
1087
1088 // Check if this instance has a parent network.
1089 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1090 if (parent) {
1091 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1092 }
1093 return (parent_property);
1094
1095 // If global value requested, return it.
1096 } else if (inheritance == Inheritance::GLOBAL) {
1097 return (getGlobalProperty(ReturnType(), global_index, min_index, max_index));
1098 }
1099
1100 // We use inheritance and the value is not specified on the network level.
1101 // Hence, we need to get the parent network specific value or global value.
1102 if (property.unspecified()) {
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 // We're using inheritance so ask for the parent specific network
1109 // and return it only if it is specified.
1110 auto parent_property = ((*parent).*MethodPointer)(inheritance);
1111 if (!parent_property.unspecified()) {
1112 return (parent_property);
1113 }
1114 }
1115
1116 // The value is not specified on network level. If the value
1117 // can be specified on global level and there is a callback
1118 // that returns the global values, try to find this parameter
1119 // at the global scope.
1120 return (getGlobalProperty(property, global_index, min_index, max_index));
1121 }
1122
1123 // We haven't found the value at any level, so return the unspecified.
1124 return (property);
1125 }
1126
1147 template<typename BaseType>
1148 OptionPtr
1149 getOptionProperty(OptionPtr(BaseType::*MethodPointer)(const Inheritance& inheritance) const,
1150 OptionPtr property,
1151 const Inheritance& inheritance) const {
1152 if (inheritance == Network::Inheritance::NONE) {
1153 return (property);
1154
1155 } else if (inheritance == Network::Inheritance::PARENT_NETWORK) {
1156 OptionPtr parent_property;
1157 // Check if this instance has a parent network.
1158 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1159 // If the parent network exists, let's fetch the parent specific
1160 // value.
1161 if (parent) {
1162 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1163 }
1164 return (parent_property);
1165
1166 } else if (inheritance == Network::Inheritance::GLOBAL) {
1167 return (OptionPtr());
1168 }
1169
1170 // We use inheritance and the value is not specified on the network level.
1171 // Hence, we need to get the parent network specific value.
1172 if (!property) {
1173 // Check if this instance has a parent network.
1174 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1175 if (parent) {
1176 // We're using inheritance so ask for the parent specific network
1177 // and return it only if it is specified.
1178 OptionPtr parent_property = (((*parent).*MethodPointer)(inheritance));
1179 if (parent_property) {
1180 return (parent_property);
1181 }
1182 }
1183 }
1184
1185 // We haven't found the value at any level, so return the unspecified.
1186 return (property);
1187 }
1188
1191
1196
1204
1211
1214
1217
1220
1223
1226
1233
1236
1239
1242
1245
1249
1253
1256
1259
1262
1265
1269
1273
1277
1280
1283
1286
1289
1292
1295
1298
1301
1304
1310
1318
1322};
1323
1325class Network4 : public virtual Network {
1326public:
1327
1330 : Network(), match_client_id_(true, true), authoritative_(),
1331 siaddr_(), sname_(), filename_(), offer_lft_() {
1332 }
1333
1340 getMatchClientId(const Inheritance& inheritance = Inheritance::ALL) const {
1342 match_client_id_,
1343 inheritance,
1345 }
1346
1353 match_client_id_ = match;
1354 }
1355
1363 getAuthoritative(const Inheritance& inheritance = Inheritance::ALL) const {
1365 authoritative_, inheritance,
1367 }
1368
1374 void setAuthoritative(const util::Optional<bool>& authoritative) {
1375 authoritative_ = authoritative;
1376 }
1377
1384
1389 getSiaddr(const Inheritance& inheritance = Inheritance::ALL) const {
1391 inheritance, CfgGlobals::NEXT_SERVER));
1392 }
1393
1397 void setSname(const util::Optional<std::string>& sname);
1398
1404 getSname(const Inheritance& inheritance = Inheritance::ALL) const {
1406 inheritance,
1408 }
1409
1413 void setFilename(const util::Optional<std::string>& filename);
1414
1420 getFilename(const Inheritance& inheritance = Inheritance::ALL) const {
1421 return (getProperty<Network4>(&Network4::getFilename, filename_,
1422 inheritance,
1424 }
1425
1429 void setOfferLft(const util::Optional<uint32_t>& offer_lft) {
1430 offer_lft_ = offer_lft;
1431 }
1432
1438 getOfferLft(const Inheritance& inheritance = Inheritance::ALL) const {
1439 return (getProperty<Network4>(&Network4::getOfferLft, offer_lft_,
1440 inheritance,
1442 }
1443
1447 virtual data::ElementPtr toElement() const;
1448
1453 virtual asiolink::IOAddress getServerId() const;
1454
1455private:
1456
1459 util::Optional<bool> match_client_id_;
1460
1462 util::Optional<bool> authoritative_;
1463
1466
1469
1472
1474 util::Optional<uint32_t> offer_lft_;
1475};
1476
1478typedef boost::shared_ptr<Network4> Network4Ptr;
1479
1480class Network6;
1481
1483typedef boost::shared_ptr<Network6> Network6Ptr;
1484
1486class Network6 : public virtual Network {
1487public:
1488
1491 : Network(), preferred_(), interface_id_(), rapid_commit_(),
1492 default_pd_allocator_type_(){
1493 }
1494
1507
1512 preferred_ = preferred;
1513 }
1514
1521 inheritance));
1522 }
1523
1527 void setInterfaceId(const OptionPtr& ifaceid) {
1528 interface_id_ = ifaceid;
1529 }
1530
1539 getRapidCommit(const Inheritance& inheritance = Inheritance::ALL) const {
1540
1541 return (getProperty<Network6>(&Network6::getRapidCommit, rapid_commit_,
1542 inheritance));
1543 }
1544
1549 void setRapidCommit(const util::Optional<bool>& rapid_commit) {
1550 rapid_commit_ = rapid_commit;
1551 }
1552
1559 pd_allocator_type_,
1560 inheritance,
1562 }
1563
1572 pd_allocator_type_ = allocator_type;
1573 }
1574
1584 default_pd_allocator_type_,
1585 inheritance));
1586 }
1587
1591 void setDefaultPdAllocatorType(const std::string& allocator_type) {
1592 default_pd_allocator_type_ = allocator_type;
1593 }
1594
1598 virtual data::ElementPtr toElement() const;
1599
1600private:
1601
1604
1606 OptionPtr interface_id_;
1607
1613 util::Optional<bool> rapid_commit_;
1614
1616 util::Optional<std::string> pd_allocator_type_;
1617
1618 // @brief Default allocator type for prefix delegation.
1619 util::Optional<std::string> default_pd_allocator_type_;
1620};
1621
1622} // end of namespace isc::dhcp
1623} // end of namespace isc
1624
1625#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:1325
util::Optional< std::string > getFilename(const Inheritance &inheritance=Inheritance::ALL) const
Returns boot file name for this subnet.
Definition network.h:1420
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:1352
util::Optional< std::string > getSname(const Inheritance &inheritance=Inheritance::ALL) const
Returns server hostname for this network.
Definition network.h:1404
util::Optional< asiolink::IOAddress > getSiaddr(const Inheritance &inheritance=Inheritance::ALL) const
Returns siaddr for this network.
Definition network.h:1389
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:1374
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:1438
void setOfferLft(const util::Optional< uint32_t > &offer_lft)
Sets offer lifetime for the network.
Definition network.h:1429
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:1340
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:1363
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:1329
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:1486
void setRapidCommit(const util::Optional< bool > &rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
Definition network.h:1549
void setDefaultPdAllocatorType(const std::string &allocator_type)
Sets a defalt allocator type for prefix delegation.
Definition network.h:1591
util::Optional< std::string > getDefaultPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type for prefix delegation.
Definition network.h:1582
isc::util::Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds)
Definition network.h:1500
void setPdAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type for prefix delegation.
Definition network.h:1571
Network6()
Constructor.
Definition network.h:1490
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:1539
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
Definition network.h:1527
void setPreferred(const isc::util::Triplet< uint32_t > &preferred)
Sets new preferred lifetime for a network.
Definition network.h:1511
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:1519
util::Optional< std::string > getPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type for prefix delegation.
Definition network.h:1557
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:1216
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:1272
RelayInfo relay_
Relay information.
Definition network.h:1195
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:1232
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:1285
util::Optional< std::string > allocator_type_
Allocator used for IP address allocations.
Definition network.h:1303
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
Definition network.h:1235
void setAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type.
Definition network.h:873
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:1210
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:1222
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:1255
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:1149
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:1225
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:915
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:1321
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:1244
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:1203
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:1317
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:1073
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:1261
util::Optional< double > t1_percent_
Percentage of the lease lifetime to use when calculating T1 timer.
Definition network.h:1241
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 ddns-conflict-resolution-mode.
Definition network.h:851
util::Optional< uint32_t > ddns_ttl_min_
Minimum value to use for DNS TTL.
Definition network.h:1297
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:859
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:1268
util::Optional< std::string > getDefaultAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type.
Definition network.h:884
util::Optional< std::string > getDdnsConflictResolutionMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-conflict-resolution-mode.
Definition network.h:841
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:1190
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:905
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:984
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
Definition network.h:1248
virtual ~Network()
Virtual destructor.
Definition network.h:230
util::Optional< std::string > ddns_conflict_resolution_mode_
DDNS conflict resolution mode.
Definition network.h:1288
util::Optional< bool > store_extended_info_
Should Kea store additional client query data (e.g.
Definition network.h:1276
isc::util::Triplet< uint32_t > valid_
a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
Definition network.h:1219
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:1238
util::Optional< uint32_t > cache_max_age_
Value in seconds to use as cache maximal age.
Definition network.h:1282
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:946
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
Definition network.h:1252
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:1264
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:893
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:1300
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:1291
util::Optional< uint32_t > ddns_ttl_
Explicit value to use for DNS TTL.
Definition network.h:1294
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:1258
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:1309
isc::util::Triplet< uint32_t > t1_
a isc::util::Triplet (min/default/max) holding allowed renew timer values
Definition network.h:1213
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:1279
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:1478
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:1483
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