if (type_ == OPT_BINARY_TYPE) {
return (factoryGeneric(u, type, begin, end));
} else if (type_ == OPT_IPV6_ADDRESS_TYPE && array_type_) {
- return (factoryAddrList6(u, type, begin, end));
+ return (factoryAddrList6(type, begin, end));
} else if (type_ == OPT_IPV4_ADDRESS_TYPE && array_type_) {
- return (factoryAddrList4(u, type, begin, end));
+ return (factoryAddrList4(type, begin, end));
} else if (type_ == OPT_EMPTY_TYPE) {
- return (factoryEmpty(u, type, begin, end));
- } else if (code_ == D6O_IA_NA && haveIA6Format()) {
- return (factoryIA6(u, type, begin, end));
- } else if (code_ == D6O_IAADDR && haveIAAddr6Format()) {
- return (factoryIAAddr6(u, type, begin, end));
+ return (factoryEmpty(u, type));
+ } else if (u == Option::V6 &&
+ code_ == D6O_IA_NA &&
+ haveIA6Format()) {
+ return (factoryIA6(type, begin, end));
+ } else if (u == Option::V6 &&
+ code_ == D6O_IAADDR &&
+ haveIAAddr6Format()) {
+ return (factoryIAAddr6(type, begin, end));
} else if (type_ == OPT_UINT8_TYPE) {
if (array_type_) {
return (factoryGeneric(u, type, begin, end));
}
} else if (type_ == OPT_UINT16_TYPE) {
if (array_type_) {
- return (factoryIntegerArray<uint16_t>(u, type, begin, end));
+ return (factoryIntegerArray<uint16_t>(type, begin, end));
} else {
return (factoryInteger<uint16_t>(u, type, begin, end));
}
} else if (type_ == OPT_UINT32_TYPE) {
if (array_type_) {
- return (factoryIntegerArray<uint32_t>(u, type, begin, end));
+ return (factoryIntegerArray<uint32_t>(type, begin, end));
} else {
return (factoryInteger<uint32_t>(u, type, begin, end));
}
}
OptionPtr
-OptionDefinition::factoryAddrList4(Option::Universe u, uint16_t type,
+OptionDefinition::factoryAddrList4(uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end) {
- sanityCheckUniverse(u, Option::V4);
boost::shared_ptr<Option4AddrLst> option(new Option4AddrLst(type, begin, end));
return (option);
}
OptionPtr
-OptionDefinition::factoryAddrList6(Option::Universe u, uint16_t type,
+OptionDefinition::factoryAddrList6(uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end) {
- sanityCheckUniverse(u, Option::V6);
boost::shared_ptr<Option6AddrLst> option(new Option6AddrLst(type, begin, end));
return (option);
}
OptionPtr
-OptionDefinition::factoryEmpty(Option::Universe u, uint16_t type,
- OptionBufferConstIter,
- OptionBufferConstIter) {
+OptionDefinition::factoryEmpty(Option::Universe u, uint16_t type) {
OptionPtr option(new Option(u, type));
return (option);
}
}
OptionPtr
-OptionDefinition::factoryIA6(Option::Universe u, uint16_t type,
+OptionDefinition::factoryIA6(uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end) {
- sanityCheckUniverse(u, Option::V6);
if (std::distance(begin, end) < Option6IA::OPTION6_IA_LEN) {
isc_throw(isc::OutOfRange, "input option buffer has invalid size, expected "
"at least " << Option6IA::OPTION6_IA_LEN << " bytes");
}
OptionPtr
-OptionDefinition::factoryIAAddr6(Option::Universe u, uint16_t type,
+OptionDefinition::factoryIAAddr6(uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end) {
- sanityCheckUniverse(u, Option::V6);
if (std::distance(begin, end) < Option6IAAddr::OPTION6_IAADDR_LEN) {
isc_throw(isc::OutOfRange, "input option buffer has invalid size, expected "
" at least " << Option6IAAddr::OPTION6_IAADDR_LEN << " bytes");
///
/// Should the option comprise data fields of different types, the "record"
/// option type is used. In such cases the data field types within the record
-/// are specified using \ref OptioDefinition::addRecordField.
+/// are specified using \ref OptionDefinition::addRecordField.
///
/// When the OptionDefinition object has been sucessfully created, it can be
/// queried to return the appropriate option factory function for the specified
/// provided chunk of buffer. This function may be used to
/// create option which is to be sent in the outgoing packet.
///
- /// @param universe option universe (V4 or V6).
+ /// @param u option universe (V4 or V6).
/// @param type option type.
/// @param begin beginning of the option buffer.
/// @param end end of the option buffer.
/// whole provided buffer. This function may be used to
/// create option which is to be sent in the outgoing packet.
///
- /// @param universe option universe (V4 or V6).
+ /// @param u option universe (V4 or V6).
/// @param type option type.
/// @param buf option buffer.
///
/// must be tokenized into the vector of string values and this vector
/// can be supplied to this function.
///
- /// @param universe option universe (V4 or V6).
+ /// @param u option universe (V4 or V6).
/// @param type option type.
/// @param values a vector of values to be used to set data for an option.
///
/// @brief Factory to create option with address list.
///
- /// @param u universe (must be V4).
/// @param type option type.
- /// @param buf option buffer with a list of IPv4 addresses.
+ /// @param begin iterator pointing to the beginning of the buffer
+ /// with a list of IPv4 addresses.
+ /// @param end iterator pointing to the end of the buffer with
+ /// a list of IPv4 addresses.
///
/// @throw isc::OutOfRange if length of the provided option buffer
/// is not multiple of IPV4 address length.
- static OptionPtr factoryAddrList4(Option::Universe u, uint16_t type,
+ static OptionPtr factoryAddrList4(uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end);
/// @brief Factory to create option with address list.
///
- /// @param u universe (must be V6).
/// @param type option type.
- /// @param buf option buffer with a list of IPv6 addresses.
+ /// @param begin iterator pointing to the beginning of the buffer
+ /// with a list of IPv6 addresses.
+ /// @param end iterator pointing to the end of the buffer with
+ /// a list of IPv6 addresses.
///
/// @throw isc::OutOfaRange if length of provided option buffer
/// is not multiple of IPV6 address length.
- static OptionPtr factoryAddrList6(Option::Universe u, uint16_t type,
+ static OptionPtr factoryAddrList6(uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end);
///
/// @param u universe (V6 or V4).
/// @param type option type.
- /// @param buf option buffer (must be empty).
- static OptionPtr factoryEmpty(Option::Universe u, uint16_t type,
- OptionBufferConstIter begin,
- OptionBufferConstIter end);
+ static OptionPtr factoryEmpty(Option::Universe u, uint16_t type);
/// @brief Factory to create generic option.
///
/// @param u universe (V6 or V4).
/// @param type option type.
- /// @param buf option buffer.
+ /// @param begin iterator pointing to the beginning of the buffer.
+ /// @param end iterator pointing to the end of the buffer.
static OptionPtr factoryGeneric(Option::Universe u, uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end);
/// @brief Factory for IA-type of option.
///
- /// @param u universe (must be V6).
/// @param type option type.
- /// @param buf option buffer.
+ /// @param begin iterator pointing to the beginning of the buffer.
+ /// @param end iterator pointing to the end of the buffer.
///
/// @throw isc::OutOfRange if provided option buffer is too short or
/// too long. Expected size is 12 bytes.
/// @throw isc::BadValue if specified universe value is not V6.
- static OptionPtr factoryIA6(Option::Universe u, uint16_t type,
+ static OptionPtr factoryIA6(uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end);
/// @brief Factory for IAADDR-type of option.
///
- /// @param u universe (must be V6).
/// @param type option type.
- /// @param buf option buffer.
+ /// @param begin iterator pointing to the beginning of the buffer.
+ /// @param end iterator pointing to the end of the buffer.
///
/// @throw isc::OutOfRange if provided option buffer is too short or
/// too long. Expected size is 24 bytes.
/// @throw isc::BadValue if specified universe value is not V6.
- static OptionPtr factoryIAAddr6(Option::Universe u, uint16_t type,
+ static OptionPtr factoryIAAddr6(uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end);
/// @brief Factory function to create option with integer value.
///
/// @param type option type.
- /// @param buf option buffer.
+ /// @param begin iterator pointing to the beginning of the buffer.
+ /// @param end iterator pointing to the end of the buffer.
/// @tparam T type of the data field (must be one of the uintX_t or intX_t).
///
/// @throw isc::OutOfRange if provided option buffer length is invalid.
/// @brief Factory function to create option with array of integer values.
///
/// @param type option type.
- /// @param buf option buffer.
+ /// @param begin iterator pointing to the beginning of the buffer.
+ /// @param end iterator pointing to the end of the buffer.
/// @tparam T type of the data field (must be one of the uintX_t or intX_t).
///
/// @throw isc::OutOfRange if provided option buffer length is invalid.
template<typename T>
- static OptionPtr factoryIntegerArray(Option::Universe, uint16_t type,
+ static OptionPtr factoryIntegerArray(uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end) {
OptionPtr option(new Option6IntArray<T>(type, begin, end));
EXPECT_EQ(0x04050607, option_cast_v6->getT1());
EXPECT_EQ(0x08090A0B, option_cast_v6->getT2());
- // This should work for DHCPv6 only, try passing invalid universe value.
- EXPECT_THROW(
- opt_def.optionFactory(Option::V4, D6O_IA_NA, OptionBuffer(option6_ia_len)),
- InvalidOptionValue
- );
// The length of the buffer must be at least 12 bytes.
// Check too short buffer.
EXPECT_THROW(
EXPECT_EQ(0x00010203, option_cast_v6->getPreferred());
EXPECT_EQ(0x04050607, option_cast_v6->getValid());
- // This should work for DHCPv6 only, try passing invalid universe value.
- EXPECT_THROW(
- opt_def.optionFactory(Option::V4, D6O_IAADDR, OptionBuffer(option6_iaaddr_len)),
- InvalidOptionValue
- );
// The length of the buffer must be at least 12 bytes.
// Check too short buffer.
EXPECT_THROW(
EXPECT_EQ("2001:db8::ff00:42:8329", option_cast_v6->getAddress().toText());
EXPECT_EQ(1234, option_cast_v6->getPreferred());
EXPECT_EQ(5678, option_cast_v6->getValid());
-
- // This should work for DHCPv6 only, try passing in\valid universe value.
- EXPECT_THROW(
- opt_def.optionFactory(Option::V4, D6O_IAADDR, data_field_values),
- InvalidOptionValue
- );
}
// The purpose of this test is to verify that definition for option that