/// \brief Checks if option is valid.
///
/// \return true, if option is valid.
- virtual bool valid() {
+ virtual bool valid() const {
return (Option::valid() && option_valid_);
}
}
void
-Option::check() {
+Option::check() const {
if ( (universe_ != V4) && (universe_ != V6) ) {
isc_throw(BadValue, "Invalid universe type specified. "
<< "Only V4 and V6 are allowed.");
// both types and data size.
}
-void Option::pack(isc::util::OutputBuffer& buf) {
+void Option::pack(isc::util::OutputBuffer& buf) const {
// Write a header.
packHeader(buf);
// Write data.
}
void
-Option::packHeader(isc::util::OutputBuffer& buf) {
+Option::packHeader(isc::util::OutputBuffer& buf) const {
if (universe_ == V4) {
if (len() > 255) {
isc_throw(OutOfRange, "DHCPv4 Option " << type_ << " is too big. "
}
void
-Option::packOptions(isc::util::OutputBuffer& buf) {
+Option::packOptions(isc::util::OutputBuffer& buf) const {
switch (universe_) {
case V4:
LibDHCP::packOptions4(buf, options_);
}
}
-uint16_t Option::len() {
+uint16_t Option::len() const {
// Returns length of the complete option (data length + DHCPv4/DHCPv6
// option header)
size_t length = getHeaderLen() + data_.size();
// ... and sum of lengths of all suboptions
- for (OptionCollection::iterator it = options_.begin();
+ for (OptionCollection::const_iterator it = options_.begin();
it != options_.end();
++it) {
length += (*it).second->len();
}
bool
-Option::valid() {
+Option::valid() const {
if (universe_ != V4 &&
universe_ != V6) {
return (false);
return (true);
}
-OptionPtr Option::getOption(uint16_t opt_type) {
+OptionPtr Option::getOption(uint16_t opt_type) const {
isc::dhcp::OptionCollection::const_iterator x =
options_.find(opt_type);
if ( x != options_.end() ) {
}
-std::string Option::toText(int indent) {
+std::string Option::toText(int indent) const {
std::stringstream output;
output << headerToText(indent) << ": ";
}
std::string
-Option::toString() {
+Option::toString() const {
/// @todo: Implement actual conversion in derived classes.
return (toText(0));
}
std::vector<uint8_t>
-Option::toBinary(const bool include_header) {
+Option::toBinary(const bool include_header) const {
OutputBuffer buf(len());
try {
// If the option is too long, exception will be thrown. We allow
}
std::string
-Option::toHexString(const bool include_header) {
+Option::toHexString(const bool include_header) const {
// Prepare binary version of the option.
std::vector<uint8_t> option_vec = toBinary(include_header);
}
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;
for (int i = 0; i < indent; i++)
output << " ";
}
uint16_t
-Option::getHeaderLen() {
+Option::getHeaderLen() const {
switch (universe_) {
case V4:
return OPTION4_HDR_LEN; // header length for v4
options_.insert(make_pair(opt->getType(), opt));
}
-uint8_t Option::getUint8() {
+uint8_t Option::getUint8() const {
if (data_.size() < sizeof(uint8_t) ) {
isc_throw(OutOfRange, "Attempt to read uint8 from option " << type_
<< " that has size " << data_.size());
return (data_[0]);
}
-uint16_t Option::getUint16() {
+uint16_t Option::getUint16() const {
// readUint16() checks and throws OutOfRange if data_ is too small.
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.
return (readUint32(&data_[0], data_.size()));
}
/// @param buf pointer to a buffer
///
/// @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.
///
/// @param indent number of spaces before printing text
///
/// @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
///
/// refers to a specific 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.
///
/// header fields.
///
/// @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.
///
/// header fields.
///
/// @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)
///
/// option header)
///
/// @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)
///
/// @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)
///
/// @return true, if option is valid
- virtual bool valid();
+ virtual bool valid() const;
/// Returns pointer to actual data.
///
/// @param type type of requested suboption
///
/// @return shared_ptr to requested suoption
- OptionPtr getOption(uint16_t type);
+ OptionPtr getOption(uint16_t type) const;
/// @brief Returns all encapsulated options.
///
/// @throw isc::OutOfRange Thrown if the option has a length of 0.
///
/// @return value of the first byte
- uint8_t getUint8();
+ uint8_t getUint8() const;
/// @brief Returns content of first word.
///
/// @throw isc::OutOfRange Thrown if the option has a length less than 2.
///
/// @return uint16_t value stored on first two bytes
- uint16_t getUint16();
+ uint16_t getUint16() const;
/// @brief Returns content of first double word.
///
/// @throw isc::OutOfRange Thrown if the option has a length less than 4.
///
/// @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.
///
/// directly by other classes.
///
/// @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.
///
/// exceptions thrown by pack methods invoked on objects
/// representing sub options. We should consider whether to aggregate
/// 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.
///
///
/// @return Option header in the textual format.
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.
///
/// It is used in constructors. In there are any problems detected
/// (like specifying type > 255 for DHCPv4 option), it will throw
/// BadValue or OutOfRange exceptions.
- void check();
+ void check() const;
/// option universe (V4 or V6)
Universe universe_;
}
void
-Option4AddrLst::pack(isc::util::OutputBuffer& buf) {
+Option4AddrLst::pack(isc::util::OutputBuffer& buf) const {
if (addrs_.size() * V4ADDRESS_LEN > 255) {
isc_throw(OutOfRange, "DHCPv4 Option4AddrLst " << type_ << " is too big."
addrs_.push_back(addr);
}
-uint16_t Option4AddrLst::len() {
+uint16_t Option4AddrLst::len() const {
// Returns length of the complete option (option header + data length)
return (getHeaderLen() + addrs_.size() * V4ADDRESS_LEN);
}
-std::string Option4AddrLst::toText(int indent) {
+std::string Option4AddrLst::toText(int indent) const {
std::stringstream output;
output << headerToText(indent) << ":";
/// Method will throw if option storing fails for some reason.
///
/// @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.
///
/// @param indent number of spaces before printing text
///
/// @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
/// option header)
///
/// @return length of the option
- virtual uint16_t len();
+ virtual uint16_t len() const;
/// @brief Returns vector with addresses.
///
}
void
-Option4ClientFqdn::pack(isc::util::OutputBuffer& buf) {
+Option4ClientFqdn::pack(isc::util::OutputBuffer& buf) const {
// Header = option code and length.
packHeader(buf);
// Flags field.
}
std::string
-Option4ClientFqdn::toText(int indent) {
+Option4ClientFqdn::toText(int indent) const {
std::ostringstream stream;
std::string in(indent, ' '); // base indentation
stream << in << "type=" << type_ << " (CLIENT_FQDN), "
}
uint16_t
-Option4ClientFqdn::len() {
+Option4ClientFqdn::len() const {
uint16_t domain_name_length = 0;
// Try to calculate the length of the domain name only if there is
// any domain name specified.
/// @brief Writes option in the wire format into a buffer.
///
/// @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.
///
/// @param indent number of spaces before printed text.
///
/// @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 +
/// DHCPv4 option header).
///
/// @return length of the option.
- virtual uint16_t len();
+ virtual uint16_t len() const;
///
/// @name Well known Rcode declarations for DHCPv4 Client FQDN %Option
addrs_ = addrs;
}
-void Option6AddrLst::pack(isc::util::OutputBuffer& buf) {
+void Option6AddrLst::pack(isc::util::OutputBuffer& buf) const {
buf.writeUint16(type_);
}
}
-std::string Option6AddrLst::toText(int indent) {
+std::string Option6AddrLst::toText(int indent) const {
stringstream output;
output << headerToText(indent) << ":";
return (output.str());
}
-uint16_t Option6AddrLst::len() {
+uint16_t Option6AddrLst::len() const {
return (OPTION6_HDR_LEN + addrs_.size() * V6ADDRESS_LEN);
}
/// @brief Assembles on-wire form of this option
///
/// @param buf pointer to packet buffer
- void pack(isc::util::OutputBuffer& buf);
+ void pack(isc::util::OutputBuffer& buf) const;
/// @brief Parses received data
///
virtual void unpack(OptionBufferConstIter begin,
OptionBufferConstIter end);
- virtual std::string toText(int indent = 0);
+ virtual std::string toText(int indent = 0) const;
/// @brief Sets a single address.
///
AddressContainer getAddresses() const { return addrs_; };
// returns data length (data length + DHCPv4/DHCPv6 option header)
- virtual uint16_t len();
+ virtual uint16_t len() const;
protected:
AddressContainer addrs_;
}
void
-Option6ClientFqdn::pack(isc::util::OutputBuffer& buf) {
+Option6ClientFqdn::pack(isc::util::OutputBuffer& buf) const {
// Header = option code and length.
packHeader(buf);
// Flags field.
}
std::string
-Option6ClientFqdn::toText(int indent) {
+Option6ClientFqdn::toText(int indent) const {
std::ostringstream stream;
std::string in(indent, ' '); // base indentation
stream << in << "type=" << type_ << "(CLIENT_FQDN)" << ", "
}
uint16_t
-Option6ClientFqdn::len() {
+Option6ClientFqdn::len() const {
uint16_t domain_name_length = 0;
if (impl_->domain_name_) {
// If domain name is partial, the NULL terminating character
/// @brief Writes option in the wire format into a buffer.
///
/// @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.
///
/// @param indent number of spaces before printed text.
///
/// @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 +
/// DHCPv6 option header).
///
/// @return length of the option.
- virtual uint16_t len();
+ virtual uint16_t len() const;
private:
unpack(begin, end);
}
-void Option6IA::pack(isc::util::OutputBuffer& buf) {
+void Option6IA::pack(isc::util::OutputBuffer& buf) const {
buf.writeUint16(type_);
buf.writeUint16(len() - OPTION6_HDR_LEN);
buf.writeUint32(iaid_);
unpackOptions(OptionBuffer(begin, end));
}
-std::string Option6IA::toText(int indent) {
+std::string Option6IA::toText(int indent) const {
stringstream output;
switch(getType()) {
return (output.str());
}
-uint16_t Option6IA::len() {
+uint16_t Option6IA::len() const {
uint16_t length = OPTION6_HDR_LEN /*header (4)*/ +
OPTION6_IA_LEN /* option content (12) */;
// length of all suboptions
- for (OptionCollection::iterator it = options_.begin();
+ for (OptionCollection::const_iterator it = options_.begin();
it != options_.end();
++it) {
length += (*it).second->len();
/// byte after stored option.
///
/// @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
///
/// @param indent number of leading space characters
///
/// @return string with text represenation
- virtual std::string
- toText(int indent = 0);
+ virtual std::string toText(int indent = 0) const;
/// Sets T1 timer.
///
/// Returns length of this option, including option header and suboptions
///
/// @return length of this option
- virtual uint16_t len();
+ virtual uint16_t len() const;
protected:
unpack(begin, end);
}
-void Option6IAAddr::pack(isc::util::OutputBuffer& buf) {
+void Option6IAAddr::pack(isc::util::OutputBuffer& buf) const {
buf.writeUint16(type_);
unpackOptions(OptionBuffer(begin, end));
}
-std::string Option6IAAddr::toText(int indent) {
+std::string Option6IAAddr::toText(int indent) const {
std::stringstream output;
output << headerToText(indent, "IAADDR") << ": "
<< "address=" << addr_
return (output.str());
}
-uint16_t Option6IAAddr::len() {
+uint16_t Option6IAAddr::len() const {
uint16_t length = OPTION6_HDR_LEN + OPTION6_IAADDR_LEN;
// length of all suboptions
// TODO implement:
// 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) {
length += (*it).second->len();
/// byte after stored option.
///
/// @param buf pointer to a buffer
- void pack(isc::util::OutputBuffer& buf);
+ void pack(isc::util::OutputBuffer& buf) const;
/// @brief Parses received buffer.
///
///
/// @return string with text representation.
virtual std::string
- toText(int indent = 0);
+ toText(int indent = 0) const;
/// sets address in this option.
getValid() const { return valid_; }
/// returns data length (data length + DHCPv4/DHCPv6 option header)
- virtual uint16_t len();
+ virtual uint16_t len() const;
protected:
/// contains an IPv6 address
unpack(begin, end);
}
-void Option6IAPrefix::pack(isc::util::OutputBuffer& buf) {
+void Option6IAPrefix::pack(isc::util::OutputBuffer& buf) const {
if (!addr_.isV6()) {
isc_throw(isc::BadValue, addr_ << " is not an IPv6 address");
}
unpackOptions(OptionBuffer(begin, end));
}
-std::string Option6IAPrefix::toText(int indent) {
+std::string Option6IAPrefix::toText(int indent) const {
std::stringstream output;
output << headerToText(indent, "IAPREFIX") << ": "
<< "prefix=" << addr_ << "/" << static_cast<int>(prefix_len_)
return (output.str());
}
-uint16_t Option6IAPrefix::len() {
+uint16_t Option6IAPrefix::len() const {
uint16_t length = OPTION6_HDR_LEN + OPTION6_IAPREFIX_LEN;
Option6IAPrefix::mask(OptionBuffer::const_iterator begin,
OptionBuffer::const_iterator end,
const uint8_t len,
- OptionBuffer& output_address) {
+ OptionBuffer& output_address) const {
output_address.resize(16, 0);
if (len >= 128) {
std::copy(begin, end, output_address.begin());
/// @throw BadValue if the address is not IPv6
///
/// @param buf pointer to a buffer
- void pack(isc::util::OutputBuffer& buf);
+ void pack(isc::util::OutputBuffer& buf) const;
/// @brief Parses received buffer.
///
/// @param indent number of spaces before printing text
///
/// @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.
///
uint8_t getLength() const { return prefix_len_; }
/// returns data length (data length + DHCPv4/DHCPv6 option header)
- virtual uint16_t len();
+ virtual uint16_t len() const;
private:
void mask(OptionBuffer::const_iterator begin,
OptionBuffer::const_iterator end,
const uint8_t len,
- OptionBuffer& output_address);
+ OptionBuffer& output_address) const;
uint8_t prefix_len_;
};
}
void
-Option6StatusCode::pack(isc::util::OutputBuffer& buf) {
+Option6StatusCode::pack(isc::util::OutputBuffer& buf) const {
// Pack option header.
packHeader(buf);
// Write numeric status code.
}
uint16_t
-Option6StatusCode::len() {
+Option6StatusCode::len() const {
return (getHeaderLen() + sizeof(uint16_t) + status_message_.size());
}
std::string
-Option6StatusCode::toText(int indent) {
+Option6StatusCode::toText(int indent) const {
std::ostringstream output;
output << headerToText(indent) << ": " << dataToText();
/// byte after stored option.
///
/// @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 Returns total length of the option.
///
/// 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.
///
/// @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.
///
}
void
-OptionCustom::pack(isc::util::OutputBuffer& buf) {
+OptionCustom::pack(isc::util::OutputBuffer& buf) const {
// Pack DHCP header (V4 or V6).
packHeader(buf);
}
uint16_t
-OptionCustom::len() {
+OptionCustom::len() const {
// The length of the option is a sum of option header ...
size_t length = getHeaderLen();
}
// ... and lengths of all suboptions
- for (OptionCollection::iterator it = options_.begin();
+ for (OptionCollection::const_iterator it = options_.begin();
it != options_.end();
++it) {
length += (*it).second->len();
createBuffers(getData());
}
-std::string OptionCustom::toText(int indent) {
+std::string OptionCustom::toText(int indent) const {
std::stringstream output;
output << headerToText(indent) << ":";
/// @brief Writes DHCP option in a wire format to a buffer.
///
/// @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.
///
/// @param indent number of spaces before printed text.
///
/// @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 +
/// DHCPv4/DHCPv6 option header)
///
/// @return length of the option
- virtual uint16_t len();
+ virtual uint16_t len() const;
/// @brief Sets content of this option from buffer.
///
/// @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
/// because it is checked in a constructor.
- void pack(isc::util::OutputBuffer& buf) {
+ void pack(isc::util::OutputBuffer& buf) const {
// Pack option header.
packHeader(buf);
// Depending on the data type length we use different utility functions
/// Returns length of this option, including option header and suboptions
///
/// @return length of this option
- virtual uint16_t len() {
+ virtual uint16_t len() const {
// Calculate the length of the header.
uint16_t length = (getUniverse() == Option::V4) ? OPTION4_HDR_LEN : OPTION6_HDR_LEN;
// The data length is equal to size of T.
length += sizeof(T);;
// length of all suboptions
- for (OptionCollection::iterator it = options_.begin();
+ for (OptionCollection::const_iterator it = options_.begin();
it != options_.end();
++it) {
length += (*it).second->len();
/// The returned value also includes the suboptions if present.
///
/// @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;
output << headerToText(indent) << ": ";
/// @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
/// because it is checked in a constructor.
- void pack(isc::util::OutputBuffer& buf) {
+ void pack(isc::util::OutputBuffer& buf) const {
// Pack option header.
packHeader(buf);
// Pack option data.
/// Returns length of this option, including option header and suboptions
///
/// @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;
length += values_.size() * sizeof(T);
// length of all suboptions
- for (OptionCollection::iterator it = options_.begin();
+ for (OptionCollection::const_iterator it = options_.begin();
it != options_.end();
++it) {
length += (*it).second->len();
/// the text.
///
/// @return textual representation of the option.
- virtual std::string toText(int indent = 0) {
+ virtual std::string toText(int indent = 0) const {
std::stringstream output;
output << headerToText(indent) << ":";
}
void
-OptionOpaqueDataTuples::pack(isc::util::OutputBuffer& buf) {
+OptionOpaqueDataTuples::pack(isc::util::OutputBuffer& buf) const {
packHeader(buf);
for (TuplesCollection::const_iterator it = tuples_.begin();
}
uint16_t
-OptionOpaqueDataTuples::len() {
+OptionOpaqueDataTuples::len() const {
// The option starts with the header.
uint16_t length = getHeaderLen();
// Now iterate over existing tuples and add their size.
}
std::string
-OptionOpaqueDataTuples::toText(int indent) {
+OptionOpaqueDataTuples::toText(int indent) const {
std::ostringstream s;
// Apply indentation
/// @brief Renders option into the buffer in the wire format.
///
/// @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.
///
bool hasTuple(const std::string& tuple_str) const;
/// @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.
///
/// @param indent Number of space characters before text.
/// @return Text representation of the option.
- virtual std::string toText(int indent = 0);
+ virtual std::string toText(int indent = 0) const;
private:
uint16_t
-OptionString::len() {
+OptionString::len() const {
return (getHeaderLen() + getData().size());
}
void
-OptionString::pack(isc::util::OutputBuffer& buf) {
+OptionString::pack(isc::util::OutputBuffer& buf) const {
// Pack option header.
packHeader(buf);
// Pack data.
}
std::string
-OptionString::toText(int indent) {
+OptionString::toText(int indent) const {
std::ostringstream output;
output << headerToText(indent) << ": "
<< "\"" << getValue() << "\" (string)";
}
std::string
-OptionString::toString() {
+OptionString::toString() const {
return (getValue());
}
/// @brief Returns length of the whole option, including header.
///
/// @return length of the whole option.
- virtual uint16_t len();
+ virtual uint16_t len() const;
/// @brief Returns the string value held by the option.
///
/// is moved to the end of stored data.
///
/// @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.
///
/// the text.
///
/// @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.
///
/// This method is used in client classification.
/// @return Content of the option.
- virtual std::string toString();
+ virtual std::string toString() const;
};
/// Pointer to the OptionString object.
}
-void OptionVendor::pack(isc::util::OutputBuffer& buf) {
+void OptionVendor::pack(isc::util::OutputBuffer& buf) const {
packHeader(buf);
// Store vendor-id
}
}
-uint16_t OptionVendor::len() {
+uint16_t OptionVendor::len() const {
uint16_t length = getHeaderLen();
length += sizeof(uint32_t); // Vendor-id field
}
// length of all suboptions
- for (OptionCollection::iterator it = options_.begin();
+ for (OptionCollection::const_iterator it = options_.begin();
it != options_.end();
++it) {
length += (*it).second->len();
}
uint8_t
-OptionVendor::dataLen() {
+OptionVendor::dataLen() const {
// Calculate and store data-len as follows:
// data-len = total option length - header length
// - enterprise id field length - data-len field size
}
std::string
-OptionVendor::toText(int indent) {
+OptionVendor::toText(int indent) const {
std::stringstream output;
output << headerToText(indent) << ": "
<< getVendorId() << " (uint32)";
/// unused byte after stored option.
///
/// @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
///
/// Returns length of this option, including option header and suboptions
///
/// @return length of this option
- virtual uint16_t len();
+ virtual uint16_t len() const;
/// @brief Returns the option in the textual format.
///
/// @param indent Number of spaces to be inserted before the text.
///
/// @return Vendor option in the textual format.
- virtual std::string toText(int indent = 0);
+ virtual std::string toText(int indent = 0) const;
private:
/// this value.
///
/// @return Returns calculated data-len value.
- uint8_t dataLen();
+ uint8_t dataLen() const;
uint32_t vendor_id_; ///< Enterprise-id
};
}
void
-OptionVendorClass::pack(isc::util::OutputBuffer& buf) {
+OptionVendorClass::pack(isc::util::OutputBuffer& buf) const {
packHeader(buf);
buf.writeUint32(getVendorId());
uint16_t
-OptionVendorClass::len() {
+OptionVendorClass::len() const {
// The option starts with the header and enterprise id.
uint16_t length = getHeaderLen() + sizeof(uint32_t);
// Now iterate over existing tuples and add their size.
}
std::string
-OptionVendorClass::toText(int indent) {
+OptionVendorClass::toText(int indent) const {
std::ostringstream s;
// Apply indentation
/// @brief Renders option into the buffer in the wire format.
///
/// @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.
///
bool hasTuple(const std::string& tuple_str) const;
/// @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.
///
/// @param indent Number of space characters before text.
/// @return Text representation of the option.
- virtual std::string toText(int indent = 0);
+ virtual std::string toText(int indent = 0) const;
private: