7 #ifndef OPTION_CUSTOM_H 8 #define OPTION_CUSTOM_H 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_;
468 OptionCustom::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" 509 #endif // OPTION_CUSTOM_H void writeTuple(const std::string &value, const uint32_t index=0)
Write a length and string tuple into a buffer.
void addArrayDataField(const asiolink::IOAddress &address)
Create new buffer and set its value as an IP address.
Encapsulates PSID length.
asiolink::IOAddress readAddress(const uint32_t index=0) const
Read a buffer as IP address.
Base class representing a DHCP option definition.
boost::shared_ptr< OptionCustom > OptionCustomPtr
A pointer to the OptionCustom object.
uint32_t getDataFieldsNum() const
Return a number of the data fields.
bool readBoolean(const uint32_t index=0) const
Read a buffer as boolean value.
void writeAddress(const asiolink::IOAddress &address, const uint32_t index=0)
Write an IP address into a buffer.
std::vector< OptionDataType > RecordFieldsCollection
List of fields within the record.
std::string readFqdn(const uint32_t index=0) const
Read a buffer as FQDN.
OptionCustom(const OptionDefinition &def, Universe u)
Constructor, used for options to be sent.
boost::shared_ptr< Option > OptionPtr
Universe
defines option universe DHCPv4 or DHCPv6
std::pair< PrefixLen, asiolink::IOAddress > PrefixTuple
Defines a pair of prefix length / value.
Exception to be thrown when invalid type specified as template parameter.
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses received buffer.
void writeBoolean(const bool value, const uint32_t index=0)
Write a boolean value into a buffer.
PSIDTuple readPsid(const uint32_t index=0) const
Read a buffer as a PSID length / value tuple.
virtual uint16_t len() const
Returns length of the complete option (data length + DHCPv4/DHCPv6 option header)
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
std::string readTuple(const uint32_t index=0) const
Read a buffer as length and string tuple.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
OptionDataType
Data types of DHCP option fields.
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
void writePsid(const PSIDLen &psid_len, const PSID &psid, const uint32_t index=0)
Write PSID length / value into a buffer.
void writePrefix(const PrefixLen &prefix_len, const asiolink::IOAddress &prefix, const uint32_t index=0)
Write prefix length and value into a buffer.
PrefixTuple readPrefix(const uint32_t index=0) const
Read a buffer as variable length prefix.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
std::pair< PSIDLen, PSID > PSIDTuple
Defines a pair of PSID length / value.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual void pack(isc::util::OutputBuffer &buf) const
Writes DHCP option in a wire format to a buffer.
void writeInteger(const T value, const uint32_t index=0)
Write an integer value into a buffer.
const RecordFieldsCollection & getRecordFields() const
Return list of record fields.
void writeBinary(const OptionBuffer &buf, const uint32_t index=0)
Write binary data into a buffer.
virtual std::string toText(int indent=0) const
Returns string representation of the option.
A generic exception that is thrown if a function is called in a prohibited way.
void writeFqdn(const std::string &fqdn, const uint32_t index=0)
Write an FQDN into a buffer.
Represents a single instance of the opaque data preceded by length.
T readInteger(const uint32_t index=0) const
Read a buffer as integer value.
Trait class for data types supported in DHCP option definitions.
std::string readString(const uint32_t index=0) const
Read a buffer as string value.
The IOAddress class represents an IP addresses (version agnostic)
bool getArrayType() const
Return array type indicator.
OptionDataType getType() const
Return option data type.
Option with defined data fields represented as buffers that can be accessed using data field index.
void setData(InputIterator first, InputIterator last)
Sets content of this option from buffer.
Encapsulates prefix length.
void writeString(const std::string &text, const uint32_t index=0)
Write a string value into a buffer.
void addArrayDataField(const T value)
Create new buffer and store integer value in it.
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.