53 typedef boost::shared_ptr<OptionInt<T> > OptionIntTypePtr;
66 :
Option(u, type), value_(value) {
96 unpack(begin, end, rec_level);
169 if (
static_cast<size_t>(distance(begin, end)) <
sizeof(T)) {
180 switch (data_size_len) {
186 std::distance(begin, end));
190 std::distance(begin, end));
199 begin += data_size_len;
218 virtual uint16_t
len()
const {
222 length +=
sizeof(T);;
225 length += it.second->len();
236 virtual std::string
toText(
int indent = 0)
const {
237 std::stringstream output;
244 output << static_cast<int>(
getValue());
257 return (output.str());
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
Exception to be thrown when invalid type specified as template parameter.
static const std::string & getDataTypeName(const OptionDataType data_type)
Return option data type name from the data type enumerator.
Forward declaration to OptionInt.
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
virtual std::string toText(int indent=0) const
Returns option carrying an integer value in the textual format.
OptionInt(Option::Universe u, uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end, size_t rec_level=0)
Constructor.
T getValue() const
Return option value.
void setValue(T value)
Set option value.
OptionInt(Option::Universe u, uint16_t type, T value)
Constructor.
void unpack(OptionBufferConstIter begin, OptionBufferConstIter end, size_t rec_level)
Parses received buffer with limited recursion.
virtual uint16_t len() const
returns complete length of option
virtual void pack(isc::util::OutputBuffer &buf, bool check=true) const
Writes option in wire-format to buf, returns pointer to first unused byte after stored option.
std::string headerToText(const int indent=0, const std::string &type_name="") const
Returns option header in the textual format.
std::string suboptionsToText(const int indent=0) const
Returns collection of suboptions in the textual format.
void setEncapsulatedSpace(const std::string &encapsulated_space)
Sets the name of the option space encapsulated by this option.
Universe
defines option universe DHCPv4 or DHCPv6
uint16_t getType() const
Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6).
void packOptions(isc::util::OutputBuffer &buf, bool check=true) const
Store sub options in a buffer.
static const size_t OPTION6_HDR_LEN
length of any DHCPv6 option header
OptionCollection options_
collection for storing suboptions
void unpackOptions(const OptionBuffer &buf, size_t rec_level=0)
Builds a collection of sub options from the buffer.
OptionPtr cloneInternal() const
Copies this option and returns a pointer to the copy.
Universe getUniverse() const
returns option universe (V4 or V6)
void packHeader(isc::util::OutputBuffer &buf, bool check=true) const
Store option's header in a buffer.
Option(Universe u, uint16_t type)
ctor, used for options constructed, usually during transmission
void check() const
A protected method used for option correctness.
static const size_t OPTION4_HDR_LEN
length of the usual DHCPv4 option header (there are exceptions)
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
void writeUint8(uint8_t data)
Write an unsigned 8-bit integer into the buffer.
void writeUint16(uint16_t data)
Write an unsigned 16-bit integer in host byte order into the buffer in network byte order.
void writeUint32(uint32_t data)
Write an unsigned 32-bit integer in host byte order into the buffer in network byte order.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
OptionInt< uint8_t > OptionUint8
OptionInt< uint32_t > OptionUint32
OptionInt< uint16_t > OptionUint16
boost::shared_ptr< OptionUint8 > OptionUint8Ptr
boost::shared_ptr< OptionUint32 > OptionUint32Ptr
boost::shared_ptr< OptionUint16 > OptionUint16Ptr
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
boost::shared_ptr< Option > OptionPtr
uint16_t readUint16(void const *const buffer, size_t const length)
uint16_t wrapper over readUint.
uint32_t readUint32(void const *const buffer, size_t const length)
uint32_t wrapper over readUint.
Defines the logger used by the top-level component of kea-lfc.
#define DHCP4_OPTION_SPACE
global std option spaces
#define DHCP6_OPTION_SPACE
static const bool integer_type
static const OptionDataType type