Kea 2.7.5
cfg_option.cc
Go to the documentation of this file.
1// Copyright (C) 2014-2024 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#include <config.h>
8
9#include <dhcp/libdhcp++.h>
10#include <dhcpsrv/cfg_option.h>
11#include <dhcp/dhcp6.h>
12#include <dhcp/option_space.h>
13#include <util/encode/encode.h>
14#include <boost/algorithm/string/split.hpp>
15#include <boost/algorithm/string/classification.hpp>
16#include <boost/make_shared.hpp>
17#include <string>
18#include <sstream>
19#include <vector>
20
21using namespace isc::data;
22
23namespace isc {
24namespace dhcp {
25
27OptionDescriptor::create(const OptionPtr& opt, bool persist, bool cancel,
28 const std::string& formatted_value,
29 ConstElementPtr user_context) {
30 return (boost::make_shared<OptionDescriptor>(opt, persist, cancel,
31 formatted_value,
32 user_context));
33}
34
36OptionDescriptor::create(bool persist, bool cancel) {
37 return (boost::make_shared<OptionDescriptor>(persist, cancel));
38}
39
42 return (boost::make_shared<OptionDescriptor>(desc));
43}
44
45bool
47 return ((persistent_ == other.persistent_) &&
48 (cancelled_ == other.cancelled_) &&
49 (formatted_value_ == other.formatted_value_) &&
50 (space_name_ == other.space_name_) &&
51 option_->equals(other.option_));
52}
53
54void
55OptionDescriptor::addClientClass(const std::string& class_name) {
56 std::string trimmed = util::str::trim(class_name);
57 if (!trimmed.empty()) {
59 }
60}
61
62bool
64 if (client_classes_.empty()) {
65 return (true);
66 }
67
68 if (cclasses.size() > client_classes_.size()) {
69 for (const auto& cclass : client_classes_) {
70 if (cclasses.contains(cclass)) {
71 return (true);
72 }
73 }
74 }
75 else {
76 for (const auto& cclass : cclasses) {
77 if (client_classes_.contains(cclass)) {
78 return (true);
79 }
80 }
81 }
82
83 return (false);
84}
85
87 : encapsulated_(false) {
88}
89
90bool
92 return (options_.empty() && vendor_options_.empty());
93}
94
95bool
96CfgOption::equals(const CfgOption& other) const {
97 return (options_.equals(other.options_) &&
98 vendor_options_.equals(other.vendor_options_));
99}
100
101void
103 const bool persistent,
104 const bool cancelled,
105 const std::string& option_space,
106 const uint64_t id) {
107 OptionDescriptor desc(option, persistent, cancelled);
108 if (id > 0) {
109 desc.setId(id);
110 }
111 add(desc, option_space);
112}
113
114void
115CfgOption::add(const OptionDescriptor& desc, const std::string& option_space) {
116 if (!desc.option_) {
117 isc_throw(isc::BadValue, "option being configured must not be NULL");
118
119 } else if (!OptionSpace::validateName(option_space)) {
120 isc_throw(isc::BadValue, "invalid option space name: '"
121 << option_space << "'");
122 }
123
124 const uint32_t vendor_id = LibDHCP::optionSpaceToVendorId(option_space);
125 if (vendor_id) {
126 vendor_options_.addItem(desc, vendor_id);
127 } else {
128 options_.addItem(desc, option_space);
129 }
130}
131
132void
133CfgOption::replace(const OptionDescriptor& desc, const std::string& option_space) {
134 if (!desc.option_) {
135 isc_throw(isc::BadValue, "option being replaced must not be NULL");
136 }
137
138 // Check for presence of options.
139 OptionContainerPtr options = getAll(option_space);
140 if (!options) {
141 isc_throw(isc::BadValue, "option space " << option_space
142 << " does not exist");
143 }
144
145 // Find the option we want to replace.
146 OptionContainerTypeIndex& idx = options->get<1>();
147 auto const& od_itr = idx.find(desc.option_->getType());
148 if (od_itr == idx.end()) {
149 isc_throw(isc::BadValue, "cannot replace option: "
150 << option_space << ":" << desc.option_->getType()
151 << ", it does not exist");
152 }
153
154 idx.replace(od_itr, desc);
155}
156
157std::list<std::string>
159 std::list<uint32_t> ids = getVendorIds();
160 std::list<std::string> names;
161 for (auto const& id : ids) {
162 std::ostringstream s;
163 // Vendor space name is constructed as "vendor-XYZ" where XYZ is an
164 // uint32_t value, without leading zeros.
165 s << "vendor-" << id;
166 names.push_back(s.str());
167 }
168 return (names);
169}
170
171void
173 // First we merge our options into other.
174 // This adds my options that are not
175 // in other, to other (i.e we skip over
176 // duplicates).
177 mergeTo(other);
178
179 // Create option instances based on the given definitions.
180 other.createOptions(cfg_def);
181
182 // Next we copy "other" on top of ourself.
183 other.copyTo(*this);
184
185 // If we copied new options we may need to populate the
186 // sub-options into the upper level options. The server
187 // expects that the top-level options have suitable
188 // suboptions appended.
189 encapsulate();
190}
191
192void
194 // Iterate over all the option descriptors in
195 // all the spaces and instantiate the options
196 // based on the given definitions.
197 for (auto const& space : getOptionSpaceNames()) {
198 for (auto opt_desc : *(getAll(space))) {
199 if (createDescriptorOption(cfg_def, space, opt_desc)) {
200 // Option was recreated, let's replace the descriptor.
201 replace(opt_desc, space);
202 }
203 }
204 }
205}
206
207bool
208CfgOption::createDescriptorOption(CfgOptionDefPtr cfg_def, const std::string& space,
209 OptionDescriptor& opt_desc) {
210 if (!opt_desc.option_) {
212 "validateCreateOption: descriptor has no option instance");
213 }
214
215 Option::Universe universe = opt_desc.option_->getUniverse();
216 uint16_t code = opt_desc.option_->getType();
217
218 // Find the option's defintion, if it has one.
219 // First, check for a standard definition.
221
222 // If there is no standard definition but the option is vendor specific,
223 // we should search the definition within the vendor option space.
224 if (!def && (space != DHCP4_OPTION_SPACE) && (space != DHCP6_OPTION_SPACE)) {
225 uint32_t vendor_id = LibDHCP::optionSpaceToVendorId(space);
226 if (vendor_id > 0) {
227 def = LibDHCP::getVendorOptionDef(universe, vendor_id, code);
228 }
229 }
230
231 // Still haven't found the definition, so look for custom
232 // definition in the given set of configured definitions
233 if (!def) {
234 def = cfg_def->get(space, code);
235 }
236
237 // Finish with a last resort option definition.
238 if (!def) {
239 def = LibDHCP::getLastResortOptionDef(space, code);
240 }
241
242 std::string& formatted_value = opt_desc.formatted_value_;
243 if (!def) {
244 if (!formatted_value.empty()) {
245 isc_throw(InvalidOperation, "option: " << space << "." << code
246 << " has a formatted value: '" << formatted_value
247 << "' but no option definition");
248 }
249
250 // If there's no definition and no formatted string, we'll
251 // settle for the generic option already in the descriptor.
252 // Indicate no-change by returning false.
253 return (false);
254 }
255
256 try {
257 // Definition found. Let's replace the generic option in
258 // the descriptor with one created based on definition's factory.
259 if (formatted_value.empty()) {
260 // No formatted value, use data stored in the generic option.
261 opt_desc.option_ = def->optionFactory(universe, code, opt_desc.option_->getData());
262 } else {
263 // Spit the value specified in comma separated values format.
264 std::vector<std::string> split_vec;
265 boost::split(split_vec, formatted_value, boost::is_any_of(","));
266 opt_desc.option_ = def->optionFactory(universe, code, split_vec);
267 }
268 } catch (const std::exception& ex) {
269 isc_throw(InvalidOperation, "could not create option: " << space << "." << code
270 << " from data specified, reason: " << ex.what());
271 }
272
273 // Indicate we replaced the definition.
274 return(true);
275}
276
277void
279 // Merge non-vendor options.
280 mergeInternal(options_, other.options_);
281 // Merge vendor options.
282 mergeInternal(vendor_options_, other.vendor_options_);
283}
284
285void
287 // Remove any existing data in the destination.
288 other.options_.clearItems();
289 other.vendor_options_.clearItems();
290 mergeTo(other);
291 other.encapsulated_ = isEncapsulated();
292}
293
294void
296 // Append sub-options to the top level "dhcp4" option space.
297 encapsulateInternal(DHCP4_OPTION_SPACE);
298 // Append sub-options to the top level "dhcp6" option space.
299 encapsulateInternal(DHCP6_OPTION_SPACE);
300 encapsulated_ = true;
301}
302
303void
304CfgOption::encapsulateInternal(const std::string& option_space) {
305 // Get all options for the particular option space.
306 OptionContainerPtr options = getAll(option_space);
307 // For each option in the option space we will append sub-options
308 // from the option spaces they encapsulate.
309 for (auto const& opt : *options) {
310 encapsulateInternal(opt.option_);
311 }
312}
313
314void
315CfgOption::encapsulateInternal(const OptionPtr& option) {
316 // Get encapsulated option space for the option.
317 const std::string& encap_space = option->getEncapsulatedSpace();
318 // Empty value means that no option space is encapsulated.
319 if (!encap_space.empty()) {
320 if (encap_space == DHCP4_OPTION_SPACE || encap_space == DHCP6_OPTION_SPACE) {
321 return;
322 }
323 // Retrieve all options from the encapsulated option space.
324 OptionContainerPtr encap_options = getAll(encap_space);
325 for (auto const& encap_opt : *encap_options) {
326 if (option.get() == encap_opt.option_.get()) {
327 // Avoid recursion by not adding options to themselves.
328 continue;
329 }
330
331 // Add sub-option if there isn't one added already.
332 if (!option->getOption(encap_opt.option_->getType())) {
333 option->addOption(encap_opt.option_);
334 }
335 encapsulateInternal(encap_opt.option_);
336 }
337 }
338}
339
340template <typename Selector>
341void
342CfgOption::mergeInternal(const OptionSpaceContainer<OptionContainer,
343 OptionDescriptor, Selector>& src_container,
344 OptionSpaceContainer<OptionContainer,
345 OptionDescriptor, Selector>& dest_container) const {
346 // Get all option spaces used in source container.
347 std::list<Selector> selectors = src_container.getOptionSpaceNames();
348
349 // For each space in the source container retrieve the actual options and
350 // match them with the options held in the destination container under
351 // the same space.
352 for (auto const& it : selectors) {
353 // Get all options in the destination container for the particular
354 // option space.
355 OptionContainerPtr dest_all = dest_container.getItems(it);
356 OptionContainerPtr src_all = src_container.getItems(it);
357 // For each option under this option space check if there is a
358 // corresponding option in the destination container. If not,
359 // add one.
360 for (auto const& src_opt : *src_all) {
361 const OptionContainerTypeIndex& idx = dest_all->get<1>();
362 const OptionContainerTypeRange& range =
363 idx.equal_range(src_opt.option_->getType());
364 // If there is no such option in the destination container,
365 // add one.
366 if (std::distance(range.first, range.second) == 0) {
367 dest_container.addItem(OptionDescriptor(src_opt), it);
368 }
369 }
370 }
371}
372
374CfgOption::getAll(const std::string& option_space) const {
375 return (options_.getItems(option_space));
376}
377
379CfgOption::getAll(const uint32_t vendor_id) const {
380 return (vendor_options_.getItems(vendor_id));
381}
382
384CfgOption::getAllCombined(const std::string& option_space) const {
385 auto vendor_id = LibDHCP::optionSpaceToVendorId(option_space);
386 if (vendor_id > 0) {
387 return (getAll(vendor_id));
388 }
389 return (getAll(option_space));
390}
391
392size_t
393CfgOption::del(const std::string& option_space, const uint16_t option_code) {
394 // Check for presence of options.
395 OptionContainerPtr options = getAll(option_space);
396 if (!options || options->empty()) {
397 // There are no options, so there is nothing to do.
398 return (0);
399 }
400
401 // If this is not top level option we may also need to delete the
402 // option instance from options encapsulating the particular option
403 // space.
404 if ((option_space != DHCP4_OPTION_SPACE) &&
405 (option_space != DHCP6_OPTION_SPACE)) {
406 // For each option space name iterate over the existing options.
407 auto option_space_names = getOptionSpaceNames();
408 for (auto const& option_space_from_list : option_space_names) {
409 // Get all options within the particular option space.
410 auto const& options_in_space = getAll(option_space_from_list);
411 for (auto const& option_it : *options_in_space) {
412
413 // Check if the option encapsulates our option space and
414 // it does, try to delete our option.
415 if (option_it.option_ &&
416 (option_it.option_->getEncapsulatedSpace() == option_space)) {
417 option_it.option_->delOption(option_code);
418 }
419 }
420 }
421 }
422
423 auto& idx = options->get<1>();
424 return (idx.erase(option_code));
425}
426
427size_t
428CfgOption::del(const uint32_t vendor_id, const uint16_t option_code) {
429 // Check for presence of options.
430 OptionContainerPtr vendor_options = getAll(vendor_id);
431 if (!vendor_options || vendor_options->empty()) {
432 // There are no options, so there is nothing to do.
433 return (0);
434 }
435
436 auto& idx = vendor_options->get<1>();
437 return (idx.erase(option_code));
438}
439
440size_t
441CfgOption::del(const uint64_t id) {
442 // Hierarchical nature of the options configuration requires that
443 // we go over all options and decapsulate them before removing
444 // any of them. Let's walk over the existing option spaces.
445 for (auto const& space_name : getOptionSpaceNames()) {
446 // Get all options for the option space.
447 auto const& options = getAll(space_name);
448 for (auto const& option_it : *options) {
449 if (!option_it.option_) {
450 continue;
451 }
452
453 // For each option within the option space we need to dereference
454 // any existing sub options.
455 auto sub_options = option_it.option_->getOptions();
456 for (auto const& sub : sub_options) {
457 // Dereference sub option.
458 option_it.option_->delOption(sub.second->getType());
459 }
460 }
461 }
462
463 // Now that we got rid of dependencies between the instances of the options
464 // we can delete all options having a specified id.
465 size_t num_deleted = options_.deleteItems(id) + vendor_options_.deleteItems(id);
466
467 // Let's encapsulate those options that remain in the configuration.
468 encapsulate();
469
470 // Return the number of deleted options.
471 return (num_deleted);
472}
473
476 return (toElementWithMetadata(false));
477}
478
481 return (toElementWithMetadata(false, cfg_option_def));
482}
483
485CfgOption::toElementWithMetadata(const bool include_metadata,
486 CfgOptionDefPtr cfg_option_def) const {
487 // option-data value is a list of maps
489 // Iterate first on options using space names
490 const std::list<std::string>& names = options_.getOptionSpaceNames();
491 for (auto const& name : names) {
492 OptionContainerPtr opts = getAll(name);
493 for (auto const& opt : *opts) {
494 // Get and fill the map for this option
496 // Set user context
497 opt.contextToElement(map);
498 // Set space from parent iterator
499 map->set("space", Element::create(name));
500 // Set the code
501 uint16_t code = opt.option_->getType();
502 map->set("code", Element::create(code));
503 // Set the name (always for standard options else when asked for)
505 if (cfg_option_def) {
506 def = cfg_option_def->get(name, code);
507 }
508 if (!def) {
509 def = LibDHCP::getOptionDef(name, code);
510 }
511 if (!def) {
512 def = LibDHCP::getRuntimeOptionDef(name, code);
513 }
514 if (!def) {
515 def = LibDHCP::getLastResortOptionDef(name, code);
516 }
517 if (def) {
518 map->set("name", Element::create(def->getName()));
519 }
520 // Set the data item
521 if (!opt.formatted_value_.empty()) {
522 map->set("csv-format", Element::create(true));
523 if (def && def->getType() == OPT_EMPTY_TYPE) {
524 map->set("data", Element::create(""));
525 } else {
526 map->set("data", Element::create(opt.formatted_value_));
527 }
528 } else {
529 std::vector<uint8_t> bin = opt.option_->toBinary();
530 if (!opt.cancelled_ || !bin.empty()) {
531 map->set("csv-format", Element::create(false));
532 if (def && def->getType() == OPT_EMPTY_TYPE) {
533 map->set("data", Element::create(""));
534 } else {
535 std::string repr = util::encode::encodeHex(bin);
536 map->set("data", Element::create(repr));
537 }
538 }
539 }
540 // Set the persistency flag
541 map->set("always-send", Element::create(opt.persistent_));
542 // Set the cancelled flag.
543 map->set("never-send", Element::create(opt.cancelled_));
544 // Include metadata if requested.
545 if (include_metadata) {
546 map->set("metadata", opt.getMetadata());
547 }
548
549 // Include client-classes if not empty.
550 if (!opt.client_classes_.empty()) {
551 map->set("client-classes", opt.client_classes_.toElement());
552 }
553
554 // Push on the list
555 result->add(map);
556 }
557 }
558 // Iterate first on vendor_options using vendor ids
559 const std::list<uint32_t>& ids = vendor_options_.getOptionSpaceNames();
560 for (auto const& id : ids) {
561 OptionContainerPtr opts = getAll(id);
562 for (auto const& opt : *opts) {
563 // Get and fill the map for this option
565 // Set user context
566 opt.contextToElement(map);
567 // Set space from parent iterator
568 std::ostringstream oss;
569 oss << "vendor-" << id;
570 map->set("space", Element::create(oss.str()));
571 // Set the code
572 uint16_t code = opt.option_->getType();
573 map->set("code", Element::create(code));
574 // Set the name
575 Option::Universe universe = opt.option_->getUniverse();
577 LibDHCP::getVendorOptionDef(universe, id, code);
578 if (!def) {
579 // vendor-XXX space is in oss
580 def = LibDHCP::getRuntimeOptionDef(oss.str(), code);
581 }
582 if (def) {
583 map->set("name", Element::create(def->getName()));
584 }
585 // Set the data item
586 if (!opt.formatted_value_.empty()) {
587 map->set("csv-format", Element::create(true));
588 if (def && def->getType() == OPT_EMPTY_TYPE) {
589 map->set("data", Element::create(""));
590 } else {
591 map->set("data", Element::create(opt.formatted_value_));
592 }
593 } else {
594 std::vector<uint8_t> bin = opt.option_->toBinary();
595 if (!opt.cancelled_ || !bin.empty()) {
596 map->set("csv-format", Element::create(false));
597 if (def && def->getType() == OPT_EMPTY_TYPE) {
598 map->set("data", Element::create(""));
599 } else {
600 std::string repr = util::encode::encodeHex(bin);
601 map->set("data", Element::create(repr));
602 }
603 }
604 }
605 // Set the persistency flag
606 map->set("always-send", Element::create(opt.persistent_));
607 // Set the cancellation flag
608 map->set("never-send", Element::create(opt.cancelled_));
609
610 // Include client-classes if not empty.
611 if (!opt.client_classes_.empty()) {
612 map->set("client-classes", opt.client_classes_.toElement());
613 }
614
615 // Push on the list
616 result->add(map);
617 }
618 }
619
620 return (result);
621}
622
623} // namespace dhcp
624} // namespace isc
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown if a function is called in a prohibited way.
static ElementPtr create(const Position &pos=ZERO_POSITION())
Definition data.cc:249
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
Definition data.cc:304
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition data.cc:299
Represents option data configuration for the DHCP server.
Definition cfg_option.h:372
bool isEncapsulated() const
Checks if options have been encapsulated.
Definition cfg_option.h:570
OptionContainerPtr getAllCombined(const std::string &option_space) const
Returns all non-vendor or vendor options for the specified option space.
void encapsulate()
Appends encapsulated options to top-level options.
void replace(const OptionDescriptor &desc, const std::string &option_space)
Replaces the instance of an option within this collection.
static bool createDescriptorOption(CfgOptionDefPtr cfg_def, const std::string &space, OptionDescriptor &opt_desc)
Creates an option descriptor's option based on a set of option defs.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
void createOptions(CfgOptionDefPtr cfg_def)
Re-create the option in each descriptor based on given definitions.
isc::data::ElementPtr toElementWithMetadata(const bool include_metadata, CfgOptionDefPtr cfg_option_def=CfgOptionDefPtr()) const
Unparse a configuration object with optionally including the metadata.
size_t del(const std::string &option_space, const uint16_t option_code)
Deletes option for the specified option space and option code.
std::list< std::string > getOptionSpaceNames() const
Returns a list of configured option space names.
Definition cfg_option.h:727
bool empty() const
Indicates the object is empty.
Definition cfg_option.cc:91
void mergeTo(CfgOption &other) const
Merges this configuration to another configuration.
void copyTo(CfgOption &other) const
Copies this configuration to another configuration.
CfgOption()
default constructor
Definition cfg_option.cc:86
std::list< std::string > getVendorIdsSpaceNames() const
Returns a list of option space names for configured vendor ids.
OptionContainerPtr getAll(const std::string &option_space) const
Returns all options for the specified option space.
void merge(CfgOptionDefPtr cfg_def, CfgOption &other)
Merges another option configuration into this one.
bool equals(const CfgOption &other) const
Check if configuration is equal to other configuration.
Definition cfg_option.cc:96
void add(const OptionPtr &option, const bool persistent, const bool cancelled, const std::string &option_space, const uint64_t id=0)
Adds instance of the option to the configuration.
std::list< uint32_t > getVendorIds() const
Returns a list of all configured vendor identifiers.
Definition cfg_option.h:732
Container for storing client class names.
Definition classify.h:108
bool contains(const ClientClass &x) const
returns if class x belongs to the defined classes
Definition classify.cc:55
void insert(const ClientClass &class_name)
Insert an element.
Definition classify.h:155
bool empty() const
Check if classes is empty.
Definition classify.h:165
size_t size() const
Returns the number of classes.
Definition classify.h:173
static OptionDefinitionPtr getOptionDef(const std::string &space, const uint16_t code)
Return the first option definition matching a particular option code.
Definition libdhcp++.cc:132
static OptionDefinitionPtr getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id, const uint16_t code)
Returns vendor option definition for a given vendor-id and code.
Definition libdhcp++.cc:174
static uint32_t optionSpaceToVendorId(const std::string &option_space)
Converts option space name to vendor id.
static OptionDefinitionPtr getRuntimeOptionDef(const std::string &space, const uint16_t code)
Returns runtime (non-standard) option definition by space and option code.
Definition libdhcp++.cc:195
static OptionDefinitionPtr getLastResortOptionDef(const std::string &space, const uint16_t code)
Returns last resort option definition by space and option code.
Definition libdhcp++.cc:253
Option descriptor.
Definition cfg_option.h:48
OptionPtr option_
Option instance.
Definition cfg_option.h:51
void addClientClass(const std::string &class_name)
Adds new client class for which the option is allowed.
Definition cfg_option.cc:55
std::string space_name_
Option space name.
Definition cfg_option.h:91
bool equals(const OptionDescriptor &other) const
Checks if the one descriptor is equal to another.
Definition cfg_option.cc:46
bool allowedForClientClasses(const ClientClasses &cclasses) const
Validates an OptionDescriptor's client-classes against a list of classes.
Definition cfg_option.cc:63
bool cancelled_
Cancelled flag.
Definition cfg_option.h:65
std::string formatted_value_
Option value in textual (CSV) format.
Definition cfg_option.h:80
static OptionDescriptorPtr create(const OptionPtr &opt, bool persist, bool cancel, const std::string &formatted_value="", data::ConstElementPtr user_context=data::ConstElementPtr())
Factory function creating an instance of the OptionDescriptor.
Definition cfg_option.cc:27
ClientClasses client_classes_
Collection of classes for the which option is allowed.
Definition cfg_option.h:95
bool persistent_
Persistence flag.
Definition cfg_option.h:57
uint64_t deleteItems(const uint64_t id)
Remove all options or option definitions with a given database identifier.
void addItem(const ItemType &item, const Selector &option_space)
Adds a new item to the option_space.
bool empty() const
Indicates the container is empty.
std::list< Selector > getOptionSpaceNames() const
Get a list of existing option spaces.
ItemsContainerPtr getItems(const Selector &option_space) const
Get all items for the particular option space.
bool equals(const OptionSpaceContainer &other) const
Check if two containers are equal.
static bool validateName(const std::string &name)
Checks that the provided option space name is valid.
Universe
defines option universe DHCPv4 or DHCPv6
Definition option.h:90
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
std::string ClientClass
Defines a single class name.
Definition classify.h:42
std::pair< OptionContainerTypeIndex::const_iterator, OptionContainerTypeIndex::const_iterator > OptionContainerTypeRange
Pair of iterators to represent the range of options having the same option type value.
Definition cfg_option.h:330
OptionContainer::nth_index< 1 >::type OptionContainerTypeIndex
Type of the index #1 - option type.
Definition cfg_option.h:325
boost::shared_ptr< CfgOptionDef > CfgOptionDefPtr
Non-const pointer.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
boost::shared_ptr< OptionDescriptor > OptionDescriptorPtr
A pointer to option descriptor.
Definition cfg_option.h:37
boost::shared_ptr< OptionContainer > OptionContainerPtr
Pointer to the OptionContainer object.
Definition cfg_option.h:323
boost::multi_index_container< OptionDescriptor, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::hashed_non_unique< KeyFromKeyExtractor< boost::multi_index::const_mem_fun< Option, uint16_t, &Option::getType >, boost::multi_index::member< OptionDescriptor, OptionPtr, &OptionDescriptor::option_ > > >, boost::multi_index::hashed_non_unique< boost::multi_index::member< OptionDescriptor, bool, &OptionDescriptor::persistent_ > >, boost::multi_index::ordered_non_unique< boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime, &data::BaseStampedElement::getModificationTime > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< OptionIdIndexTag >, boost::multi_index::const_mem_fun< data::BaseStampedElement, uint64_t, &data::BaseStampedElement::getId > >, boost::multi_index::hashed_non_unique< boost::multi_index::member< OptionDescriptor, bool, &OptionDescriptor::cancelled_ > > > > OptionContainer
Multi index container for DHCP option descriptors.
Definition cfg_option.h:320
boost::shared_ptr< Option > OptionPtr
Definition option.h:37
string encodeHex(const vector< uint8_t > &binary)
Encode binary data in the base16 format.
Definition encode.cc:361
string trim(const string &input)
Trim leading and trailing spaces.
Definition str.cc:32
Defines the logger used by the top-level component of kea-lfc.
#define DHCP4_OPTION_SPACE
global std option spaces
#define DHCP6_OPTION_SPACE