7 #ifndef OPTION_DEFINITION_H
8 #define OPTION_DEFINITION_H
16 #include <boost/multi_index/hashed_index.hpp>
17 #include <boost/multi_index/mem_fun.hpp>
18 #include <boost/multi_index/ordered_index.hpp>
19 #include <boost/multi_index/sequenced_index.hpp>
20 #include <boost/multi_index_container.hpp>
21 #include <boost/shared_ptr.hpp>
156 const std::string& space,
157 const std::string& type,
158 const bool array_type =
false);
170 const std::string& space,
172 const bool array_type =
false);
191 const std::string& space,
192 const std::string& type,
193 const char* encapsulated_space);
212 const std::string& space,
214 const char* encapsulated_space);
231 static OptionDefinitionPtr
create(
const std::string& name,
233 const std::string& space,
234 const std::string& type,
235 const bool array_type =
false);
252 static OptionDefinitionPtr
create(
const std::string& name,
254 const std::string& space,
256 const bool array_type =
false);
273 static OptionDefinitionPtr
create(
const std::string& name,
275 const std::string& space,
276 const std::string& type,
277 const char* encapsulated_space);
294 static OptionDefinitionPtr
create(
const std::string& name,
296 const std::string& space,
298 const char* encapsulated_space);
362 return (encapsulated_space_);
368 std::string
getName()
const {
return (name_); }
374 return (record_fields_);
381 return (option_space_name_);
487 const std::vector<std::string>& values)
const;
598 const std::string& encapsulated_space,
602 option->setEncapsulatedSpace(encapsulated_space);
603 option->unpack(begin, end);
628 bool haveCompressedFqdnListFormat()
const;
667 return (type == type_);
673 inline bool haveSpace(
const std::string& space)
const {
674 return (space == option_space_name_);
695 bool convertToBool(
const std::string& value_str)
const;
710 T lexicalCastWithRangeCheck(
const std::string& value_str)
const;
740 std::string encapsulated_space_;
742 RecordFieldsCollection record_fields_;
744 data::UserContext user_context_;
746 std::string option_space_name_;
764 typedef boost::multi_index_container<
768 boost::multi_index::indexed_by<
771 boost::multi_index::sequenced<>,
773 boost::multi_index::hashed_non_unique<
780 boost::multi_index::const_mem_fun<
787 boost::multi_index::hashed_non_unique<
791 boost::multi_index::const_mem_fun<
798 boost::multi_index::ordered_non_unique<
801 boost::multi_index::const_mem_fun<
802 data::BaseStampedElement,
803 boost::posix_time::ptime,
809 boost::multi_index::hashed_non_unique<
810 boost::multi_index::tag<OptionIdIndexTag>,
811 boost::multi_index::const_mem_fun<data::BaseStampedElement, uint64_t,
832 typedef std::pair<OptionDefContainerTypeIndex::const_iterator,
841 typedef std::pair<OptionDefContainerNameIndex::const_iterator,
861 void addItem(
const OptionDefinitionPtr& def) {
869 #endif // OPTION_DEFINITION_H
bool getArrayType() const
Return array type indicator.
bool operator==(const OptionDefinition &other) const
Equality operator.
Simple container for option spaces holding various items.
void setContext(const data::ConstElementPtr &ctx)
Sets user context.
This class represents configuration element which is associated with database identifier, modification timestamp and servers.
static OptionDefinitionPtr create(const std::string &name, const uint16_t code, const std::string &space, const std::string &type, const bool array_type=false)
Factory function creating an instance of the OptionDefinition.
Exception to be thrown when invalid option value has been specified for a particular option definitio...
OptionPtr optionFactory(Option::Universe u, uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end) const
Option factory.
Base class representing a DHCP option definition.
void addItem(const OptionDefinitionPtr &def)
Adds a new option definition to the container.
std::vector< OptionDataType > RecordFieldsCollection
List of fields within the record.
static OptionPtr factoryAddrList4(uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Factory to create option with address list.
OptionDefContainer::nth_index< 1 >::type OptionDefContainerTypeIndex
Type of the index #1 - option type.
boost::shared_ptr< Option > OptionPtr
Universe
defines option universe DHCPv4 or DHCPv6
static OptionPtr factoryIntegerArray(Option::Universe u, uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Factory function to create option with array of integer values.
boost::shared_ptr< Element > ElementPtr
static OptionPtr factoryEmpty(Option::Universe u, uint16_t type)
Empty option factory.
OptionDefinition(const std::string &name, const uint16_t code, const std::string &space, const std::string &type, const bool array_type=false)
Constructor.
Forward declaration to OptionInt.
std::map< uint32_t, OptionDefContainerPtr > VendorOptionDefContainers
Container that holds various vendor option containers.
static OptionPtr factoryIA6(uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Factory for IA-type of option.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
bool equals(const OptionDefinition &other) const
Check if option definition is equal to other.
static OptionPtr factoryOpaqueDataTuples(Option::Universe u, uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Factory to create option with tuple list.
boost::multi_index_container< OptionDefinitionPtr, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::hashed_non_unique< boost::multi_index::const_mem_fun< OptionDefinition, uint16_t,&OptionDefinition::getCode > >, boost::multi_index::hashed_non_unique< boost::multi_index::const_mem_fun< OptionDefinition, std::string,&OptionDefinition::getName > >, boost::multi_index::ordered_non_unique< boost::multi_index::const_mem_fun< data::BaseStampedElement, boost::posix_time::ptime,&data::StampedElement::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 > > >> OptionDefContainer
Multi index container for DHCP option definitions.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
std::pair< OptionDefContainerTypeIndex::const_iterator, OptionDefContainerTypeIndex::const_iterator > OptionDefContainerTypeRange
Pair of iterators to represent the range of options definitions having the same option type value...
Class of option definition space container.
static OptionPtr factoryIAPrefix6(uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Factory for IAPREFIX-type of option.
boost::posix_time::ptime getModificationTime() const
Returns timestamp.
OptionDataType
Data types of DHCP option fields.
Forward declaration to OptionIntArray.
static OptionPtr factoryAddrList6(uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Factory to create option with address list.
void validate() const
Check if the option definition is valid.
uint16_t getCode() const
Return option code.
uint64_t getId() const
Returns element's database identifier.
boost::shared_ptr< const Element > ConstElementPtr
Exception to be thrown when the particular option definition duplicates existing option definition...
boost::shared_ptr< OptionDefContainer > OptionDefContainerPtr
Pointer to an option definition container.
data::ConstElementPtr getContext() const
Returns const pointer to the user context.
OptionSpaceContainer< OptionDefContainer, OptionDefinitionPtr, std::string > BaseOptionDefSpaceContainer
Base type of option definition space container.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
void setContext(const data::ConstElementPtr &ctx)
Sets user context.
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
std::string getName() const
Return option name.
std::map< std::string, OptionDefContainerPtr > OptionDefContainers
Container that holds option definitions for various option spaces.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
const RecordFieldsCollection & getRecordFields() const
Return list of record fields.
static OptionPtr factoryGeneric(Option::Universe u, uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Factory to create generic option.
std::string getEncapsulatedSpace() const
Return name of the encapsulated option space.
void addItem(const ItemType &item, const Selector &option_space)
Adds a new item to the option_space.
void addRecordField(const std::string &data_type_name)
Adds data field to the record.
InvalidOptionValue(const char *file, size_t line, const char *what)
data::ConstElementPtr getContext() const
Returns const pointer to the user context.
boost::shared_ptr< OptionDefinition > OptionDefinitionPtr
Pointer to option definition object.
std::string getOptionSpaceName() const
Returns option space name.
std::vector< OptionDataType >::const_iterator RecordFieldsConstIter
Const iterator for record data fields.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
bool operator!=(const OptionDefinition &other) const
Inequality operator.
static OptionPtr factoryIAAddr6(uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Factory for IAADDR-type of option.
DuplicateOptionDefinition(const char *file, size_t line, const char *what)
static OptionPtr factoryInteger(Option::Universe u, uint16_t type, const std::string &encapsulated_space, OptionBufferConstIter begin, OptionBufferConstIter end)
Factory function to create option with integer value.
OptionDataType getType() const
Return option data type.
OptionDefContainer::nth_index< 2 >::type OptionDefContainerNameIndex
Type of the index #2 - option name.
std::pair< OptionDefContainerNameIndex::const_iterator, OptionDefContainerNameIndex::const_iterator > OptionDefContainerNameRange
Pair of iterators to represent the range of options definitions having the same option name...