13 #include <boost/pointer_cast.hpp>
24 if (containsAddress(addr)) {
29 addresses_.push_back(addr);
33 Network::RelayInfo::hasAddresses()
const {
34 return (!addresses_.empty());
39 for (
auto address = addresses_.begin(); address != addresses_.end();
41 if ((*address) == addr) {
50 Network::RelayInfo::getAddresses()
const {
56 relay_.addAddress(addr);
60 Network::hasRelays()
const {
61 return (relay_.hasAddresses());
66 return (relay_.containsAddress(addr));
70 Network::getRelayAddresses()
const {
71 return (relay_.getAddresses());
76 if (client_class_.empty()) {
82 return (classes.
contains(client_class_));
87 client_class_ = class_name;
92 if (!required_classes_.contains(class_name)) {
93 required_classes_.insert(class_name);
98 Network::getRequiredClasses()
const {
99 return (required_classes_);
104 const std::string& global_name,
106 const std::string& )
const {
107 if (!global_name.empty() && fetch_globals_fn_) {
109 if (globals && (globals->getType() == Element::map)) {
112 std::string global_str = global_param->stringValue();
113 if (!global_str.empty()) {
123 Network::toElement()
const {
127 contextToElement(map);
130 if (!iface_name_.unspecified()) {
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);
145 if (!client_class_.unspecified()) {
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())));
178 if (valid_.getMin() < valid_.get()) {
179 map->set(
"min-valid-lifetime",
180 Element::create(static_cast<long long>(valid_.getMin())));
182 if (valid_.getMax() > valid_.get()) {
183 map->set(
"max-valid-lifetime",
184 Element::create(static_cast<long long>(valid_.getMax())));
189 if (!reservations_global_.unspecified()) {
190 map->set(
"reservations-global",
191 Element::create(reservations_global_.get()));
195 if (!reservations_in_subnet_.unspecified()) {
196 map->set(
"reservations-in-subnet",
197 Element::create(reservations_in_subnet_.get()));
201 if (!reservations_out_of_pool_.unspecified()) {
202 map->set(
"reservations-out-of-pool",
203 Element::create(reservations_out_of_pool_.get()));
208 map->set(
"option-data", opts->toElement());
211 if (!calculate_tee_times_.unspecified()) {
212 map->set(
"calculate-tee-times", Element::create(calculate_tee_times_));
215 if (!t1_percent_.unspecified()) {
216 map->set(
"t1-percent", Element::create(t1_percent_));
219 if (!t2_percent_.unspecified()) {
220 map->set(
"t2-percent", Element::create(t2_percent_));
223 if (!ddns_send_updates_.unspecified()) {
224 map->set(
"ddns-send-updates", Element::create(ddns_send_updates_));
227 if (!ddns_override_no_update_.unspecified()) {
228 map->set(
"ddns-override-no-update", Element::create(ddns_override_no_update_));
231 if (!ddns_override_client_update_.unspecified()) {
232 map->set(
"ddns-override-client-update", Element::create(ddns_override_client_update_));
235 if (!ddns_replace_client_name_mode_.unspecified()) {
236 map->set(
"ddns-replace-client-name",
238 replaceClientNameModeToString(ddns_replace_client_name_mode_)));
241 if (!ddns_generated_prefix_.unspecified()) {
242 map->set(
"ddns-generated-prefix", Element::create(ddns_generated_prefix_));
245 if (!ddns_qualifying_suffix_.unspecified()) {
246 map->set(
"ddns-qualifying-suffix", Element::create(ddns_qualifying_suffix_));
249 if (!hostname_char_set_.unspecified()) {
250 map->set(
"hostname-char-set", Element::create(hostname_char_set_));
253 if (!hostname_char_replacement_.unspecified()) {
254 map->set(
"hostname-char-replacement", Element::create(hostname_char_replacement_));
257 if (!store_extended_info_.unspecified()) {
258 map->set(
"store-extended-info", Element::create(store_extended_info_));
261 if (!cache_threshold_.unspecified()) {
262 map->set(
"cache-threshold", Element::create(cache_threshold_));
265 if (!cache_max_age_.unspecified()) {
266 map->set(
"cache-max-age",
267 Element::create(static_cast<long long>(cache_max_age_)));
270 if (!ddns_update_on_renew_.unspecified()) {
271 map->set(
"ddns-update-on-renew", Element::create(ddns_update_on_renew_));
274 if (!ddns_use_conflict_resolution_.unspecified()) {
275 map->set(
"ddns-use-conflict-resolution", Element::create(ddns_use_conflict_resolution_));
297 filename_ = filename;
301 Network4::toElement()
const {
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()));
333 Network4::getServerId()
const {
338 return (opt_server_id->readAddress());
340 }
catch (
const std::exception&) {
348 Network6::toElement()
const {
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()));
std::vector< isc::asiolink::IOAddress > IOAddressList
List of IOAddresses.
boost::shared_ptr< OptionCustom > OptionCustomPtr
A pointer to the OptionCustom object.
boost::shared_ptr< const CfgOption > ConstCfgOptionPtr
Const pointer.
boost::shared_ptr< Element > ElementPtr
bool isV4() const
Convenience function to check for an IPv4 address.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
std::list< ClientClass >::const_iterator const_iterator
Type of iterators.
bool contains(const ClientClass &x) const
returns if class x belongs to the defined classes
const_iterator cend() const
Iterator to the past the end element.
Acts as a storage vault for D2 client configuration.
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
boost::shared_ptr< const Element > ConstElementPtr
Defines the logger used by the top-level component of kea-dhcp-ddns.
T get() const
Retrieves the encapsulated value.
#define DHCP4_OPTION_SPACE
global std option spaces
std::string toText() const
Convert the address to a string.
std::string ClientClass
Defines a single class name.
bool empty() const
Check if classes is empty.
The IOAddress class represents an IP addresses (version agnostic)
Option with defined data fields represented as buffers that can be accessed using data field index...
const_iterator cbegin() const
Iterator to the first element.
A template representing an optional value.
Container for storing client class names.