Kea 3.3.4
network.h
Go to the documentation of this file.
1// Copyright (C) 2017-2026 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
208
210 typedef boost::shared_ptr<Network::RelayInfo> RelayInfoPtr;
211
227
231 virtual ~Network() { }
232
238 fetch_globals_fn_ = fetch_globals_fn;
239 }
240
245 bool hasFetchGlobalsFn() const {
246 return (static_cast<bool>(fetch_globals_fn_));
247 }
248
258 void setIface(const util::Optional<std::string>& iface_name) {
259 if (iface_name.empty()) {
261 } else {
262 iface_name_ = iface_name;
263 }
264 }
265
272 getIface(const Inheritance& inheritance = Inheritance::ALL) const {
274 inheritance));
275 }
276
296 void setRelayInfo(const RelayInfo& relay) {
297 relay_ = relay;
298 }
299
306 const RelayInfo& getRelayInfo() const {
307 return (relay_);
308 }
309
314 void addRelayAddress(const asiolink::IOAddress& addr);
315
319 const IOAddressList& getRelayAddresses() const;
320
324 bool hasRelays() const;
325
330 bool hasRelayAddress(const asiolink::IOAddress& address) const;
331
343 virtual bool
344 clientSupported(const isc::dhcp::ClientClasses& client_classes) const;
345
349 void allowClientClass(const isc::dhcp::ClientClass& class_name);
350
353 return (client_classes_);
354 }
355
360
364 void addAdditionalClass(const isc::dhcp::ClientClass& class_name);
365
368 return (additional_classes_);
369 }
370
375
385
390 valid_ = valid;
391 }
392
400
405 t1_ = t1;
406 }
407
415
420 t2_ = t2;
421 }
422
433
437 void setReservationsGlobal(const util::Optional<bool>& reservations_global) {
438 reservations_global_ = reservations_global;
439 }
440
451
455 void setReservationsInSubnet(const util::Optional<bool>& reservations_in_subnet) {
456 reservations_in_subnet_ = reservations_in_subnet;
457 }
458
469
473 void setReservationsOutOfPool(const util::Optional<bool>& reservations_out_of_pool) {
474 reservations_out_of_pool_ = reservations_out_of_pool;
475 }
476
479 return (cfg_option_);
480 }
481
485 return (cfg_option_);
486 }
487
498
502 void setCalculateTeeTimes(const util::Optional<bool>& calculate_tee_times) {
503 calculate_tee_times_ = calculate_tee_times;
504 }
505
510 getT1Percent(const Inheritance& inheritance = Inheritance::ALL) const {
512 inheritance, CfgGlobals::T1_PERCENT));
513 }
514
518 void setT1Percent(const util::Optional<double>& t1_percent) {
519 t1_percent_ = t1_percent;
520 }
521
526 getT2Percent(const Inheritance& inheritance = Inheritance::ALL) const {
528 inheritance, CfgGlobals::T2_PERCENT));
529 }
530
534 void setT2Percent(const util::Optional<double>& t2_percent) {
535 t2_percent_ = t2_percent;
536 }
537
547
551 void setDdnsSendUpdates(const util::Optional<bool>& ddns_send_updates) {
552 ddns_send_updates_ = ddns_send_updates;
553 }
554
564
568 void setDdnsOverrideNoUpdate(const util::Optional<bool>& ddns_override_no_update) {
569 ddns_override_no_update_ = ddns_override_no_update;
570 }
571
581
586 ddns_override_client_update) {
587 ddns_override_client_update_ = ddns_override_client_update;
588 }
589
595 // Inheritance for ddns-replace-client-name is a little different than for other
596 // parameters. The value at the global level is given as a string.
597 // Thus we call getProperty here without a global name to check if it
598 // is specified on network level only.
601 ddns_replace_client_name_mode_, inheritance);
602
603 // If it is not specified at network level we need this special
604 // case code to convert the global string value to an enum.
605 if (mode.unspecified() && (inheritance != Inheritance::NONE) &&
606 (inheritance != Inheritance::PARENT_NETWORK)) {
607 // Get global mode.
609 mode_label = getGlobalProperty(mode_label,
611 if (!mode_label.unspecified()) {
612 try {
613 // If the mode is globally configured, convert it to an enum.
615 } catch (...) {
616 // This should not really happen because the configuration
617 // parser should have already verified the globally configured
618 // mode. However, we want to be 100% sure that this
619 // method doesn't throw. Let's just return unspecified.
620 return (mode);
621 }
622 }
623 }
624 return (mode);
625 }
626
630 void
632 ddns_replace_client_name_mode) {
633 ddns_replace_client_name_mode_ = ddns_replace_client_name_mode;
634 }
635
645
649 void setDdnsGeneratedPrefix(const util::Optional<std::string>& ddns_generated_prefix) {
650 ddns_generated_prefix_ = ddns_generated_prefix;
651 }
652
662
666 void setDdnsQualifyingSuffix(const util::Optional<std::string>& ddns_qualifying_suffix) {
667 ddns_qualifying_suffix_ = ddns_qualifying_suffix;
668 }
669
679
683 void setDdnsReverseZone(const util::Optional<std::string>& ddns_reverse_zone) {
684 ddns_reverse_zone_ = ddns_reverse_zone;
685 }
686
696
700 void setDdnsTtlPercent(const util::Optional<double>& ddns_ttl_percent) {
701 ddns_ttl_percent_ = ddns_ttl_percent;
702 }
703
704
709 getDdnsTtl(const Inheritance& inheritance = Inheritance::ALL) const {
711 ddns_ttl_, inheritance,
713 }
714
718 void setDdnsTtl(const util::Optional<uint32_t>& ddns_ttl) {
719 ddns_ttl_ = ddns_ttl;
720 }
721
726 getDdnsTtlMin(const Inheritance& inheritance = Inheritance::ALL) const {
728 ddns_ttl_min_, inheritance,
730 }
731
735 void setDdnsTtlMin(const util::Optional<uint32_t>& ddns_ttl_min) {
736 ddns_ttl_min_ = ddns_ttl_min;
737 }
738
743 getDdnsTtlMax(const Inheritance& inheritance = Inheritance::ALL) const {
745 ddns_ttl_max_, inheritance,
747 }
748
752 void setDdnsTtlMax(const util::Optional<uint32_t>& ddns_ttl_max) {
753 ddns_ttl_max_ = ddns_ttl_max;
754 }
755
763
767 void setHostnameCharSet(const util::Optional<std::string>& hostname_char_set) {
768 hostname_char_set_ = hostname_char_set;
769 }
770
778
783 hostname_char_replacement) {
784 hostname_char_replacement_ = hostname_char_replacement;
785 }
786
796
800 void setStoreExtendedInfo(const util::Optional<bool>& store_extended_info) {
801 store_extended_info_ = store_extended_info;
802 }
803
813
817 void setCacheThreshold(const util::Optional<double>& cache_threshold) {
818 cache_threshold_ = cache_threshold;
819 }
820
829
833 void setCacheMaxAge(const util::Optional<uint32_t>& cache_max_age) {
834 cache_max_age_ = cache_max_age;
835 }
836
846
850 void setDdnsUpdateOnRenew(const util::Optional<bool>& ddns_update_on_renew) {
851 ddns_update_on_renew_ = ddns_update_on_renew;
852 }
853
864
868 void setDdnsConflictResolutionMode(const util::Optional<std::string>& ddns_conflict_resolution_mode) {
869 ddns_conflict_resolution_mode_ = ddns_conflict_resolution_mode;
870 }
871
876 getAllocatorType(const Inheritance& inheritance = Inheritance::ALL) const {
879 inheritance,
881 }
882
890 void setAllocatorType(const util::Optional<std::string>& allocator_type) {
891 allocator_type_ = allocator_type;
892 }
893
906
910 void setDefaultAllocatorType(const std::string& allocator_type) {
911 default_allocator_type_ = allocator_type;
912 }
913
924
929 adaptive_lease_time_threshold) {
930 adaptive_lease_time_threshold_ = adaptive_lease_time_threshold;
931 }
932
936 virtual data::ElementPtr toElement() const;
937
941 virtual std::string getLabel() const {
942 return ("base-network");
943 }
944
945protected:
946
954
981 template<typename ReturnType>
982 ReturnType getGlobalProperty(ReturnType property,
983 const int global_index,
984 const int min_index = -1,
985 const int max_index = -1) const {
986 unused(min_index, max_index);
987 if ((global_index >= 0) && fetch_globals_fn_) {
989 if (globals) {
990 data::ConstElementPtr global_param = globals->get(global_index);
991 if (global_param) {
992 // If there is a global parameter, convert it to the
993 // optional value of the given type and return.
995 }
996 }
997 }
998 return (property);
999 }
1000
1019 template<typename NumType>
1021 const int global_index,
1022 const int min_index = -1,
1023 const int max_index = -1) const {
1024
1025 if ((global_index >= 0) && fetch_globals_fn_) {
1027 if (globals) {
1028 data::ConstElementPtr param = globals->get(global_index);
1029 if (param) {
1030 NumType def_value = static_cast<NumType>(param->intValue());
1031 if ((min_index < 0) || (max_index < 0)) {
1032 return (def_value);
1033 } else {
1034 NumType min_value = def_value;
1035 NumType max_value = def_value;
1036 data::ConstElementPtr min_param = globals->get(min_index);
1037 if (min_param) {
1038 min_value = static_cast<NumType>(min_param->intValue());
1039 }
1040 data::ConstElementPtr max_param = globals->get(max_index);
1041 if (max_param) {
1042 max_value = static_cast<NumType>(max_param->intValue());
1043 }
1044 return (isc::util::Triplet<NumType>(min_value, def_value, max_value));
1045 }
1046 }
1047 }
1048 }
1049 return (property);
1050 }
1051
1074 const int global_index,
1075 const int min_index = -1,
1076 const int max_index = -1) const;
1077
1108 template<typename BaseType, typename ReturnType>
1109 ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance&) const,
1110 ReturnType property,
1111 const Inheritance& inheritance,
1112 const int global_index = -1,
1113 const int min_index = -1,
1114 const int max_index = -1) const {
1115
1116 // If no inheritance is to be used, return the value for this
1117 // network regardless if it is specified or not.
1118 if (inheritance == Inheritance::NONE) {
1119 return (property);
1120
1121 } else if (inheritance == Inheritance::PARENT_NETWORK) {
1122 ReturnType parent_property;
1123
1124 // Check if this instance has a parent network.
1125 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1126 if (parent) {
1127 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1128 }
1129 return (parent_property);
1130
1131 // If global value requested, return it.
1132 } else if (inheritance == Inheritance::GLOBAL) {
1133 return (getGlobalProperty(ReturnType(), global_index, min_index, max_index));
1134 }
1135
1136 // We use inheritance and the value is not specified on the network level.
1137 // Hence, we need to get the parent network specific value or global value.
1138 if (property.unspecified()) {
1139 // Check if this instance has a parent network.
1140 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1141 // If the parent network exists, let's fetch the parent specific
1142 // value.
1143 if (parent) {
1144 // We're using inheritance so ask for the parent specific network
1145 // and return it only if it is specified.
1146 auto parent_property = ((*parent).*MethodPointer)(inheritance);
1147 if (!parent_property.unspecified()) {
1148 return (parent_property);
1149 }
1150 }
1151
1152 // The value is not specified on network level. If the value
1153 // can be specified on global level and there is a callback
1154 // that returns the global values, try to find this parameter
1155 // at the global scope.
1156 return (getGlobalProperty(property, global_index, min_index, max_index));
1157 }
1158
1159 // We haven't found the value at any level, so return the unspecified.
1160 return (property);
1161 }
1162
1183 template<typename BaseType>
1184 OptionPtr
1185 getOptionProperty(OptionPtr(BaseType::*MethodPointer)(const Inheritance& inheritance) const,
1186 OptionPtr property,
1187 const Inheritance& inheritance) const {
1188 if (inheritance == Network::Inheritance::NONE) {
1189 return (property);
1190
1191 } else if (inheritance == Network::Inheritance::PARENT_NETWORK) {
1192 OptionPtr parent_property;
1193 // Check if this instance has a parent network.
1194 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1195 // If the parent network exists, let's fetch the parent specific
1196 // value.
1197 if (parent) {
1198 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1199 }
1200 return (parent_property);
1201
1202 } else if (inheritance == Network::Inheritance::GLOBAL) {
1203 return (OptionPtr());
1204 }
1205
1206 // We use inheritance and the value is not specified on the network level.
1207 // Hence, we need to get the parent network specific value.
1208 if (!property) {
1209 // Check if this instance has a parent network.
1210 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1211 if (parent) {
1212 // We're using inheritance so ask for the parent specific network
1213 // and return it only if it is specified.
1214 OptionPtr parent_property = (((*parent).*MethodPointer)(inheritance));
1215 if (parent_property) {
1216 return (parent_property);
1217 }
1218 }
1219 }
1220
1221 // We haven't found the value at any level, so return the unspecified.
1222 return (property);
1223 }
1224
1227
1232
1240
1247
1250
1253
1256
1259
1262
1269
1272
1275
1278
1281
1285
1289
1292
1295
1298
1301
1304
1308
1312
1316
1319
1322
1325
1328
1331
1334
1337
1340
1343
1349
1354
1362
1366};
1367
1369class Network4 : public virtual Network {
1370public:
1371
1374 : Network(), match_client_id_(true, true), authoritative_(),
1375 siaddr_(), sname_(), filename_(), offer_lft_() {
1376 }
1377
1384 getMatchClientId(const Inheritance& inheritance = Inheritance::ALL) const {
1386 match_client_id_,
1387 inheritance,
1389 }
1390
1397 match_client_id_ = match;
1398 }
1399
1407 getAuthoritative(const Inheritance& inheritance = Inheritance::ALL) const {
1409 authoritative_, inheritance,
1411 }
1412
1418 void setAuthoritative(const util::Optional<bool>& authoritative) {
1419 authoritative_ = authoritative;
1420 }
1421
1428
1433 getSiaddr(const Inheritance& inheritance = Inheritance::ALL) const {
1435 inheritance, CfgGlobals::NEXT_SERVER));
1436 }
1437
1441 void setSname(const util::Optional<std::string>& sname);
1442
1448 getSname(const Inheritance& inheritance = Inheritance::ALL) const {
1450 inheritance,
1452 }
1453
1457 void setFilename(const util::Optional<std::string>& filename);
1458
1464 getFilename(const Inheritance& inheritance = Inheritance::ALL) const {
1465 return (getProperty<Network4>(&Network4::getFilename, filename_,
1466 inheritance,
1468 }
1469
1473 void setOfferLft(const util::Optional<uint32_t>& offer_lft) {
1474 offer_lft_ = offer_lft;
1475 }
1476
1482 getOfferLft(const Inheritance& inheritance = Inheritance::ALL) const {
1483 return (getProperty<Network4>(&Network4::getOfferLft, offer_lft_,
1484 inheritance,
1486 }
1487
1491 virtual data::ElementPtr toElement() const;
1492
1497 virtual asiolink::IOAddress getServerId() const;
1498
1499private:
1500
1503 util::Optional<bool> match_client_id_;
1504
1506 util::Optional<bool> authoritative_;
1507
1510
1513
1516
1518 util::Optional<uint32_t> offer_lft_;
1519};
1520
1522typedef boost::shared_ptr<Network4> Network4Ptr;
1523
1524class Network6;
1525
1527typedef boost::shared_ptr<Network6> Network6Ptr;
1528
1530class Network6 : public virtual Network {
1531public:
1532
1535 : Network(), preferred_(), interface_id_(), rapid_commit_(),
1536 default_pd_allocator_type_(){
1537 }
1538
1551
1556 preferred_ = preferred;
1557 }
1558
1565 inheritance));
1566 }
1567
1571 void setInterfaceId(const OptionPtr& ifaceid) {
1572 interface_id_ = ifaceid;
1573 }
1574
1583 getRapidCommit(const Inheritance& inheritance = Inheritance::ALL) const {
1584
1585 return (getProperty<Network6>(&Network6::getRapidCommit, rapid_commit_,
1586 inheritance));
1587 }
1588
1593 void setRapidCommit(const util::Optional<bool>& rapid_commit) {
1594 rapid_commit_ = rapid_commit;
1595 }
1596
1603 pd_allocator_type_,
1604 inheritance,
1606 }
1607
1616 pd_allocator_type_ = allocator_type;
1617 }
1618
1628 default_pd_allocator_type_,
1629 inheritance));
1630 }
1631
1635 void setDefaultPdAllocatorType(const std::string& allocator_type) {
1636 default_pd_allocator_type_ = allocator_type;
1637 }
1638
1642 virtual data::ElementPtr toElement() const;
1643
1644private:
1645
1648
1650 OptionPtr interface_id_;
1651
1657 util::Optional<bool> rapid_commit_;
1658
1660 util::Optional<std::string> pd_allocator_type_;
1661
1662 // @brief Default allocator type for prefix delegation.
1663 util::Optional<std::string> default_pd_allocator_type_;
1664};
1665
1666} // end of namespace isc::dhcp
1667} // end of namespace isc
1668
1669#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:405
Container for storing client class names.
Definition classify.h:111
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
util::Optional< std::string > getFilename(const Inheritance &inheritance=Inheritance::ALL) const
Returns boot file name for this subnet.
Definition network.h:1464
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:1396
util::Optional< std::string > getSname(const Inheritance &inheritance=Inheritance::ALL) const
Returns server hostname for this network.
Definition network.h:1448
util::Optional< asiolink::IOAddress > getSiaddr(const Inheritance &inheritance=Inheritance::ALL) const
Returns siaddr for this network.
Definition network.h:1433
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:1418
void setSiaddr(const util::Optional< asiolink::IOAddress > &siaddr)
Sets siaddr for the network.
Definition network.cc:292
util::Optional< uint32_t > getOfferLft(const Inheritance &inheritance=Inheritance::ALL) const
Returns offer lifetime for the network.
Definition network.h:1482
void setOfferLft(const util::Optional< uint32_t > &offer_lft)
Sets offer lifetime for the network.
Definition network.h:1473
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:1384
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:1407
void setFilename(const util::Optional< std::string > &filename)
Sets boot file name for the network.
Definition network.cc:306
virtual asiolink::IOAddress getServerId() const
Returns binary representation of the dhcp-server-identifier option (54).
Definition network.cc:348
Network4()
Constructor.
Definition network.h:1373
virtual data::ElementPtr toElement() const
Unparses network object.
Definition network.cc:311
void setSname(const util::Optional< std::string > &sname)
Sets server hostname for the network.
Definition network.cc:301
Specialization of the Network object for DHCPv6 case.
Definition network.h:1530
void setRapidCommit(const util::Optional< bool > &rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
Definition network.h:1593
void setDefaultPdAllocatorType(const std::string &allocator_type)
Sets a default allocator type for prefix delegation.
Definition network.h:1635
util::Optional< std::string > getDefaultPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type for prefix delegation.
Definition network.h:1626
isc::util::Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds).
Definition network.h:1544
void setPdAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type for prefix delegation.
Definition network.h:1615
Network6()
Constructor.
Definition network.h:1534
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:1583
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
Definition network.h:1571
void setPreferred(const isc::util::Triplet< uint32_t > &preferred)
Sets new preferred lifetime for a network.
Definition network.h:1555
virtual data::ElementPtr toElement() const
Unparses network object.
Definition network.cc:363
OptionPtr getInterfaceId(const Inheritance &inheritance=Inheritance::ALL) const
Returns interface-id value (if specified).
Definition network.h:1563
util::Optional< std::string > getPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type for prefix delegation.
Definition network.h:1601
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:492
util::Optional< std::string > getDdnsQualifyingSuffix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-qualifying-suffix.
Definition network.h:657
isc::util::Triplet< uint32_t > t2_
a isc::util::Triplet (min/default/max) holding allowed rebind timer values
Definition network.h:1252
util::Optional< D2ClientConfig::ReplaceClientNameMode > getDdnsReplaceClientNameMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-replace-client-name-mode.
Definition network.h:594
void setT2(const isc::util::Triplet< uint32_t > &t2)
Sets new rebind timer for a network.
Definition network.h:419
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:1311
util::Optional< std::string > ddns_reverse_zone_
Reverse zone Kea should use for PTR records.
Definition network.h:1303
RelayInfo relay_
Relay information.
Definition network.h:1231
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:808
util::Optional< bool > reservations_out_of_pool_
Enables out-of-pool reservations optimization.
Definition network.h:1268
util::Optional< std::string > getHostnameCharReplacement(const Inheritance &inheritance=Inheritance::ALL) const
Return the invalid char replacement used to sanitize client hostnames.
Definition network.h:773
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
Definition network.h:1324
util::Optional< std::string > allocator_type_
Allocator used for IP address allocations.
Definition network.h:1342
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
Definition network.h:1271
void setAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type.
Definition network.h:890
void setDdnsReplaceClientNameMode(const util::Optional< D2ClientConfig::ReplaceClientNameMode > &ddns_replace_client_name_mode)
Sets new ddns-replace-client-name-mode.
Definition network.h:631
Network()
Constructor.
Definition network.h:213
void setDdnsTtlMin(const util::Optional< uint32_t > &ddns_ttl_min)
Sets new ddns-ttl-min.
Definition network.h:735
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:372
void setCacheMaxAge(const util::Optional< uint32_t > &cache_max_age)
Sets cache max for a network.
Definition network.h:833
ClientClasses additional_classes_
Additional classes.
Definition network.h:1246
util::Optional< double > getDdnsTtlPercent(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl-percent.
Definition network.h:691
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:817
void setT1Percent(const util::Optional< double > &t1_percent)
Sets new percentage for calculating T1 (renew timer).
Definition network.h:518
util::Optional< bool > reservations_global_
Enables global reservations.
Definition network.h:1258
util::Optional< bool > getDdnsOverrideClientUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-client-update.
Definition network.h:576
bool hasFetchGlobalsFn() const
Checks if the network is associated with a function used to fetch globally configured parameters.
Definition network.h:245
util::Optional< bool > ddns_override_client_update_
Should Kea perform updates, even if client requested delegation.
Definition network.h:1291
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:1185
void setDdnsTtlMax(const util::Optional< uint32_t > &ddns_ttl_max)
Sets new ddns-ttl-max.
Definition network.h:752
util::Optional< bool > reservations_in_subnet_
Enables subnet reservations.
Definition network.h:1261
util::Optional< std::string > getDdnsReverseZone(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-reverse-zone.
Definition network.h:674
util::Optional< std::string > getHostnameCharSet(const Inheritance &inheritance=Inheritance::ALL) const
Return the char set regexp used to sanitize client hostnames.
Definition network.h:758
FetchNetworkGlobalsFn getFetchGlobalsFn() const
Gets the optional callback function used to fetch globally configured parameters.
Definition network.h:951
void setReservationsInSubnet(const util::Optional< bool > &reservations_in_subnet)
Sets whether subnet reservations should be fetched.
Definition network.h:455
FetchNetworkGlobalsFn fetch_globals_fn_
Pointer to the optional callback used to fetch globally configured parameters inherited to the Networ...
Definition network.h:1365
void setStoreExtendedInfo(const util::Optional< bool > &store_extended_info)
Sets new store-extended-info.
Definition network.h:800
util::Optional< double > t2_percent_
Percentage of the lease lifetime to use when calculating T2 timer.
Definition network.h:1280
void setIface(const util::Optional< std::string > &iface_name)
Sets local name of the interface for which this network is selected.
Definition network.h:258
util::Optional< bool > getDdnsUpdateOnRenew(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-update-on-renew.
Definition network.h:841
util::Optional< uint32_t > getDdnsTtlMax(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl-max.
Definition network.h:743
ClientClasses client_classes_
List of client classes allowed to use this network.
Definition network.h:1239
util::Optional< double > adaptive_lease_time_threshold_
Percentage of the adaptive lease time threshold.
Definition network.h:1353
void setDdnsOverrideClientUpdate(const util::Optional< bool > &ddns_override_client_update)
Sets new ddns-override-client-update.
Definition network.h:585
const ClientClasses & getClientClasses() const
Returns the list of allowed client classes.
Definition network.h:352
const RelayInfo & getRelayInfo() const
Returns const reference to relay information.
Definition network.h:306
WeakNetworkPtr parent_network_
Pointer to another network that this network belongs to.
Definition network.h:1361
util::Optional< double > getAdaptiveLeaseTimeThreshold(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage of the adaptive lease time threshold,.
Definition network.h:918
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:1109
isc::util::Triplet< uint32_t > getT1(const Inheritance &inheritance=Inheritance::ALL) const
Returns T1 (renew timer), expressed in seconds.
Definition network.h:396
util::Optional< bool > getReservationsGlobal(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether global reservations should be fetched.
Definition network.h:427
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
Definition network.h:1297
util::Optional< double > t1_percent_
Percentage of the lease lifetime to use when calculating T1 timer.
Definition network.h:1277
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:868
util::Optional< uint32_t > ddns_ttl_min_
Minimum value to use for DNS TTL.
Definition network.h:1336
util::Optional< bool > getDdnsOverrideNoUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-no-update.
Definition network.h:559
util::Optional< std::string > getAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type.
Definition network.h:876
void setHostnameCharSet(const util::Optional< std::string > &hostname_char_set)
Sets new hostname-char-set.
Definition network.h:767
util::Optional< std::string > getDdnsGeneratedPrefix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-generated-prefix.
Definition network.h:640
void setDdnsTtl(const util::Optional< uint32_t > &ddns_ttl)
Sets new ddns-ttl.
Definition network.h:718
util::Optional< bool > getDdnsSendUpdates(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-send-updates.
Definition network.h:542
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:473
util::Optional< std::string > hostname_char_set_
Regular expression describing invalid characters for client hostnames.
Definition network.h:1307
util::Optional< std::string > getDefaultAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type.
Definition network.h:901
util::Optional< std::string > getDdnsConflictResolutionMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-conflict-resolution-mode.
Definition network.h:858
void setDdnsGeneratedPrefix(const util::Optional< std::string > &ddns_generated_prefix)
Sets new ddns-generated-prefix.
Definition network.h:649
void setT1(const isc::util::Triplet< uint32_t > &t1)
Sets new renew timer for a network.
Definition network.h:404
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:526
util::Optional< uint32_t > getDdnsTtl(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl.
Definition network.h:709
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:1226
void setFetchGlobalsFn(FetchNetworkGlobalsFn fetch_globals_fn)
Sets the optional callback function used to fetch globally configured parameters.
Definition network.h:237
isc::util::Triplet< uint32_t > getT2(const Inheritance &inheritance=Inheritance::ALL) const
Returns T2 (rebind timer), expressed in seconds.
Definition network.h:411
void setValid(const isc::util::Triplet< uint32_t > &valid)
Sets new valid lifetime for a network.
Definition network.h:389
virtual std::string getLabel() const
Generates an identifying label for logging.
Definition network.h:941
void setT2Percent(const util::Optional< double > &t2_percent)
Sets new percentage for calculating T2 (rebind timer).
Definition network.h:534
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:1020
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
Definition network.h:1284
virtual ~Network()
Virtual destructor.
Definition network.h:231
util::Optional< std::string > ddns_conflict_resolution_mode_
DDNS conflict resolution mode.
Definition network.h:1327
util::Optional< bool > store_extended_info_
Should Kea store additional client query data (e.g.
Definition network.h:1315
isc::util::Triplet< uint32_t > valid_
a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
Definition network.h:1255
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this network.
Definition network.h:484
const ClientClasses & getAdditionalClasses() const
Returns the additional classes list.
Definition network.h:367
util::Optional< bool > getReservationsOutOfPool(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether only out-of-pool reservations are allowed.
Definition network.h:463
util::Optional< bool > calculate_tee_times_
Enables calculation of T1 and T2 timers.
Definition network.h:1274
util::Optional< uint32_t > cache_max_age_
Value in seconds to use as cache maximal age.
Definition network.h:1321
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:982
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
Definition network.h:1288
void setCalculateTeeTimes(const util::Optional< bool > &calculate_tee_times)
Sets whether or not T1/T2 calculation is enabled.
Definition network.h:502
util::Optional< std::string > ddns_qualifying_suffix_
Suffix Kea should use when to qualify partial domain-names.
Definition network.h:1300
util::Optional< bool > getStoreExtendedInfo(const Inheritance &inheritance=Inheritance::ALL) const
Returns store-extended-info.
Definition network.h:791
void setDdnsOverrideNoUpdate(const util::Optional< bool > &ddns_override_no_update)
Sets new ddns-override-no-update.
Definition network.h:568
void setDefaultAllocatorType(const std::string &allocator_type)
Sets a default allocator type.
Definition network.h:910
util::Optional< bool > getReservationsInSubnet(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether subnet reservations should be fetched.
Definition network.h:445
void setHostnameCharReplacement(const util::Optional< std::string > &hostname_char_replacement)
Sets new hostname-char-replacement.
Definition network.h:782
util::Optional< uint32_t > getCacheMaxAge(const Inheritance &inheritance=Inheritance::ALL) const
Returns value in seconds to use as cache maximum age.
Definition network.h:825
void setReservationsGlobal(const util::Optional< bool > &reservations_global)
Sets whether global reservations should be fetched.
Definition network.h:437
util::Optional< double > getT1Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T1 (renew timer).
Definition network.h:510
util::Optional< uint32_t > ddns_ttl_max_
Maximum value to use for DNS TTL.
Definition network.h:1339
void setDdnsSendUpdates(const util::Optional< bool > &ddns_send_updates)
Sets new ddns-send-updates.
Definition network.h:551
void setDdnsUpdateOnRenew(const util::Optional< bool > &ddns_update_on_renew)
Sets new ddns-update-on-renew.
Definition network.h:850
void setDdnsQualifyingSuffix(const util::Optional< std::string > &ddns_qualifying_suffix)
Sets new ddns-qualifying-suffix.
Definition network.h:666
void setDdnsReverseZone(const util::Optional< std::string > &ddns_reverse_zone)
Sets new ddns-reverse-zone.
Definition network.h:683
util::Optional< double > ddns_ttl_percent_
Percentage of the lease lifetime to use for DNS TTL.
Definition network.h:1330
util::Optional< uint32_t > ddns_ttl_
Explicit value to use for DNS TTL.
Definition network.h:1333
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:272
void setDdnsTtlPercent(const util::Optional< double > &ddns_ttl_percent)
Sets new ddns-ttl-percent.
Definition network.h:700
ClientClasses & getMutableClientClasses()
Returns the mutable list of allowed client classes.
Definition network.h:357
util::Optional< D2ClientConfig::ReplaceClientNameMode > ddns_replace_client_name_mode_
How Kea should handle the domain-name supplied by the client.
Definition network.h:1294
void setRelayInfo(const RelayInfo &relay)
Sets information about relay.
Definition network.h:296
isc::util::Triplet< uint32_t > getValid(const Inheritance &inheritance=Inheritance::ALL) const
Return valid-lifetime for addresses in that prefix.
Definition network.h:379
util::Optional< std::string > default_allocator_type_
Default allocator type.
Definition network.h:1348
isc::util::Triplet< uint32_t > t1_
a isc::util::Triplet (min/default/max) holding allowed renew timer values
Definition network.h:1249
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this network.
Definition network.h:478
void setAdaptiveLeaseTimeThreshold(const util::Optional< double > &adaptive_lease_time_threshold)
Sets new percentage of the adaptive lease time threshold.
Definition network.h:928
util::Optional< double > cache_threshold_
Percentage of the lease lifetime to use as cache threshold.
Definition network.h:1318
util::Optional< uint32_t > getDdnsTtlMin(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl-min.
Definition network.h:726
A template representing an optional value.
Definition optional.h:37
T get() const
Retrieves the encapsulated value.
Definition optional.h:123
bool empty() const
Checks if the encapsulated value is empty.
Definition optional.h:162
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
Definition optional.h:145
This template specifies a parameter value.
Definition triplet.h:37
Defines the D2ClientConfig class.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
std::string ClientClass
Defines a single class name.
Definition classify.h:45
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:1522
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition cfg_option.h:983
boost::shared_ptr< Network6 > Network6Ptr
Pointer to the Network6 object.
Definition network.h:1527
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:38
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
Definition cfg_option.h:986
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