 |
Kea
1.5.0
|
Go to the documentation of this file.
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 {
243 uint16_t length = (getUniverse() ==
Option::V4) ? OPTION4_HDR_LEN : OPTION6_HDR_LEN;
244 length += values_.size() *
sizeof(T);
246 for (OptionCollection::const_iterator it = options_.begin();
247 it != options_.end();
249 length += (*it).second->len();
260 virtual std::string
toText(
int indent = 0)
const {
261 std::stringstream output;
262 output << headerToText(indent) <<
":";
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
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
static const std::string & getDataTypeName(const OptionDataType data_type)
Return option data type name from the data type enumerator.
void pack(isc::util::OutputBuffer &buf) const
Writes option in wire-format to buf, returns pointer to first unused byte after stored option.
uint32_t readUint32(const uint8_t *buffer, size_t length)
Read Unsigned 32-Bit Integer from Buffer.
virtual std::string toText(int indent=0) const
Returns textual representation of the option.
void writeUint16(uint16_t data)
Write an unsigned 16-bit integer in host byte order into the buffer in network byte order.
OptionIntArray< uint16_t > OptionUint16Array
Defines the logger used by the top-level component of kea-dhcp-ddns.
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 uint16_t len() const
returns complete length of option
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Trait class for data types supported in DHCP option definitions.
void writeUint8(uint8_t data)
Write an unsigned 8-bit integer into the buffer.
boost::shared_ptr< OptionUint16Array > OptionUint16ArrayPtr
void addValue(const T value)
Adds a new value to the array.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Exception to be thrown when invalid type specified as template parameter.
uint16_t readUint16(const void *buffer, size_t length)
Read Unsigned 16-Bit Integer from Buffer.
OptionIntArray(const Option::Universe u, const uint16_t type, const OptionBuffer &buf)
Constructor.
const std::vector< T > & getValues() const
Return collection of option values.
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
boost::shared_ptr< Option > OptionPtr
void writeUint32(uint32_t data)
Write an unsigned 32-bit integer in host byte order into the buffer in network byte order.
Forward declaration to OptionIntArray.
OptionIntArray(const Option::Universe u, const uint16_t type)
Constructor.
Universe
defines option universe DHCPv4 or DHCPv6
void setValues(const std::vector< T > &values)
Set option values.
OptionIntArray< uint32_t > OptionUint32Array
OptionIntArray(const Option::Universe u, const uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end)
Constructor.
OptionIntArray< uint8_t > OptionUint8Array
boost::shared_ptr< OptionUint32Array > OptionUint32ArrayPtr
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
boost::shared_ptr< OptionUint8Array > OptionUint8ArrayPtr