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);
148 for (
size_t i = 0; i < values_.size(); ++i) {
185 if (distance(begin, end) == 0) {
188 if (distance(begin, end) %
sizeof(T) != 0) {
194 while (begin != end) {
201 switch (data_size_len) {
203 values_.push_back(*begin);
207 std::distance(begin, end)));
211 std::distance(begin, end)));
220 begin += data_size_len;
230 const std::vector<T>&
getValues()
const {
return (values_); }
235 void setValues(
const std::vector<T>& values) { values_ = values; }
242 virtual uint16_t
len()
const {
244 length += values_.size() *
sizeof(T);
246 for (OptionCollection::const_iterator it =
options_.begin();
249 length += (*it).second->len();
260 virtual std::string
toText(
int indent = 0)
const {
261 std::stringstream output;
265 for (
typename std::vector<T>::const_iterator value = values_.begin();
266 value != values_.end(); ++value) {
273 output << static_cast<int>(*value);
280 output <<
"(" << data_type <<
")";
283 return (output.str());
288 std::vector<T> values_;
294 #endif // OPTION_INT_ARRAY_H
Universe getUniverse() const
returns option universe (V4 or V6)
virtual std::string toText(int indent=0) const
Returns textual representation of the option.
void packHeader(isc::util::OutputBuffer &buf) const
Store option's header in a buffer.
static const std::string & getDataTypeName(const OptionDataType data_type)
Return option data type name from the data type enumerator.
OptionIntArray(const Option::Universe u, const uint16_t type)
Constructor.
virtual uint16_t len() const
returns complete length of option
boost::shared_ptr< OptionUint8Array > OptionUint8ArrayPtr
boost::shared_ptr< Option > OptionPtr
void addValue(const T value)
Adds a new value to the array.
Universe
defines option universe DHCPv4 or DHCPv6
Exception to be thrown when invalid type specified as template parameter.
OptionPtr cloneInternal() const
Copies this option and returns a pointer to the copy.
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)
OptionIntArray< uint16_t > OptionUint16Array
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
OptionIntArray< uint8_t > OptionUint8Array
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses received buffer.
Forward declaration to OptionIntArray.
void setValues(const std::vector< T > &values)
Set option values.
OptionCollection options_
collection for storing suboptions
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
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.
OptionIntArray(const Option::Universe u, const uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Constructor.
uint16_t readUint16(const void *buffer, size_t length)
Read Unsigned 16-Bit Integer from Buffer.
boost::shared_ptr< OptionUint32Array > OptionUint32ArrayPtr
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.
void pack(isc::util::OutputBuffer &buf) const
Writes option in wire-format to buf, returns pointer to first unused byte after stored option...
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...
Trait class for data types supported in DHCP option definitions.
OptionIntArray< uint32_t > OptionUint32Array
boost::shared_ptr< OptionUint16Array > OptionUint16ArrayPtr
OptionIntArray(const Option::Universe u, const uint16_t type, const OptionBuffer &buf)
Constructor.
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
static const size_t OPTION6_HDR_LEN
length of any DHCPv6 option header
const std::vector< T > & getValues() const
Return collection of option values.