Kea 3.1.1
network.h
Go to the documentation of this file.
1// Copyright (C) 2017-2025 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 setDdnsTtlPercent(const util::Optional<double>& ddns_ttl_percent) {
684 ddns_ttl_percent_ = ddns_ttl_percent;
685 }
686
687
692 getDdnsTtl(const Inheritance& inheritance = Inheritance::ALL) const {
694 ddns_ttl_, inheritance,
696 }
697
701 void setDdnsTtl(const util::Optional<uint32_t>& ddns_ttl) {
702 ddns_ttl_ = ddns_ttl;
703 }
704
705
710 getDdnsTtlMin(const Inheritance& inheritance = Inheritance::ALL) const {
712 ddns_ttl_min_, inheritance,
714 }
715
719 void setDdnsTtlMin(const util::Optional<uint32_t>& ddns_ttl_min) {
720 ddns_ttl_min_ = ddns_ttl_min;
721 }
722
727 getDdnsTtlMax(const Inheritance& inheritance = Inheritance::ALL) const {
729 ddns_ttl_max_, inheritance,
731 }
732
736 void setDdnsTtlMax(const util::Optional<uint32_t>& ddns_ttl_max) {
737 ddns_ttl_max_ = ddns_ttl_max;
738 }
739
747
751 void setHostnameCharSet(const util::Optional<std::string>& hostname_char_set) {
752 hostname_char_set_ = hostname_char_set;
753 }
754
762
767 hostname_char_replacement) {
768 hostname_char_replacement_ = hostname_char_replacement;
769 }
770
780
784 void setStoreExtendedInfo(const util::Optional<bool>& store_extended_info) {
785 store_extended_info_ = store_extended_info;
786 }
787
797
801 void setCacheThreshold(const util::Optional<double>& cache_threshold) {
802 cache_threshold_ = cache_threshold;
803 }
804
813
817 void setCacheMaxAge(const util::Optional<uint32_t>& cache_max_age) {
818 cache_max_age_ = cache_max_age;
819 }
820
830
834 void setDdnsUpdateOnRenew(const util::Optional<bool>& ddns_update_on_renew) {
835 ddns_update_on_renew_ = ddns_update_on_renew;
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
908
913 adaptive_lease_time_threshold) {
914 adaptive_lease_time_threshold_ = adaptive_lease_time_threshold;
915 }
916
920 virtual data::ElementPtr toElement() const;
921
925 virtual std::string getLabel() const {
926 return ("base-network");
927 }
928
929protected:
930
938
965 template<typename ReturnType>
966 ReturnType getGlobalProperty(ReturnType property,
967 const int global_index,
968 const int min_index = -1,
969 const int max_index = -1) const {
970 unused(min_index, max_index);
971 if ((global_index >= 0) && fetch_globals_fn_) {
973 if (globals) {
974 data::ConstElementPtr global_param = globals->get(global_index);
975 if (global_param) {
976 // If there is a global parameter, convert it to the
977 // optional value of the given type and return.
979 }
980 }
981 }
982 return (property);
983 }
984
1003 template<typename NumType>
1005 const int global_index,
1006 const int min_index = -1,
1007 const int max_index = -1) const {
1008
1009 if ((global_index >= 0) && fetch_globals_fn_) {
1011 if (globals) {
1012 data::ConstElementPtr param = globals->get(global_index);
1013 if (param) {
1014 NumType def_value = static_cast<NumType>(param->intValue());
1015 if ((min_index < 0) || (max_index < 0)) {
1016 return (def_value);
1017 } else {
1018 NumType min_value = def_value;
1019 NumType max_value = def_value;
1020 data::ConstElementPtr min_param = globals->get(min_index);
1021 if (min_param) {
1022 min_value = static_cast<NumType>(min_param->intValue());
1023 }
1024 data::ConstElementPtr max_param = globals->get(max_index);
1025 if (max_param) {
1026 max_value = static_cast<NumType>(max_param->intValue());
1027 }
1028 return (isc::util::Triplet<NumType>(min_value, def_value, max_value));
1029 }
1030 }
1031 }
1032 }
1033 return (property);
1034 }
1035
1058 const int global_index,
1059 const int min_index = -1,
1060 const int max_index = -1) const;
1061
1092 template<typename BaseType, typename ReturnType>
1093 ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance&) const,
1094 ReturnType property,
1095 const Inheritance& inheritance,
1096 const int global_index = -1,
1097 const int min_index = -1,
1098 const int max_index = -1) const {
1099
1100 // If no inheritance is to be used, return the value for this
1101 // network regardless if it is specified or not.
1102 if (inheritance == Inheritance::NONE) {
1103 return (property);
1104
1105 } else if (inheritance == Inheritance::PARENT_NETWORK) {
1106 ReturnType parent_property;
1107
1108 // Check if this instance has a parent network.
1109 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1110 if (parent) {
1111 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1112 }
1113 return (parent_property);
1114
1115 // If global value requested, return it.
1116 } else if (inheritance == Inheritance::GLOBAL) {
1117 return (getGlobalProperty(ReturnType(), global_index, min_index, max_index));
1118 }
1119
1120 // We use inheritance and the value is not specified on the network level.
1121 // Hence, we need to get the parent network specific value or global value.
1122 if (property.unspecified()) {
1123 // Check if this instance has a parent network.
1124 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1125 // If the parent network exists, let's fetch the parent specific
1126 // value.
1127 if (parent) {
1128 // We're using inheritance so ask for the parent specific network
1129 // and return it only if it is specified.
1130 auto parent_property = ((*parent).*MethodPointer)(inheritance);
1131 if (!parent_property.unspecified()) {
1132 return (parent_property);
1133 }
1134 }
1135
1136 // The value is not specified on network level. If the value
1137 // can be specified on global level and there is a callback
1138 // that returns the global values, try to find this parameter
1139 // at the global scope.
1140 return (getGlobalProperty(property, global_index, min_index, max_index));
1141 }
1142
1143 // We haven't found the value at any level, so return the unspecified.
1144 return (property);
1145 }
1146
1167 template<typename BaseType>
1168 OptionPtr
1169 getOptionProperty(OptionPtr(BaseType::*MethodPointer)(const Inheritance& inheritance) const,
1170 OptionPtr property,
1171 const Inheritance& inheritance) const {
1172 if (inheritance == Network::Inheritance::NONE) {
1173 return (property);
1174
1175 } else if (inheritance == Network::Inheritance::PARENT_NETWORK) {
1176 OptionPtr parent_property;
1177 // Check if this instance has a parent network.
1178 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1179 // If the parent network exists, let's fetch the parent specific
1180 // value.
1181 if (parent) {
1182 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1183 }
1184 return (parent_property);
1185
1186 } else if (inheritance == Network::Inheritance::GLOBAL) {
1187 return (OptionPtr());
1188 }
1189
1190 // We use inheritance and the value is not specified on the network level.
1191 // Hence, we need to get the parent network specific value.
1192 if (!property) {
1193 // Check if this instance has a parent network.
1194 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1195 if (parent) {
1196 // We're using inheritance so ask for the parent specific network
1197 // and return it only if it is specified.
1198 OptionPtr parent_property = (((*parent).*MethodPointer)(inheritance));
1199 if (parent_property) {
1200 return (parent_property);
1201 }
1202 }
1203 }
1204
1205 // We haven't found the value at any level, so return the unspecified.
1206 return (property);
1207 }
1208
1211
1216
1224
1231
1234
1237
1240
1243
1246
1253
1256
1259
1262
1265
1269
1273
1276
1279
1282
1285
1289
1293
1297
1300
1303
1306
1309
1312
1315
1318
1321
1324
1330
1335
1343
1347};
1348
1350class Network4 : public virtual Network {
1351public:
1352
1355 : Network(), match_client_id_(true, true), authoritative_(),
1356 siaddr_(), sname_(), filename_(), offer_lft_() {
1357 }
1358
1365 getMatchClientId(const Inheritance& inheritance = Inheritance::ALL) const {
1367 match_client_id_,
1368 inheritance,
1370 }
1371
1378 match_client_id_ = match;
1379 }
1380
1388 getAuthoritative(const Inheritance& inheritance = Inheritance::ALL) const {
1390 authoritative_, inheritance,
1392 }
1393
1399 void setAuthoritative(const util::Optional<bool>& authoritative) {
1400 authoritative_ = authoritative;
1401 }
1402
1409
1414 getSiaddr(const Inheritance& inheritance = Inheritance::ALL) const {
1416 inheritance, CfgGlobals::NEXT_SERVER));
1417 }
1418
1422 void setSname(const util::Optional<std::string>& sname);
1423
1429 getSname(const Inheritance& inheritance = Inheritance::ALL) const {
1431 inheritance,
1433 }
1434
1438 void setFilename(const util::Optional<std::string>& filename);
1439
1445 getFilename(const Inheritance& inheritance = Inheritance::ALL) const {
1446 return (getProperty<Network4>(&Network4::getFilename, filename_,
1447 inheritance,
1449 }
1450
1454 void setOfferLft(const util::Optional<uint32_t>& offer_lft) {
1455 offer_lft_ = offer_lft;
1456 }
1457
1463 getOfferLft(const Inheritance& inheritance = Inheritance::ALL) const {
1464 return (getProperty<Network4>(&Network4::getOfferLft, offer_lft_,
1465 inheritance,
1467 }
1468
1472 virtual data::ElementPtr toElement() const;
1473
1478 virtual asiolink::IOAddress getServerId() const;
1479
1480private:
1481
1484 util::Optional<bool> match_client_id_;
1485
1487 util::Optional<bool> authoritative_;
1488
1491
1494
1497
1499 util::Optional<uint32_t> offer_lft_;
1500};
1501
1503typedef boost::shared_ptr<Network4> Network4Ptr;
1504
1505class Network6;
1506
1508typedef boost::shared_ptr<Network6> Network6Ptr;
1509
1511class Network6 : public virtual Network {
1512public:
1513
1516 : Network(), preferred_(), interface_id_(), rapid_commit_(),
1517 default_pd_allocator_type_(){
1518 }
1519
1532
1537 preferred_ = preferred;
1538 }
1539
1546 inheritance));
1547 }
1548
1552 void setInterfaceId(const OptionPtr& ifaceid) {
1553 interface_id_ = ifaceid;
1554 }
1555
1564 getRapidCommit(const Inheritance& inheritance = Inheritance::ALL) const {
1565
1566 return (getProperty<Network6>(&Network6::getRapidCommit, rapid_commit_,
1567 inheritance));
1568 }
1569
1574 void setRapidCommit(const util::Optional<bool>& rapid_commit) {
1575 rapid_commit_ = rapid_commit;
1576 }
1577
1584 pd_allocator_type_,
1585 inheritance,
1587 }
1588
1597 pd_allocator_type_ = allocator_type;
1598 }
1599
1609 default_pd_allocator_type_,
1610 inheritance));
1611 }
1612
1616 void setDefaultPdAllocatorType(const std::string& allocator_type) {
1617 default_pd_allocator_type_ = allocator_type;
1618 }
1619
1623 virtual data::ElementPtr toElement() const;
1624
1625private:
1626
1629
1631 OptionPtr interface_id_;
1632
1638 util::Optional<bool> rapid_commit_;
1639
1641 util::Optional<std::string> pd_allocator_type_;
1642
1643 // @brief Default allocator type for prefix delegation.
1644 util::Optional<std::string> default_pd_allocator_type_;
1645};
1646
1647} // end of namespace isc::dhcp
1648} // end of namespace isc
1649
1650#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:404
Container for storing client class names.
Definition classify.h:110
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:1445
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:1377
util::Optional< std::string > getSname(const Inheritance &inheritance=Inheritance::ALL) const
Returns server hostname for this network.
Definition network.h:1429
util::Optional< asiolink::IOAddress > getSiaddr(const Inheritance &inheritance=Inheritance::ALL) const
Returns siaddr for this network.
Definition network.h:1414
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:1399
void setSiaddr(const util::Optional< asiolink::IOAddress > &siaddr)
Sets siaddr for the network.
Definition network.cc:288
util::Optional< uint32_t > getOfferLft(const Inheritance &inheritance=Inheritance::ALL) const
Returns offer lifetime for the network.
Definition network.h:1463
void setOfferLft(const util::Optional< uint32_t > &offer_lft)
Sets offer lifetime for the network.
Definition network.h:1454
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:1365
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:1388
void setFilename(const util::Optional< std::string > &filename)
Sets boot file name for the network.
Definition network.cc:302
virtual asiolink::IOAddress getServerId() const
Returns binary representation of the dhcp-server-identifier option (54).
Definition network.cc:344
Network4()
Constructor.
Definition network.h:1354
virtual data::ElementPtr toElement() const
Unparses network object.
Definition network.cc:307
void setSname(const util::Optional< std::string > &sname)
Sets server hostname for the network.
Definition network.cc:297
Specialization of the Network object for DHCPv6 case.
Definition network.h:1511
void setRapidCommit(const util::Optional< bool > &rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
Definition network.h:1574
void setDefaultPdAllocatorType(const std::string &allocator_type)
Sets a defalt allocator type for prefix delegation.
Definition network.h:1616
util::Optional< std::string > getDefaultPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns a default allocator type for prefix delegation.
Definition network.h:1607
isc::util::Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds)
Definition network.h:1525
void setPdAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type for prefix delegation.
Definition network.h:1596
Network6()
Constructor.
Definition network.h:1515
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:1564
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
Definition network.h:1552
void setPreferred(const isc::util::Triplet< uint32_t > &preferred)
Sets new preferred lifetime for a network.
Definition network.h:1536
virtual data::ElementPtr toElement() const
Unparses network object.
Definition network.cc:359
OptionPtr getInterfaceId(const Inheritance &inheritance=Inheritance::ALL) const
Returns interface-id value (if specified)
Definition network.h:1544
util::Optional< std::string > getPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type for prefix delegation.
Definition network.h:1582
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:1236
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:1292
RelayInfo relay_
Relay information.
Definition network.h:1215
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:792
util::Optional< bool > reservations_out_of_pool_
Enables out-of-pool reservations optimization.
Definition network.h:1252
util::Optional< std::string > getHostnameCharReplacement(const Inheritance &inheritance=Inheritance::ALL) const
Return the invalid char replacement used to sanitize client hostnames.
Definition network.h:757
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
Definition network.h:1305
util::Optional< std::string > allocator_type_
Allocator used for IP address allocations.
Definition network.h:1323
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
Definition network.h:1255
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: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:719
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:817
ClientClasses additional_classes_
Additional classes.
Definition network.h:1230
util::Optional< double > getDdnsTtlPercent(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl-percent.
Definition network.h:674
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:801
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:1242
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:1275
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:1169
void setDdnsTtlMax(const util::Optional< uint32_t > &ddns_ttl_max)
Sets new ddns-ttl-max.
Definition network.h:736
util::Optional< bool > reservations_in_subnet_
Enables subnet reservations.
Definition network.h:1245
util::Optional< std::string > getHostnameCharSet(const Inheritance &inheritance=Inheritance::ALL) const
Return the char set regexp used to sanitize client hostnames.
Definition network.h:742
FetchNetworkGlobalsFn getFetchGlobalsFn() const
Gets the optional callback function used to fetch globally configured parameters.
Definition network.h:935
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:1346
void setStoreExtendedInfo(const util::Optional< bool > &store_extended_info)
Sets new store-extended-info.
Definition network.h:784
util::Optional< double > t2_percent_
Percentage of the lease lifetime to use when calculating T2 timer.
Definition network.h:1264
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:825
util::Optional< uint32_t > getDdnsTtlMax(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl-max.
Definition network.h:727
ClientClasses client_classes_
List of client classes allowed to use this network.
Definition network.h:1223
util::Optional< double > adaptive_lease_time_threshold_
Percentage of the adaptive lease time threshold.
Definition network.h:1334
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:1342
util::Optional< double > getAdaptiveLeaseTimeThreshold(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage of the adaptive lease time threshold,.
Definition network.h:902
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:1093
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:1281
util::Optional< double > t1_percent_
Percentage of the lease lifetime to use when calculating T1 timer.
Definition network.h:1261
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:852
util::Optional< uint32_t > ddns_ttl_min_
Minimum value to use for DNS TTL.
Definition network.h:1317
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:860
void setHostnameCharSet(const util::Optional< std::string > &hostname_char_set)
Sets new hostname-char-set.
Definition network.h:751
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:701
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:1288
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 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: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:692
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:1210
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:925
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:1004
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
Definition network.h:1268
virtual ~Network()
Virtual destructor.
Definition network.h:231
util::Optional< std::string > ddns_conflict_resolution_mode_
DDNS conflict resolution mode.
Definition network.h:1308
util::Optional< bool > store_extended_info_
Should Kea store additional client query data (e.g.
Definition network.h:1296
isc::util::Triplet< uint32_t > valid_
a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
Definition network.h:1239
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:1258
util::Optional< uint32_t > cache_max_age_
Value in seconds to use as cache maximal age.
Definition network.h:1302
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:966
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
Definition network.h:1272
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:1284
util::Optional< bool > getStoreExtendedInfo(const Inheritance &inheritance=Inheritance::ALL) const
Returns store-extended-info.
Definition network.h:775
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 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:445
void setHostnameCharReplacement(const util::Optional< std::string > &hostname_char_replacement)
Sets new hostname-char-replacement.
Definition network.h:766
util::Optional< uint32_t > getCacheMaxAge(const Inheritance &inheritance=Inheritance::ALL) const
Returns value in seconds to use as cache maximum age.
Definition network.h:809
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:1320
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:834
void setDdnsQualifyingSuffix(const util::Optional< std::string > &ddns_qualifying_suffix)
Sets new ddns-qualifying-suffix.
Definition network.h:666
util::Optional< double > ddns_ttl_percent_
Percentage of the lease lifetime to use for DNS TTL.
Definition network.h:1311
util::Optional< uint32_t > ddns_ttl_
Explicit value to use for DNS TTL.
Definition network.h:1314
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:683
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:1278
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:1329
isc::util::Triplet< uint32_t > t1_
a isc::util::Triplet (min/default/max) holding allowed renew timer values
Definition network.h:1233
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:912
util::Optional< double > cache_threshold_
Percentage of the lease lifetime to use as cache threshold.
Definition network.h:1299
util::Optional< uint32_t > getDdnsTtlMin(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-ttl-min.
Definition network.h:710
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:44
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:1503
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition cfg_option.h:973
boost::shared_ptr< Network6 > Network6Ptr
Pointer to the Network6 object.
Definition network.h:1508
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:976
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