Commit 69950d29 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[2365] Added packOptions and unpackOptions.

parent 8b10f38a
......@@ -114,7 +114,7 @@ Option::pack4(isc::util::OutputBuffer& buf) {
buf.writeData(&data_[0], data_.size());
}
LibDHCP::packOptions(buf, options_);
packOptions(buf);
} else {
isc_throw(BadValue, "Invalid universe type " << universe_);
......@@ -131,18 +131,46 @@ void Option::pack6(isc::util::OutputBuffer& buf) {
buf.writeData(&data_[0], data_.size());
}
LibDHCP::packOptions6(buf, options_);
packOptions(buf);
} else {
isc_throw(BadValue, "Invalid universe type " << universe_);
}
return;
}
void
Option::packOptions(isc::util::OutputBuffer& buf) {
switch (universe_) {
case V4:
LibDHCP::packOptions(buf, options_);
return;
case V6:
LibDHCP::packOptions6(buf, options_);
return;
default:
isc_throw(isc::BadValue, "Invalid universe type " << universe_);
}
}
void Option::unpack(OptionBufferConstIter begin,
OptionBufferConstIter end) {
data_ = OptionBuffer(begin, end);
}
void
Option::unpackOptions(const OptionBuffer& buf) {
switch (universe_) {
case V4:
LibDHCP::unpackOptions4(buf, options_);
return;
case V6:
LibDHCP::unpackOptions6(buf, options_);
return;
default:
isc_throw(isc::BadValue, "Invalid universe type " << universe_);
}
}
uint16_t Option::len() {
// Returns length of the complete option (data length + DHCPv4/DHCPv6
// option header)
......
......@@ -312,6 +312,25 @@ protected:
/// @throw BadValue Universe is not V6.
virtual void pack6(isc::util::OutputBuffer& buf);
/// @brief Store sub options in a buffer.
///
/// This method stores all sub-options defined for a particular
/// option in a on-wire format in output buffer provided.
/// This function is called by pack function in this class or
/// derived classes that override pack.
///
/// @param [out] buf output buffer.
void packOptions(isc::util::OutputBuffer& buf);
/// @brief Builds a collection of sub options from the buffer.
///
/// This method parses the provided buffer and builds a collection
/// of objects representing sub options. This function may throw
/// different exceptions when option assembly fails.
///
/// @param buf buffer to be parsed.
void unpackOptions(const OptionBuffer& buf);
/// @brief A private method used for option correctness.
///
/// It is used in constructors. In there are any problems detected
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment