7 #ifndef OPTION_CUSTOM_H 8 #define OPTION_CUSTOM_H 112 "specified data type " << data_type <<
" does not" 113 " match the data type in an option definition");
117 OptionDataTypeUtil::writeInt<T>(value, buf);
118 buffers_.push_back(buf);
165 const uint32_t index = 0);
187 std::string
readTuple(
const uint32_t index = 0)
const;
201 void writeTuple(
const std::string& value,
const uint32_t index = 0);
223 void writeBoolean(
const bool value,
const uint32_t index = 0);
233 std::string
readFqdn(
const uint32_t index = 0)
const;
241 void writeFqdn(
const std::string& fqdn,
const uint32_t index = 0);
257 checkDataType<T>(index);
262 return (OptionDataTypeUtil::readInt<T>(buffers_[index]));
279 checkDataType<T>(index);
283 OptionDataTypeUtil::writeInt<T>(value, buf);
285 std::swap(buffers_[index], buf);
305 const uint32_t index = 0);
325 const uint32_t index = 0);
333 std::string
readString(
const uint32_t index = 0)
const;
340 const uint32_t index = 0);
359 virtual std::string
toText(
int indent = 0)
const;
365 virtual uint16_t
len()
const;
385 inline void checkArrayType()
const {
388 <<
" option. The option is not an array.");
404 void checkDataType(
const uint32_t index)
const;
411 void checkIndex(
const uint32_t index)
const;
421 void createBuffers();
432 size_t bufferLength(
const OptionDataType data_type,
bool in_array,
433 OptionBuffer::const_iterator begin,
434 OptionBuffer::const_iterator end)
const;
448 const uint32_t index)
const;
461 std::vector<OptionBuffer> buffers_;
469 OptionCustom::checkDataType(
const uint32_t index)
const {
473 " is not a supported integer type.");
483 if (index < record_fields.size()) {
485 data_type = record_fields[index];
488 data_type = record_fields.back();
496 data_type = record_fields[index];
502 "specified data type " << data_type <<
" does not" 503 " match the data type in an option definition for field" 510 #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.
#define isc_throw_assert(expr)
Replacement for assert() that throws if the expression is false.
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.
virtual void pack(isc::util::OutputBuffer &buf, bool check=true) const
Writes DHCP option in a wire format to a buffer.
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.
void check() const
A protected method used for option correctness.
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-lfc.
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.