Kea 2.2.0
network.h
Go to the documentation of this file.
1// Copyright (C) 2017-2022 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#include <boost/shared_ptr.hpp>
24#include <boost/weak_ptr.hpp>
25#include <cstdint>
26#include <functional>
27#include <string>
28
30namespace {
31template <typename... Args>
32inline void unused(Args const& ...) {}
33} // end of anonymous namespace
34
35namespace isc {
36namespace dhcp {
37
39typedef std::vector<isc::asiolink::IOAddress> IOAddressList;
40
41class Network;
42
44typedef boost::shared_ptr<Network> NetworkPtr;
45
47typedef boost::weak_ptr<Network> WeakNetworkPtr;
48
51typedef std::function<ConstCfgGlobalsPtr()> FetchNetworkGlobalsFn;
52
123class Network : public virtual isc::data::StampedElement,
124 public virtual isc::data::UserContext,
126public:
133 class RelayInfo {
134 public:
135
140 void addAddress(const asiolink::IOAddress& addr);
141
145 const IOAddressList& getAddresses() const;
146
150 bool hasAddresses() const;
151
155 bool containsAddress(const asiolink::IOAddress& addr) const;
156
157 private:
159 IOAddressList addresses_;
160 };
161
173 enum class Inheritance {
174 NONE,
175 PARENT_NETWORK,
176 GLOBAL,
177 ALL
178 };
179
181 typedef boost::shared_ptr<Network::RelayInfo> RelayInfoPtr;
182
185 : iface_name_(), client_class_(), t1_(), t2_(), valid_(),
186 reservations_global_(false, true), reservations_in_subnet_(true, true),
194 }
195
199 virtual ~Network() { };
200
206 fetch_globals_fn_ = fetch_globals_fn;
207 }
208
213 bool hasFetchGlobalsFn() const {
214 return (static_cast<bool>(fetch_globals_fn_));
215 }
216
226 void setIface(const util::Optional<std::string>& iface_name) {
227 if (iface_name.empty()) {
229 } else {
230 iface_name_ = iface_name;
231 }
232 }
233
240 getIface(const Inheritance& inheritance = Inheritance::ALL) const {
241 return (getProperty<Network>(&Network::getIface, iface_name_,
242 inheritance));
243 };
244
264 void setRelayInfo(const RelayInfo& relay) {
265 relay_ = relay;
266 }
267
274 const RelayInfo& getRelayInfo() const {
275 return (relay_);
276 }
277
282 void addRelayAddress(const asiolink::IOAddress& addr);
283
287 const IOAddressList& getRelayAddresses() const;
288
292 bool hasRelays() const;
293
298 bool hasRelayAddress(const asiolink::IOAddress& address) const;
299
314 virtual bool
315 clientSupported(const isc::dhcp::ClientClasses& client_classes) const;
316
320 void allowClientClass(const isc::dhcp::ClientClass& class_name);
321
325 void requireClientClass(const isc::dhcp::ClientClass& class_name);
326
328 const ClientClasses& getRequiredClasses() const;
329
338 getClientClass(const Inheritance& inheritance = Inheritance::ALL) const {
339 return (getProperty<Network>(&Network::getClientClass, client_class_,
340 inheritance));
341 }
342
347 return (getProperty<Network>(&Network::getValid, valid_, inheritance,
351 }
352
357 valid_ = valid;
358 }
359
364 return (getProperty<Network>(&Network::getT1, t1_, inheritance,
366 }
367
372 t1_ = t1;
373 }
374
379 return (getProperty<Network>(&Network::getT2, t2_, inheritance,
381 }
382
387 t2_ = t2;
388 }
389
395 return (getProperty<Network>(&Network::getReservationsGlobal,
397 inheritance,
399 }
400
404 void setReservationsGlobal(const util::Optional<bool>& reservations_global) {
405 reservations_global_ = reservations_global;
406 }
407
413 return (getProperty<Network>(&Network::getReservationsInSubnet,
415 inheritance,
417 }
418
422 void setReservationsInSubnet(const util::Optional<bool>& reservations_in_subnet) {
423 reservations_in_subnet_ = reservations_in_subnet;
424 }
425
431 return (getProperty<Network>(&Network::getReservationsOutOfPool,
433 inheritance,
435 }
436
440 void setReservationsOutOfPool(const util::Optional<bool>& reservations_out_of_pool) {
441 reservations_out_of_pool_ = reservations_out_of_pool;
442 }
443
446 return (cfg_option_);
447 }
448
452 return (cfg_option_);
453 }
454
460 return (getProperty<Network>(&Network::getCalculateTeeTimes,
462 inheritance,
464 }
465
469 void setCalculateTeeTimes(const util::Optional<bool>& calculate_tee_times) {
470 calculate_tee_times_ = calculate_tee_times;
471 }
472
477 getT1Percent(const Inheritance& inheritance = Inheritance::ALL) const {
478 return (getProperty<Network>(&Network::getT1Percent, t1_percent_,
479 inheritance, CfgGlobals::T1_PERCENT));
480 }
481
485 void setT1Percent(const util::Optional<double>& t1_percent) {
486 t1_percent_ = t1_percent;
487 }
488
493 getT2Percent(const Inheritance& inheritance = Inheritance::ALL) const {
494 return (getProperty<Network>(&Network::getT2Percent, t2_percent_,
495 inheritance, CfgGlobals::T2_PERCENT));
496 }
497
501 void setT2Percent(const util::Optional<double>& t2_percent) {
502 t2_percent_ = t2_percent;
503 }
504
509 getDdnsSendUpdates(const Inheritance& inheritance = Inheritance::ALL) const {
510 return (getProperty<Network>(&Network::getDdnsSendUpdates,
511 ddns_send_updates_, inheritance,
513 }
514
518 void setDdnsSendUpdates(const util::Optional<bool>& ddns_send_updates) {
519 ddns_send_updates_ = ddns_send_updates;
520 }
521
527 return (getProperty<Network>(&Network::getDdnsOverrideNoUpdate,
528 ddns_override_no_update_, inheritance,
530 }
531
535 void setDdnsOverrideNoUpdate(const util::Optional<bool>& ddns_override_no_update) {
536 ddns_override_no_update_ = ddns_override_no_update;
537 }
538
544 return (getProperty<Network>(&Network::getDdnsOverrideClientUpdate,
545 ddns_override_client_update_, inheritance,
547 }
548
553 ddns_override_client_update) {
554 ddns_override_client_update_ = ddns_override_client_update;
555 }
556
562 // Inheritance for ddns-replace-client-name is a little different than for other
563 // parameters. The value at the global level is given as a string.
564 // Thus we call getProperty here without a global name to check if it
565 // is specified on network level only.
567 getProperty<Network>(&Network::getDdnsReplaceClientNameMode,
568 ddns_replace_client_name_mode_, inheritance);
569
570 // If it is not specified at network level we need this special
571 // case code to convert the global string value to an enum.
572 if (mode.unspecified() && (inheritance != Inheritance::NONE) &&
573 (inheritance != Inheritance::PARENT_NETWORK)) {
574 // Get global mode.
576 mode_label = getGlobalProperty(mode_label,
578 if (!mode_label.unspecified()) {
579 try {
580 // If the mode is globally configured, convert it to an enum.
582 } catch (...) {
583 // This should not really happen because the configuration
584 // parser should have already verified the globally configured
585 // mode. However, we want to be 100% sure that this
586 // method doesn't throw. Let's just return unspecified.
587 return (mode);
588 }
589 }
590 }
591 return (mode);
592 }
593
597 void
599 ddns_replace_client_name_mode) {
600 ddns_replace_client_name_mode_ = ddns_replace_client_name_mode;
601 }
602
608 return (getProperty<Network>(&Network::getDdnsGeneratedPrefix,
609 ddns_generated_prefix_, inheritance,
611 }
612
616 void setDdnsGeneratedPrefix(const util::Optional<std::string>& ddns_generated_prefix) {
617 ddns_generated_prefix_ = ddns_generated_prefix;
618 }
619
625 return (getProperty<Network>(&Network::getDdnsQualifyingSuffix,
626 ddns_qualifying_suffix_, inheritance,
628 }
629
633 void setDdnsQualifyingSuffix(const util::Optional<std::string>& ddns_qualifying_suffix) {
634 ddns_qualifying_suffix_ = ddns_qualifying_suffix;
635 }
636
639 getHostnameCharSet(const Inheritance& inheritance = Inheritance::ALL) const {
640 return (getProperty<Network>(&Network::getHostnameCharSet,
641 hostname_char_set_, inheritance,
643 }
644
648 void setHostnameCharSet(const util::Optional<std::string>& hostname_char_set) {
649 hostname_char_set_ = hostname_char_set;
650 }
651
655 return (getProperty<Network>(&Network::getHostnameCharReplacement,
656 hostname_char_replacement_, inheritance,
658 }
659
664 hostname_char_replacement) {
665 hostname_char_replacement_ = hostname_char_replacement;
666 }
667
673 return (getProperty<Network>(&Network::getStoreExtendedInfo,
674 store_extended_info_, inheritance,
676 }
677
681 void setStoreExtendedInfo(const util::Optional<bool>& store_extended_info) {
682 store_extended_info_ = store_extended_info;
683 }
684
689 getCacheThreshold(const Inheritance& inheritance = Inheritance::ALL) const {
690 return (getProperty<Network>(&Network::getCacheThreshold,
691 cache_threshold_, inheritance,
693 }
694
698 void setCacheThreshold(const util::Optional<double>& cache_threshold) {
699 cache_threshold_ = cache_threshold;
700 }
701
706 getCacheMaxAge(const Inheritance& inheritance = Inheritance::ALL) const {
707 return (getProperty<Network>(&Network::getCacheMaxAge, cache_max_age_,
708 inheritance, CfgGlobals::CACHE_MAX_AGE));
709 }
710
714 void setCacheMaxAge(const util::Optional<uint32_t>& cache_max_age) {
715 cache_max_age_ = cache_max_age;
716 }
717
723 return (getProperty<Network>(&Network::getDdnsUpdateOnRenew,
724 ddns_update_on_renew_, inheritance,
726 }
727
731 void setDdnsUpdateOnRenew(const util::Optional<bool>& ddns_update_on_renew) {
732 ddns_update_on_renew_ = ddns_update_on_renew;
733 }
734
740 return (getProperty<Network>(&Network::getDdnsUseConflictResolution,
742 inheritance,
744 }
745
749 void setDdnsUseConflictResolution(const util::Optional<bool>& ddns_use_conflict_resolution) {
750 ddns_use_conflict_resolution_ = ddns_use_conflict_resolution;
751 }
752
756 virtual data::ElementPtr toElement() const;
757
758protected:
759
765 return (fetch_globals_fn_);
766 }
767
794 template<typename ReturnType>
795 ReturnType getGlobalProperty(ReturnType property,
796 const int global_index,
797 const int min_index = -1,
798 const int max_index = -1) const {
799 unused(min_index, max_index);
800 if ((global_index >= 0) && fetch_globals_fn_) {
802 if (globals) {
803 data::ConstElementPtr global_param = globals->get(global_index);
804 if (global_param) {
805 // If there is a global parameter, convert it to the
806 // optional value of the given type and return.
808 }
809 }
810 }
811 return (property);
812 }
813
832 template<typename NumType>
834 const int global_index,
835 const int min_index = -1,
836 const int max_index = -1) const {
837
838 if ((global_index >= 0) && fetch_globals_fn_) {
840 if (globals) {
841 data::ConstElementPtr param = globals->get(global_index);
842 if (param) {
843 NumType def_value = static_cast<NumType>(param->intValue());
844 if ((min_index < 0) || (max_index < 0)) {
845 return (def_value);
846 } else {
847 NumType min_value = def_value;
848 NumType max_value = def_value;
849 data::ConstElementPtr min_param = globals->get(min_index);
850 if (min_param) {
851 min_value = static_cast<NumType>(min_param->intValue());
852 }
853 data::ConstElementPtr max_param = globals->get(max_index);
854 if (max_param) {
855 max_value = static_cast<NumType>(max_param->intValue());
856 }
857 return (isc::util::Triplet<NumType>(min_value, def_value, max_value));
858 }
859 }
860 }
861 }
862 return (property);
863 }
864
887 const int global_index,
888 const int min_index = -1,
889 const int max_index = -1) const;
890
921 template<typename BaseType, typename ReturnType>
922 ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance&) const,
923 ReturnType property,
924 const Inheritance& inheritance,
925 const int global_index = -1,
926 const int min_index = -1,
927 const int max_index = -1) const {
928
929 // If no inheritance is to be used, return the value for this
930 // network regardless if it is specified or not.
931 if (inheritance == Inheritance::NONE) {
932 return (property);
933
934 } else if (inheritance == Inheritance::PARENT_NETWORK) {
935 ReturnType parent_property;
936
937 // Check if this instance has a parent network.
938 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
939 if (parent) {
940 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
941 }
942 return (parent_property);
943
944 // If global value requested, return it.
945 } else if (inheritance == Inheritance::GLOBAL) {
946 return (getGlobalProperty(ReturnType(), global_index, min_index, max_index));
947 }
948
949 // We use inheritance and the value is not specified on the network level.
950 // Hence, we need to get the parent network specific value or global value.
951 if (property.unspecified()) {
952 // Check if this instance has a parent network.
953 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
954 // If the parent network exists, let's fetch the parent specific
955 // value.
956 if (parent) {
957 // We're using inheritance so ask for the parent specific network
958 // and return it only if it is specified.
959 auto parent_property = ((*parent).*MethodPointer)(inheritance);
960 if (!parent_property.unspecified()) {
961 return (parent_property);
962 }
963 }
964
965 // The value is not specified on network level. If the value
966 // can be specified on global level and there is a callback
967 // that returns the global values, try to find this parameter
968 // at the global scope.
969 return (getGlobalProperty(property, global_index, min_index, max_index));
970 }
971
972 // We haven't found the value at any level, so return the unspecified.
973 return (property);
974 }
975
996 template<typename BaseType>
998 getOptionProperty(OptionPtr(BaseType::*MethodPointer)(const Inheritance& inheritance) const,
999 OptionPtr property,
1000 const Inheritance& inheritance) const {
1001 if (inheritance == Network::Inheritance::NONE) {
1002 return (property);
1003
1004 } else if (inheritance == Network::Inheritance::PARENT_NETWORK) {
1005 OptionPtr parent_property;
1006 // Check if this instance has a parent network.
1007 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1008 // If the parent network exists, let's fetch the parent specific
1009 // value.
1010 if (parent) {
1011 parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1012 }
1013 return (parent_property);
1014
1015 } else if (inheritance == Network::Inheritance::GLOBAL) {
1016 return (OptionPtr());
1017 }
1018
1019 // We use inheritance and the value is not specified on the network level.
1020 // Hence, we need to get the parent network specific value.
1021 if (!property) {
1022 // Check if this instance has a parent network.
1023 auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1024 if (parent) {
1025 // We're using inheritance so ask for the parent specific network
1026 // and return it only if it is specified.
1027 OptionPtr parent_property = (((*parent).*MethodPointer)(inheritance));
1028 if (parent_property) {
1029 return (parent_property);
1030 }
1031 }
1032 }
1033
1034 // We haven't found the value at any level, so return the unspecified.
1035 return (property);
1036 }
1037
1040
1045
1052
1058
1061
1064
1067
1070
1073
1080
1083
1086
1089
1092
1096
1100
1103
1106
1109
1112
1116
1120
1124
1127
1130
1133
1136
1144
1148};
1149
1151class Network4 : public virtual Network {
1152public:
1153
1156 : Network(), match_client_id_(true, true), authoritative_(),
1157 siaddr_(), sname_(), filename_() {
1158 }
1159
1166 getMatchClientId(const Inheritance& inheritance = Inheritance::ALL) const {
1167 return (getProperty<Network4>(&Network4::getMatchClientId,
1168 match_client_id_,
1169 inheritance,
1171 }
1172
1179 match_client_id_ = match;
1180 }
1181
1189 getAuthoritative(const Inheritance& inheritance = Inheritance::ALL) const {
1190 return (getProperty<Network4>(&Network4::getAuthoritative,
1191 authoritative_, inheritance,
1193 }
1194
1200 void setAuthoritative(const util::Optional<bool>& authoritative) {
1201 authoritative_ = authoritative;
1202 }
1203
1210
1215 getSiaddr(const Inheritance& inheritance = Inheritance::ALL) const {
1216 return (getProperty<Network4>(&Network4::getSiaddr, siaddr_,
1217 inheritance, CfgGlobals::NEXT_SERVER));
1218 }
1219
1223 void setSname(const util::Optional<std::string>& sname);
1224
1230 getSname(const Inheritance& inheritance = Inheritance::ALL) const {
1231 return (getProperty<Network4>(&Network4::getSname, sname_,
1232 inheritance,
1234 }
1235
1239 void setFilename(const util::Optional<std::string>& filename);
1240
1246 getFilename(const Inheritance& inheritance = Inheritance::ALL) const {
1247 return (getProperty<Network4>(&Network4::getFilename, filename_,
1248 inheritance,
1250 }
1251
1255 virtual data::ElementPtr toElement() const;
1256
1261 virtual asiolink::IOAddress getServerId() const;
1262
1263private:
1264
1267 util::Optional<bool> match_client_id_;
1268
1270 util::Optional<bool> authoritative_;
1271
1274
1277
1280};
1281
1283class Network6 : public virtual Network {
1284public:
1285
1288 : Network(), preferred_(), interface_id_(), rapid_commit_() {
1289 }
1290
1296 getPreferred(const Inheritance& inheritance = Inheritance::ALL) const {
1297 return (getProperty<Network6>(&Network6::getPreferred, preferred_,
1298 inheritance,
1302 }
1303
1308 preferred_ = preferred;
1309 }
1310
1316 return (getOptionProperty<Network6>(&Network6::getInterfaceId, interface_id_,
1317 inheritance));
1318 }
1319
1323 void setInterfaceId(const OptionPtr& ifaceid) {
1324 interface_id_ = ifaceid;
1325 }
1326
1335 getRapidCommit(const Inheritance& inheritance = Inheritance::ALL) const {
1336
1337 return (getProperty<Network6>(&Network6::getRapidCommit, rapid_commit_,
1338 inheritance));
1339 }
1340
1345 void setRapidCommit(const util::Optional<bool>& rapid_commit) {
1346 rapid_commit_ = rapid_commit;
1347 };
1348
1352 virtual data::ElementPtr toElement() const;
1353
1354private:
1355
1358
1360 OptionPtr interface_id_;
1361
1367 util::Optional<bool> rapid_commit_;
1368};
1369
1370} // end of namespace isc::dhcp
1371} // end of namespace isc
1372
1373#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.
Definition: element_value.h:43
This class represents configuration element which is associated with database identifier,...
Represents option data configuration for the DHCP server.
Definition: cfg_option.h:314
Container for storing client class names.
Definition: classify.h:70
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:1151
util::Optional< std::string > getFilename(const Inheritance &inheritance=Inheritance::ALL) const
Returns boot file name for this subnet.
Definition: network.h:1246
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:1178
util::Optional< std::string > getSname(const Inheritance &inheritance=Inheritance::ALL) const
Returns server hostname for this network.
Definition: network.h:1230
util::Optional< asiolink::IOAddress > getSiaddr(const Inheritance &inheritance=Inheritance::ALL) const
Returns siaddr for this network.
Definition: network.h:1215
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:1200
void setSiaddr(const util::Optional< asiolink::IOAddress > &siaddr)
Sets siaddr for the network.
Definition: network.cc:278
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:1166
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:1189
void setFilename(const util::Optional< std::string > &filename)
Sets boot file name for the network.
Definition: network.cc:292
virtual asiolink::IOAddress getServerId() const
Returns binary representation of the dhcp-server-identifier option (54).
Definition: network.cc:329
Network4()
Constructor.
Definition: network.h:1155
virtual data::ElementPtr toElement() const
Unparses network object.
Definition: network.cc:297
void setSname(const util::Optional< std::string > &sname)
Sets server hostname for the network.
Definition: network.cc:287
Specialization of the Network object for DHCPv6 case.
Definition: network.h:1283
void setRapidCommit(const util::Optional< bool > &rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
Definition: network.h:1345
isc::util::Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds)
Definition: network.h:1296
Network6()
Constructor.
Definition: network.h:1287
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:1335
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
Definition: network.h:1323
void setPreferred(const isc::util::Triplet< uint32_t > &preferred)
Sets new preferred lifetime for a network.
Definition: network.h:1307
virtual data::ElementPtr toElement() const
Unparses network object.
Definition: network.cc:344
OptionPtr getInterfaceId(const Inheritance &inheritance=Inheritance::ALL) const
Returns interface-id value (if specified)
Definition: network.h:1315
Holds optional information about relay.
Definition: network.h:133
const IOAddressList & getAddresses() const
Returns const reference to the list of addresses.
Definition: network.cc:50
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:125
virtual bool clientSupported(const isc::dhcp::ClientClasses &client_classes) const
Checks whether this network supports client that belongs to specified classes.
Definition: network.cc:75
util::Optional< bool > getCalculateTeeTimes(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether or not T1/T2 calculation is enabled.
Definition: network.h:459
util::Optional< std::string > getDdnsQualifyingSuffix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-qualifying-suffix.
Definition: network.h:624
isc::util::Triplet< uint32_t > t2_
a isc::util::Triplet (min/default/max) holding allowed rebind timer values
Definition: network.h:1063
util::Optional< D2ClientConfig::ReplaceClientNameMode > getDdnsReplaceClientNameMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-replace-client-name-mode.
Definition: network.h:561
void setT2(const isc::util::Triplet< uint32_t > &t2)
Sets new rebind timer for a network.
Definition: network.h:386
void addRelayAddress(const asiolink::IOAddress &addr)
Adds an address to the list addresses in the network's relay info.
Definition: network.cc:55
util::Optional< std::string > hostname_char_replacement_
A string to replace invalid characters when scrubbing hostnames.
Definition: network.h:1119
RelayInfo relay_
Relay information.
Definition: network.h:1044
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
Definition: network.h:181
util::Optional< double > getCacheThreshold(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use as cache threshold.
Definition: network.h:689
util::Optional< bool > reservations_out_of_pool_
Enables out-of-pool reservations optimization.
Definition: network.h:1079
util::Optional< std::string > getHostnameCharReplacement(const Inheritance &inheritance=Inheritance::ALL) const
Return the invalid char replacement used to sanitize client hostnames.
Definition: network.h:654
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
Definition: network.h:1132
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
Definition: network.h:1082
void setDdnsReplaceClientNameMode(const util::Optional< D2ClientConfig::ReplaceClientNameMode > &ddns_replace_client_name_mode)
Sets new ddns-replace-client-name-mode.
Definition: network.h:598
Network()
Constructor.
Definition: network.h:184
void requireClientClass(const isc::dhcp::ClientClass &class_name)
Adds class class_name to classes required to be evaluated.
Definition: network.cc:91
const IOAddressList & getRelayAddresses() const
Returns the list of relay addresses from the network's relay info.
Definition: network.cc:70
void setCacheMaxAge(const util::Optional< uint32_t > &cache_max_age)
Sets cache max for a network.
Definition: network.h:714
void allowClientClass(const isc::dhcp::ClientClass &class_name)
Sets the supported class to class class_name.
Definition: network.cc:86
Inheritance
Inheritance "mode" used when fetching an optional Network parameter.
Definition: network.h:173
void setCacheThreshold(const util::Optional< double > &cache_threshold)
Sets cache threshold for a network.
Definition: network.h:698
void setT1Percent(const util::Optional< double > &t1_percent)
Sets new percentage for calculating T1 (renew timer).
Definition: network.h:485
util::Optional< bool > reservations_global_
Enables global reservations.
Definition: network.h:1069
util::Optional< bool > getDdnsOverrideClientUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-client-update.
Definition: network.h:543
bool hasFetchGlobalsFn() const
Checks if the network is associated with a function used to fetch globally configured parameters.
Definition: network.h:213
util::Optional< bool > ddns_override_client_update_
Should Kea perform updates, even if client requested delegation.
Definition: network.h:1102
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:998
util::Optional< bool > reservations_in_subnet_
Enables subnet reservations.
Definition: network.h:1072
util::Optional< std::string > getHostnameCharSet(const Inheritance &inheritance=Inheritance::ALL) const
Return the char set regexp used to sanitize client hostnames.
Definition: network.h:639
FetchNetworkGlobalsFn getFetchGlobalsFn() const
Gets the optional callback function used to fetch globally configured parameters.
Definition: network.h:764
void setReservationsInSubnet(const util::Optional< bool > &reservations_in_subnet)
Sets whether subnet reservations should be fetched.
Definition: network.h:422
FetchNetworkGlobalsFn fetch_globals_fn_
Pointer to the optional callback used to fetch globally configured parameters inherited to the Networ...
Definition: network.h:1147
void setStoreExtendedInfo(const util::Optional< bool > &store_extended_info)
Sets new store-extended-info.
Definition: network.h:681
util::Optional< double > t2_percent_
Percentage of the lease lifetime to use when calculating T2 timer.
Definition: network.h:1091
void setIface(const util::Optional< std::string > &iface_name)
Sets local name of the interface for which this network is selected.
Definition: network.h:226
util::Optional< bool > getDdnsUpdateOnRenew(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-update-on-renew.
Definition: network.h:722
void setDdnsOverrideClientUpdate(const util::Optional< bool > &ddns_override_client_update)
Sets new ddns-override-client-update.
Definition: network.h:552
const RelayInfo & getRelayInfo() const
Returns const reference to relay information.
Definition: network.h:274
WeakNetworkPtr parent_network_
Pointer to another network that this network belongs to.
Definition: network.h:1143
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:922
isc::util::Triplet< uint32_t > getT1(const Inheritance &inheritance=Inheritance::ALL) const
Returns T1 (renew timer), expressed in seconds.
Definition: network.h:363
util::Optional< bool > getReservationsGlobal(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether global reservations should be fetched.
Definition: network.h:394
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
Definition: network.h:1108
util::Optional< double > t1_percent_
Percentage of the lease lifetime to use when calculating T1 timer.
Definition: network.h:1088
bool hasRelays() const
Indicates if network's relay info has relay addresses.
Definition: network.cc:60
util::Optional< bool > getDdnsOverrideNoUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-no-update.
Definition: network.h:526
util::Optional< ClientClass > client_class_
Optional definition of a client class.
Definition: network.h:1051
void setHostnameCharSet(const util::Optional< std::string > &hostname_char_set)
Sets new hostname-char-set.
Definition: network.h:648
util::Optional< std::string > getDdnsGeneratedPrefix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-generated-prefix.
Definition: network.h:607
util::Optional< bool > getDdnsSendUpdates(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-send-updates.
Definition: network.h:509
virtual data::ElementPtr toElement() const
Unparses network object.
Definition: network.cc:123
void setReservationsOutOfPool(const util::Optional< bool > &reservations_out_of_pool)
Sets whether only out-of-pool reservations are allowed.
Definition: network.h:440
util::Optional< std::string > hostname_char_set_
Regular expression describing invalid characters for client hostnames.
Definition: network.h:1115
void setDdnsGeneratedPrefix(const util::Optional< std::string > &ddns_generated_prefix)
Sets new ddns-generated-prefix.
Definition: network.h:616
void setT1(const isc::util::Triplet< uint32_t > &t1)
Sets new renew timer for a network.
Definition: network.h:371
bool hasRelayAddress(const asiolink::IOAddress &address) const
Tests if the network's relay info contains the given address.
Definition: network.cc:65
util::Optional< double > getT2Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T2 (rebind timer).
Definition: network.h:493
util::Optional< std::string > iface_name_
Holds interface name for which this network is selected.
Definition: network.h:1039
void setFetchGlobalsFn(FetchNetworkGlobalsFn fetch_globals_fn)
Sets the optional callback function used to fetch globally configured parameters.
Definition: network.h:205
isc::util::Triplet< uint32_t > getT2(const Inheritance &inheritance=Inheritance::ALL) const
Returns T2 (rebind timer), expressed in seconds.
Definition: network.h:378
void setDdnsUseConflictResolution(const util::Optional< bool > &ddns_use_conflict_resolution)
Sets new ddns-use-conflict-resolution.
Definition: network.h:749
void setValid(const isc::util::Triplet< uint32_t > &valid)
Sets new valid lifetime for a network.
Definition: network.h:356
void setT2Percent(const util::Optional< double > &t2_percent)
Sets new percentage for calculating T2 (rebind timer).
Definition: network.h:501
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:833
const ClientClasses & getRequiredClasses() const
Returns classes which are required to be evaluated.
Definition: network.cc:98
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
Definition: network.h:1095
virtual ~Network()
Virtual destructor.
Definition: network.h:199
util::Optional< bool > store_extended_info_
Should Kea store additional client query data (e.g.
Definition: network.h:1123
isc::util::Triplet< uint32_t > valid_
a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
Definition: network.h:1066
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this network.
Definition: network.h:451
util::Optional< bool > getReservationsOutOfPool(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether only out-of-pool reservations are allowed.
Definition: network.h:430
util::Optional< bool > calculate_tee_times_
Enables calculation of T1 and T2 timers.
Definition: network.h:1085
util::Optional< bool > ddns_use_conflict_resolution_
Used to to tell kea-dhcp-ddns whether or not to use conflict resolution.
Definition: network.h:1135
util::Optional< uint32_t > cache_max_age_
Value in seconds to use as cache maximal age.
Definition: network.h:1129
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:795
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
Definition: network.h:1099
void setCalculateTeeTimes(const util::Optional< bool > &calculate_tee_times)
Sets whether or not T1/T2 calculation is enabled.
Definition: network.h:469
util::Optional< std::string > ddns_qualifying_suffix_
Suffix Kea should use when to qualify partial domain-names.
Definition: network.h:1111
ClientClasses required_classes_
Required classes.
Definition: network.h:1057
util::Optional< bool > getStoreExtendedInfo(const Inheritance &inheritance=Inheritance::ALL) const
Returns store-extended-info.
Definition: network.h:672
void setDdnsOverrideNoUpdate(const util::Optional< bool > &ddns_override_no_update)
Sets new ddns-override-no-update.
Definition: network.h:535
util::Optional< bool > getReservationsInSubnet(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether subnet reservations should be fetched.
Definition: network.h:412
void setHostnameCharReplacement(const util::Optional< std::string > &hostname_char_replacement)
Sets new hostname-char-replacement.
Definition: network.h:663
util::Optional< bool > getDdnsUseConflictResolution(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-use-conflict-resolution.
Definition: network.h:739
util::Optional< uint32_t > getCacheMaxAge(const Inheritance &inheritance=Inheritance::ALL) const
Returns value in seconds to use as cache maximum age.
Definition: network.h:706
void setReservationsGlobal(const util::Optional< bool > &reservations_global)
Sets whether global reservations should be fetched.
Definition: network.h:404
util::Optional< double > getT1Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T1 (renew timer).
Definition: network.h:477
void setDdnsSendUpdates(const util::Optional< bool > &ddns_send_updates)
Sets new ddns-send-updates.
Definition: network.h:518
void setDdnsUpdateOnRenew(const util::Optional< bool > &ddns_update_on_renew)
Sets new ddns-update-on-renew.
Definition: network.h:731
void setDdnsQualifyingSuffix(const util::Optional< std::string > &ddns_qualifying_suffix)
Sets new ddns-qualifying-suffix.
Definition: network.h:633
util::Optional< ClientClass > getClientClass(const Inheritance &inheritance=Inheritance::ALL) const
returns the client class
Definition: network.h:338
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:240
util::Optional< D2ClientConfig::ReplaceClientNameMode > ddns_replace_client_name_mode_
How Kea should handle the domain-name supplied by the client.
Definition: network.h:1105
void setRelayInfo(const RelayInfo &relay)
Sets information about relay.
Definition: network.h:264
isc::util::Triplet< uint32_t > getValid(const Inheritance &inheritance=Inheritance::ALL) const
Return valid-lifetime for addresses in that prefix.
Definition: network.h:346
isc::util::Triplet< uint32_t > t1_
a isc::util::Triplet (min/default/max) holding allowed renew timer values
Definition: network.h:1060
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this network.
Definition: network.h:445
util::Optional< double > cache_threshold_
Percentage of the lease lifetime to use as cache threshold.
Definition: network.h:1126
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
Defines the D2ClientConfig class.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
std::string ClientClass
Defines a single class name.
Definition: classify.h:42
boost::shared_ptr< const CfgGlobals > ConstCfgGlobalsPtr
Const shared pointer to a CfgGlobals instance.
Definition: cfg_globals.h:159
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition: cfg_option.h:706
std::vector< isc::asiolink::IOAddress > IOAddressList
List of IOAddresses.
Definition: network.h:39
std::function< ConstCfgGlobalsPtr()> FetchNetworkGlobalsFn
Callback function for D2ClientConfig that retrieves globally configured parameters.
Definition: d2_client_cfg.h:48
boost::weak_ptr< Network > WeakNetworkPtr
Weak pointer to the Network object.
Definition: network.h:47
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
Definition: network.h:41
boost::shared_ptr< Option > OptionPtr
Definition: option.h:36
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
Definition: cfg_option.h:709
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.
Base class for user context.
Definition: user_context.h:22