83 size_t rec_level = 0);
109 data_type = definition_.getRecordFields().back();
113 "specified data type " << data_type <<
" does not"
114 " match the data type in an option definition");
119 buffers_.push_back(buf);
166 const uint32_t index = 0);
188 std::string
readTuple(
const uint32_t index = 0)
const;
202 void writeTuple(
const std::string& value,
const uint32_t index = 0);
224 void writeBoolean(
const bool value,
const uint32_t index = 0);
234 std::string
readFqdn(
const uint32_t index = 0)
const;
242 void writeFqdn(
const std::string& fqdn,
const uint32_t index = 0);
258 checkDataType<T>(index);
280 checkDataType<T>(index);
286 std::swap(buffers_[index], buf);
306 const uint32_t index = 0);
326 const uint32_t index = 0);
334 std::string
readString(
const uint32_t index = 0)
const;
341 const uint32_t index = 0);
361 virtual std::string
toText(
int indent = 0)
const;
367 virtual uint16_t
len()
const;
387 inline void checkArrayType()
const {
390 <<
" option. The option is not an array.");
406 void checkDataType(
const uint32_t index)
const;
413 void checkIndex(
const uint32_t index)
const;
423 void createBuffers();
434 size_t bufferLength(
const OptionDataType data_type,
bool in_array,
435 OptionBuffer::const_iterator begin,
436 OptionBuffer::const_iterator end)
const;
442 void createBuffers(
const OptionBuffer& data_buf,
size_t rec_level = 0);
451 const uint32_t index)
const;
459 OptionDefinition definition_;
464 std::vector<OptionBuffer> buffers_;
472OptionCustom::checkDataType(
const uint32_t index)
const {
476 " is not a supported integer type.");
486 if (index < record_fields.size()) {
488 data_type = record_fields[index];
491 data_type = record_fields.back();
499 data_type = record_fields[index];
505 "specified data type " << data_type <<
" does not"
506 " match the data type in an option definition for field"
A generic exception that is thrown if a function is called in a prohibited way.
The IOAddress class represents an IP addresses (version agnostic).
Exception to be thrown when invalid type specified as template parameter.
Represents a single instance of the opaque data preceded by length.
std::string readString(const uint32_t index=0) const
Read a buffer as string value.
void addArrayDataField(const T value)
Create new buffer and store integer value in it.
bool readBoolean(const uint32_t index=0) const
Read a buffer as boolean value.
virtual uint16_t len() const
Returns length of the complete option (data length + DHCPv4/DHCPv6 option header).
std::string readTuple(const uint32_t index=0) const
Read a buffer as length and string tuple.
void writeFqdn(const std::string &fqdn, const uint32_t index=0)
Write an FQDN into a buffer.
std::string readFqdn(const uint32_t index=0) const
Read a buffer as FQDN.
void writePrefix(const PrefixLen &prefix_len, const asiolink::IOAddress &prefix, const uint32_t index=0)
Write prefix length and value into a buffer.
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses received buffer.
void writeAddress(const asiolink::IOAddress &address, const uint32_t index=0)
Write an IP address into a buffer.
virtual void pack(isc::util::OutputBuffer &buf, bool check=true) const
Writes DHCP option in a wire format to a buffer.
void initialize(const OptionBufferConstIter first, const OptionBufferConstIter last)
Sets content of this option from buffer.
const OptionBuffer & readBinary(const uint32_t index=0) const
Read a buffer as binary data.
PrefixTuple readPrefix(const uint32_t index=0) const
Read a buffer as variable length prefix.
void writePsid(const PSIDLen &psid_len, const PSID &psid, const uint32_t index=0)
Write PSID length / value into a buffer.
void writeBoolean(const bool value, const uint32_t index=0)
Write a boolean value into a buffer.
asiolink::IOAddress readAddress(const uint32_t index=0) const
Read a buffer as IP address.
PSIDTuple readPsid(const uint32_t index=0) const
Read a buffer as a PSID length / value tuple.
void writeString(const std::string &text, const uint32_t index=0)
Write a string value into a buffer.
T readInteger(const uint32_t index=0) const
Read a buffer as integer value.
void writeBinary(const OptionBuffer &buf, const uint32_t index=0)
Write binary data into a buffer.
void addArrayDataField(const asiolink::IOAddress &address)
Create new buffer and set its value as an IP address.
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
void writeTuple(const std::string &value, const uint32_t index=0)
Write a length and string tuple into a buffer.
virtual std::string toText(int indent=0) const
Returns string representation of the option.
OptionCustom(const OptionDefinition &def, Universe u)
Constructor, used for options to be sent.
uint32_t getDataFieldsNum() const
Return a number of the data fields.
void writeInteger(const T value, const uint32_t index=0)
Write an integer value into a buffer.
static void writeInt(const T value, std::vector< uint8_t > &buf)
Append integer or unsigned integer value to a buffer.
static T readInt(const std::vector< uint8_t > &buf)
Read integer value from a buffer.
Base class representing a DHCP option definition.
OptionDataType getType() const
Return option data type.
const RecordFieldsCollection & getRecordFields() const
Return list of record fields.
std::vector< OptionDataType > RecordFieldsCollection
List of fields within the record.
bool getArrayType() const
Return array type indicator.
Universe
defines option universe DHCPv4 or DHCPv6
void setData(InputIterator first, InputIterator last)
Sets content of this option from 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.
Encapsulates PSID length.
Encapsulates prefix length.
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.
#define isc_throw_assert(expr)
Replacement for assert() that throws if the expression is false.
std::pair< PSIDLen, PSID > PSIDTuple
Defines a pair of PSID length / value.
boost::shared_ptr< OptionCustom > OptionCustomPtr
A pointer to the OptionCustom object.
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
std::pair< PrefixLen, asiolink::IOAddress > PrefixTuple
Defines a pair of prefix length / value.
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
OptionDataType
Data types of DHCP option fields.
boost::shared_ptr< Option > OptionPtr
Defines the logger used by the top-level component of kea-lfc.
static const bool integer_type
static const OptionDataType type