53 typedef boost::shared_ptr<OptionInt<T> > OptionIntTypePtr;
66 :
Option(u, type), value_(value) {
148 if (distance(begin, end) <
sizeof(T)) {
159 switch (data_size_len) {
165 std::distance(begin, end));
169 std::distance(begin, end));
178 begin += data_size_len;
197 virtual uint16_t
len()
const {
201 length +=
sizeof(T);;
203 for (OptionCollection::const_iterator it =
options_.begin();
206 length += (*it).second->len();
217 virtual std::string
toText(
int indent = 0)
const {
218 std::stringstream output;
225 output << static_cast<int>(
getValue());
238 return (output.str());
249 #endif // OPTION_INT_H
Universe getUniverse() const
returns option universe (V4 or V6)
OptionInt(Option::Universe u, uint16_t type, T value)
Constructor.
void setValue(T value)
Set option value.
OptionInt< uint8_t > OptionUint8
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 void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses received buffer.
static const std::string & getDataTypeName(const OptionDataType data_type)
Return option data type name from the data type enumerator.
virtual uint16_t len() const
returns complete length of option
boost::shared_ptr< Option > OptionPtr
Universe
defines option universe DHCPv4 or DHCPv6
Forward declaration to OptionInt.
Exception to be thrown when invalid type specified as template parameter.
void pack(isc::util::OutputBuffer &buf) const
Writes option in wire-format to buf, returns pointer to first unused byte after stored option...
boost::shared_ptr< OptionUint32 > OptionUint32Ptr
boost::shared_ptr< OptionUint8 > OptionUint8Ptr
OptionPtr cloneInternal() const
Copies this option and returns a pointer to the copy.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
OptionInt< uint16_t > OptionUint16
static const size_t OPTION4_HDR_LEN
length of the usual DHCPv4 option header (there are exceptions)
OptionInt< uint32_t > OptionUint32
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< OptionUint16 > OptionUint16Ptr
OptionCollection options_
collection for storing suboptions
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 option carrying an integer value in the textual format.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
uint32_t readUint32(const uint8_t *buffer, size_t length)
Read Unsigned 32-Bit Integer from Buffer.
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.
void writeUint32(uint32_t data)
Write an unsigned 32-bit integer in host byte order into the buffer in network byte order...
Defines the logger used by the top-level component of kea-dhcp-ddns.
void unpackOptions(const OptionBuffer &buf)
Builds a collection of sub options from the buffer.
uint16_t readUint16(const void *buffer, size_t length)
Read Unsigned 16-Bit Integer from Buffer.
#define DHCP6_OPTION_SPACE
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.
void writeUint8(uint8_t data)
Write an unsigned 8-bit integer into the buffer.
#define DHCP4_OPTION_SPACE
global std option spaces
void writeUint16(uint16_t data)
Write an unsigned 16-bit integer in host byte order into the buffer in network byte order...
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
Trait class for data types supported in DHCP option definitions.
T getValue() const
Return option value.
OptionInt(Option::Universe u, uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Constructor.
static const size_t OPTION6_HDR_LEN
length of any DHCPv6 option header