53 typedef boost::shared_ptr<OptionInt<T> > OptionIntTypePtr;
66 :
Option(u, type), value_(value) {
122 buf.writeUint8(value_);
125 buf.writeUint16(value_);
128 buf.writeUint32(value_);
149 if (distance(begin, end) <
sizeof(T)) {
160 switch (data_size_len) {
166 std::distance(begin, end));
170 std::distance(begin, end));
179 begin += data_size_len;
198 virtual uint16_t
len()
const {
202 length +=
sizeof(T);;
205 length += it.second->len();
216 virtual std::string
toText(
int indent = 0)
const {
217 std::stringstream output;
224 output << static_cast<int>(
getValue());
237 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)
Parses received buffer.
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.
T getValue() const
Return option value.
void setValue(T value)
Set option value.
OptionInt(Option::Universe u, uint16_t type, T value)
Constructor.
virtual uint16_t len() const
returns complete length of option
OptionInt(Option::Universe u, uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Constructor.
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 unpackOptions(const OptionBuffer &buf)
Builds a collection of sub options from the buffer.
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
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.
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.
#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
Trait class for data types supported in DHCP option definitions.