12 #include <boost/shared_ptr.hpp>
37 typedef boost::shared_ptr<Option>
OptionPtr;
113 const OptionBuffer& buf);
173 OptionBufferConstIter last);
208 static OptionPtr
create(
Universe u, uint16_t type,
const OptionBuffer& data);
227 virtual OptionPtr
clone()
const;
249 virtual void unpack(OptionBufferConstIter begin,
250 OptionBufferConstIter end);
257 virtual std::string
toText(
int indent = 0)
const;
265 virtual std::string
toString()
const;
274 virtual std::vector<uint8_t>
toBinary(
const bool include_header =
false)
const;
283 virtual std::string
toHexString(
const bool include_header =
false)
const;
294 virtual uint16_t
len()
const;
304 virtual bool valid()
const;
331 OptionPtr
getOption(uint16_t type)
const;
407 template<
typename InputIterator>
408 void setData(InputIterator first, InputIterator last) {
409 data_.assign(first, last);
438 bool equals(
const OptionPtr& other)
const;
477 template<
typename OptionType>
479 const OptionType* cast_this =
dynamic_cast<const OptionType*
>(
this);
481 return (boost::shared_ptr<OptionType>(
new OptionType(*cast_this)));
542 const std::string& type_name =
"")
const;
Universe getUniverse() const
returns option universe (V4 or V6)
const OptionCollection & getOptions() const
Returns all encapsulated options.
void packHeader(isc::util::OutputBuffer &buf) const
Store option's header in a buffer.
void packOptions(isc::util::OutputBuffer &buf) const
Store sub options in a buffer.
virtual std::string toHexString(const bool include_header=false) const
Returns string containing hexadecimal representation of option.
Exception thrown during option unpacking This exception is thrown when an error has occurred...
virtual ~Option()
just to force that every option has virtual dtor
OptionPtr getOption(uint16_t type) const
Returns shared_ptr to suboption of specific type.
bool equals(const OptionPtr &other) const
Checks if options are equal.
virtual std::vector< uint8_t > toBinary(const bool include_header=false) const
Returns binary representation of the option.
virtual void pack(isc::util::OutputBuffer &buf) const
Writes option in wire-format to a buffer.
boost::shared_ptr< OptionBuffer > OptionBufferPtr
pointer to a DHCP buffer
void setUint16(uint16_t value)
Sets content of this option to a single uint16 value.
boost::shared_ptr< Option > OptionPtr
Universe
defines option universe DHCPv4 or DHCPv6
virtual const OptionBuffer & getData() const
Returns pointer to actual data.
static OptionPtr factory(Option::Universe u, uint16_t type)
Factory function to create instance of option.
virtual std::string toString() const
Returns string representation of the value.
Option(Universe u, uint16_t type)
ctor, used for options constructed, usually during transmission
virtual uint16_t getHeaderLen() const
Returns length of header (2 for v4, 4 for v6)
OptionPtr cloneInternal() const
Copies this option and returns a pointer to the copy.
Universe universe_
option universe (V4 or V6)
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
static const size_t OPTION4_HDR_LEN
length of the usual DHCPv4 option header (there are exceptions)
void setUint32(uint32_t value)
Sets content of this option to a single uint32 value.
uint8_t getUint8() const
Returns content of first byte.
void check() const
A protected method used for option correctness.
bool delOption(uint16_t type)
Attempts to delete first suboption of requested type.
OptionCollection options_
collection for storing suboptions
SkipThisOptionError(const char *file, size_t line, const char *what)
void setEncapsulatedSpace(const std::string &encapsulated_space)
Sets the name of the option space encapsulated by this option.
virtual std::string toText(int indent=0) const
Returns string representation of the option.
std::multimap< unsigned int, OptionPtr > OptionCollection
A collection of DHCP (v4 or v6) options.
void addOption(OptionPtr opt)
Adds a sub-option.
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
std::string suboptionsToText(const int indent=0) const
Returns collection of suboptions in the textual format.
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.
Option & operator=(const Option &rhs)
Assignment operator.
static OptionPtr factory(Option::Universe u, uint16_t type, const OptionBuffer &buf)
Factory function to create instance of option.
void unpackOptions(const OptionBuffer &buf)
Builds a collection of sub options from the buffer.
uint16_t getType() const
Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
std::string headerToText(const int indent=0, const std::string &type_name="") const
Returns option header in the textual format.
static OptionPtr create(Universe u, uint16_t type)
Factory function creating an instance of the Option.
OptionBuffer::iterator OptionBufferIter
iterator for walking over OptionBuffer
std::string getEncapsulatedSpace() const
Returns the name of the option space encapsulated by this option.
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses received buffer.
Exception thrown during option unpacking This exception is thrown when an error has occurred unpackin...
void setUint8(uint8_t value)
Sets content of this option to a single uint8 value.
uint32_t getUint32() const
Returns content of first double word.
OptionBuffer data_
contains content of this data
uint16_t type_
option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
void setData(InputIterator first, InputIterator last)
Sets content of this option from buffer.
void getOptionsCopy(OptionCollection &options_copy) const
Performs deep copy of suboptions.
virtual uint16_t len() const
Returns length of the complete option (data length + DHCPv4/DHCPv6 option header) ...
uint16_t getUint16() const
Returns content of first word.
static bool lenient_parsing_
Governs whether options should be parsed less strictly.
SkipRemainingOptionsError(const char *file, size_t line, const char *what)
boost::shared_ptr< OptionCollection > OptionCollectionPtr
A pointer to an OptionCollection.
std::string encapsulated_space_
Name of the option space being encapsulated by this option.
OptionPtr Factory(Option::Universe u, uint16_t type, const OptionBuffer &buf)
a factory function prototype
static const size_t OPTION6_HDR_LEN
length of any DHCPv6 option header
virtual bool valid() const
returns if option is valid (e.g.