|
@@ -131,24 +131,44 @@ public:
|
|
|
|
|
|
/// @brief Compares options within two configurations.
|
|
/// @brief Compares options within two configurations.
|
|
///
|
|
///
|
|
|
|
+ /// This method uses gtest macros to signal errors.
|
|
|
|
+ ///
|
|
/// @param cfg1 First configuration.
|
|
/// @param cfg1 First configuration.
|
|
/// @param cfg2 Second configuration.
|
|
/// @param cfg2 Second configuration.
|
|
void compareOptions(const ConstCfgOptionPtr& cfg1,
|
|
void compareOptions(const ConstCfgOptionPtr& cfg1,
|
|
const ConstCfgOptionPtr& cfg2) const;
|
|
const ConstCfgOptionPtr& cfg2) const;
|
|
|
|
|
|
|
|
+ /// @brief Creates an opton descriptor holding an empty option.
|
|
|
|
+ ///
|
|
|
|
+ /// @param universe V4 or V6.
|
|
|
|
+ /// @param option_type Option type.
|
|
|
|
+ /// @param persist A boolean flag indicating if the option is always
|
|
|
|
+ /// returned to the client or only when requested.
|
|
|
|
+ ///
|
|
|
|
+ /// @return Descriptor holding an empty option.
|
|
OptionDescriptor createEmptyOption(const Option::Universe& universe,
|
|
OptionDescriptor createEmptyOption(const Option::Universe& universe,
|
|
const uint16_t option_type,
|
|
const uint16_t option_type,
|
|
const bool persist) const;
|
|
const bool persist) const;
|
|
|
|
|
|
/// @brief Creates an instance of the option for which it is possible to
|
|
/// @brief Creates an instance of the option for which it is possible to
|
|
- /// specify universe, option type and value in the constructor.
|
|
|
|
|
|
+ /// specify universe, option type, persistence flag and value in
|
|
|
|
+ /// the constructor.
|
|
///
|
|
///
|
|
/// Examples of options that can be created using this function are:
|
|
/// Examples of options that can be created using this function are:
|
|
/// - @ref OptionString
|
|
/// - @ref OptionString
|
|
/// - different variants of @ref OptionInt.
|
|
/// - different variants of @ref OptionInt.
|
|
///
|
|
///
|
|
- /// @param encapsulated_space
|
|
|
|
- /// @return Instance of the option created.
|
|
|
|
|
|
+ /// @param universe V4 or V6.
|
|
|
|
+ /// @param option_type Option type.
|
|
|
|
+ /// @param persist A boolean flag indicating if the option is always
|
|
|
|
+ /// returned to the client or only when requested.
|
|
|
|
+ /// @param formatted A boolean value selecting if the formatted option
|
|
|
|
+ /// value should be used (if true), or binary value (if false).
|
|
|
|
+ /// @param value Option value to be assigned to the option.
|
|
|
|
+ /// @tparam OptionType Class encapsulating the option.
|
|
|
|
+ /// @tparam DataType Option value data type.
|
|
|
|
+ ///
|
|
|
|
+ /// @return Descriptor holding an instance of the option created.
|
|
template<typename OptionType, typename DataType>
|
|
template<typename OptionType, typename DataType>
|
|
OptionDescriptor createOption(const Option::Universe& universe,
|
|
OptionDescriptor createOption(const Option::Universe& universe,
|
|
const uint16_t option_type,
|
|
const uint16_t option_type,
|
|
@@ -159,12 +179,31 @@ public:
|
|
value));
|
|
value));
|
|
std::ostringstream s;
|
|
std::ostringstream s;
|
|
if (formatted) {
|
|
if (formatted) {
|
|
|
|
+ // Using formatted option value. Convert option value to a
|
|
|
|
+ // textual format.
|
|
s << value;
|
|
s << value;
|
|
}
|
|
}
|
|
OptionDescriptor desc(option, persist, s.str());
|
|
OptionDescriptor desc(option, persist, s.str());
|
|
return (desc);
|
|
return (desc);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// @brief Creates an instance of the option for which it is possible to
|
|
|
|
+ /// specify option type, persistence flag and value in the constructor.
|
|
|
|
+ ///
|
|
|
|
+ /// Examples of options that can be created using this function are:
|
|
|
|
+ /// - @ref Option4AddrLst
|
|
|
|
+ /// - @ref Option6AddrLst
|
|
|
|
+ ///
|
|
|
|
+ /// @param option_type Option type.
|
|
|
|
+ /// @param persist A boolean flag indicating if the option is always
|
|
|
|
+ /// returned to the client or only when requested.
|
|
|
|
+ /// @param formatted A boolean value selecting if the formatted option
|
|
|
|
+ /// value should be used (if true), or binary value (if false).
|
|
|
|
+ /// @param value Option value to be assigned to the option.
|
|
|
|
+ /// @tparam OptionType Class encapsulating the option.
|
|
|
|
+ /// @tparam DataType Option value data type.
|
|
|
|
+ ///
|
|
|
|
+ /// @return Descriptor holding an instance of the option created.
|
|
template<typename OptionType, typename DataType>
|
|
template<typename OptionType, typename DataType>
|
|
OptionDescriptor createOption(const uint16_t option_type,
|
|
OptionDescriptor createOption(const uint16_t option_type,
|
|
const bool persist,
|
|
const bool persist,
|
|
@@ -174,6 +213,8 @@ public:
|
|
|
|
|
|
std::ostringstream s;
|
|
std::ostringstream s;
|
|
if (formatted) {
|
|
if (formatted) {
|
|
|
|
+ // Using formatted option value. Convert option value to a
|
|
|
|
+ // textual format.
|
|
s << value;
|
|
s << value;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -181,6 +222,22 @@ public:
|
|
return (desc);
|
|
return (desc);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// @brief Creates an instance of the option holding list of IP addresses.
|
|
|
|
+ ///
|
|
|
|
+ /// @param option_type Option type.
|
|
|
|
+ /// @param persist A boolean flag indicating if the option is always
|
|
|
|
+ /// returned to the client or only when requested.
|
|
|
|
+ /// @param formatted A boolean value selecting if the formatted option
|
|
|
|
+ /// value should be used (if true), or binary value (if false).
|
|
|
|
+ /// @param address1 First address to be included. If address is empty, it is
|
|
|
|
+ /// not included.
|
|
|
|
+ /// @param address2 Second address to be included. If address is empty, it
|
|
|
|
+ /// is not included.
|
|
|
|
+ /// @param address3 Third address to be included. If address is empty, it
|
|
|
|
+ /// is not included.
|
|
|
|
+ /// @tparam OptionType Class encapsulating the option.
|
|
|
|
+ ///
|
|
|
|
+ /// @return Descriptor holding an instance of the option created.
|
|
template<typename OptionType>
|
|
template<typename OptionType>
|
|
OptionDescriptor
|
|
OptionDescriptor
|
|
createAddressOption(const uint16_t option_type,
|
|
createAddressOption(const uint16_t option_type,
|
|
@@ -190,6 +247,7 @@ public:
|
|
const std::string& address2 = "",
|
|
const std::string& address2 = "",
|
|
const std::string& address3 = "") const {
|
|
const std::string& address3 = "") const {
|
|
std::ostringstream s;
|
|
std::ostringstream s;
|
|
|
|
+ // First address.
|
|
typename OptionType::AddressContainer addresses;
|
|
typename OptionType::AddressContainer addresses;
|
|
if (!address1.empty()) {
|
|
if (!address1.empty()) {
|
|
addresses.push_back(asiolink::IOAddress(address1));
|
|
addresses.push_back(asiolink::IOAddress(address1));
|
|
@@ -197,6 +255,7 @@ public:
|
|
s << address1;
|
|
s << address1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // Second address.
|
|
if (!address2.empty()) {
|
|
if (!address2.empty()) {
|
|
addresses.push_back(asiolink::IOAddress(address2));
|
|
addresses.push_back(asiolink::IOAddress(address2));
|
|
if (formatted) {
|
|
if (formatted) {
|
|
@@ -206,6 +265,7 @@ public:
|
|
s << address2;
|
|
s << address2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // Third address.
|
|
if (!address3.empty()) {
|
|
if (!address3.empty()) {
|
|
addresses.push_back(asiolink::IOAddress(address3));
|
|
addresses.push_back(asiolink::IOAddress(address3));
|
|
if (formatted) {
|
|
if (formatted) {
|
|
@@ -216,16 +276,49 @@ public:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- boost::shared_ptr<OptionType> option(new OptionType(option_type, addresses));
|
|
|
|
|
|
+ boost::shared_ptr<OptionType> option(new OptionType(option_type,
|
|
|
|
+ addresses));
|
|
OptionDescriptor desc(option, persist, s.str());
|
|
OptionDescriptor desc(option, persist, s.str());
|
|
return (desc);
|
|
return (desc);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// @brief Creates an instance of the vendor option.
|
|
|
|
+ ///
|
|
|
|
+ /// @param universe V4 or V6.
|
|
|
|
+ /// @param persist A boolean flag indicating if the option is always
|
|
|
|
+ /// returned to the client or only when requested.
|
|
|
|
+ /// @param formatted A boolean value selecting if the formatted option
|
|
|
|
+ /// value should be used (if true), or binary value (if false).
|
|
|
|
+ /// @param vendor_id Vendor identifier.
|
|
|
|
+ ///
|
|
|
|
+ /// @return Descriptor holding an instance of the option created.
|
|
OptionDescriptor createVendorOption(const Option::Universe& universe,
|
|
OptionDescriptor createVendorOption(const Option::Universe& universe,
|
|
const bool persist,
|
|
const bool persist,
|
|
const bool formatted,
|
|
const bool formatted,
|
|
const uint32_t vendor_id) const;
|
|
const uint32_t vendor_id) const;
|
|
|
|
|
|
|
|
+ /// @brief Adds multiple options into the host.
|
|
|
|
+ ///
|
|
|
|
+ /// This method creates the following options into the host object:
|
|
|
|
+ /// - DHCPv4 boot file name option,
|
|
|
|
+ /// - DHCPv4 default ip ttl option,
|
|
|
|
+ /// - DHCPv4 option 1 within vendor-encapsulated-options space,
|
|
|
|
+ /// - DHCPv4 option 254 with a single IPv4 address,
|
|
|
|
+ /// - DHCPv4 option 1 within isc option space,
|
|
|
|
+ /// - DHCPv6 boot file url option,
|
|
|
|
+ /// - DHCPv6 information refresh time option,
|
|
|
|
+ /// - DHCPv6 vendor option with vendor id 2495,
|
|
|
|
+ /// - DHCPv6 option 1024, with a sigle IPv6 address,
|
|
|
|
+ /// - DHCPv6 empty option 1, within isc2 option space,
|
|
|
|
+ /// - DHCPv6 option 2, within isc2 option space with 3 IPv6 addresses,
|
|
|
|
+ ///
|
|
|
|
+ /// This method also creates option definitions for the non-standard
|
|
|
|
+ /// options and registers them in the LibDHCP as runtime option
|
|
|
|
+ /// definitions.
|
|
|
|
+ ///
|
|
|
|
+ /// @param host Host object into which options should be added.
|
|
|
|
+ /// @param formatted A boolean value selecting if the formatted option
|
|
|
|
+ /// value should be used (if true), or binary value (if false).
|
|
void addTestOptions(const HostPtr& host, const bool formatted) const;
|
|
void addTestOptions(const HostPtr& host, const bool formatted) const;
|
|
|
|
|
|
/// @brief Pointer to the host data source
|
|
/// @brief Pointer to the host data source
|
|
@@ -342,8 +435,6 @@ public:
|
|
/// Uses gtest macros to report failures.
|
|
/// Uses gtest macros to report failures.
|
|
void testAddDuplicate4();
|
|
void testAddDuplicate4();
|
|
|
|
|
|
- void testAddRollback();
|
|
|
|
-
|
|
|
|
/// @brief Test that DHCPv4 options can be inserted and retrieved from
|
|
/// @brief Test that DHCPv4 options can be inserted and retrieved from
|
|
/// the database.
|
|
/// the database.
|
|
///
|
|
///
|