mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-03 15:35:17 +00:00
[4497] Fix constness of methods in Option classes.
This commit is contained in:
@@ -126,7 +126,7 @@ public:
|
|||||||
/// \brief Checks if option is valid.
|
/// \brief Checks if option is valid.
|
||||||
///
|
///
|
||||||
/// \return true, if option is valid.
|
/// \return true, if option is valid.
|
||||||
virtual bool valid() {
|
virtual bool valid() const {
|
||||||
return (Option::valid() && option_valid_);
|
return (Option::valid() && option_valid_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@ Option::Option(Universe u, uint16_t type, OptionBufferConstIter first,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Option::check() {
|
Option::check() const {
|
||||||
if ( (universe_ != V4) && (universe_ != V6) ) {
|
if ( (universe_ != V4) && (universe_ != V6) ) {
|
||||||
isc_throw(BadValue, "Invalid universe type specified. "
|
isc_throw(BadValue, "Invalid universe type specified. "
|
||||||
<< "Only V4 and V6 are allowed.");
|
<< "Only V4 and V6 are allowed.");
|
||||||
@@ -77,7 +77,7 @@ Option::check() {
|
|||||||
// both types and data size.
|
// both types and data size.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Option::pack(isc::util::OutputBuffer& buf) {
|
void Option::pack(isc::util::OutputBuffer& buf) const {
|
||||||
// Write a header.
|
// Write a header.
|
||||||
packHeader(buf);
|
packHeader(buf);
|
||||||
// Write data.
|
// Write data.
|
||||||
@@ -89,7 +89,7 @@ void Option::pack(isc::util::OutputBuffer& buf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Option::packHeader(isc::util::OutputBuffer& buf) {
|
Option::packHeader(isc::util::OutputBuffer& buf) const {
|
||||||
if (universe_ == V4) {
|
if (universe_ == V4) {
|
||||||
if (len() > 255) {
|
if (len() > 255) {
|
||||||
isc_throw(OutOfRange, "DHCPv4 Option " << type_ << " is too big. "
|
isc_throw(OutOfRange, "DHCPv4 Option " << type_ << " is too big. "
|
||||||
@@ -109,7 +109,7 @@ Option::packHeader(isc::util::OutputBuffer& buf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Option::packOptions(isc::util::OutputBuffer& buf) {
|
Option::packOptions(isc::util::OutputBuffer& buf) const {
|
||||||
switch (universe_) {
|
switch (universe_) {
|
||||||
case V4:
|
case V4:
|
||||||
LibDHCP::packOptions4(buf, options_);
|
LibDHCP::packOptions4(buf, options_);
|
||||||
@@ -141,7 +141,7 @@ Option::unpackOptions(const OptionBuffer& buf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Option::len() {
|
uint16_t Option::len() const {
|
||||||
// Returns length of the complete option (data length + DHCPv4/DHCPv6
|
// Returns length of the complete option (data length + DHCPv4/DHCPv6
|
||||||
// option header)
|
// option header)
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ uint16_t Option::len() {
|
|||||||
size_t length = getHeaderLen() + data_.size();
|
size_t length = getHeaderLen() + data_.size();
|
||||||
|
|
||||||
// ... and sum of lengths of all suboptions
|
// ... and sum of lengths of all suboptions
|
||||||
for (OptionCollection::iterator it = options_.begin();
|
for (OptionCollection::const_iterator it = options_.begin();
|
||||||
it != options_.end();
|
it != options_.end();
|
||||||
++it) {
|
++it) {
|
||||||
length += (*it).second->len();
|
length += (*it).second->len();
|
||||||
@@ -162,7 +162,7 @@ uint16_t Option::len() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Option::valid() {
|
Option::valid() const {
|
||||||
if (universe_ != V4 &&
|
if (universe_ != V4 &&
|
||||||
universe_ != V6) {
|
universe_ != V6) {
|
||||||
return (false);
|
return (false);
|
||||||
@@ -171,7 +171,7 @@ Option::valid() {
|
|||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionPtr Option::getOption(uint16_t opt_type) {
|
OptionPtr Option::getOption(uint16_t opt_type) const {
|
||||||
isc::dhcp::OptionCollection::const_iterator x =
|
isc::dhcp::OptionCollection::const_iterator x =
|
||||||
options_.find(opt_type);
|
options_.find(opt_type);
|
||||||
if ( x != options_.end() ) {
|
if ( x != options_.end() ) {
|
||||||
@@ -190,7 +190,7 @@ bool Option::delOption(uint16_t opt_type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string Option::toText(int indent) {
|
std::string Option::toText(int indent) const {
|
||||||
std::stringstream output;
|
std::stringstream output;
|
||||||
output << headerToText(indent) << ": ";
|
output << headerToText(indent) << ": ";
|
||||||
|
|
||||||
@@ -209,13 +209,13 @@ std::string Option::toText(int indent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
Option::toString() {
|
Option::toString() const {
|
||||||
/// @todo: Implement actual conversion in derived classes.
|
/// @todo: Implement actual conversion in derived classes.
|
||||||
return (toText(0));
|
return (toText(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t>
|
std::vector<uint8_t>
|
||||||
Option::toBinary(const bool include_header) {
|
Option::toBinary(const bool include_header) const {
|
||||||
OutputBuffer buf(len());
|
OutputBuffer buf(len());
|
||||||
try {
|
try {
|
||||||
// If the option is too long, exception will be thrown. We allow
|
// If the option is too long, exception will be thrown. We allow
|
||||||
@@ -236,7 +236,7 @@ Option::toBinary(const bool include_header) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
Option::toHexString(const bool include_header) {
|
Option::toHexString(const bool include_header) const {
|
||||||
// Prepare binary version of the option.
|
// Prepare binary version of the option.
|
||||||
std::vector<uint8_t> option_vec = toBinary(include_header);
|
std::vector<uint8_t> option_vec = toBinary(include_header);
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ Option::toHexString(const bool include_header) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
Option::headerToText(const int indent, const std::string& type_name) {
|
Option::headerToText(const int indent, const std::string& type_name) const {
|
||||||
std::stringstream output;
|
std::stringstream output;
|
||||||
for (int i = 0; i < indent; i++)
|
for (int i = 0; i < indent; i++)
|
||||||
output << " ";
|
output << " ";
|
||||||
@@ -284,7 +284,7 @@ Option::suboptionsToText(const int indent) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
Option::getHeaderLen() {
|
Option::getHeaderLen() const {
|
||||||
switch (universe_) {
|
switch (universe_) {
|
||||||
case V4:
|
case V4:
|
||||||
return OPTION4_HDR_LEN; // header length for v4
|
return OPTION4_HDR_LEN; // header length for v4
|
||||||
@@ -305,7 +305,7 @@ void Option::addOption(OptionPtr opt) {
|
|||||||
options_.insert(make_pair(opt->getType(), opt));
|
options_.insert(make_pair(opt->getType(), opt));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Option::getUint8() {
|
uint8_t Option::getUint8() const {
|
||||||
if (data_.size() < sizeof(uint8_t) ) {
|
if (data_.size() < sizeof(uint8_t) ) {
|
||||||
isc_throw(OutOfRange, "Attempt to read uint8 from option " << type_
|
isc_throw(OutOfRange, "Attempt to read uint8 from option " << type_
|
||||||
<< " that has size " << data_.size());
|
<< " that has size " << data_.size());
|
||||||
@@ -313,12 +313,12 @@ uint8_t Option::getUint8() {
|
|||||||
return (data_[0]);
|
return (data_[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Option::getUint16() {
|
uint16_t Option::getUint16() const {
|
||||||
// readUint16() checks and throws OutOfRange if data_ is too small.
|
// readUint16() checks and throws OutOfRange if data_ is too small.
|
||||||
return (readUint16(&data_[0], data_.size()));
|
return (readUint16(&data_[0], data_.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Option::getUint32() {
|
uint32_t Option::getUint32() const {
|
||||||
// readUint32() checks and throws OutOfRange if data_ is too small.
|
// readUint32() checks and throws OutOfRange if data_ is too small.
|
||||||
return (readUint32(&data_[0], data_.size()));
|
return (readUint32(&data_[0], data_.size()));
|
||||||
}
|
}
|
||||||
|
@@ -158,7 +158,7 @@ public:
|
|||||||
/// @param buf pointer to a buffer
|
/// @param buf pointer to a buffer
|
||||||
///
|
///
|
||||||
/// @throw BadValue Universe of the option is neither V4 nor V6.
|
/// @throw BadValue Universe of the option is neither V4 nor V6.
|
||||||
virtual void pack(isc::util::OutputBuffer& buf);
|
virtual void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Parses received buffer.
|
/// @brief Parses received buffer.
|
||||||
///
|
///
|
||||||
@@ -172,7 +172,7 @@ public:
|
|||||||
/// @param indent number of spaces before printing text
|
/// @param indent number of spaces before printing text
|
||||||
///
|
///
|
||||||
/// @return string with text representation.
|
/// @return string with text representation.
|
||||||
virtual std::string toText(int indent = 0);
|
virtual std::string toText(int indent = 0) const;
|
||||||
|
|
||||||
/// @brief Returns string representation of the value
|
/// @brief Returns string representation of the value
|
||||||
///
|
///
|
||||||
@@ -180,7 +180,7 @@ public:
|
|||||||
/// refers to a specific option.
|
/// refers to a specific option.
|
||||||
///
|
///
|
||||||
/// @return string that represents the value of the option.
|
/// @return string that represents the value of the option.
|
||||||
virtual std::string toString();
|
virtual std::string toString() const;
|
||||||
|
|
||||||
/// @brief Returns binary representation of the option.
|
/// @brief Returns binary representation of the option.
|
||||||
///
|
///
|
||||||
@@ -189,7 +189,7 @@ public:
|
|||||||
/// header fields.
|
/// header fields.
|
||||||
///
|
///
|
||||||
/// @return Vector holding binary representation of the option.
|
/// @return Vector holding binary representation of the option.
|
||||||
virtual std::vector<uint8_t> toBinary(const bool include_header = false);
|
virtual std::vector<uint8_t> toBinary(const bool include_header = false) const;
|
||||||
|
|
||||||
/// @brief Returns string containing hexadecimal representation of option.
|
/// @brief Returns string containing hexadecimal representation of option.
|
||||||
///
|
///
|
||||||
@@ -198,7 +198,7 @@ public:
|
|||||||
/// header fields.
|
/// header fields.
|
||||||
///
|
///
|
||||||
/// @return String containing hexadecimal representation of the option.
|
/// @return String containing hexadecimal representation of the option.
|
||||||
virtual std::string toHexString(const bool include_header = false);
|
virtual std::string toHexString(const bool include_header = false) const;
|
||||||
|
|
||||||
/// Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
|
/// Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
|
||||||
///
|
///
|
||||||
@@ -209,17 +209,17 @@ public:
|
|||||||
/// option header)
|
/// option header)
|
||||||
///
|
///
|
||||||
/// @return length of the option
|
/// @return length of the option
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
/// @brief Returns length of header (2 for v4, 4 for v6)
|
/// @brief Returns length of header (2 for v4, 4 for v6)
|
||||||
///
|
///
|
||||||
/// @return length of option header
|
/// @return length of option header
|
||||||
virtual uint16_t getHeaderLen();
|
virtual uint16_t getHeaderLen() const;
|
||||||
|
|
||||||
/// returns if option is valid (e.g. option may be truncated)
|
/// returns if option is valid (e.g. option may be truncated)
|
||||||
///
|
///
|
||||||
/// @return true, if option is valid
|
/// @return true, if option is valid
|
||||||
virtual bool valid();
|
virtual bool valid() const;
|
||||||
|
|
||||||
/// Returns pointer to actual data.
|
/// Returns pointer to actual data.
|
||||||
///
|
///
|
||||||
@@ -246,7 +246,7 @@ public:
|
|||||||
/// @param type type of requested suboption
|
/// @param type type of requested suboption
|
||||||
///
|
///
|
||||||
/// @return shared_ptr to requested suoption
|
/// @return shared_ptr to requested suoption
|
||||||
OptionPtr getOption(uint16_t type);
|
OptionPtr getOption(uint16_t type) const;
|
||||||
|
|
||||||
/// @brief Returns all encapsulated options.
|
/// @brief Returns all encapsulated options.
|
||||||
///
|
///
|
||||||
@@ -269,21 +269,21 @@ public:
|
|||||||
/// @throw isc::OutOfRange Thrown if the option has a length of 0.
|
/// @throw isc::OutOfRange Thrown if the option has a length of 0.
|
||||||
///
|
///
|
||||||
/// @return value of the first byte
|
/// @return value of the first byte
|
||||||
uint8_t getUint8();
|
uint8_t getUint8() const;
|
||||||
|
|
||||||
/// @brief Returns content of first word.
|
/// @brief Returns content of first word.
|
||||||
///
|
///
|
||||||
/// @throw isc::OutOfRange Thrown if the option has a length less than 2.
|
/// @throw isc::OutOfRange Thrown if the option has a length less than 2.
|
||||||
///
|
///
|
||||||
/// @return uint16_t value stored on first two bytes
|
/// @return uint16_t value stored on first two bytes
|
||||||
uint16_t getUint16();
|
uint16_t getUint16() const;
|
||||||
|
|
||||||
/// @brief Returns content of first double word.
|
/// @brief Returns content of first double word.
|
||||||
///
|
///
|
||||||
/// @throw isc::OutOfRange Thrown if the option has a length less than 4.
|
/// @throw isc::OutOfRange Thrown if the option has a length less than 4.
|
||||||
///
|
///
|
||||||
/// @return uint32_t value stored on first four bytes
|
/// @return uint32_t value stored on first four bytes
|
||||||
uint32_t getUint32();
|
uint32_t getUint32() const;
|
||||||
|
|
||||||
/// @brief Sets content of this option to singe uint8 value.
|
/// @brief Sets content of this option to singe uint8 value.
|
||||||
///
|
///
|
||||||
@@ -378,7 +378,7 @@ protected:
|
|||||||
/// directly by other classes.
|
/// directly by other classes.
|
||||||
///
|
///
|
||||||
/// @param [out] buf output buffer.
|
/// @param [out] buf output buffer.
|
||||||
void packHeader(isc::util::OutputBuffer& buf);
|
void packHeader(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Store sub options in a buffer.
|
/// @brief Store sub options in a buffer.
|
||||||
///
|
///
|
||||||
@@ -393,7 +393,7 @@ protected:
|
|||||||
/// exceptions thrown by pack methods invoked on objects
|
/// exceptions thrown by pack methods invoked on objects
|
||||||
/// representing sub options. We should consider whether to aggregate
|
/// representing sub options. We should consider whether to aggregate
|
||||||
/// those into one exception which can be documented here.
|
/// those into one exception which can be documented here.
|
||||||
void packOptions(isc::util::OutputBuffer& buf);
|
void packOptions(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Builds a collection of sub options from the buffer.
|
/// @brief Builds a collection of sub options from the buffer.
|
||||||
///
|
///
|
||||||
@@ -420,7 +420,7 @@ protected:
|
|||||||
///
|
///
|
||||||
/// @return Option header in the textual format.
|
/// @return Option header in the textual format.
|
||||||
std::string headerToText(const int indent = 0,
|
std::string headerToText(const int indent = 0,
|
||||||
const std::string& type_name = "");
|
const std::string& type_name = "") const;
|
||||||
|
|
||||||
/// @brief Returns collection of suboptions in the textual format.
|
/// @brief Returns collection of suboptions in the textual format.
|
||||||
///
|
///
|
||||||
@@ -441,7 +441,7 @@ protected:
|
|||||||
/// It is used in constructors. In there are any problems detected
|
/// It is used in constructors. In there are any problems detected
|
||||||
/// (like specifying type > 255 for DHCPv4 option), it will throw
|
/// (like specifying type > 255 for DHCPv4 option), it will throw
|
||||||
/// BadValue or OutOfRange exceptions.
|
/// BadValue or OutOfRange exceptions.
|
||||||
void check();
|
void check() const;
|
||||||
|
|
||||||
/// option universe (V4 or V6)
|
/// option universe (V4 or V6)
|
||||||
Universe universe_;
|
Universe universe_;
|
||||||
|
@@ -56,7 +56,7 @@ Option4AddrLst::Option4AddrLst(uint8_t type, const IOAddress& addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Option4AddrLst::pack(isc::util::OutputBuffer& buf) {
|
Option4AddrLst::pack(isc::util::OutputBuffer& buf) const {
|
||||||
|
|
||||||
if (addrs_.size() * V4ADDRESS_LEN > 255) {
|
if (addrs_.size() * V4ADDRESS_LEN > 255) {
|
||||||
isc_throw(OutOfRange, "DHCPv4 Option4AddrLst " << type_ << " is too big."
|
isc_throw(OutOfRange, "DHCPv4 Option4AddrLst " << type_ << " is too big."
|
||||||
@@ -106,13 +106,13 @@ void Option4AddrLst::addAddress(const isc::asiolink::IOAddress& addr) {
|
|||||||
addrs_.push_back(addr);
|
addrs_.push_back(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Option4AddrLst::len() {
|
uint16_t Option4AddrLst::len() const {
|
||||||
|
|
||||||
// Returns length of the complete option (option header + data length)
|
// Returns length of the complete option (option header + data length)
|
||||||
return (getHeaderLen() + addrs_.size() * V4ADDRESS_LEN);
|
return (getHeaderLen() + addrs_.size() * V4ADDRESS_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Option4AddrLst::toText(int indent) {
|
std::string Option4AddrLst::toText(int indent) const {
|
||||||
std::stringstream output;
|
std::stringstream output;
|
||||||
output << headerToText(indent) << ":";
|
output << headerToText(indent) << ":";
|
||||||
|
|
||||||
|
@@ -85,20 +85,20 @@ public:
|
|||||||
/// Method will throw if option storing fails for some reason.
|
/// Method will throw if option storing fails for some reason.
|
||||||
///
|
///
|
||||||
/// @param buf output buffer (option will be stored there)
|
/// @param buf output buffer (option will be stored there)
|
||||||
virtual void pack(isc::util::OutputBuffer& buf);
|
virtual void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// Returns string representation of the option.
|
/// Returns string representation of the option.
|
||||||
///
|
///
|
||||||
/// @param indent number of spaces before printing text
|
/// @param indent number of spaces before printing text
|
||||||
///
|
///
|
||||||
/// @return string with text representation.
|
/// @return string with text representation.
|
||||||
virtual std::string toText(int indent = 0);
|
virtual std::string toText(int indent = 0) const;
|
||||||
|
|
||||||
/// Returns length of the complete option (data length + DHCPv4/DHCPv6
|
/// Returns length of the complete option (data length + DHCPv4/DHCPv6
|
||||||
/// option header)
|
/// option header)
|
||||||
///
|
///
|
||||||
/// @return length of the option
|
/// @return length of the option
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
/// @brief Returns vector with addresses.
|
/// @brief Returns vector with addresses.
|
||||||
///
|
///
|
||||||
|
@@ -463,7 +463,7 @@ Option4ClientFqdn::getDomainNameType() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Option4ClientFqdn::pack(isc::util::OutputBuffer& buf) {
|
Option4ClientFqdn::pack(isc::util::OutputBuffer& buf) const {
|
||||||
// Header = option code and length.
|
// Header = option code and length.
|
||||||
packHeader(buf);
|
packHeader(buf);
|
||||||
// Flags field.
|
// Flags field.
|
||||||
@@ -487,7 +487,7 @@ Option4ClientFqdn::unpack(OptionBufferConstIter first,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
Option4ClientFqdn::toText(int indent) {
|
Option4ClientFqdn::toText(int indent) const {
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
std::string in(indent, ' '); // base indentation
|
std::string in(indent, ' '); // base indentation
|
||||||
stream << in << "type=" << type_ << " (CLIENT_FQDN), "
|
stream << in << "type=" << type_ << " (CLIENT_FQDN), "
|
||||||
@@ -504,7 +504,7 @@ Option4ClientFqdn::toText(int indent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
Option4ClientFqdn::len() {
|
Option4ClientFqdn::len() const {
|
||||||
uint16_t domain_name_length = 0;
|
uint16_t domain_name_length = 0;
|
||||||
// Try to calculate the length of the domain name only if there is
|
// Try to calculate the length of the domain name only if there is
|
||||||
// any domain name specified.
|
// any domain name specified.
|
||||||
|
@@ -299,7 +299,7 @@ public:
|
|||||||
/// @brief Writes option in the wire format into a buffer.
|
/// @brief Writes option in the wire format into a buffer.
|
||||||
///
|
///
|
||||||
/// @param [out] buf output buffer where option data will be stored.
|
/// @param [out] buf output buffer where option data will be stored.
|
||||||
virtual void pack(isc::util::OutputBuffer& buf);
|
virtual void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Parses option from the received buffer.
|
/// @brief Parses option from the received buffer.
|
||||||
///
|
///
|
||||||
@@ -322,13 +322,13 @@ public:
|
|||||||
/// @param indent number of spaces before printed text.
|
/// @param indent number of spaces before printed text.
|
||||||
///
|
///
|
||||||
/// @return string with text representation.
|
/// @return string with text representation.
|
||||||
virtual std::string toText(int indent = 0);
|
virtual std::string toText(int indent = 0) const;
|
||||||
|
|
||||||
/// @brief Returns length of the complete option (data length +
|
/// @brief Returns length of the complete option (data length +
|
||||||
/// DHCPv4 option header).
|
/// DHCPv4 option header).
|
||||||
///
|
///
|
||||||
/// @return length of the option.
|
/// @return length of the option.
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// @name Well known Rcode declarations for DHCPv4 Client FQDN %Option
|
/// @name Well known Rcode declarations for DHCPv4 Client FQDN %Option
|
||||||
|
@@ -56,7 +56,7 @@ Option6AddrLst::setAddresses(const AddressContainer& addrs) {
|
|||||||
addrs_ = addrs;
|
addrs_ = addrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Option6AddrLst::pack(isc::util::OutputBuffer& buf) {
|
void Option6AddrLst::pack(isc::util::OutputBuffer& buf) const {
|
||||||
|
|
||||||
buf.writeUint16(type_);
|
buf.writeUint16(type_);
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ void Option6AddrLst::unpack(OptionBufferConstIter begin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Option6AddrLst::toText(int indent) {
|
std::string Option6AddrLst::toText(int indent) const {
|
||||||
stringstream output;
|
stringstream output;
|
||||||
output << headerToText(indent) << ":";
|
output << headerToText(indent) << ":";
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ std::string Option6AddrLst::toText(int indent) {
|
|||||||
return (output.str());
|
return (output.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Option6AddrLst::len() {
|
uint16_t Option6AddrLst::len() const {
|
||||||
return (OPTION6_HDR_LEN + addrs_.size() * V6ADDRESS_LEN);
|
return (OPTION6_HDR_LEN + addrs_.size() * V6ADDRESS_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,7 +48,7 @@ public:
|
|||||||
/// @brief Assembles on-wire form of this option
|
/// @brief Assembles on-wire form of this option
|
||||||
///
|
///
|
||||||
/// @param buf pointer to packet buffer
|
/// @param buf pointer to packet buffer
|
||||||
void pack(isc::util::OutputBuffer& buf);
|
void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Parses received data
|
/// @brief Parses received data
|
||||||
///
|
///
|
||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
virtual void unpack(OptionBufferConstIter begin,
|
virtual void unpack(OptionBufferConstIter begin,
|
||||||
OptionBufferConstIter end);
|
OptionBufferConstIter end);
|
||||||
|
|
||||||
virtual std::string toText(int indent = 0);
|
virtual std::string toText(int indent = 0) const;
|
||||||
|
|
||||||
/// @brief Sets a single address.
|
/// @brief Sets a single address.
|
||||||
///
|
///
|
||||||
@@ -80,7 +80,7 @@ public:
|
|||||||
AddressContainer getAddresses() const { return addrs_; };
|
AddressContainer getAddresses() const { return addrs_; };
|
||||||
|
|
||||||
// returns data length (data length + DHCPv4/DHCPv6 option header)
|
// returns data length (data length + DHCPv4/DHCPv6 option header)
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AddressContainer addrs_;
|
AddressContainer addrs_;
|
||||||
|
@@ -395,7 +395,7 @@ Option6ClientFqdn::getDomainNameType() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Option6ClientFqdn::pack(isc::util::OutputBuffer& buf) {
|
Option6ClientFqdn::pack(isc::util::OutputBuffer& buf) const {
|
||||||
// Header = option code and length.
|
// Header = option code and length.
|
||||||
packHeader(buf);
|
packHeader(buf);
|
||||||
// Flags field.
|
// Flags field.
|
||||||
@@ -416,7 +416,7 @@ Option6ClientFqdn::unpack(OptionBufferConstIter first,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
Option6ClientFqdn::toText(int indent) {
|
Option6ClientFqdn::toText(int indent) const {
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
std::string in(indent, ' '); // base indentation
|
std::string in(indent, ' '); // base indentation
|
||||||
stream << in << "type=" << type_ << "(CLIENT_FQDN)" << ", "
|
stream << in << "type=" << type_ << "(CLIENT_FQDN)" << ", "
|
||||||
@@ -432,7 +432,7 @@ Option6ClientFqdn::toText(int indent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
Option6ClientFqdn::len() {
|
Option6ClientFqdn::len() const {
|
||||||
uint16_t domain_name_length = 0;
|
uint16_t domain_name_length = 0;
|
||||||
if (impl_->domain_name_) {
|
if (impl_->domain_name_) {
|
||||||
// If domain name is partial, the NULL terminating character
|
// If domain name is partial, the NULL terminating character
|
||||||
|
@@ -217,7 +217,7 @@ public:
|
|||||||
/// @brief Writes option in the wire format into a buffer.
|
/// @brief Writes option in the wire format into a buffer.
|
||||||
///
|
///
|
||||||
/// @param [out] buf output buffer where option data will be stored.
|
/// @param [out] buf output buffer where option data will be stored.
|
||||||
virtual void pack(isc::util::OutputBuffer& buf);
|
virtual void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Parses option from the received buffer.
|
/// @brief Parses option from the received buffer.
|
||||||
///
|
///
|
||||||
@@ -240,13 +240,13 @@ public:
|
|||||||
/// @param indent number of spaces before printed text.
|
/// @param indent number of spaces before printed text.
|
||||||
///
|
///
|
||||||
/// @return string with text representation.
|
/// @return string with text representation.
|
||||||
virtual std::string toText(int indent = 0);
|
virtual std::string toText(int indent = 0) const;
|
||||||
|
|
||||||
/// @brief Returns length of the complete option (data length +
|
/// @brief Returns length of the complete option (data length +
|
||||||
/// DHCPv6 option header).
|
/// DHCPv6 option header).
|
||||||
///
|
///
|
||||||
/// @return length of the option.
|
/// @return length of the option.
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@@ -48,7 +48,7 @@ Option6IA::Option6IA(uint16_t type, OptionBufferConstIter begin,
|
|||||||
unpack(begin, end);
|
unpack(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Option6IA::pack(isc::util::OutputBuffer& buf) {
|
void Option6IA::pack(isc::util::OutputBuffer& buf) const {
|
||||||
buf.writeUint16(type_);
|
buf.writeUint16(type_);
|
||||||
buf.writeUint16(len() - OPTION6_HDR_LEN);
|
buf.writeUint16(len() - OPTION6_HDR_LEN);
|
||||||
buf.writeUint32(iaid_);
|
buf.writeUint32(iaid_);
|
||||||
@@ -76,7 +76,7 @@ void Option6IA::unpack(OptionBufferConstIter begin,
|
|||||||
unpackOptions(OptionBuffer(begin, end));
|
unpackOptions(OptionBuffer(begin, end));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Option6IA::toText(int indent) {
|
std::string Option6IA::toText(int indent) const {
|
||||||
stringstream output;
|
stringstream output;
|
||||||
|
|
||||||
switch(getType()) {
|
switch(getType()) {
|
||||||
@@ -96,13 +96,13 @@ std::string Option6IA::toText(int indent) {
|
|||||||
return (output.str());
|
return (output.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Option6IA::len() {
|
uint16_t Option6IA::len() const {
|
||||||
|
|
||||||
uint16_t length = OPTION6_HDR_LEN /*header (4)*/ +
|
uint16_t length = OPTION6_HDR_LEN /*header (4)*/ +
|
||||||
OPTION6_IA_LEN /* option content (12) */;
|
OPTION6_IA_LEN /* option content (12) */;
|
||||||
|
|
||||||
// length of all suboptions
|
// length of all suboptions
|
||||||
for (OptionCollection::iterator it = options_.begin();
|
for (OptionCollection::const_iterator it = options_.begin();
|
||||||
it != options_.end();
|
it != options_.end();
|
||||||
++it) {
|
++it) {
|
||||||
length += (*it).second->len();
|
length += (*it).second->len();
|
||||||
|
@@ -43,7 +43,7 @@ public:
|
|||||||
/// byte after stored option.
|
/// byte after stored option.
|
||||||
///
|
///
|
||||||
/// @param buf buffer (option will be stored here)
|
/// @param buf buffer (option will be stored here)
|
||||||
void pack(isc::util::OutputBuffer& buf);
|
void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Parses received buffer
|
/// @brief Parses received buffer
|
||||||
///
|
///
|
||||||
@@ -59,8 +59,7 @@ public:
|
|||||||
/// @param indent number of leading space characters
|
/// @param indent number of leading space characters
|
||||||
///
|
///
|
||||||
/// @return string with text represenation
|
/// @return string with text represenation
|
||||||
virtual std::string
|
virtual std::string toText(int indent = 0) const;
|
||||||
toText(int indent = 0);
|
|
||||||
|
|
||||||
/// Sets T1 timer.
|
/// Sets T1 timer.
|
||||||
///
|
///
|
||||||
@@ -98,7 +97,7 @@ public:
|
|||||||
/// Returns length of this option, including option header and suboptions
|
/// Returns length of this option, including option header and suboptions
|
||||||
///
|
///
|
||||||
/// @return length of this option
|
/// @return length of this option
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ Option6IAAddr::Option6IAAddr(uint32_t type, OptionBuffer::const_iterator begin,
|
|||||||
unpack(begin, end);
|
unpack(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Option6IAAddr::pack(isc::util::OutputBuffer& buf) {
|
void Option6IAAddr::pack(isc::util::OutputBuffer& buf) const {
|
||||||
|
|
||||||
buf.writeUint16(type_);
|
buf.writeUint16(type_);
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ void Option6IAAddr::unpack(OptionBuffer::const_iterator begin,
|
|||||||
unpackOptions(OptionBuffer(begin, end));
|
unpackOptions(OptionBuffer(begin, end));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Option6IAAddr::toText(int indent) {
|
std::string Option6IAAddr::toText(int indent) const {
|
||||||
std::stringstream output;
|
std::stringstream output;
|
||||||
output << headerToText(indent, "IAADDR") << ": "
|
output << headerToText(indent, "IAADDR") << ": "
|
||||||
<< "address=" << addr_
|
<< "address=" << addr_
|
||||||
@@ -92,14 +92,14 @@ std::string Option6IAAddr::toText(int indent) {
|
|||||||
return (output.str());
|
return (output.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Option6IAAddr::len() {
|
uint16_t Option6IAAddr::len() const {
|
||||||
|
|
||||||
uint16_t length = OPTION6_HDR_LEN + OPTION6_IAADDR_LEN;
|
uint16_t length = OPTION6_HDR_LEN + OPTION6_IAADDR_LEN;
|
||||||
|
|
||||||
// length of all suboptions
|
// length of all suboptions
|
||||||
// TODO implement:
|
// TODO implement:
|
||||||
// protected: unsigned short Option::lenHelper(int header_size);
|
// protected: unsigned short Option::lenHelper(int header_size);
|
||||||
for (OptionCollection::iterator it = options_.begin();
|
for (OptionCollection::const_iterator it = options_.begin();
|
||||||
it != options_.end();
|
it != options_.end();
|
||||||
++it) {
|
++it) {
|
||||||
length += (*it).second->len();
|
length += (*it).second->len();
|
||||||
|
@@ -52,7 +52,7 @@ public:
|
|||||||
/// byte after stored option.
|
/// byte after stored option.
|
||||||
///
|
///
|
||||||
/// @param buf pointer to a buffer
|
/// @param buf pointer to a buffer
|
||||||
void pack(isc::util::OutputBuffer& buf);
|
void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Parses received buffer.
|
/// @brief Parses received buffer.
|
||||||
///
|
///
|
||||||
@@ -67,7 +67,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// @return string with text representation.
|
/// @return string with text representation.
|
||||||
virtual std::string
|
virtual std::string
|
||||||
toText(int indent = 0);
|
toText(int indent = 0) const;
|
||||||
|
|
||||||
|
|
||||||
/// sets address in this option.
|
/// sets address in this option.
|
||||||
@@ -106,7 +106,7 @@ public:
|
|||||||
getValid() const { return valid_; }
|
getValid() const { return valid_; }
|
||||||
|
|
||||||
/// returns data length (data length + DHCPv4/DHCPv6 option header)
|
/// returns data length (data length + DHCPv4/DHCPv6 option header)
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// contains an IPv6 address
|
/// contains an IPv6 address
|
||||||
|
@@ -44,7 +44,7 @@ Option6IAPrefix::Option6IAPrefix(uint32_t type, OptionBuffer::const_iterator beg
|
|||||||
unpack(begin, end);
|
unpack(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Option6IAPrefix::pack(isc::util::OutputBuffer& buf) {
|
void Option6IAPrefix::pack(isc::util::OutputBuffer& buf) const {
|
||||||
if (!addr_.isV6()) {
|
if (!addr_.isV6()) {
|
||||||
isc_throw(isc::BadValue, addr_ << " is not an IPv6 address");
|
isc_throw(isc::BadValue, addr_ << " is not an IPv6 address");
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ void Option6IAPrefix::unpack(OptionBuffer::const_iterator begin,
|
|||||||
unpackOptions(OptionBuffer(begin, end));
|
unpackOptions(OptionBuffer(begin, end));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Option6IAPrefix::toText(int indent) {
|
std::string Option6IAPrefix::toText(int indent) const {
|
||||||
std::stringstream output;
|
std::stringstream output;
|
||||||
output << headerToText(indent, "IAPREFIX") << ": "
|
output << headerToText(indent, "IAPREFIX") << ": "
|
||||||
<< "prefix=" << addr_ << "/" << static_cast<int>(prefix_len_)
|
<< "prefix=" << addr_ << "/" << static_cast<int>(prefix_len_)
|
||||||
@@ -101,7 +101,7 @@ std::string Option6IAPrefix::toText(int indent) {
|
|||||||
return (output.str());
|
return (output.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Option6IAPrefix::len() {
|
uint16_t Option6IAPrefix::len() const {
|
||||||
|
|
||||||
uint16_t length = OPTION6_HDR_LEN + OPTION6_IAPREFIX_LEN;
|
uint16_t length = OPTION6_HDR_LEN + OPTION6_IAPREFIX_LEN;
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ void
|
|||||||
Option6IAPrefix::mask(OptionBuffer::const_iterator begin,
|
Option6IAPrefix::mask(OptionBuffer::const_iterator begin,
|
||||||
OptionBuffer::const_iterator end,
|
OptionBuffer::const_iterator end,
|
||||||
const uint8_t len,
|
const uint8_t len,
|
||||||
OptionBuffer& output_address) {
|
OptionBuffer& output_address) const {
|
||||||
output_address.resize(16, 0);
|
output_address.resize(16, 0);
|
||||||
if (len >= 128) {
|
if (len >= 128) {
|
||||||
std::copy(begin, end, output_address.begin());
|
std::copy(begin, end, output_address.begin());
|
||||||
|
@@ -82,7 +82,7 @@ public:
|
|||||||
/// @throw BadValue if the address is not IPv6
|
/// @throw BadValue if the address is not IPv6
|
||||||
///
|
///
|
||||||
/// @param buf pointer to a buffer
|
/// @param buf pointer to a buffer
|
||||||
void pack(isc::util::OutputBuffer& buf);
|
void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Parses received buffer.
|
/// @brief Parses received buffer.
|
||||||
///
|
///
|
||||||
@@ -103,7 +103,7 @@ public:
|
|||||||
/// @param indent number of spaces before printing text
|
/// @param indent number of spaces before printing text
|
||||||
///
|
///
|
||||||
/// @return string with text representation.
|
/// @return string with text representation.
|
||||||
virtual std::string toText(int indent = 0);
|
virtual std::string toText(int indent = 0) const;
|
||||||
|
|
||||||
/// sets address in this option.
|
/// sets address in this option.
|
||||||
///
|
///
|
||||||
@@ -115,7 +115,7 @@ public:
|
|||||||
uint8_t getLength() const { return prefix_len_; }
|
uint8_t getLength() const { return prefix_len_; }
|
||||||
|
|
||||||
/// returns data length (data length + DHCPv4/DHCPv6 option header)
|
/// returns data length (data length + DHCPv4/DHCPv6 option header)
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ private:
|
|||||||
void mask(OptionBuffer::const_iterator begin,
|
void mask(OptionBuffer::const_iterator begin,
|
||||||
OptionBuffer::const_iterator end,
|
OptionBuffer::const_iterator end,
|
||||||
const uint8_t len,
|
const uint8_t len,
|
||||||
OptionBuffer& output_address);
|
OptionBuffer& output_address) const;
|
||||||
|
|
||||||
uint8_t prefix_len_;
|
uint8_t prefix_len_;
|
||||||
};
|
};
|
||||||
|
@@ -41,7 +41,7 @@ Option6StatusCode::Option6StatusCode(OptionBufferConstIter begin,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Option6StatusCode::pack(isc::util::OutputBuffer& buf) {
|
Option6StatusCode::pack(isc::util::OutputBuffer& buf) const {
|
||||||
// Pack option header.
|
// Pack option header.
|
||||||
packHeader(buf);
|
packHeader(buf);
|
||||||
// Write numeric status code.
|
// Write numeric status code.
|
||||||
@@ -69,12 +69,12 @@ Option6StatusCode::unpack(OptionBufferConstIter begin, OptionBufferConstIter end
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
Option6StatusCode::len() {
|
Option6StatusCode::len() const {
|
||||||
return (getHeaderLen() + sizeof(uint16_t) + status_message_.size());
|
return (getHeaderLen() + sizeof(uint16_t) + status_message_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
Option6StatusCode::toText(int indent) {
|
Option6StatusCode::toText(int indent) const {
|
||||||
std::ostringstream output;
|
std::ostringstream output;
|
||||||
output << headerToText(indent) << ": " << dataToText();
|
output << headerToText(indent) << ": " << dataToText();
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ public:
|
|||||||
/// byte after stored option.
|
/// byte after stored option.
|
||||||
///
|
///
|
||||||
/// @param [out] buf Pointer to the output buffer.
|
/// @param [out] buf Pointer to the output buffer.
|
||||||
virtual void pack(isc::util::OutputBuffer& buf);
|
virtual void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Parses received buffer.
|
/// @brief Parses received buffer.
|
||||||
///
|
///
|
||||||
@@ -54,12 +54,12 @@ public:
|
|||||||
/// @brief Returns total length of the option.
|
/// @brief Returns total length of the option.
|
||||||
///
|
///
|
||||||
/// The returned length is a sum of the option header and data fields.
|
/// The returned length is a sum of the option header and data fields.
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
/// @brief Returns textual representation of the option.
|
/// @brief Returns textual representation of the option.
|
||||||
///
|
///
|
||||||
/// @param indent Number of spaces before printing text.
|
/// @param indent Number of spaces before printing text.
|
||||||
virtual std::string toText(int indent = 0);
|
virtual std::string toText(int indent = 0) const;
|
||||||
|
|
||||||
/// @brief Returns textual representation of the option data.
|
/// @brief Returns textual representation of the option data.
|
||||||
///
|
///
|
||||||
|
@@ -357,7 +357,7 @@ OptionCustom::dataFieldToText(const OptionDataType data_type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OptionCustom::pack(isc::util::OutputBuffer& buf) {
|
OptionCustom::pack(isc::util::OutputBuffer& buf) const {
|
||||||
|
|
||||||
// Pack DHCP header (V4 or V6).
|
// Pack DHCP header (V4 or V6).
|
||||||
packHeader(buf);
|
packHeader(buf);
|
||||||
@@ -494,7 +494,7 @@ OptionCustom::unpack(OptionBufferConstIter begin,
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
OptionCustom::len() {
|
OptionCustom::len() const {
|
||||||
// The length of the option is a sum of option header ...
|
// The length of the option is a sum of option header ...
|
||||||
size_t length = getHeaderLen();
|
size_t length = getHeaderLen();
|
||||||
|
|
||||||
@@ -505,7 +505,7 @@ OptionCustom::len() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ... and lengths of all suboptions
|
// ... and lengths of all suboptions
|
||||||
for (OptionCollection::iterator it = options_.begin();
|
for (OptionCollection::const_iterator it = options_.begin();
|
||||||
it != options_.end();
|
it != options_.end();
|
||||||
++it) {
|
++it) {
|
||||||
length += (*it).second->len();
|
length += (*it).second->len();
|
||||||
@@ -523,7 +523,7 @@ void OptionCustom::initialize(const OptionBufferConstIter first,
|
|||||||
createBuffers(getData());
|
createBuffers(getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string OptionCustom::toText(int indent) {
|
std::string OptionCustom::toText(int indent) const {
|
||||||
std::stringstream output;
|
std::stringstream output;
|
||||||
|
|
||||||
output << headerToText(indent) << ":";
|
output << headerToText(indent) << ":";
|
||||||
|
@@ -243,7 +243,7 @@ public:
|
|||||||
/// @brief Writes DHCP option in a wire format to a buffer.
|
/// @brief Writes DHCP option in a wire format to a buffer.
|
||||||
///
|
///
|
||||||
/// @param buf output buffer (option will be stored there).
|
/// @param buf output buffer (option will be stored there).
|
||||||
virtual void pack(isc::util::OutputBuffer& buf);
|
virtual void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Parses received buffer.
|
/// @brief Parses received buffer.
|
||||||
///
|
///
|
||||||
@@ -257,13 +257,13 @@ public:
|
|||||||
/// @param indent number of spaces before printed text.
|
/// @param indent number of spaces before printed text.
|
||||||
///
|
///
|
||||||
/// @return string with text representation.
|
/// @return string with text representation.
|
||||||
virtual std::string toText(int indent = 0);
|
virtual std::string toText(int indent = 0) const;
|
||||||
|
|
||||||
/// @brief Returns length of the complete option (data length +
|
/// @brief Returns length of the complete option (data length +
|
||||||
/// DHCPv4/DHCPv6 option header)
|
/// DHCPv4/DHCPv6 option header)
|
||||||
///
|
///
|
||||||
/// @return length of the option
|
/// @return length of the option
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
/// @brief Sets content of this option from buffer.
|
/// @brief Sets content of this option from buffer.
|
||||||
///
|
///
|
||||||
|
@@ -98,7 +98,7 @@ public:
|
|||||||
/// @throw isc::dhcp::InvalidDataType if size of a data field type is not
|
/// @throw isc::dhcp::InvalidDataType if size of a data field type is not
|
||||||
/// equal to 1, 2 or 4 bytes. The data type is not checked in this function
|
/// equal to 1, 2 or 4 bytes. The data type is not checked in this function
|
||||||
/// because it is checked in a constructor.
|
/// because it is checked in a constructor.
|
||||||
void pack(isc::util::OutputBuffer& buf) {
|
void pack(isc::util::OutputBuffer& buf) const {
|
||||||
// Pack option header.
|
// Pack option header.
|
||||||
packHeader(buf);
|
packHeader(buf);
|
||||||
// Depending on the data type length we use different utility functions
|
// Depending on the data type length we use different utility functions
|
||||||
@@ -184,13 +184,13 @@ public:
|
|||||||
/// Returns length of this option, including option header and suboptions
|
/// Returns length of this option, including option header and suboptions
|
||||||
///
|
///
|
||||||
/// @return length of this option
|
/// @return length of this option
|
||||||
virtual uint16_t len() {
|
virtual uint16_t len() const {
|
||||||
// Calculate the length of the header.
|
// Calculate the length of the header.
|
||||||
uint16_t length = (getUniverse() == Option::V4) ? OPTION4_HDR_LEN : OPTION6_HDR_LEN;
|
uint16_t length = (getUniverse() == Option::V4) ? OPTION4_HDR_LEN : OPTION6_HDR_LEN;
|
||||||
// The data length is equal to size of T.
|
// The data length is equal to size of T.
|
||||||
length += sizeof(T);;
|
length += sizeof(T);;
|
||||||
// length of all suboptions
|
// length of all suboptions
|
||||||
for (OptionCollection::iterator it = options_.begin();
|
for (OptionCollection::const_iterator it = options_.begin();
|
||||||
it != options_.end();
|
it != options_.end();
|
||||||
++it) {
|
++it) {
|
||||||
length += (*it).second->len();
|
length += (*it).second->len();
|
||||||
@@ -204,7 +204,7 @@ public:
|
|||||||
/// The returned value also includes the suboptions if present.
|
/// The returned value also includes the suboptions if present.
|
||||||
///
|
///
|
||||||
/// @param indent Number of spaces to be inserted before the text.
|
/// @param indent Number of spaces to be inserted before the text.
|
||||||
virtual std::string toText(int indent = 0) {
|
virtual std::string toText(int indent = 0) const {
|
||||||
std::stringstream output;
|
std::stringstream output;
|
||||||
output << headerToText(indent) << ": ";
|
output << headerToText(indent) << ": ";
|
||||||
|
|
||||||
|
@@ -131,7 +131,7 @@ public:
|
|||||||
/// @throw isc::dhcp::InvalidDataType if size of a data fields type is not
|
/// @throw isc::dhcp::InvalidDataType if size of a data fields type is not
|
||||||
/// equal to 1, 2 or 4 bytes. The data type is not checked in this function
|
/// equal to 1, 2 or 4 bytes. The data type is not checked in this function
|
||||||
/// because it is checked in a constructor.
|
/// because it is checked in a constructor.
|
||||||
void pack(isc::util::OutputBuffer& buf) {
|
void pack(isc::util::OutputBuffer& buf) const {
|
||||||
// Pack option header.
|
// Pack option header.
|
||||||
packHeader(buf);
|
packHeader(buf);
|
||||||
// Pack option data.
|
// Pack option data.
|
||||||
@@ -229,11 +229,11 @@ public:
|
|||||||
/// Returns length of this option, including option header and suboptions
|
/// Returns length of this option, including option header and suboptions
|
||||||
///
|
///
|
||||||
/// @return length of this option
|
/// @return length of this option
|
||||||
virtual uint16_t len() {
|
virtual uint16_t len() const {
|
||||||
uint16_t length = (getUniverse() == Option::V4) ? OPTION4_HDR_LEN : OPTION6_HDR_LEN;
|
uint16_t length = (getUniverse() == Option::V4) ? OPTION4_HDR_LEN : OPTION6_HDR_LEN;
|
||||||
length += values_.size() * sizeof(T);
|
length += values_.size() * sizeof(T);
|
||||||
// length of all suboptions
|
// length of all suboptions
|
||||||
for (OptionCollection::iterator it = options_.begin();
|
for (OptionCollection::const_iterator it = options_.begin();
|
||||||
it != options_.end();
|
it != options_.end();
|
||||||
++it) {
|
++it) {
|
||||||
length += (*it).second->len();
|
length += (*it).second->len();
|
||||||
@@ -247,7 +247,7 @@ public:
|
|||||||
/// the text.
|
/// the text.
|
||||||
///
|
///
|
||||||
/// @return textual representation of the option.
|
/// @return textual representation of the option.
|
||||||
virtual std::string toText(int indent = 0) {
|
virtual std::string toText(int indent = 0) const {
|
||||||
std::stringstream output;
|
std::stringstream output;
|
||||||
output << headerToText(indent) << ":";
|
output << headerToText(indent) << ":";
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@ OptionOpaqueDataTuples::OptionOpaqueDataTuples(Option::Universe u,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OptionOpaqueDataTuples::pack(isc::util::OutputBuffer& buf) {
|
OptionOpaqueDataTuples::pack(isc::util::OutputBuffer& buf) const {
|
||||||
packHeader(buf);
|
packHeader(buf);
|
||||||
|
|
||||||
for (TuplesCollection::const_iterator it = tuples_.begin();
|
for (TuplesCollection::const_iterator it = tuples_.begin();
|
||||||
@@ -107,7 +107,7 @@ OptionOpaqueDataTuples::hasTuple(const std::string& tuple_str) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
OptionOpaqueDataTuples::len() {
|
OptionOpaqueDataTuples::len() const {
|
||||||
// The option starts with the header.
|
// The option starts with the header.
|
||||||
uint16_t length = getHeaderLen();
|
uint16_t length = getHeaderLen();
|
||||||
// Now iterate over existing tuples and add their size.
|
// Now iterate over existing tuples and add their size.
|
||||||
@@ -120,7 +120,7 @@ OptionOpaqueDataTuples::len() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
OptionOpaqueDataTuples::toText(int indent) {
|
OptionOpaqueDataTuples::toText(int indent) const {
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
|
|
||||||
// Apply indentation
|
// Apply indentation
|
||||||
|
@@ -65,7 +65,7 @@ public:
|
|||||||
/// @brief Renders option into the buffer in the wire format.
|
/// @brief Renders option into the buffer in the wire format.
|
||||||
///
|
///
|
||||||
/// @param [out] buf Buffer to which the option is rendered.
|
/// @param [out] buf Buffer to which the option is rendered.
|
||||||
virtual void pack(isc::util::OutputBuffer& buf);
|
virtual void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Parses buffer holding an option.
|
/// @brief Parses buffer holding an option.
|
||||||
///
|
///
|
||||||
@@ -123,13 +123,13 @@ public:
|
|||||||
bool hasTuple(const std::string& tuple_str) const;
|
bool hasTuple(const std::string& tuple_str) const;
|
||||||
|
|
||||||
/// @brief Returns the full length of the option, including option header.
|
/// @brief Returns the full length of the option, including option header.
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
/// @brief Returns text representation of the option.
|
/// @brief Returns text representation of the option.
|
||||||
///
|
///
|
||||||
/// @param indent Number of space characters before text.
|
/// @param indent Number of space characters before text.
|
||||||
/// @return Text representation of the option.
|
/// @return Text representation of the option.
|
||||||
virtual std::string toText(int indent = 0);
|
virtual std::string toText(int indent = 0) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@@ -48,12 +48,12 @@ OptionString::setValue(const std::string& value) {
|
|||||||
|
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
OptionString::len() {
|
OptionString::len() const {
|
||||||
return (getHeaderLen() + getData().size());
|
return (getHeaderLen() + getData().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OptionString::pack(isc::util::OutputBuffer& buf) {
|
OptionString::pack(isc::util::OutputBuffer& buf) const {
|
||||||
// Pack option header.
|
// Pack option header.
|
||||||
packHeader(buf);
|
packHeader(buf);
|
||||||
// Pack data.
|
// Pack data.
|
||||||
@@ -76,7 +76,7 @@ OptionString::unpack(OptionBufferConstIter begin,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
OptionString::toText(int indent) {
|
OptionString::toText(int indent) const {
|
||||||
std::ostringstream output;
|
std::ostringstream output;
|
||||||
output << headerToText(indent) << ": "
|
output << headerToText(indent) << ": "
|
||||||
<< "\"" << getValue() << "\" (string)";
|
<< "\"" << getValue() << "\" (string)";
|
||||||
@@ -85,7 +85,7 @@ OptionString::toText(int indent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
OptionString::toString() {
|
OptionString::toString() const {
|
||||||
return (getValue());
|
return (getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,7 +59,7 @@ public:
|
|||||||
/// @brief Returns length of the whole option, including header.
|
/// @brief Returns length of the whole option, including header.
|
||||||
///
|
///
|
||||||
/// @return length of the whole option.
|
/// @return length of the whole option.
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
/// @brief Returns the string value held by the option.
|
/// @brief Returns the string value held by the option.
|
||||||
///
|
///
|
||||||
@@ -80,7 +80,7 @@ public:
|
|||||||
/// is moved to the end of stored data.
|
/// is moved to the end of stored data.
|
||||||
///
|
///
|
||||||
/// @param [out] buf output buffer where the option will be stored.
|
/// @param [out] buf output buffer where the option will be stored.
|
||||||
virtual void pack(isc::util::OutputBuffer& buf);
|
virtual void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Decodes option data from the provided buffer.
|
/// @brief Decodes option data from the provided buffer.
|
||||||
///
|
///
|
||||||
@@ -101,13 +101,13 @@ public:
|
|||||||
/// the text.
|
/// the text.
|
||||||
///
|
///
|
||||||
/// @return Option information in the textual format.
|
/// @return Option information in the textual format.
|
||||||
virtual std::string toText(int indent = 0);
|
virtual std::string toText(int indent = 0) const;
|
||||||
|
|
||||||
/// @brief Returns actual value of the option in string format.
|
/// @brief Returns actual value of the option in string format.
|
||||||
///
|
///
|
||||||
/// This method is used in client classification.
|
/// This method is used in client classification.
|
||||||
/// @return Content of the option.
|
/// @return Content of the option.
|
||||||
virtual std::string toString();
|
virtual std::string toString() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Pointer to the OptionString object.
|
/// Pointer to the OptionString object.
|
||||||
|
@@ -24,7 +24,7 @@ OptionVendor::OptionVendor(Option::Universe u, OptionBufferConstIter begin,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OptionVendor::pack(isc::util::OutputBuffer& buf) {
|
void OptionVendor::pack(isc::util::OutputBuffer& buf) const {
|
||||||
packHeader(buf);
|
packHeader(buf);
|
||||||
|
|
||||||
// Store vendor-id
|
// Store vendor-id
|
||||||
@@ -59,7 +59,7 @@ void OptionVendor::unpack(OptionBufferConstIter begin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t OptionVendor::len() {
|
uint16_t OptionVendor::len() const {
|
||||||
uint16_t length = getHeaderLen();
|
uint16_t length = getHeaderLen();
|
||||||
|
|
||||||
length += sizeof(uint32_t); // Vendor-id field
|
length += sizeof(uint32_t); // Vendor-id field
|
||||||
@@ -70,7 +70,7 @@ uint16_t OptionVendor::len() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// length of all suboptions
|
// length of all suboptions
|
||||||
for (OptionCollection::iterator it = options_.begin();
|
for (OptionCollection::const_iterator it = options_.begin();
|
||||||
it != options_.end();
|
it != options_.end();
|
||||||
++it) {
|
++it) {
|
||||||
length += (*it).second->len();
|
length += (*it).second->len();
|
||||||
@@ -79,7 +79,7 @@ uint16_t OptionVendor::len() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
uint8_t
|
||||||
OptionVendor::dataLen() {
|
OptionVendor::dataLen() const {
|
||||||
// Calculate and store data-len as follows:
|
// Calculate and store data-len as follows:
|
||||||
// data-len = total option length - header length
|
// data-len = total option length - header length
|
||||||
// - enterprise id field length - data-len field size
|
// - enterprise id field length - data-len field size
|
||||||
@@ -87,7 +87,7 @@ OptionVendor::dataLen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
OptionVendor::toText(int indent) {
|
OptionVendor::toText(int indent) const {
|
||||||
std::stringstream output;
|
std::stringstream output;
|
||||||
output << headerToText(indent) << ": "
|
output << headerToText(indent) << ": "
|
||||||
<< getVendorId() << " (uint32)";
|
<< getVendorId() << " (uint32)";
|
||||||
|
@@ -54,7 +54,7 @@ public:
|
|||||||
/// unused byte after stored option.
|
/// unused byte after stored option.
|
||||||
///
|
///
|
||||||
/// @param [out] buf buffer (option will be stored here)
|
/// @param [out] buf buffer (option will be stored here)
|
||||||
virtual void pack(isc::util::OutputBuffer& buf);
|
virtual void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Parses received buffer
|
/// @brief Parses received buffer
|
||||||
///
|
///
|
||||||
@@ -82,14 +82,14 @@ public:
|
|||||||
/// Returns length of this option, including option header and suboptions
|
/// Returns length of this option, including option header and suboptions
|
||||||
///
|
///
|
||||||
/// @return length of this option
|
/// @return length of this option
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
/// @brief Returns the option in the textual format.
|
/// @brief Returns the option in the textual format.
|
||||||
///
|
///
|
||||||
/// @param indent Number of spaces to be inserted before the text.
|
/// @param indent Number of spaces to be inserted before the text.
|
||||||
///
|
///
|
||||||
/// @return Vendor option in the textual format.
|
/// @return Vendor option in the textual format.
|
||||||
virtual std::string toText(int indent = 0);
|
virtual std::string toText(int indent = 0) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ private:
|
|||||||
/// this value.
|
/// this value.
|
||||||
///
|
///
|
||||||
/// @return Returns calculated data-len value.
|
/// @return Returns calculated data-len value.
|
||||||
uint8_t dataLen();
|
uint8_t dataLen() const;
|
||||||
|
|
||||||
uint32_t vendor_id_; ///< Enterprise-id
|
uint32_t vendor_id_; ///< Enterprise-id
|
||||||
};
|
};
|
||||||
|
@@ -28,7 +28,7 @@ OptionVendorClass::OptionVendorClass(Option::Universe u,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OptionVendorClass::pack(isc::util::OutputBuffer& buf) {
|
OptionVendorClass::pack(isc::util::OutputBuffer& buf) const {
|
||||||
packHeader(buf);
|
packHeader(buf);
|
||||||
|
|
||||||
buf.writeUint32(getVendorId());
|
buf.writeUint32(getVendorId());
|
||||||
@@ -138,7 +138,7 @@ OptionVendorClass::hasTuple(const std::string& tuple_str) const {
|
|||||||
|
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
OptionVendorClass::len() {
|
OptionVendorClass::len() const {
|
||||||
// The option starts with the header and enterprise id.
|
// The option starts with the header and enterprise id.
|
||||||
uint16_t length = getHeaderLen() + sizeof(uint32_t);
|
uint16_t length = getHeaderLen() + sizeof(uint32_t);
|
||||||
// Now iterate over existing tuples and add their size.
|
// Now iterate over existing tuples and add their size.
|
||||||
@@ -157,7 +157,7 @@ OptionVendorClass::len() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
OptionVendorClass::toText(int indent) {
|
OptionVendorClass::toText(int indent) const {
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
|
|
||||||
// Apply indentation
|
// Apply indentation
|
||||||
|
@@ -72,7 +72,7 @@ public:
|
|||||||
/// @brief Renders option into the buffer in the wire format.
|
/// @brief Renders option into the buffer in the wire format.
|
||||||
///
|
///
|
||||||
/// @param [out] buf Buffer to which the option is rendered.
|
/// @param [out] buf Buffer to which the option is rendered.
|
||||||
virtual void pack(isc::util::OutputBuffer& buf);
|
virtual void pack(isc::util::OutputBuffer& buf) const;
|
||||||
|
|
||||||
/// @brief Parses buffer holding an option.
|
/// @brief Parses buffer holding an option.
|
||||||
///
|
///
|
||||||
@@ -135,13 +135,13 @@ public:
|
|||||||
bool hasTuple(const std::string& tuple_str) const;
|
bool hasTuple(const std::string& tuple_str) const;
|
||||||
|
|
||||||
/// @brief Returns the full length of the option, including option header.
|
/// @brief Returns the full length of the option, including option header.
|
||||||
virtual uint16_t len();
|
virtual uint16_t len() const;
|
||||||
|
|
||||||
/// @brief Returns text representation of the option.
|
/// @brief Returns text representation of the option.
|
||||||
///
|
///
|
||||||
/// @param indent Number of space characters before text.
|
/// @param indent Number of space characters before text.
|
||||||
/// @return Text representation of the option.
|
/// @return Text representation of the option.
|
||||||
virtual std::string toText(int indent = 0);
|
virtual std::string toText(int indent = 0) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user