13#include <boost/pointer_cast.hpp>
29 addresses_.push_back(addr);
34 return (!addresses_.empty());
39 for (
auto address = addresses_.begin(); address != addresses_.end();
41 if ((*address) == addr) {
104 const std::string& global_name,
106 const std::string& )
const {
109 if (globals && (globals->getType() == Element::map)) {
112 std::string global_str = global_param->stringValue();
113 if (!global_str.empty()) {
131 map->set(
"interface", Element::create(
iface_name_.get()));
135 ElementPtr address_list = Element::createList();
137 for (
auto address = addresses.begin(); address != addresses.end(); ++address) {
138 address_list->add(Element::create((*address).toText()));
141 relay_map->set(
"ip-addresses", address_list);
142 map->set(
"relay", relay_map);
146 map->set(
"client-class", Element::create(
client_class_.get()));
151 if (!classes.
empty()) {
152 ElementPtr class_list = Element::createList();
154 it != classes.
cend(); ++it) {
155 class_list->add(Element::create(*it));
157 map->set(
"require-client-classes", class_list);
163 if (!
t1_.unspecified()) {
164 map->set(
"renew-timer",
165 Element::create(
static_cast<long long>(
t1_.get())));
169 if (!
t2_.unspecified()) {
170 map->set(
"rebind-timer",
171 Element::create(
static_cast<long long>(
t2_.get())));
175 if (!
valid_.unspecified()) {
176 map->set(
"valid-lifetime",
177 Element::create(
static_cast<long long>(
valid_.get())));
179 map->set(
"min-valid-lifetime",
180 Element::create(
static_cast<long long>(
valid_.getMin())));
183 map->set(
"max-valid-lifetime",
184 Element::create(
static_cast<long long>(
valid_.getMax())));
190 map->set(
"reservations-global",
196 map->set(
"reservations-in-subnet",
202 map->set(
"reservations-out-of-pool",
208 map->set(
"option-data", opts->toElement());
216 map->set(
"t1-percent", Element::create(
t1_percent_));
220 map->set(
"t2-percent", Element::create(
t2_percent_));
236 map->set(
"ddns-replace-client-name",
266 map->set(
"cache-max-age",
283 if (!siaddr.
get().isV4()) {
297 filename_ = filename;
305 if (!match_client_id_.unspecified()) {
306 map->set(
"match-client-id", Element::create(match_client_id_.get()));
310 if (!authoritative_.unspecified()) {
311 map->set(
"authoritative", Element::create(authoritative_.get()));
315 if (!siaddr_.unspecified()) {
316 map->set(
"next-server", Element::create(siaddr_.get().toText()));
320 if (!sname_.unspecified()) {
321 map->set(
"server-hostname", Element::create(sname_.get()));
325 if (!filename_.unspecified()) {
326 map->set(
"boot-file-name",Element::create(filename_.get()));
335 OptionCustomPtr opt_server_id = boost::dynamic_pointer_cast<OptionCustom>
338 return (opt_server_id->readAddress());
340 }
catch (
const std::exception&) {
352 if (!preferred_.unspecified()) {
353 map->set(
"preferred-lifetime",
354 Element::create(
static_cast<long long>(preferred_.get())));
355 if (preferred_.getMin() < preferred_.get()) {
356 map->set(
"min-preferred-lifetime",
357 Element::create(
static_cast<long long>(preferred_.getMin())));
359 if (preferred_.getMax() > preferred_.get()) {
360 map->set(
"max-preferred-lifetime",
361 Element::create(
static_cast<long long>(preferred_.getMax())));
367 std::vector<uint8_t> bin = interface_id_->getData();
369 ifid.resize(bin.size());
371 std::memcpy(&ifid[0], &bin[0], bin.size());
373 map->set(
"interface-id", Element::create(ifid));
377 if (!rapid_commit_.unspecified()) {
378 map->set(
"rapid-commit", Element::create(rapid_commit_.get()));
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
The IOAddress class represents an IP addresses (version agnostic)
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
std::string toText() const
Convert the address to a string.
Container for storing client class names.
bool contains(const ClientClass &x) const
returns if class x belongs to the defined classes
void insert(const ClientClass &class_name)
Insert an element.
std::list< ClientClass >::const_iterator const_iterator
Type of iterators.
bool empty() const
Check if classes is empty.
const_iterator cbegin() const
Iterator to the first element.
const_iterator cend() const
Iterator to the past the end element.
Acts as a storage vault for D2 client configuration.
void setSiaddr(const util::Optional< asiolink::IOAddress > &siaddr)
Sets siaddr for the network.
void setFilename(const util::Optional< std::string > &filename)
Sets boot file name for the network.
virtual asiolink::IOAddress getServerId() const
Returns binary representation of the dhcp-server-identifier option (54).
virtual data::ElementPtr toElement() const
Unparses network object.
void setSname(const util::Optional< std::string > &sname)
Sets server hostname for the network.
virtual data::ElementPtr toElement() const
Unparses network object.
const IOAddressList & getAddresses() const
Returns const reference to the list of addresses.
void addAddress(const asiolink::IOAddress &addr)
Adds an address to the list of addresses.
bool containsAddress(const asiolink::IOAddress &addr) const
Checks the address list for the given address.
bool hasAddresses() const
Indicates whether or not the address list has entries.
virtual bool clientSupported(const isc::dhcp::ClientClasses &client_classes) const
Checks whether this network supports client that belongs to specified classes.
void addRelayAddress(const asiolink::IOAddress &addr)
Adds an address to the list addresses in the network's relay info.
util::Optional< std::string > hostname_char_replacement_
A string to replace invalid characters when scrubbing hostnames.
RelayInfo relay_
Relay information.
util::Optional< bool > reservations_out_of_pool_
Enables out-of-pool reservations optimization.
util::Optional< bool > ddns_update_on_renew_
Should Kea perform updates when leases are extended.
CfgOptionPtr cfg_option_
Pointer to the option data configuration for this subnet.
void requireClientClass(const isc::dhcp::ClientClass &class_name)
Adds class class_name to classes required to be evaluated.
const IOAddressList & getRelayAddresses() const
Returns the list of relay addresses from the network's relay info.
void allowClientClass(const isc::dhcp::ClientClass &class_name)
Sets the supported class to class class_name.
util::Optional< bool > reservations_global_
Enables global reservations.
util::Optional< bool > ddns_override_client_update_
Should Kea perform updates, even if client requested delegation.
util::Optional< bool > reservations_in_subnet_
Enables subnet reservations.
FetchNetworkGlobalsFn fetch_globals_fn_
Pointer to the optional callback used to fetch globally configured parameters inherited to the Networ...
util::Optional< double > t2_percent_
Percentage of the lease lifetime to use when calculating T2 timer.
util::Optional< std::string > ddns_generated_prefix_
Prefix Kea should use when generating domain-names.
util::Optional< double > t1_percent_
Percentage of the lease lifetime to use when calculating T1 timer.
bool hasRelays() const
Indicates if network's relay info has relay addresses.
util::Optional< ClientClass > client_class_
Optional definition of a client class.
virtual data::ElementPtr toElement() const
Unparses network object.
util::Optional< std::string > hostname_char_set_
Regular expression describing invalid characters for client hostnames.
bool hasRelayAddress(const asiolink::IOAddress &address) const
Tests if the network's relay info contains the given address.
util::Optional< std::string > iface_name_
Holds interface name for which this network is selected.
Triplet< uint32_t > valid_
a Triplet (min/default/max) holding allowed valid lifetime values
const ClientClasses & getRequiredClasses() const
Returns classes which are required to be evaluated.
util::Optional< bool > ddns_send_updates_
Should Kea perform DNS updates.
Triplet< uint32_t > t1_
a Triplet (min/default/max) holding allowed renew timer values
util::Optional< bool > store_extended_info_
Should Kea store additional client query data (e.g.
util::Optional< bool > calculate_tee_times_
Enables calculation of T1 and T2 timers.
util::Optional< bool > ddns_use_conflict_resolution_
Used to to tell kea-dhcp-ddns whether or not to use conflict resolution.
util::Optional< uint32_t > cache_max_age_
Value in seconds to use as cache maximal age.
util::Optional< bool > ddns_override_no_update_
Should Kea perform updates, even if client requested no updates.
util::Optional< std::string > ddns_qualifying_suffix_
Suffix Kea should use when to qualify partial domain-names.
ClientClasses required_classes_
Required classes.
Triplet< uint32_t > t2_
a Triplet (min/default/max) holding allowed rebind timer values
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.
util::Optional< D2ClientConfig::ReplaceClientNameMode > ddns_replace_client_name_mode_
How Kea should handle the domain-name supplied by the client.
CfgOptionPtr getCfgOption()
Returns pointer to the option data configuration for this network.
util::Optional< double > cache_threshold_
Percentage of the lease lifetime to use as cache threshold.
A template representing an optional value.
T get() const
Retrieves the encapsulated value.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
std::string ClientClass
Defines a single class name.
@ DHO_DHCP_SERVER_IDENTIFIER
boost::shared_ptr< OptionCustom > OptionCustomPtr
A pointer to the OptionCustom object.
std::vector< isc::asiolink::IOAddress > IOAddressList
List of IOAddresses.
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
Defines the logger used by the top-level component of kea-lfc.
#define DHCP4_OPTION_SPACE
global std option spaces
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.