7#ifndef OPTION_INT_ARRAY_H
8#define OPTION_INT_ARRAY_H
14#include <boost/shared_ptr.hpp>
60 typedef boost::shared_ptr<OptionIntArray<T> > OptionIntArrayTypePtr;
97 unpack(buf.begin(), buf.end());
133 values_.push_back(value);
149 for (
size_t i = 0; i < values_.size(); ++i) {
186 if (distance(begin, end) == 0) {
189 if (distance(begin, end) %
sizeof(T) != 0) {
195 while (begin != end) {
202 switch (data_size_len) {
204 values_.push_back(*begin);
208 std::distance(begin, end)));
212 std::distance(begin, end)));
221 begin += data_size_len;
231 const std::vector<T>&
getValues()
const {
return (values_); }
236 void setValues(
const std::vector<T>& values) { values_ = values; }
243 virtual uint16_t
len()
const {
245 length += values_.size() *
sizeof(T);
248 length += it.second->len();
259 virtual std::string
toText(
int indent = 0)
const {
260 std::stringstream output;
264 for (
auto const& value : values_) {
271 output << static_cast<int>(value);
278 output <<
"(" << data_type <<
")";
281 return (output.str());
286 std::vector<T> values_;
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 OptionIntArray.
OptionIntArray(const Option::Universe u, const uint16_t type)
Constructor.
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses received buffer.
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.
virtual uint16_t len() const
returns complete length of option
const std::vector< T > & getValues() const
Return collection of option values.
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
OptionIntArray(const Option::Universe u, const uint16_t type, const OptionBuffer &buf)
Constructor.
OptionIntArray(const Option::Universe u, const uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Constructor.
void setValues(const std::vector< T > &values)
Set option values.
virtual std::string toText(int indent=0) const
Returns textual representation of the option.
void addValue(const T value)
Adds a new value to the array.
std::string headerToText(const int indent=0, const std::string &type_name="") const
Returns option header in the textual format.
Universe
defines option universe DHCPv4 or DHCPv6
uint16_t getType() const
Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
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.
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.
boost::shared_ptr< OptionUint8Array > OptionUint8ArrayPtr
OptionIntArray< uint32_t > OptionUint32Array
OptionIntArray< uint8_t > OptionUint8Array
boost::shared_ptr< OptionUint32Array > OptionUint32ArrayPtr
boost::shared_ptr< OptionUint16Array > OptionUint16ArrayPtr
OptionIntArray< uint16_t > OptionUint16Array
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.
Trait class for data types supported in DHCP option definitions.