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