Commit d7460a8c authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3194] Check if option definition for Vendor option has correct format.

parent 1a0dd0c7
......@@ -372,6 +372,16 @@ OptionDefinition::haveClientFqdnFormat() const {
(record_fields_[1] == OPT_FQDN_TYPE));
}
bool
OptionDefinition::haveVendor4Format() const {
return (true);
}
bool
OptionDefinition::haveVendor6Format() const {
return (getType() == OPT_UINT32_TYPE && !getEncapsulatedSpace().empty());
}
template<typename T>
T
OptionDefinition::lexicalCastWithRangeCheck(const std::string& value_str)
......@@ -582,7 +592,8 @@ OptionDefinition::factorySpecialFormatOption(Option::Universe u,
// a specialized class to handle it.
return (OptionPtr(new Option6ClientFqdn(begin, end)));
} else if (getCode() == D6O_VENDOR_OPTS) {
} else if (getCode() == D6O_VENDOR_OPTS && haveVendor6Format()) {
// Vendor-Specific Information.
return (OptionPtr(new OptionVendor(Option::V6, begin, end)));
}
......@@ -590,7 +601,8 @@ OptionDefinition::factorySpecialFormatOption(Option::Universe u,
if ((getCode() == DHO_FQDN) && haveFqdn4Format()) {
return (OptionPtr(new Option4ClientFqdn(begin, end)));
} else if (getCode() == DHO_VIVSO_SUBOPTIONS) {
} else if (getCode() == DHO_VIVSO_SUBOPTIONS && haveVendor4Format()) {
// Vendor-Specific Information.
return (OptionPtr(new OptionVendor(Option::V4, begin, end)));
}
......
......@@ -297,6 +297,28 @@ public:
/// %Option.
bool haveFqdn4Format() const;
/// @brief Check if the option has format of Vendor-Identifying Vendor
/// Specific Options.
///
/// @return Always true.
/// @todo The Vendor-Identifying Vendor-Specific Option has a complex format
/// which we do not support here. Therefore it is not really possible to
/// check that the current definition is valid. We may need to add support
/// for such option format or simply do not check the format for certain
/// options, e.g. vendor options, IA_NA, IAADDR and always return objects
/// of the certain type.
bool haveVendor4Format() const;
/// @brief Check if option has a format of the Vendor-Specific Information
/// %Option.
///
/// The Vendor-Specific Information %Option comprises 32-bit enterprise id
/// and the suboptions.
///
/// @return true if option definition conforms to the format of the
/// Vendor-Specific Information %Option.
bool haveVendor6Format() const;
/// @brief Option factory.
///
/// This function creates an instance of DHCP option using
......
Markdown is supported
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