Kea  2.3.5-git
network.h
Go to the documentation of this file.
1 // Copyright (C) 2017-2023 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>
20 #include <dhcpsrv/d2_client_cfg.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 
37 namespace {
38 template <typename... Args>
39 inline void unused(Args const& ...) {}
40 } // end of anonymous namespace
41 
42 namespace isc {
43 namespace dhcp {
44 
47 
50 
52 typedef 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.
70 class Network;
71 
73 typedef boost::shared_ptr<Network> NetworkPtr;
74 
76 typedef boost::weak_ptr<Network> WeakNetworkPtr;
77 
80 typedef std::function<ConstCfgGlobalsPtr()> FetchNetworkGlobalsFn;
81 
152 class Network : public virtual isc::data::StampedElement,
153  public virtual isc::data::UserContext,
154  public isc::data::CfgToElement {
155 public:
162  class RelayInfo {
163  public:
164 
169  void addAddress(const asiolink::IOAddress& addr);
170 
174  const IOAddressList& getAddresses() const;
175 
179  bool hasAddresses() const;
180 
184  bool containsAddress(const asiolink::IOAddress& addr) const;
185 
186  private:
188  IOAddressList addresses_;
189  };
190 
202  enum class Inheritance {
203  NONE,
204  PARENT_NETWORK,
205  GLOBAL,
206  ALL
207  };
208 
210  typedef boost::shared_ptr<Network::RelayInfo> RelayInfoPtr;
211 
214  : iface_name_(), client_class_(), t1_(), t2_(), valid_(),
215  reservations_global_(false, true), reservations_in_subnet_(true, true),
216  reservations_out_of_pool_(false, true), cfg_option_(new CfgOption()),
217  calculate_tee_times_(), t1_percent_(), t2_percent_(),
218  ddns_send_updates_(), ddns_override_no_update_(), ddns_override_client_update_(),
219  ddns_replace_client_name_mode_(), ddns_generated_prefix_(), ddns_qualifying_suffix_(),
220  hostname_char_set_(), hostname_char_replacement_(), store_extended_info_(),
221  cache_threshold_(), cache_max_age_(), ddns_update_on_renew_(),
222  ddns_use_conflict_resolution_() {
223  }
224 
228  virtual ~Network() { };
229 
234  void setFetchGlobalsFn(FetchNetworkGlobalsFn fetch_globals_fn) {
235  fetch_globals_fn_ = fetch_globals_fn;
236  }
237 
242  bool hasFetchGlobalsFn() const {
243  return (static_cast<bool>(fetch_globals_fn_));
244  }
245 
255  void setIface(const util::Optional<std::string>& iface_name) {
256  if (iface_name.empty()) {
257  iface_name_ = util::Optional<std::string>("", true);
258  } else {
259  iface_name_ = iface_name;
260  }
261  }
262 
269  getIface(const Inheritance& inheritance = Inheritance::ALL) const {
270  return (getProperty<Network>(&Network::getIface, iface_name_,
271  inheritance));
272  };
273 
293  void setRelayInfo(const RelayInfo& relay) {
294  relay_ = relay;
295  }
296 
303  const RelayInfo& getRelayInfo() const {
304  return (relay_);
305  }
306 
311  void addRelayAddress(const asiolink::IOAddress& addr);
312 
316  const IOAddressList& getRelayAddresses() const;
317 
321  bool hasRelays() const;
322 
327  bool hasRelayAddress(const asiolink::IOAddress& address) const;
328 
343  virtual bool
344  clientSupported(const isc::dhcp::ClientClasses& client_classes) const;
345 
349  void allowClientClass(const isc::dhcp::ClientClass& class_name);
350 
354  void requireClientClass(const isc::dhcp::ClientClass& class_name);
355 
357  const ClientClasses& getRequiredClasses() const;
358 
367  getClientClass(const Inheritance& inheritance = Inheritance::ALL) const {
368  return (getProperty<Network>(&Network::getClientClass, client_class_,
369  inheritance));
370  }
371 
375  isc::util::Triplet<uint32_t> getValid(const Inheritance& inheritance = Inheritance::ALL) const {
376  return (getProperty<Network>(&Network::getValid, valid_, inheritance,
380  }
381 
386  valid_ = valid;
387  }
388 
392  isc::util::Triplet<uint32_t> getT1(const Inheritance& inheritance = Inheritance::ALL) const {
393  return (getProperty<Network>(&Network::getT1, t1_, inheritance,
395  }
396 
401  t1_ = t1;
402  }
403 
407  isc::util::Triplet<uint32_t> getT2(const Inheritance& inheritance = Inheritance::ALL) const {
408  return (getProperty<Network>(&Network::getT2, t2_, inheritance,
410  }
411 
416  t2_ = t2;
417  }
418 
423  getReservationsGlobal(const Inheritance& inheritance = Inheritance::ALL) const {
424  return (getProperty<Network>(&Network::getReservationsGlobal,
425  reservations_global_,
426  inheritance,
428  }
429 
433  void setReservationsGlobal(const util::Optional<bool>& reservations_global) {
434  reservations_global_ = reservations_global;
435  }
436 
441  getReservationsInSubnet(const Inheritance& inheritance = Inheritance::ALL) const {
442  return (getProperty<Network>(&Network::getReservationsInSubnet,
443  reservations_in_subnet_,
444  inheritance,
446  }
447 
451  void setReservationsInSubnet(const util::Optional<bool>& reservations_in_subnet) {
452  reservations_in_subnet_ = reservations_in_subnet;
453  }
454 
459  getReservationsOutOfPool(const Inheritance& inheritance = Inheritance::ALL) const {
460  return (getProperty<Network>(&Network::getReservationsOutOfPool,
461  reservations_out_of_pool_,
462  inheritance,
464  }
465 
469  void setReservationsOutOfPool(const util::Optional<bool>& reservations_out_of_pool) {
470  reservations_out_of_pool_ = reservations_out_of_pool;
471  }
472 
475  return (cfg_option_);
476  }
477 
481  return (cfg_option_);
482  }
483 
488  getCalculateTeeTimes(const Inheritance& inheritance = Inheritance::ALL) const {
489  return (getProperty<Network>(&Network::getCalculateTeeTimes,
490  calculate_tee_times_,
491  inheritance,
493  }
494 
498  void setCalculateTeeTimes(const util::Optional<bool>& calculate_tee_times) {
499  calculate_tee_times_ = calculate_tee_times;
500  }
501 
506  getT1Percent(const Inheritance& inheritance = Inheritance::ALL) const {
507  return (getProperty<Network>(&Network::getT1Percent, t1_percent_,
508  inheritance, CfgGlobals::T1_PERCENT));
509  }
510 
514  void setT1Percent(const util::Optional<double>& t1_percent) {
515  t1_percent_ = t1_percent;
516  }
517 
522  getT2Percent(const Inheritance& inheritance = Inheritance::ALL) const {
523  return (getProperty<Network>(&Network::getT2Percent, t2_percent_,
524  inheritance, CfgGlobals::T2_PERCENT));
525  }
526 
530  void setT2Percent(const util::Optional<double>& t2_percent) {
531  t2_percent_ = t2_percent;
532  }
533 
538  getDdnsSendUpdates(const Inheritance& inheritance = Inheritance::ALL) const {
539  return (getProperty<Network>(&Network::getDdnsSendUpdates,
540  ddns_send_updates_, inheritance,
542  }
543 
547  void setDdnsSendUpdates(const util::Optional<bool>& ddns_send_updates) {
548  ddns_send_updates_ = ddns_send_updates;
549  }
550 
555  getDdnsOverrideNoUpdate(const Inheritance& inheritance = Inheritance::ALL) const {
556  return (getProperty<Network>(&Network::getDdnsOverrideNoUpdate,
557  ddns_override_no_update_, inheritance,
559  }
560 
564  void setDdnsOverrideNoUpdate(const util::Optional<bool>& ddns_override_no_update) {
565  ddns_override_no_update_ = ddns_override_no_update;
566  }
567 
572  getDdnsOverrideClientUpdate(const Inheritance& inheritance = Inheritance::ALL) const {
573  return (getProperty<Network>(&Network::getDdnsOverrideClientUpdate,
574  ddns_override_client_update_, inheritance,
576  }
577 
582  ddns_override_client_update) {
583  ddns_override_client_update_ = ddns_override_client_update;
584  }
585 
590  getDdnsReplaceClientNameMode(const Inheritance& inheritance = Inheritance::ALL) const {
591  // Inheritance for ddns-replace-client-name is a little different than for other
592  // parameters. The value at the global level is given as a string.
593  // Thus we call getProperty here without a global name to check if it
594  // is specified on network level only.
596  getProperty<Network>(&Network::getDdnsReplaceClientNameMode,
597  ddns_replace_client_name_mode_, inheritance);
598 
599  // If it is not specified at network level we need this special
600  // case code to convert the global string value to an enum.
601  if (mode.unspecified() && (inheritance != Inheritance::NONE) &&
602  (inheritance != Inheritance::PARENT_NETWORK)) {
603  // Get global mode.
604  util::Optional<std::string> mode_label;
605  mode_label = getGlobalProperty(mode_label,
607  if (!mode_label.unspecified()) {
608  try {
609  // If the mode is globally configured, convert it to an enum.
610  return (D2ClientConfig::stringToReplaceClientNameMode(mode_label.get()));
611  } catch (...) {
612  // This should not really happen because the configuration
613  // parser should have already verified the globally configured
614  // mode. However, we want to be 100% sure that this
615  // method doesn't throw. Let's just return unspecified.
616  return (mode);
617  }
618  }
619  }
620  return (mode);
621  }
622 
626  void
628  ddns_replace_client_name_mode) {
629  ddns_replace_client_name_mode_ = ddns_replace_client_name_mode;
630  }
631 
636  getDdnsGeneratedPrefix(const Inheritance& inheritance = Inheritance::ALL) const {
637  return (getProperty<Network>(&Network::getDdnsGeneratedPrefix,
638  ddns_generated_prefix_, inheritance,
640  }
641 
645  void setDdnsGeneratedPrefix(const util::Optional<std::string>& ddns_generated_prefix) {
646  ddns_generated_prefix_ = ddns_generated_prefix;
647  }
648 
653  getDdnsQualifyingSuffix(const Inheritance& inheritance = Inheritance::ALL) const {
654  return (getProperty<Network>(&Network::getDdnsQualifyingSuffix,
655  ddns_qualifying_suffix_, inheritance,
657  }
658 
662  void setDdnsQualifyingSuffix(const util::Optional<std::string>& ddns_qualifying_suffix) {
663  ddns_qualifying_suffix_ = ddns_qualifying_suffix;
664  }
665 
668  getHostnameCharSet(const Inheritance& inheritance = Inheritance::ALL) const {
669  return (getProperty<Network>(&Network::getHostnameCharSet,
670  hostname_char_set_, inheritance,
672  }
673 
677  void setHostnameCharSet(const util::Optional<std::string>& hostname_char_set) {
678  hostname_char_set_ = hostname_char_set;
679  }
680 
683  getHostnameCharReplacement(const Inheritance& inheritance = Inheritance::ALL) const {
684  return (getProperty<Network>(&Network::getHostnameCharReplacement,
685  hostname_char_replacement_, inheritance,
687  }
688 
693  hostname_char_replacement) {
694  hostname_char_replacement_ = hostname_char_replacement;
695  }
696 
701  getStoreExtendedInfo(const Inheritance& inheritance = Inheritance::ALL) const {
702  return (getProperty<Network>(&Network::getStoreExtendedInfo,
703  store_extended_info_, inheritance,
705  }
706 
710  void setStoreExtendedInfo(const util::Optional<bool>& store_extended_info) {
711  store_extended_info_ = store_extended_info;
712  }
713 
718  getCacheThreshold(const Inheritance& inheritance = Inheritance::ALL) const {
719  return (getProperty<Network>(&Network::getCacheThreshold,
720  cache_threshold_, inheritance,
722  }
723 
727  void setCacheThreshold(const util::Optional<double>& cache_threshold) {
728  cache_threshold_ = cache_threshold;
729  }
730 
735  getCacheMaxAge(const Inheritance& inheritance = Inheritance::ALL) const {
736  return (getProperty<Network>(&Network::getCacheMaxAge, cache_max_age_,
737  inheritance, CfgGlobals::CACHE_MAX_AGE));
738  }
739 
743  void setCacheMaxAge(const util::Optional<uint32_t>& cache_max_age) {
744  cache_max_age_ = cache_max_age;
745  }
746 
751  getDdnsUpdateOnRenew(const Inheritance& inheritance = Inheritance::ALL) const {
752  return (getProperty<Network>(&Network::getDdnsUpdateOnRenew,
753  ddns_update_on_renew_, inheritance,
755  }
756 
760  void setDdnsUpdateOnRenew(const util::Optional<bool>& ddns_update_on_renew) {
761  ddns_update_on_renew_ = ddns_update_on_renew;
762  }
763 
768  getDdnsUseConflictResolution(const Inheritance& inheritance = Inheritance::ALL) const {
769  return (getProperty<Network>(&Network::getDdnsUseConflictResolution,
770  ddns_use_conflict_resolution_,
771  inheritance,
773  }
774 
778  void setDdnsUseConflictResolution(const util::Optional<bool>& ddns_use_conflict_resolution) {
779  ddns_use_conflict_resolution_ = ddns_use_conflict_resolution;
780  }
781 
786  getAllocatorType(const Inheritance& inheritance = Inheritance::ALL) const {
787  return (getProperty<Network>(&Network::getAllocatorType,
788  allocator_type_,
789  inheritance,
791  }
792 
800  void setAllocatorType(const util::Optional<std::string>& allocator_type) {
801  allocator_type_ = allocator_type;
802  }
803 
807  virtual data::ElementPtr toElement() const;
808 
809 protected:
810 
815  FetchNetworkGlobalsFn getFetchGlobalsFn() const {
816  return (fetch_globals_fn_);
817  }
818 
845  template<typename ReturnType>
846  ReturnType getGlobalProperty(ReturnType property,
847  const int global_index,
848  const int min_index = -1,
849  const int max_index = -1) const {
850  unused(min_index, max_index);
851  if ((global_index >= 0) && fetch_globals_fn_) {
852  ConstCfgGlobalsPtr globals = fetch_globals_fn_();
853  if (globals) {
854  data::ConstElementPtr global_param = globals->get(global_index);
855  if (global_param) {
856  // If there is a global parameter, convert it to the
857  // optional value of the given type and return.
859  }
860  }
861  }
862  return (property);
863  }
864 
883  template<typename NumType>
885  const int global_index,
886  const int min_index = -1,
887  const int max_index = -1) const {
888 
889  if ((global_index >= 0) && fetch_globals_fn_) {
890  ConstCfgGlobalsPtr globals = fetch_globals_fn_();
891  if (globals) {
892  data::ConstElementPtr param = globals->get(global_index);
893  if (param) {
894  NumType def_value = static_cast<NumType>(param->intValue());
895  if ((min_index < 0) || (max_index < 0)) {
896  return (def_value);
897  } else {
898  NumType min_value = def_value;
899  NumType max_value = def_value;
900  data::ConstElementPtr min_param = globals->get(min_index);
901  if (min_param) {
902  min_value = static_cast<NumType>(min_param->intValue());
903  }
904  data::ConstElementPtr max_param = globals->get(max_index);
905  if (max_param) {
906  max_value = static_cast<NumType>(max_param->intValue());
907  }
908  return (isc::util::Triplet<NumType>(min_value, def_value, max_value));
909  }
910  }
911  }
912  }
913  return (property);
914  }
915 
937  getGlobalProperty(util::Optional<asiolink::IOAddress> property,
938  const int global_index,
939  const int min_index = -1,
940  const int max_index = -1) const;
941 
972  template<typename BaseType, typename ReturnType>
973  ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance&) const,
974  ReturnType property,
975  const Inheritance& inheritance,
976  const int global_index = -1,
977  const int min_index = -1,
978  const int max_index = -1) const {
979 
980  // If no inheritance is to be used, return the value for this
981  // network regardless if it is specified or not.
982  if (inheritance == Inheritance::NONE) {
983  return (property);
984 
985  } else if (inheritance == Inheritance::PARENT_NETWORK) {
986  ReturnType parent_property;
987 
988  // Check if this instance has a parent network.
989  auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
990  if (parent) {
991  parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
992  }
993  return (parent_property);
994 
995  // If global value requested, return it.
996  } else if (inheritance == Inheritance::GLOBAL) {
997  return (getGlobalProperty(ReturnType(), global_index, min_index, max_index));
998  }
999 
1000  // We use inheritance and the value is not specified on the network level.
1001  // Hence, we need to get the parent network specific value or global value.
1002  if (property.unspecified()) {
1003  // Check if this instance has a parent network.
1004  auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1005  // If the parent network exists, let's fetch the parent specific
1006  // value.
1007  if (parent) {
1008  // We're using inheritance so ask for the parent specific network
1009  // and return it only if it is specified.
1010  auto parent_property = ((*parent).*MethodPointer)(inheritance);
1011  if (!parent_property.unspecified()) {
1012  return (parent_property);
1013  }
1014  }
1015 
1016  // The value is not specified on network level. If the value
1017  // can be specified on global level and there is a callback
1018  // that returns the global values, try to find this parameter
1019  // at the global scope.
1020  return (getGlobalProperty(property, global_index, min_index, max_index));
1021  }
1022 
1023  // We haven't found the value at any level, so return the unspecified.
1024  return (property);
1025  }
1026 
1047  template<typename BaseType>
1048  OptionPtr
1049  getOptionProperty(OptionPtr(BaseType::*MethodPointer)(const Inheritance& inheritance) const,
1050  OptionPtr property,
1051  const Inheritance& inheritance) const {
1052  if (inheritance == Network::Inheritance::NONE) {
1053  return (property);
1054 
1055  } else if (inheritance == Network::Inheritance::PARENT_NETWORK) {
1056  OptionPtr parent_property;
1057  // Check if this instance has a parent network.
1058  auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1059  // If the parent network exists, let's fetch the parent specific
1060  // value.
1061  if (parent) {
1062  parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
1063  }
1064  return (parent_property);
1065 
1066  } else if (inheritance == Network::Inheritance::GLOBAL) {
1067  return (OptionPtr());
1068  }
1069 
1070  // We use inheritance and the value is not specified on the network level.
1071  // Hence, we need to get the parent network specific value.
1072  if (!property) {
1073  // Check if this instance has a parent network.
1074  auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1075  if (parent) {
1076  // We're using inheritance so ask for the parent specific network
1077  // and return it only if it is specified.
1078  OptionPtr parent_property = (((*parent).*MethodPointer)(inheritance));
1079  if (parent_property) {
1080  return (parent_property);
1081  }
1082  }
1083  }
1084 
1085  // We haven't found the value at any level, so return the unspecified.
1086  return (property);
1087  }
1088 
1091 
1096 
1103 
1109 
1112 
1115 
1118 
1121 
1124 
1131 
1134 
1137 
1140 
1143 
1147 
1151 
1154 
1157 
1160 
1163 
1167 
1171 
1175 
1178 
1181 
1184 
1187 
1190 
1197  WeakNetworkPtr parent_network_;
1198 
1201  FetchNetworkGlobalsFn fetch_globals_fn_;
1202 };
1203 
1205 class Network4 : public virtual Network {
1206 public:
1207 
1210  : Network(), match_client_id_(true, true), authoritative_(),
1211  siaddr_(), sname_(), filename_() {
1212  }
1213 
1220  getMatchClientId(const Inheritance& inheritance = Inheritance::ALL) const {
1221  return (getProperty<Network4>(&Network4::getMatchClientId,
1222  match_client_id_,
1223  inheritance,
1225  }
1226 
1233  match_client_id_ = match;
1234  }
1235 
1243  getAuthoritative(const Inheritance& inheritance = Inheritance::ALL) const {
1244  return (getProperty<Network4>(&Network4::getAuthoritative,
1245  authoritative_, inheritance,
1247  }
1248 
1254  void setAuthoritative(const util::Optional<bool>& authoritative) {
1255  authoritative_ = authoritative;
1256  }
1257 
1263  void setSiaddr(const util::Optional<asiolink::IOAddress>& siaddr);
1264 
1269  getSiaddr(const Inheritance& inheritance = Inheritance::ALL) const {
1270  return (getProperty<Network4>(&Network4::getSiaddr, siaddr_,
1271  inheritance, CfgGlobals::NEXT_SERVER));
1272  }
1273 
1277  void setSname(const util::Optional<std::string>& sname);
1278 
1284  getSname(const Inheritance& inheritance = Inheritance::ALL) const {
1285  return (getProperty<Network4>(&Network4::getSname, sname_,
1286  inheritance,
1288  }
1289 
1293  void setFilename(const util::Optional<std::string>& filename);
1294 
1300  getFilename(const Inheritance& inheritance = Inheritance::ALL) const {
1301  return (getProperty<Network4>(&Network4::getFilename, filename_,
1302  inheritance,
1304  }
1305 
1309  virtual data::ElementPtr toElement() const;
1310 
1315  virtual asiolink::IOAddress getServerId() const;
1316 
1317 private:
1318 
1321  util::Optional<bool> match_client_id_;
1322 
1324  util::Optional<bool> authoritative_;
1325 
1328 
1331 
1333  util::Optional<std::string> filename_;
1334 };
1335 
1336 class Network6;
1337 
1339 typedef boost::shared_ptr<Network6> Network6Ptr;
1340 
1342 class Network6 : public virtual Network {
1343 public:
1344 
1347  : Network(), preferred_(), interface_id_(), rapid_commit_() {
1348  }
1349 
1355  getPreferred(const Inheritance& inheritance = Inheritance::ALL) const {
1356  return (getProperty<Network6>(&Network6::getPreferred, preferred_,
1357  inheritance,
1361  }
1362 
1367  preferred_ = preferred;
1368  }
1369 
1374  OptionPtr getInterfaceId(const Inheritance& inheritance = Inheritance::ALL) const {
1375  return (getOptionProperty<Network6>(&Network6::getInterfaceId, interface_id_,
1376  inheritance));
1377  }
1378 
1382  void setInterfaceId(const OptionPtr& ifaceid) {
1383  interface_id_ = ifaceid;
1384  }
1385 
1394  getRapidCommit(const Inheritance& inheritance = Inheritance::ALL) const {
1395 
1396  return (getProperty<Network6>(&Network6::getRapidCommit, rapid_commit_,
1397  inheritance));
1398  }
1399 
1404  void setRapidCommit(const util::Optional<bool>& rapid_commit) {
1405  rapid_commit_ = rapid_commit;
1406  };
1407 
1412  getPdAllocatorType(const Inheritance& inheritance = Inheritance::ALL) const {
1413  return (getProperty<Network6>(&Network6::getPdAllocatorType,
1414  pd_allocator_type_,
1415  inheritance,
1417  }
1418 
1426  void setPdAllocatorType(const util::Optional<std::string>& allocator_type) {
1427  pd_allocator_type_ = allocator_type;
1428  }
1429 
1433  virtual data::ElementPtr toElement() const;
1434 
1435 private:
1436 
1438  isc::util::Triplet<uint32_t> preferred_;
1439 
1441  OptionPtr interface_id_;
1442 
1448  util::Optional<bool> rapid_commit_;
1449 
1451  util::Optional<std::string> pd_allocator_type_;
1452 };
1453 
1454 } // end of namespace isc::dhcp
1455 } // end of namespace isc
1456 
1457 #endif // NETWORK_H
util::Optional< bool > store_extended_info_
Should Kea store additional client query data (e.g.
Definition: network.h:1174
WeakNetworkPtr parent_network_
Pointer to another network that this network belongs to.
Definition: network.h:1197
virtual ~Network()
Virtual destructor.
Definition: network.h:228
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:884
util::Optional< uint32_t > cache_max_age_
Value in seconds to use as cache maximal age.
Definition: network.h:1180
Defines the D2ClientConfig class.
util::Optional< bool > reservations_global_
Enables global reservations.
Definition: network.h:1120
void setDdnsSendUpdates(const util::Optional< bool > &ddns_send_updates)
Sets new ddns-send-updates.
Definition: network.h:547
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
Definition: optional.h:136
boost::weak_ptr< Network > WeakNetworkPtr
Weak pointer to the Network object.
Definition: network.h:76
This class represents configuration element which is associated with database identifier, modification timestamp and servers.
util::Optional< double > t2_percent_
Percentage of the lease lifetime to use when calculating T2 timer.
Definition: network.h:1142
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:1049
util::Optional< ClientClass > client_class_
Optional definition of a client class.
Definition: network.h:1102
util::Optional< std::string > getAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type.
Definition: network.h:786
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition: cfg_option.h:745
void setHostnameCharSet(const util::Optional< std::string > &hostname_char_set)
Sets new hostname-char-set.
Definition: network.h:677
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
Definition: network.h:1150
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
Definition: network.h:70
void setCacheMaxAge(const util::Optional< uint32_t > &cache_max_age)
Sets cache max for a network.
Definition: network.h:743
util::Optional< std::string > getDdnsQualifyingSuffix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-qualifying-suffix.
Definition: network.h:653
ClientClasses required_classes_
Required classes.
Definition: network.h:1108
util::Optional< bool > getStoreExtendedInfo(const Inheritance &inheritance=Inheritance::ALL) const
Returns store-extended-info.
Definition: network.h:701
util::Optional< ClientClass > getClientClass(const Inheritance &inheritance=Inheritance::ALL) const
returns the client class
Definition: network.h:367
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:1243
Tag for the list of IO addresses as a list.
Definition: network.h:46
isc::util::Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds)
Definition: network.h:1355
util::Optional< bool > getDdnsUseConflictResolution(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-use-conflict-resolution.
Definition: network.h:768
util::Optional< std::string > ddns_qualifying_suffix_
Suffix Kea should use when to qualify partial domain-names.
Definition: network.h:1162
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
Definition: network.h:210
Base class for user context.
Definition: user_context.h:22
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
Definition: cfg_option.h:748
util::Optional< bool > getDdnsOverrideClientUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-client-update.
Definition: network.h:572
FetchNetworkGlobalsFn fetch_globals_fn_
Pointer to the optional callback used to fetch globally configured parameters inherited to the Networ...
Definition: network.h:1201
Defines elements for storing the names of client classes.
util::Optional< std::string > getHostnameCharSet(const Inheritance &inheritance=Inheritance::ALL) const
Return the char set regexp used to sanitize client hostnames.
Definition: network.h:668
void setCalculateTeeTimes(const util::Optional< bool > &calculate_tee_times)
Sets whether or not T1/T2 calculation is enabled.
Definition: network.h:498
boost::shared_ptr< Option > OptionPtr
Definition: option.h:36
util::Optional< std::string > iface_name_
Holds interface name for which this network is selected.
Definition: network.h:1090
boost::shared_ptr< const CfgGlobals > ConstCfgGlobalsPtr
Const shared pointer to a CfgGlobals instance.
Definition: cfg_globals.h:161
void setT1(const isc::util::Triplet< uint32_t > &t1)
Sets new renew timer for a network.
Definition: network.h:400
util::Optional< double > cache_threshold_
Percentage of the lease lifetime to use as cache threshold.
Definition: network.h:1177
T get() const
Retrieves the encapsulated value.
Definition: optional.h:114
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
void setHostnameCharReplacement(const util::Optional< std::string > &hostname_char_replacement)
Sets new hostname-char-replacement.
Definition: network.h:692
Network4()
Constructor.
Definition: network.h:1209
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
Definition: network.h:1146
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:846
util::Optional< double > getT2Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T2 (rebind timer).
Definition: network.h:522
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
Definition: network.h:1382
util::Optional< bool > ddns_use_conflict_resolution_
Used to to tell kea-dhcp-ddns whether or not to use conflict resolution.
Definition: network.h:1186
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this network.
Definition: network.h:474
boost::shared_ptr< Network6 > Network6Ptr
Pointer to the Network6 object.
Definition: network.h:1336
Network6()
Constructor.
Definition: network.h:1346
util::Optional< D2ClientConfig::ReplaceClientNameMode > getDdnsReplaceClientNameMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-replace-client-name-mode.
Definition: network.h:590
util::Optional< double > getT1Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T1 (renew timer).
Definition: network.h:506
util::Optional< uint32_t > getCacheMaxAge(const Inheritance &inheritance=Inheritance::ALL) const
Returns value in seconds to use as cache maximum age.
Definition: network.h:735
Specialization of the Network object for DHCPv6 case.
Definition: network.h:1342
util::Optional< std::string > getSname(const Inheritance &inheritance=Inheritance::ALL) const
Returns server hostname for this network.
Definition: network.h:1284
void setStoreExtendedInfo(const util::Optional< bool > &store_extended_info)
Sets new store-extended-info.
Definition: network.h:710
Holds optional information about relay.
Definition: network.h:162
util::Optional< std::string > hostname_char_replacement_
A string to replace invalid characters when scrubbing hostnames.
Definition: network.h:1170
void setDdnsReplaceClientNameMode(const util::Optional< D2ClientConfig::ReplaceClientNameMode > &ddns_replace_client_name_mode)
Sets new ddns-replace-client-name-mode.
Definition: network.h:627
void setDdnsQualifyingSuffix(const util::Optional< std::string > &ddns_qualifying_suffix)
Sets new ddns-qualifying-suffix.
Definition: network.h:662
std::function< ConstCfgGlobalsPtr()> FetchNetworkGlobalsFn
Callback function for D2ClientConfig that retrieves globally configured parameters.
Definition: d2_client_cfg.h:48
Represents option data configuration for the DHCP server.
Definition: cfg_option.h:318
util::Optional< double > t1_percent_
Percentage of the lease lifetime to use when calculating T1 timer.
Definition: network.h:1139
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:1254
isc::util::Triplet< uint32_t > t1_
a isc::util::Triplet (min/default/max) holding allowed renew timer values
Definition: network.h:1111
Abstract class for configuration Cfg_* classes.
void setRapidCommit(const util::Optional< bool > &rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
Definition: network.h:1404
Inheritance
Inheritance "mode" used when fetching an optional Network parameter.
Definition: network.h:202
Common interface representing a network to which the DHCP clients are connected.
Definition: network.h:152
bool hasFetchGlobalsFn() const
Checks if the network is associated with a function used to fetch globally configured parameters...
Definition: network.h:242
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
Definition: network.h:1183
void setDdnsGeneratedPrefix(const util::Optional< std::string > &ddns_generated_prefix)
Sets new ddns-generated-prefix.
Definition: network.h:645
void setMatchClientId(const util::Optional< bool > &match)
Sets the flag indicating if the client identifier should be used to identify the client&#39;s lease...
Definition: network.h:1232
void setReservationsInSubnet(const util::Optional< bool > &reservations_in_subnet)
Sets whether subnet reservations should be fetched.
Definition: network.h:451
util::Optional< std::string > getPdAllocatorType(const Inheritance &inheritance=Inheritance::ALL) const
Returns allocator type for prefix delegation.
Definition: network.h:1412
util::Optional< std::string > getFilename(const Inheritance &inheritance=Inheritance::ALL) const
Returns boot file name for this subnet.
Definition: network.h:1300
void setDdnsUseConflictResolution(const util::Optional< bool > &ddns_use_conflict_resolution)
Sets new ddns-use-conflict-resolution.
Definition: network.h:778
util::Optional< bool > getDdnsOverrideNoUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-no-update.
Definition: network.h:555
void setDdnsUpdateOnRenew(const util::Optional< bool > &ddns_update_on_renew)
Sets new ddns-update-on-renew.
Definition: network.h:760
util::Optional< std::string > getDdnsGeneratedPrefix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-generated-prefix.
Definition: network.h:636
void setT1Percent(const util::Optional< double > &t1_percent)
Sets new percentage for calculating T1 (renew timer).
Definition: network.h:514
void setPdAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type for prefix delegation.
Definition: network.h:1426
util::Optional< bool > getDdnsUpdateOnRenew(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-update-on-renew.
Definition: network.h:751
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
void setPreferred(const isc::util::Triplet< uint32_t > &preferred)
Sets new preferred lifetime for a network.
Definition: network.h:1366
isc::util::Triplet< uint32_t > getT1(const Inheritance &inheritance=Inheritance::ALL) const
Returns T1 (renew timer), expressed in seconds.
Definition: network.h:392
Defines the logger used by the top-level component of kea-lfc.
void setT2Percent(const util::Optional< double > &t2_percent)
Sets new percentage for calculating T2 (rebind timer).
Definition: network.h:530
util::Optional< asiolink::IOAddress > getSiaddr(const Inheritance &inheritance=Inheritance::ALL) const
Returns siaddr for this network.
Definition: network.h:1269
util::Optional< std::string > allocator_type_
Allocator used for IP address allocations.
Definition: network.h:1189
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:973
OptionPtr getInterfaceId(const Inheritance &inheritance=Inheritance::ALL) const
Returns interface-id value (if specified)
Definition: network.h:1374
util::Optional< bool > reservations_in_subnet_
Enables subnet reservations.
Definition: network.h:1123
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&#39;s lease...
Definition: network.h:1220
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
Definition: network.h:1133
isc::util::Triplet< uint32_t > getValid(const Inheritance &inheritance=Inheritance::ALL) const
Return valid-lifetime for addresses in that prefix.
Definition: network.h:375
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this network.
Definition: network.h:480
void setAllocatorType(const util::Optional< std::string > &allocator_type)
Sets new allocator type.
Definition: network.h:800
util::Optional< bool > reservations_out_of_pool_
Enables out-of-pool reservations optimization.
Definition: network.h:1130
Tag for the list of IO addresses as a set.
Definition: network.h:49
util::Optional< double > getCacheThreshold(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use as cache threshold.
Definition: network.h:718
void setReservationsOutOfPool(const util::Optional< bool > &reservations_out_of_pool)
Sets whether only out-of-pool reservations are allowed.
Definition: network.h:469
const RelayInfo & getRelayInfo() const
Returns const reference to relay information.
Definition: network.h:303
Specialization of the Network object for DHCPv4 case.
Definition: network.h:1205
util::Optional< std::string > getHostnameCharReplacement(const Inheritance &inheritance=Inheritance::ALL) const
Return the invalid char replacement used to sanitize client hostnames.
Definition: network.h:683
util::Optional< std::string > hostname_char_set_
Regular expression describing invalid characters for client hostnames.
Definition: network.h:1166
void setDdnsOverrideNoUpdate(const util::Optional< bool > &ddns_override_no_update)
Sets new ddns-override-no-update.
Definition: network.h:564
void setIface(const util::Optional< std::string > &iface_name)
Sets local name of the interface for which this network is selected.
Definition: network.h:255
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:269
void setValid(const isc::util::Triplet< uint32_t > &valid)
Sets new valid lifetime for a network.
Definition: network.h:385
isc::util::Triplet< uint32_t > getT2(const Inheritance &inheritance=Inheritance::ALL) const
Returns T2 (rebind timer), expressed in seconds.
Definition: network.h:407
util::Optional< bool > calculate_tee_times_
Enables calculation of T1 and T2 timers.
Definition: network.h:1136
util::Optional< bool > getCalculateTeeTimes(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether or not T1/T2 calculation is enabled.
Definition: network.h:488
isc::util::Triplet< uint32_t > t2_
a isc::util::Triplet (min/default/max) holding allowed rebind timer values
Definition: network.h:1114
void setRelayInfo(const RelayInfo &relay)
Sets information about relay.
Definition: network.h:293
void setT2(const isc::util::Triplet< uint32_t > &t2)
Sets new rebind timer for a network.
Definition: network.h:415
std::string ClientClass
Defines a single class name.
Definition: classify.h:42
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:1394
util::Optional< bool > getReservationsGlobal(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether global reservations should be fetched.
Definition: network.h:423
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
Definition: network.h:1159
bool empty() const
Checks if the encapsulated value is empty.
Definition: optional.h:153
void setCacheThreshold(const util::Optional< double > &cache_threshold)
Sets cache threshold for a network.
Definition: network.h:727
void setDdnsOverrideClientUpdate(const util::Optional< bool > &ddns_override_client_update)
Sets new ddns-override-client-update.
Definition: network.h:581
RelayInfo relay_
Relay information.
Definition: network.h:1095
util::Optional< bool > getReservationsOutOfPool(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether only out-of-pool reservations are allowed.
Definition: network.h:459
Container for storing client class names.
Definition: classify.h:108
util::Optional< bool > ddns_override_client_update_
Should Kea perform updates, even if client requested delegation.
Definition: network.h:1153
util::Optional< bool > getReservationsInSubnet(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether subnet reservations should be fetched.
Definition: network.h:441
void setFetchGlobalsFn(FetchNetworkGlobalsFn fetch_globals_fn)
Sets the optional callback function used to fetch globally configured parameters. ...
Definition: network.h:234
util::Optional< D2ClientConfig::ReplaceClientNameMode > ddns_replace_client_name_mode_
How Kea should handle the domain-name supplied by the client.
Definition: network.h:1156
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
Network()
Constructor.
Definition: network.h:213
util::Optional< bool > getDdnsSendUpdates(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-send-updates.
Definition: network.h:538
void setReservationsGlobal(const util::Optional< bool > &reservations_global)
Sets whether global reservations should be fetched.
Definition: network.h:433
FetchNetworkGlobalsFn getFetchGlobalsFn() const
Gets the optional callback function used to fetch globally configured parameters. ...
Definition: network.h:815
isc::util::Triplet< uint32_t > valid_
a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
Definition: network.h:1117
Template class for converting a value encapsulated in the Element object into a simple type...
Definition: element_value.h:43