Kea  1.9.9-git
network.h
Go to the documentation of this file.
1 // Copyright (C) 2017-2021 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_option.h>
18 #include <dhcpsrv/cfg_4o6.h>
19 #include <dhcpsrv/d2_client_cfg.h>
20 #include <dhcpsrv/triplet.h>
21 #include <util/optional.h>
22 #include <boost/shared_ptr.hpp>
23 #include <boost/weak_ptr.hpp>
24 #include <cstdint>
25 #include <functional>
26 #include <string>
27 
29 namespace {
30 template <typename... Args>
31 inline void unused(Args const& ...) {}
32 } // end of anonymous namespace
33 
34 namespace isc {
35 namespace dhcp {
36 
38 typedef std::vector<isc::asiolink::IOAddress> IOAddressList;
39 
40 class Network;
41 
43 typedef boost::shared_ptr<Network> NetworkPtr;
44 
46 typedef boost::weak_ptr<Network> WeakNetworkPtr;
47 
50 typedef std::function<data::ConstElementPtr()> FetchNetworkGlobalsFn;
51 
122 class Network : public virtual isc::data::StampedElement,
123  public virtual isc::data::UserContext,
124  public isc::data::CfgToElement {
125 public:
132  class RelayInfo {
133  public:
134 
139  void addAddress(const asiolink::IOAddress& addr);
140 
144  const IOAddressList& getAddresses() const;
145 
149  bool hasAddresses() const;
150 
154  bool containsAddress(const asiolink::IOAddress& addr) const;
155 
156  private:
158  IOAddressList addresses_;
159  };
160 
172  enum class Inheritance {
173  NONE,
175  GLOBAL,
176  ALL
177  };
178 
180  typedef boost::shared_ptr<Network::RelayInfo> RelayInfoPtr;
181 
184  : iface_name_(), client_class_(), t1_(), t2_(), valid_(),
185  reservations_global_(false, true), reservations_in_subnet_(true, true),
186  reservations_out_of_pool_(false, true), cfg_option_(new CfgOption()),
193  }
194 
198  virtual ~Network() { };
199 
204  void setFetchGlobalsFn(FetchNetworkGlobalsFn fetch_globals_fn) {
205  fetch_globals_fn_ = fetch_globals_fn;
206  }
207 
212  bool hasFetchGlobalsFn() const {
213  return (static_cast<bool>(fetch_globals_fn_));
214  }
215 
224  void setIface(const util::Optional<std::string>& iface_name) {
225  iface_name_ = iface_name;
226  }
227 
234  getIface(const Inheritance& inheritance = Inheritance::ALL) const {
235  return (getProperty<Network>(&Network::getIface, iface_name_,
236  inheritance));
237  };
238 
258  void setRelayInfo(const RelayInfo& relay) {
259  relay_ = relay;
260  }
261 
268  const RelayInfo& getRelayInfo() const {
269  return (relay_);
270  }
271 
276  void addRelayAddress(const asiolink::IOAddress& addr);
277 
281  const IOAddressList& getRelayAddresses() const;
282 
286  bool hasRelays() const;
287 
292  bool hasRelayAddress(const asiolink::IOAddress& address) const;
293 
308  virtual bool
309  clientSupported(const isc::dhcp::ClientClasses& client_classes) const;
310 
314  void allowClientClass(const isc::dhcp::ClientClass& class_name);
315 
319  void requireClientClass(const isc::dhcp::ClientClass& class_name);
320 
322  const ClientClasses& getRequiredClasses() const;
323 
332  getClientClass(const Inheritance& inheritance = Inheritance::ALL) const {
333  return (getProperty<Network>(&Network::getClientClass, client_class_,
334  inheritance));
335  }
336 
341  return (getProperty<Network>(&Network::getValid, valid_, inheritance,
342  "valid-lifetime", "min-valid-lifetime",
343  "max-valid-lifetime"));
344  }
345 
349  void setValid(const Triplet<uint32_t>& valid) {
350  valid_ = valid;
351  }
352 
356  Triplet<uint32_t> getT1(const Inheritance& inheritance = Inheritance::ALL) const {
357  return (getProperty<Network>(&Network::getT1, t1_, inheritance, "renew-timer"));
358  }
359 
363  void setT1(const Triplet<uint32_t>& t1) {
364  t1_ = t1;
365  }
366 
370  Triplet<uint32_t> getT2(const Inheritance& inheritance = Inheritance::ALL) const {
371  return (getProperty<Network>(&Network::getT2, t2_, inheritance, "rebind-timer"));
372  }
373 
377  void setT2(const Triplet<uint32_t>& t2) {
378  t2_ = t2;
379  }
380 
385  getReservationsGlobal(const Inheritance& inheritance = Inheritance::ALL) const {
386  return (getProperty<Network>(&Network::getReservationsGlobal,
388  inheritance,
389  "reservations-global"));
390  }
391 
395  void setReservationsGlobal(const util::Optional<bool>& reservations_global) {
396  reservations_global_ = reservations_global;
397  }
398 
404  return (getProperty<Network>(&Network::getReservationsInSubnet,
406  inheritance,
407  "reservations-in-subnet"));
408  }
409 
413  void setReservationsInSubnet(const util::Optional<bool>& reservations_in_subnet) {
414  reservations_in_subnet_ = reservations_in_subnet;
415  }
416 
422  return (getProperty<Network>(&Network::getReservationsOutOfPool,
424  inheritance,
425  "reservations-out-of-pool"));
426  }
427 
431  void setReservationsOutOfPool(const util::Optional<bool>& reservations_out_of_pool) {
432  reservations_out_of_pool_ = reservations_out_of_pool;
433  }
434 
437  return (cfg_option_);
438  }
439 
443  return (cfg_option_);
444  }
445 
450  getCalculateTeeTimes(const Inheritance& inheritance = Inheritance::ALL) const {
451  return (getProperty<Network>(&Network::getCalculateTeeTimes,
453  inheritance,
454  "calculate-tee-times"));
455  }
456 
460  void setCalculateTeeTimes(const util::Optional<bool>& calculate_tee_times) {
461  calculate_tee_times_ = calculate_tee_times;
462  }
463 
468  getT1Percent(const Inheritance& inheritance = Inheritance::ALL) const {
469  return (getProperty<Network>(&Network::getT1Percent, t1_percent_,
470  inheritance, "t1-percent"));
471  }
472 
476  void setT1Percent(const util::Optional<double>& t1_percent) {
477  t1_percent_ = t1_percent;
478  }
479 
484  getT2Percent(const Inheritance& inheritance = Inheritance::ALL) const {
485  return (getProperty<Network>(&Network::getT2Percent, t2_percent_,
486  inheritance, "t2-percent"));
487  }
488 
492  void setT2Percent(const util::Optional<double>& t2_percent) {
493  t2_percent_ = t2_percent;
494  }
495 
500  getDdnsSendUpdates(const Inheritance& inheritance = Inheritance::ALL) const {
501  return (getProperty<Network>(&Network::getDdnsSendUpdates, ddns_send_updates_,
502  inheritance, "ddns-send-updates"));
503  }
504 
508  void setDdnsSendUpdates(const util::Optional<bool>& ddns_send_updates) {
509  ddns_send_updates_ = ddns_send_updates;
510  }
511 
517  return (getProperty<Network>(&Network::getDdnsOverrideNoUpdate,
519  inheritance, "ddns-override-no-update"));
520  }
521 
525  void setDdnsOverrideNoUpdate(const util::Optional<bool>& ddns_override_no_update) {
526  ddns_override_no_update_ = ddns_override_no_update;
527  }
528 
534  return (getProperty<Network>(&Network::getDdnsOverrideClientUpdate,
536  inheritance, "ddns-override-client-update"));
537  }
538 
543  ddns_override_client_update) {
544  ddns_override_client_update_ = ddns_override_client_update;
545  }
546 
552  // Inheritance for ddns-replace-client-name is a little different than for other
553  // parameters. The value at the global level is given as a string.
554  // Thus we call getProperty here without a global name to check if it
555  // is specified on network level only.
557  getProperty<Network>(&Network::getDdnsReplaceClientNameMode,
558  ddns_replace_client_name_mode_, inheritance);
559 
560  // If it is not specified at network level we need this special
561  // case code to convert the global string value to an enum.
562  if (mode.unspecified() && (inheritance != Inheritance::NONE) &&
563  (inheritance != Inheritance::PARENT_NETWORK)) {
564  // Get global mode.
565  util::Optional<std::string> mode_label;
566  mode_label = getGlobalProperty(mode_label, "ddns-replace-client-name");
567  if (!mode_label.unspecified()) {
568  try {
569  // If the mode is globally configured, convert it to an enum.
570  return (D2ClientConfig::stringToReplaceClientNameMode(mode_label.get()));
571  } catch (...) {
572  // This should not really happen because the configuration
573  // parser should have already verified the globally configured
574  // mode. However, we want to be 100% sure that this
575  // method doesn't throw. Let's just return unspecified.
576  return (mode);
577  }
578  }
579  }
580  return (mode);
581  }
582 
586  void
588  ddns_replace_client_name_mode) {
589  ddns_replace_client_name_mode_ = ddns_replace_client_name_mode;
590  }
591 
597  return (getProperty<Network>(&Network::getDdnsGeneratedPrefix,
599  inheritance, "ddns-generated-prefix"));
600  }
601 
605  void setDdnsGeneratedPrefix(const util::Optional<std::string>& ddns_generated_prefix) {
606  ddns_generated_prefix_ = ddns_generated_prefix;
607  }
608 
614  return (getProperty<Network>(&Network::getDdnsQualifyingSuffix,
616  inheritance, "ddns-qualifying-suffix"));
617  }
618 
622  void setDdnsQualifyingSuffix(const util::Optional<std::string>& ddns_qualifying_suffix) {
623  ddns_qualifying_suffix_ = ddns_qualifying_suffix;
624  }
625 
628  getHostnameCharSet(const Inheritance& inheritance = Inheritance::ALL) const {
629  return (getProperty<Network>(&Network::getHostnameCharSet, hostname_char_set_,
630  inheritance, "hostname-char-set"));
631  }
632 
636  void setHostnameCharSet(const util::Optional<std::string>& hostname_char_set) {
637  hostname_char_set_ = hostname_char_set;
638  }
639 
643  return (getProperty<Network>(&Network::getHostnameCharReplacement,
645  inheritance, "hostname-char-replacement"));
646  }
647 
652  hostname_char_replacement) {
653  hostname_char_replacement_ = hostname_char_replacement;
654  }
655 
660  getStoreExtendedInfo(const Inheritance& inheritance = Inheritance::ALL) const {
661  return (getProperty<Network>(&Network::getStoreExtendedInfo,
663  inheritance, "store-extended-info"));
664  }
665 
669  void setStoreExtendedInfo(const util::Optional<bool>& store_extended_info) {
670  store_extended_info_ = store_extended_info;
671  }
672 
677  getCacheThreshold(const Inheritance& inheritance = Inheritance::ALL) const {
678  return (getProperty<Network>(&Network::getCacheThreshold,
680  inheritance, "cache-threshold"));
681  }
682 
686  void setCacheThreshold(const util::Optional<double>& cache_threshold) {
687  cache_threshold_ = cache_threshold;
688  }
689 
694  getCacheMaxAge(const Inheritance& inheritance = Inheritance::ALL) const {
695  return (getProperty<Network>(&Network::getCacheMaxAge, cache_max_age_,
696  inheritance, "cache-max-age"));
697  }
698 
702  void setCacheMaxAge(const util::Optional<uint32_t>& cache_max_age) {
703  cache_max_age_ = cache_max_age;
704  }
705 
710  getDdnsUpdateOnRenew(const Inheritance& inheritance = Inheritance::ALL) const {
711  return (getProperty<Network>(&Network::getDdnsUpdateOnRenew,
713  inheritance, "ddns-update-on-renew"));
714  }
715 
719  void setDdnsUpdateOnRenew(const util::Optional<bool>& ddns_update_on_renew) {
720  ddns_update_on_renew_ = ddns_update_on_renew;
721  }
722 
728  return (getProperty<Network>(&Network::getDdnsUseConflictResolution,
730  inheritance, "ddns-use-conflict-resolution"));
731  }
732 
736  void setDdnsUseConflictResolution(const util::Optional<bool>& ddns_use_conflict_resolution) {
737  ddns_use_conflict_resolution_ = ddns_use_conflict_resolution;
738  }
739 
743  virtual data::ElementPtr toElement() const;
744 
745 protected:
746 
751  FetchNetworkGlobalsFn getFetchGlobalsFn() const {
752  return (fetch_globals_fn_);
753  }
754 
781  template<typename ReturnType>
782  ReturnType getGlobalProperty(ReturnType property,
783  const std::string& global_name,
784  const std::string& min_name = "",
785  const std::string& max_name = "") const {
786  unused(min_name, max_name);
787  if (!global_name.empty() && fetch_globals_fn_) {
789  if (globals && (globals->getType() == data::Element::map)) {
790  data::ConstElementPtr global_param = globals->get(global_name);
791  if (global_param) {
792  // If there is a global parameter, convert it to the
793  // optional value of the given type and return.
795  }
796  }
797  }
798  return (property);
799  }
800 
819  template<typename NumType>
821  const std::string& global_name,
822  const std::string& min_name = "",
823  const std::string& max_name = "") const {
824 
825  if (!global_name.empty() && fetch_globals_fn_) {
827  if (globals && (globals->getType() == data::Element::map)) {
828  data::ConstElementPtr param = globals->get(global_name);
829  if (param) {
830  NumType def_value = static_cast<NumType>(param->intValue());
831  if (min_name.empty() || max_name.empty()) {
832  return (def_value);
833  } else {
834  NumType min_value = def_value;
835  NumType max_value = def_value;
836  data::ConstElementPtr min_param = globals->get(min_name);
837  if (min_param) {
838  min_value = static_cast<NumType>(min_param->intValue());
839  }
840  data::ConstElementPtr max_param = globals->get(max_name);
841  if (max_param) {
842  max_value = static_cast<NumType>(max_param->intValue());
843  }
844  return (Triplet<NumType>(min_value, def_value, max_value));
845  }
846  }
847  }
848  }
849  return (property);
850  }
851 
874  const std::string& global_name,
875  const std::string& min_name = "",
876  const std::string& max_name = "") const;
877 
908  template<typename BaseType, typename ReturnType>
909  ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance&) const,
910  ReturnType property,
911  const Inheritance& inheritance,
912  const std::string& global_name = "",
913  const std::string& min_name = "",
914  const std::string& max_name = "") const {
915 
916  // If no inheritance is to be used, return the value for this
917  // network regardless if it is specified or not.
918  if (inheritance == Inheritance::NONE) {
919  return (property);
920 
921  } else if (inheritance == Inheritance::PARENT_NETWORK) {
922  ReturnType parent_property;
923 
924  // Check if this instance has a parent network.
925  auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
926  if (parent) {
927  parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
928  }
929  return (parent_property);
930 
931  // If global value requested, return it.
932  } else if (inheritance == Inheritance::GLOBAL) {
933  return (getGlobalProperty(ReturnType(), global_name, min_name, max_name));
934  }
935 
936  // We use inheritance and the value is not specified on the network level.
937  // Hence, we need to get the parent network specific value or global value.
938  if (property.unspecified()) {
939  // Check if this instance has a parent network.
940  auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
941  // If the parent network exists, let's fetch the parent specific
942  // value.
943  if (parent) {
944  // We're using inheritance so ask for the parent specific network
945  // and return it only if it is specified.
946  auto parent_property = ((*parent).*MethodPointer)(inheritance);
947  if (!parent_property.unspecified()) {
948  return (parent_property);
949  }
950  }
951 
952  // The value is not specified on network level. If the value
953  // can be specified on global level and there is a callback
954  // that returns the global values, try to find this parameter
955  // at the global scope.
956  return (getGlobalProperty(property, global_name, min_name, max_name));
957  }
958 
959  // We haven't found the value at any level, so return the unspecified.
960  return (property);
961  }
962 
983  template<typename BaseType>
984  OptionPtr
985  getOptionProperty(OptionPtr(BaseType::*MethodPointer)(const Inheritance& inheritance) const,
986  OptionPtr property,
987  const Inheritance& inheritance) const {
988  if (inheritance == Network::Inheritance::NONE) {
989  return (property);
990 
991  } else if (inheritance == Network::Inheritance::PARENT_NETWORK) {
992  OptionPtr parent_property;
993  // Check if this instance has a parent network.
994  auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
995  // If the parent network exists, let's fetch the parent specific
996  // value.
997  if (parent) {
998  parent_property = ((*parent).*MethodPointer)(Network::Inheritance::NONE);
999  }
1000  return (parent_property);
1001 
1002  } else if (inheritance == Network::Inheritance::GLOBAL) {
1003  return (OptionPtr());
1004  }
1005 
1006  // We use inheritance and the value is not specified on the network level.
1007  // Hence, we need to get the parent network specific value.
1008  if (!property) {
1009  // Check if this instance has a parent network.
1010  auto parent = boost::dynamic_pointer_cast<BaseType>(parent_network_.lock());
1011  if (parent) {
1012  // We're using inheritance so ask for the parent specific network
1013  // and return it only if it is specified.
1014  OptionPtr parent_property = (((*parent).*MethodPointer)(inheritance));
1015  if (parent_property) {
1016  return (parent_property);
1017  }
1018  }
1019  }
1020 
1021  // We haven't found the value at any level, so return the unspecified.
1022  return (property);
1023  }
1024 
1027 
1032 
1039 
1045 
1048 
1051 
1054 
1057 
1060 
1067 
1070 
1073 
1076 
1079 
1083 
1087 
1090 
1093 
1096 
1099 
1103 
1107 
1111 
1114 
1117 
1120 
1123 
1130  WeakNetworkPtr parent_network_;
1131 
1134  FetchNetworkGlobalsFn fetch_globals_fn_;
1135 };
1136 
1138 class Network4 : public virtual Network {
1139 public:
1140 
1143  : Network(), match_client_id_(true, true), authoritative_(),
1144  siaddr_(), sname_(), filename_() {
1145  }
1146 
1153  getMatchClientId(const Inheritance& inheritance = Inheritance::ALL) const {
1154  return (getProperty<Network4>(&Network4::getMatchClientId,
1155  match_client_id_,
1156  inheritance,
1157  "match-client-id"));
1158  }
1159 
1166  match_client_id_ = match;
1167  }
1168 
1176  getAuthoritative(const Inheritance& inheritance = Inheritance::ALL) const {
1177  return (getProperty<Network4>(&Network4::getAuthoritative, authoritative_,
1178  inheritance, "authoritative"));
1179  }
1180 
1186  void setAuthoritative(const util::Optional<bool>& authoritative) {
1187  authoritative_ = authoritative;
1188  }
1189 
1195  void setSiaddr(const util::Optional<asiolink::IOAddress>& siaddr);
1196 
1201  getSiaddr(const Inheritance& inheritance = Inheritance::ALL) const {
1202  return (getProperty<Network4>(&Network4::getSiaddr, siaddr_,
1203  inheritance, "next-server"));
1204  }
1205 
1209  void setSname(const util::Optional<std::string>& sname);
1210 
1216  getSname(const Inheritance& inheritance = Inheritance::ALL) const {
1217  return (getProperty<Network4>(&Network4::getSname, sname_,
1218  inheritance, "server-hostname"));
1219  }
1220 
1224  void setFilename(const util::Optional<std::string>& filename);
1225 
1231  getFilename(const Inheritance& inheritance = Inheritance::ALL) const {
1232  return (getProperty<Network4>(&Network4::getFilename, filename_,
1233  inheritance, "boot-file-name"));
1234  }
1235 
1239  virtual data::ElementPtr toElement() const;
1240 
1245  virtual asiolink::IOAddress getServerId() const;
1246 
1247 private:
1248 
1251  util::Optional<bool> match_client_id_;
1252 
1254  util::Optional<bool> authoritative_;
1255 
1258 
1261 
1263  util::Optional<std::string> filename_;
1264 };
1265 
1267 class Network6 : public virtual Network {
1268 public:
1269 
1272  : Network(), preferred_(), interface_id_(), rapid_commit_() {
1273  }
1274 
1280  getPreferred(const Inheritance& inheritance = Inheritance::ALL) const {
1281  return (getProperty<Network6>(&Network6::getPreferred, preferred_,
1282  inheritance, "preferred-lifetime",
1283  "min-preferred-lifetime",
1284  "max-preferred-lifetime"));
1285  }
1286 
1290  void setPreferred(const Triplet<uint32_t>& preferred) {
1291  preferred_ = preferred;
1292  }
1293 
1299  return (getOptionProperty<Network6>(&Network6::getInterfaceId, interface_id_,
1300  inheritance));
1301  }
1302 
1306  void setInterfaceId(const OptionPtr& ifaceid) {
1307  interface_id_ = ifaceid;
1308  }
1309 
1316  getRapidCommit(const Inheritance& inheritance = Inheritance::ALL) const {
1317 
1318  return (getProperty<Network6>(&Network6::getRapidCommit, rapid_commit_,
1319  inheritance, "rapid-commit"));
1320  }
1321 
1326  void setRapidCommit(const util::Optional<bool>& rapid_commit) {
1327  rapid_commit_ = rapid_commit;
1328  };
1329 
1333  virtual data::ElementPtr toElement() const;
1334 
1335 private:
1336 
1338  Triplet<uint32_t> preferred_;
1339 
1341  OptionPtr interface_id_;
1342 
1348  util::Optional<bool> rapid_commit_;
1349 };
1350 
1351 } // end of namespace isc::dhcp
1352 } // end of namespace isc
1353 
1354 #endif // NETWORK_H
util::Optional< bool > store_extended_info_
Should Kea store additional client query data (e.g.
Definition: network.h:1110
WeakNetworkPtr parent_network_
Pointer to another network that this network belongs to.
Definition: network.h:1130
virtual ~Network()
Virtual destructor.
Definition: network.h:198
util::Optional< bool > getReservationsInSubnet(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether subnet reservations should be fetched.
Definition: network.h:403
util::Optional< uint32_t > cache_max_age_
Value in seconds to use as cache maximal age.
Definition: network.h:1116
Defines the D2ClientConfig class.
util::Optional< bool > reservations_global_
Enables global reservations.
Definition: network.h:1056
void setDdnsSendUpdates(const util::Optional< bool > &ddns_send_updates)
Sets new ddns-send-updates.
Definition: network.h:508
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
Definition: optional.h:121
util::Optional< bool > getDdnsOverrideClientUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-client-update.
Definition: network.h:533
boost::weak_ptr< Network > WeakNetworkPtr
Weak pointer to the Network object.
Definition: network.h:46
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:1078
util::Optional< ClientClass > getClientClass(const Inheritance &inheritance=Inheritance::ALL) const
returns the client class
Definition: network.h:332
Triplet< uint32_t > getT2(const Inheritance &inheritance=Inheritance::ALL) const
Returns T2 (rebind timer), expressed in seconds.
Definition: network.h:370
util::Optional< ClientClass > client_class_
Optional definition of a client class.
Definition: network.h:1038
std::vector< isc::asiolink::IOAddress > IOAddressList
List of IOAddresses.
Definition: network.h:38
boost::shared_ptr< CfgOption > CfgOptionPtr
Non-const pointer.
Definition: cfg_option.h:706
void setHostnameCharSet(const util::Optional< std::string > &hostname_char_set)
Sets new hostname-char-set.
Definition: network.h:636
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
Definition: network.h:1086
util::Optional< asiolink::IOAddress > getSiaddr(const Inheritance &inheritance=Inheritance::ALL) const
Returns siaddr for this network.
Definition: network.h:1201
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
Definition: network.h:40
OptionPtr getInterfaceId(const Inheritance &inheritance=Inheritance::ALL) const
Returns interface-id value (if specified)
Definition: network.h:1298
void setSname(const util::Optional< std::string > &sname)
Sets server hostname for the network.
Definition: network.cc:291
void setCacheMaxAge(const util::Optional< uint32_t > &cache_max_age)
Sets cache max for a network.
Definition: network.h:702
ClientClasses required_classes_
Required classes.
Definition: network.h:1044
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
Triplet< uint32_t > getT1(const Inheritance &inheritance=Inheritance::ALL) const
Returns T1 (renew timer), expressed in seconds.
Definition: network.h:356
util::Optional< uint32_t > getCacheMaxAge(const Inheritance &inheritance=Inheritance::ALL) const
Returns value in seconds to use as cache maximum age.
Definition: network.h:694
Triplet< uint32_t > t2_
a Triplet (min/default/max) holding allowed rebind timer values
Definition: network.h:1050
Triplet< NumType > getGlobalProperty(Triplet< NumType > property, const std::string &global_name, const std::string &min_name="", const std::string &max_name="") const
The getGlobalProperty specialization for Triplet.
Definition: network.h:820
bool hasRelayAddress(const asiolink::IOAddress &address) const
Tests if the network's relay info contains the given address.
Definition: network.cc:65
virtual data::ElementPtr toElement() const
Unparses network object.
Definition: network.cc:348
util::Optional< std::string > ddns_qualifying_suffix_
Suffix Kea should use when to qualify partial domain-names.
Definition: network.h:1098
boost::shared_ptr< Network::RelayInfo > RelayInfoPtr
Pointer to the RelayInfo structure.
Definition: network.h:180
Base class for user context.
Definition: user_context.h:22
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
Definition: cfg_option.h:709
void setValid(const Triplet< uint32_t > &valid)
Sets new valid lifetime for a network.
Definition: network.h:349
bool hasAddresses() const
Indicates whether or not the address list has entries.
Definition: network.cc:33
util::Optional< std::string > getFilename(const Inheritance &inheritance=Inheritance::ALL) const
Returns boot file name for this subnet.
Definition: network.h:1231
FetchNetworkGlobalsFn fetch_globals_fn_
Pointer to the optional callback used to fetch globally configured parameters inherited to the Networ...
Definition: network.h:1134
Defines elements for storing the names of client classes.
ReturnType getProperty(ReturnType(BaseType::*MethodPointer)(const Inheritance &) const, ReturnType property, const Inheritance &inheritance, const std::string &global_name="", const std::string &min_name="", const std::string &max_name="") const
Returns a value associated with a network using inheritance.
Definition: network.h:909
std::function< data::ConstElementPtr()> FetchNetworkGlobalsFn
Callback function for D2ClientConfig that retrieves globally configured parameters.
Definition: d2_client_cfg.h:47
util::Optional< bool > getDdnsUseConflictResolution(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-use-conflict-resolution.
Definition: network.h:727
void setCalculateTeeTimes(const util::Optional< bool > &calculate_tee_times)
Sets whether or not T1/T2 calculation is enabled.
Definition: network.h:460
boost::shared_ptr< Option > OptionPtr
Definition: option.h:36
virtual data::ElementPtr toElement() const
Unparses network object.
Definition: network.cc:301
FetchNetworkGlobalsFn getFetchGlobalsFn() const
Gets the optional callback function used to fetch globally configured parameters. ...
Definition: network.h:751
const RelayInfo & getRelayInfo() const
Returns const reference to relay information.
Definition: network.h:268
ConstCfgOptionPtr getCfgOption() const
Returns const pointer to the option data configuration for this network.
Definition: network.h:442
util::Optional< std::string > iface_name_
Holds interface name for which this network is selected.
Definition: network.h:1026
util::Optional< double > cache_threshold_
Percentage of the lease lifetime to use as cache threshold.
Definition: network.h:1113
void setSiaddr(const util::Optional< asiolink::IOAddress > &siaddr)
Sets siaddr for the network.
Definition: network.cc:282
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
void setHostnameCharReplacement(const util::Optional< std::string > &hostname_char_replacement)
Sets new hostname-char-replacement.
Definition: network.h:651
Network4()
Constructor.
Definition: network.h:1142
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
Definition: network.h:1082
void setInterfaceId(const OptionPtr &ifaceid)
sets interface-id option (if defined)
Definition: network.h:1306
util::Optional< bool > ddns_use_conflict_resolution_
Used to to tell kea-dhcp-ddns whether or not to use conflict resolution.
Definition: network.h:1122
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this network.
Definition: network.h:436
util::Optional< bool > getDdnsOverrideNoUpdate(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-override-no-update.
Definition: network.h:516
Network6()
Constructor.
Definition: network.h:1271
Specialization of the Network object for DHCPv6 case.
Definition: network.h:1267
const ClientClasses & getRequiredClasses() const
Returns classes which are required to be evaluated.
Definition: network.cc:98
virtual data::ElementPtr toElement() const
Unparses network object.
Definition: network.cc:123
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:985
void setStoreExtendedInfo(const util::Optional< bool > &store_extended_info)
Sets new store-extended-info.
Definition: network.h:669
util::Optional< std::string > getDdnsQualifyingSuffix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-qualifying-suffix.
Definition: network.h:613
util::Optional< double > getT1Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T1 (renew timer).
Definition: network.h:468
Triplet< uint32_t > getPreferred(const Inheritance &inheritance=Inheritance::ALL) const
Returns preferred lifetime (in seconds)
Definition: network.h:1280
bool hasFetchGlobalsFn() const
Checks if the network is associated with a function used to fetch globally configured parameters...
Definition: network.h:212
Holds optional information about relay.
Definition: network.h:132
util::Optional< std::string > hostname_char_replacement_
A string to replace invalid characters when scrubbing hostnames.
Definition: network.h:1106
void setDdnsReplaceClientNameMode(const util::Optional< D2ClientConfig::ReplaceClientNameMode > &ddns_replace_client_name_mode)
Sets new ddns-replace-client-name-mode.
Definition: network.h:587
void setDdnsQualifyingSuffix(const util::Optional< std::string > &ddns_qualifying_suffix)
Sets new ddns-qualifying-suffix.
Definition: network.h:622
void setFilename(const util::Optional< std::string > &filename)
Sets boot file name for the network.
Definition: network.cc:296
void addRelayAddress(const asiolink::IOAddress &addr)
Adds an address to the list addresses in the network's relay info.
Definition: network.cc:55
Represents option data configuration for the DHCP server.
Definition: cfg_option.h:314
util::Optional< std::string > getSname(const Inheritance &inheritance=Inheritance::ALL) const
Returns server hostname for this network.
Definition: network.h:1216
Triplet< uint32_t > valid_
a Triplet (min/default/max) holding allowed valid lifetime values
Definition: network.h:1053
util::Optional< double > t1_percent_
Percentage of the lease lifetime to use when calculating T1 timer.
Definition: network.h:1075
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:1186
Abstract class for configuration Cfg_* classes.
void allowClientClass(const isc::dhcp::ClientClass &class_name)
Sets the supported class to class class_name.
Definition: network.cc:86
void setRapidCommit(const util::Optional< bool > &rapid_commit)
Enables or disables Rapid Commit option support for the subnet.
Definition: network.h:1326
Inheritance
Inheritance "mode" used when fetching an optional Network parameter.
Definition: network.h:172
ReturnType getGlobalProperty(ReturnType property, const std::string &global_name, const std::string &min_name="", const std::string &max_name="") const
Returns a value of global configuration parameter with a given name.
Definition: network.h:782
Common interface representing a network to which the DHCP clients are connected.
Definition: network.h:122
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
Definition: network.h:1119
util::Optional< bool > getDdnsSendUpdates(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-send-updates.
Definition: network.h:500
void setDdnsGeneratedPrefix(const util::Optional< std::string > &ddns_generated_prefix)
Sets new ddns-generated-prefix.
Definition: network.h:605
void setPreferred(const Triplet< uint32_t > &preferred)
Sets new preferred lifetime for a network.
Definition: network.h:1290
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:1165
void setReservationsInSubnet(const util::Optional< bool > &reservations_in_subnet)
Sets whether subnet reservations should be fetched.
Definition: network.h:413
const IOAddressList & getAddresses() const
Returns const reference to the list of addresses.
Definition: network.cc:50
void setDdnsUseConflictResolution(const util::Optional< bool > &ddns_use_conflict_resolution)
Sets new ddns-use-conflict-resolution.
Definition: network.h:736
void setDdnsUpdateOnRenew(const util::Optional< bool > &ddns_update_on_renew)
Sets new ddns-update-on-renew.
Definition: network.h:719
void setT1Percent(const util::Optional< double > &t1_percent)
Sets new percentage for calculating T1 (renew timer).
Definition: network.h:476
util::Optional< bool > getReservationsGlobal(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether global reservations should be fetched.
Definition: network.h:385
util::Optional< std::string > getHostnameCharSet(const Inheritance &inheritance=Inheritance::ALL) const
Return the char set regexp used to sanitize client hostnames.
Definition: network.h:628
Defines the logger used by the top-level component of kea-dhcp-ddns.
T get() const
Retrieves the encapsulated value.
Definition: optional.h:112
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:1176
void setT2Percent(const util::Optional< double > &t2_percent)
Sets new percentage for calculating T2 (rebind timer).
Definition: network.h:492
void addAddress(const asiolink::IOAddress &addr)
Adds an address to the list of addresses.
Definition: network.cc:23
Triplet< uint32_t > getValid(const Inheritance &inheritance=Inheritance::ALL) const
Return valid-lifetime for addresses in that prefix.
Definition: network.h:340
util::Optional< bool > reservations_in_subnet_
Enables subnet reservations.
Definition: network.h:1059
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:1316
bool hasRelays() const
Indicates if network's relay info has relay addresses.
Definition: network.cc:60
util::Optional< double > getT2Percent(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use when calculating the T2 (rebind timer).
Definition: network.h:484
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
Definition: network.h:1069
bool containsAddress(const asiolink::IOAddress &addr) const
Checks the address list for the given address.
Definition: network.cc:38
util::Optional< std::string > getHostnameCharReplacement(const Inheritance &inheritance=Inheritance::ALL) const
Return the invalid char replacement used to sanitize client hostnames.
Definition: network.h:642
void requireClientClass(const isc::dhcp::ClientClass &class_name)
Adds class class_name to classes required to be evaluated.
Definition: network.cc:91
util::Optional< bool > getStoreExtendedInfo(const Inheritance &inheritance=Inheritance::ALL) const
Returns store-extended-info.
Definition: network.h:660
const IOAddressList & getRelayAddresses() const
Returns the list of relay addresses from the network's relay info.
Definition: network.cc:70
util::Optional< bool > reservations_out_of_pool_
Enables out-of-pool reservations optimization.
Definition: network.h:1066
util::Optional< D2ClientConfig::ReplaceClientNameMode > getDdnsReplaceClientNameMode(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-replace-client-name-mode.
Definition: network.h:551
void setReservationsOutOfPool(const util::Optional< bool > &reservations_out_of_pool)
Sets whether only out-of-pool reservations are allowed.
Definition: network.h:431
Specialization of the Network object for DHCPv4 case.
Definition: network.h:1138
virtual asiolink::IOAddress getServerId() const
Returns binary representation of the dhcp-server-identifier option (54).
Definition: network.cc:333
util::Optional< std::string > hostname_char_set_
Regular expression describing invalid characters for client hostnames.
Definition: network.h:1102
void setDdnsOverrideNoUpdate(const util::Optional< bool > &ddns_override_no_update)
Sets new ddns-override-no-update.
Definition: network.h:525
void setIface(const util::Optional< std::string > &iface_name)
Sets local name of the interface for which this network is selected.
Definition: network.h:224
util::Optional< bool > getCalculateTeeTimes(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether or not T1/T2 calculation is enabled.
Definition: network.h:450
util::Optional< bool > calculate_tee_times_
Enables calculation of T1 and T2 timers.
Definition: network.h:1072
void setRelayInfo(const RelayInfo &relay)
Sets information about relay.
Definition: network.h:258
std::string ClientClass
Defines a single class name.
Definition: classify.h:37
util::Optional< std::string > getDdnsGeneratedPrefix(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-generated-prefix.
Definition: network.h:596
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
Definition: network.h:1095
void setCacheThreshold(const util::Optional< double > &cache_threshold)
Sets cache threshold for a network.
Definition: network.h:686
util::Optional< double > getCacheThreshold(const Inheritance &inheritance=Inheritance::ALL) const
Returns percentage to use as cache threshold.
Definition: network.h:677
util::Optional< bool > getDdnsUpdateOnRenew(const Inheritance &inheritance=Inheritance::ALL) const
Returns ddns-update-on-renew.
Definition: network.h:710
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:1153
void setDdnsOverrideClientUpdate(const util::Optional< bool > &ddns_override_client_update)
Sets new ddns-override-client-update.
Definition: network.h:542
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:234
RelayInfo relay_
Relay information.
Definition: network.h:1031
Container for storing client class names.
Definition: classify.h:43
void setT1(const Triplet< uint32_t > &t1)
Sets new renew timer for a network.
Definition: network.h:363
util::Optional< bool > ddns_override_client_update_
Should Kea perform updates, even if client requested delegation.
Definition: network.h:1089
void setFetchGlobalsFn(FetchNetworkGlobalsFn fetch_globals_fn)
Sets the optional callback function used to fetch globally configured parameters. ...
Definition: network.h:204
void setT2(const Triplet< uint32_t > &t2)
Sets new rebind timer for a network.
Definition: network.h:377
util::Optional< D2ClientConfig::ReplaceClientNameMode > ddns_replace_client_name_mode_
How Kea should handle the domain-name supplied by the client.
Definition: network.h:1092
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
Network()
Constructor.
Definition: network.h:183
Triplet< uint32_t > t1_
a Triplet (min/default/max) holding allowed renew timer values
Definition: network.h:1047
void setReservationsGlobal(const util::Optional< bool > &reservations_global)
Sets whether global reservations should be fetched.
Definition: network.h:395
util::Optional< bool > getReservationsOutOfPool(const Inheritance &inheritance=Inheritance::ALL) const
Returns whether only out-of-pool reservations are allowed.
Definition: network.h:421
Template class for converting a value encapsulated in the Element object into a simple type...
Definition: element_value.h:43