}
std::string txt_prefix_len = txt_subnet_prefix.substr(pos + 1);
- int8_t prefix_len = 0;
+ int16_t prefix_len = 0;
try {
- // We should be able to lexically cast IPv4 prefix len to short int,
- // and then downcast it to signed char. After that len<=32 check is
- // also required.
- prefix_len = boost::numeric_cast<int8_t>(boost::lexical_cast<int16_t>(txt_prefix_len));
+ // We should be able to lexically cast IPv4 prefix len to short int.
+ // After that len<=32 check is also required.
+ prefix_len = boost::lexical_cast<int16_t>(txt_prefix_len);
if (prefix_len > 32) {
isc_throw(BadValue, "Provided IPv4 prefix len is out of 0-32 range.");
}
uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end,
- bool custom_data) const {
+ bool convenient_format) const {
try {
// Some of the options are represented by the specialized classes derived
// type to be returned. Therefore, we first check that if we are dealing
// with such an option. If the instance is returned we just exit at this
// point. If not, we will search for a generic option type to return.
- OptionPtr option = factorySpecialFormatOption(u, begin, end, custom_data);
+ OptionPtr option = factorySpecialFormatOption(u, begin, end, convenient_format);
if (option) {
return (option);
}
OptionDefinition::factorySpecialFormatOption(Option::Universe u,
OptionBufferConstIter begin,
OptionBufferConstIter end,
- bool custom_data) const {
+ bool convenient_format) const {
if ((u == Option::V6) && haveSpace(DHCP6_OPTION_SPACE)) {
switch (getCode()) {
case D6O_IA_NA:
return (OptionPtr(new Option4ClientFqdn(begin, end)));
case DHO_CLASSLESS_STATIC_ROUTE:
- return (OptionPtr(new OptionClasslessStaticRoute(begin, end, custom_data)));
+ return (OptionPtr(new OptionClasslessStaticRoute(begin, end, convenient_format)));
case DHO_VIVCO_SUBOPTIONS:
// Record of uint32 followed by binary.
/// @param type option type.
/// @param begin beginning of the option buffer.
/// @param end end of the option buffer.
- /// @param custom_data flag letting know the factory that the buffer contains custom data.
- /// Intended use case is @c OPT_CUSTOM_TYPE option def and csv-format=true.
- /// Defaults to false.
+ /// @param convenient_format flag which indicates that the buffer contains option data
+ /// as a string formatted in user-friendly, convenient way.
+ /// The flag is propagated to the option constructor, so that
+ /// the data could be parsed properly. Defaults to false.
///
/// @return instance of the DHCP option.
/// @throw InvalidOptionValue if data for the option is invalid.
uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end,
- bool custom_data = false) const;
+ bool convenient_format = false) const;
/// @brief Option factory.
///
/// @param u A universe (V4 or V6).
/// @param begin beginning of the option buffer.
/// @param end end of the option buffer.
- /// @param custom_data flag letting know the factory that the buffer contains custom data.
- /// Intended use case is @c OPT_CUSTOM_TYPE option def and csv-format=true.
- /// Defaults to false.
- ///
+ /// @param convenient_format flag which indicates that the buffer contains option data
+ /// as a string formatted in user-friendly, convenient way.
+ /// The flag is propagated to the option constructor, so that
+ /// the data could be parsed properly. Defaults to false.
///
/// @return An instance of the option having special format or NULL if
/// such an option can't be created because an option with the given
OptionPtr factorySpecialFormatOption(Option::Universe u,
OptionBufferConstIter begin,
OptionBufferConstIter end,
- bool custom_data = false) const;
+ bool convenient_format = false) const;
/// @brief Check if specified type matches option definition type.
///
// Validate that option's fields were correctly parsed from strings.
OptionClasslessStaticRoutePtr option_cast = boost::dynamic_pointer_cast<OptionClasslessStaticRoute>(option);
+ // Check that cast was successful.
+ ASSERT_TRUE(option_cast);
+
// Expected len: 2 (option code + option len headers) + 5 (1 dest descriptor + 4 router addr)
// + 9 (5 dest descriptor + 4 router addr) + 8 (4 dest descriptor + 4 router addr).
EXPECT_EQ(24, option_cast->len());
// Validate parsed values.
OptionClasslessStaticRoutePtr option_cast = boost::dynamic_pointer_cast<OptionClasslessStaticRoute>(option);
+ // Check that cast was successful.
+ ASSERT_TRUE(option_cast);
+
// Expected len: 2 (option code + option len headers) + 5 (1 dest descriptor + 4 router addr)
// + 9 (5 dest descriptor + 4 router addr) + 8 (4 dest descriptor + 4 router addr).
EXPECT_EQ(24, option_cast->len());