111 "specified data type " << data_type <<
" does not"
112 " match the data type in an option definition");
116 OptionDataTypeUtil::writeInt<T>(value, buf);
117 buffers_.push_back(buf);
164 const uint32_t index = 0);
186 std::string
readTuple(
const uint32_t index = 0)
const;
200 void writeTuple(
const std::string& value,
const uint32_t index = 0);
222 void writeBoolean(
const bool value,
const uint32_t index = 0);
232 std::string
readFqdn(
const uint32_t index = 0)
const;
240 void writeFqdn(
const std::string& fqdn,
const uint32_t index = 0);
256 checkDataType<T>(index);
261 return (OptionDataTypeUtil::readInt<T>(buffers_[index]));
278 checkDataType<T>(index);
282 OptionDataTypeUtil::writeInt<T>(value, buf);
284 std::swap(buffers_[index], buf);
304 const uint32_t index = 0);
324 const uint32_t index = 0);
332 std::string
readString(
const uint32_t index = 0)
const;
339 const uint32_t index = 0);
358 virtual std::string
toText(
int indent = 0)
const;
364 virtual uint16_t
len()
const;
384 inline void checkArrayType()
const {
387 <<
" option. The option is not an array.");
403 void checkDataType(
const uint32_t index)
const;
410 void checkIndex(
const uint32_t index)
const;
420 void createBuffers();
431 size_t bufferLength(
const OptionDataType data_type,
bool in_array,
432 OptionBuffer::const_iterator begin,
433 OptionBuffer::const_iterator end)
const;
447 const uint32_t index)
const;
455 OptionDefinition definition_;
460 std::vector<OptionBuffer> buffers_;
468OptionCustom::checkDataType(
const uint32_t index)
const {
472 " is not a supported integer type.");
482 if (index < record_fields.size()) {
484 data_type = record_fields[index];
487 data_type = record_fields.back();
493 assert(index < record_fields.size());
495 data_type = record_fields[index];
501 "specified data type " << data_type <<
" does not"
502 " 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.
Option with defined data fields represented as buffers that can be accessed using data field index.
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.
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.
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.
virtual void pack(isc::util::OutputBuffer &buf) const
Writes DHCP option in a wire format to 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.
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.
std::pair< PSIDLen, PSID > PSIDTuple
Defines a pair of PSID length / value.
OptionDataType
Data types of DHCP option fields.
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.
boost::shared_ptr< Option > OptionPtr
Defines the logger used by the top-level component of kea-dhcp-ddns.
Trait class for data types supported in DHCP option definitions.