Router 1...N The IP address of the router that should
be used to reach that destination.
*/
- // Type: custom
+ // Type: internal
{
"code": 121,
// please mind the convenience notation used:
+----------------------------------------+------+---------------------------+-------------+-------------+
| domain-search | 119 | fqdn | true | false |
+----------------------------------------+------+---------------------------+-------------+-------------+
- | classless-static-route | 121 | custom | false | false |
+ | classless-static-route | 121 | internal | false | false |
+----------------------------------------+------+---------------------------+-------------+-------------+
| vivco-suboptions | 124 | record (uint32, binary) | false | false |
+----------------------------------------+------+---------------------------+-------------+-------------+
| boolean | A boolean value with allowed |
| | values true or false. |
+-----------------+-------------------------------------------------------+
- | custom | A custom value which is intended to be used only |
- | | internally. It is meant for options which provide |
- | | custom configuration syntax for users convenience. |
- +-----------------+-------------------------------------------------------+
| empty | No value; data is carried in |
| | sub-options. |
+-----------------+-------------------------------------------------------+
data_types_["string"] = OPT_STRING_TYPE;
data_types_["tuple"] = OPT_TUPLE_TYPE;
data_types_["fqdn"] = OPT_FQDN_TYPE;
- data_types_["custom"] = OPT_CUSTOM_TYPE;
+ data_types_["internal"] = OPT_INTERNAL_TYPE;
data_types_["record"] = OPT_RECORD_TYPE;
data_type_names_[OPT_EMPTY_TYPE] = "empty";
data_type_names_[OPT_STRING_TYPE] = "string";
data_type_names_[OPT_TUPLE_TYPE] = "tuple";
data_type_names_[OPT_FQDN_TYPE] = "fqdn";
- data_type_names_[OPT_CUSTOM_TYPE] = "custom";
+ data_type_names_[OPT_INTERNAL_TYPE] = "internal";
data_type_names_[OPT_RECORD_TYPE] = "record";
// The "unknown" data type is declared here so as
// it can be returned by reference by a getDataTypeName
OPT_STRING_TYPE,
OPT_TUPLE_TYPE,
OPT_FQDN_TYPE,
- OPT_CUSTOM_TYPE,
+ // Type to be used only internally. Allows convenient notation of the option config.
+ OPT_INTERNAL_TYPE,
OPT_RECORD_TYPE,
OPT_UNKNOWN_TYPE
};
uint16_t type,
OptionBufferConstIter begin,
OptionBufferConstIter end,
- bool convenient_format) const {
+ bool convenient_notation) 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, convenient_format);
+ OptionPtr option = factorySpecialFormatOption(u, begin, end, convenient_notation);
if (option) {
return (option);
}
}
case OPT_BINARY_TYPE:
- // If this is Custom type, and it wasn't handled by factorySpecialFormatOption() before,
+ // If this is Internal type, and it wasn't handled by factorySpecialFormatOption() before,
// let's treat it like normal Binary type.
- case OPT_CUSTOM_TYPE:
+ case OPT_INTERNAL_TYPE:
return (factoryGeneric(u, type, begin, end));
case OPT_UINT8_TYPE:
if (type_ != OPT_EMPTY_TYPE) {
isc_throw(InvalidOptionValue, "no option value specified");
}
- } else if (type_ == OPT_CUSTOM_TYPE) {
- // If Custom type is used together with csv-format=true, let's treat it
- // like String type. optionFactory() will be called with custom_data flag set to true,
- // so that the factory will have a chance to handle it in a custom way.
+ } else if (type_ == OPT_INTERNAL_TYPE) {
+ // If an Option of type Internal is configured using csv-format=true, it means it is
+ // convenient notation option config that needs special parsing. Let's treat it like
+ // String type. optionFactory() will be called with convenient_notation flag set to
+ // true, so that the factory will have a chance to handle it in a special way.
writeToBuffer(u, boost::algorithm::join(values, ","), OPT_STRING_TYPE, buf);
} else {
writeToBuffer(u, util::str::trim(values[0]), type_, buf);
}
}
}
- return (optionFactory(u, type, buf.begin(), buf.end(), (type_ == OPT_CUSTOM_TYPE)));
+ return (optionFactory(u, type, buf.begin(), buf.end(), (type_ == OPT_INTERNAL_TYPE)));
}
void
<< " an option record.";
break;
}
- // Custom type is not allowed within a record.
- if (*it == OPT_CUSTOM_TYPE) {
- err_str << "custom data type can't be stored as a field in"
+ // Internal type is not allowed within a record.
+ if (*it == OPT_INTERNAL_TYPE) {
+ err_str << "internal data type can't be stored as a field in"
<< " an option record.";
break;
}
err_str << "array of empty value is not"
<< " a valid option definition.";
- } else if (type_ == OPT_CUSTOM_TYPE) {
- err_str << "array of custom type value is not"
+ } else if (type_ == OPT_INTERNAL_TYPE) {
+ err_str << "array of internal type value is not"
<< " a valid option definition.";
}
OptionDefinition::factorySpecialFormatOption(Option::Universe u,
OptionBufferConstIter begin,
OptionBufferConstIter end,
- bool convenient_format) const {
+ bool convenient_notation) 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, convenient_format)));
+ return (OptionPtr(new OptionClasslessStaticRoute(begin, end, convenient_notation)));
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 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.
+ /// @param convenient_notation 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 convenient_format = false) const;
+ bool convenient_notation = 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 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.
+ /// @param convenient_notation 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 convenient_format = false) const;
+ bool convenient_notation = false) const;
/// @brief Check if specified type matches option definition type.
///
OPT_IPV4_ADDRESS_TYPE, false, NO_RECORD_DEF, "" },
{ "domain-search", DHO_DOMAIN_SEARCH, DHCP4_OPTION_SPACE, OPT_FQDN_TYPE,
true, NO_RECORD_DEF, "" },
- { "classless-static-route", DHO_CLASSLESS_STATIC_ROUTE, DHCP4_OPTION_SPACE, OPT_CUSTOM_TYPE,
+ { "classless-static-route", DHO_CLASSLESS_STATIC_ROUTE, DHCP4_OPTION_SPACE, OPT_INTERNAL_TYPE,
false, NO_RECORD_DEF, "" },
{ "vivco-suboptions", DHO_VIVCO_SUBOPTIONS, DHCP4_OPTION_SPACE,
OPT_RECORD_TYPE, false, RECORD_DEF(VIVCO_RECORDS), "" },
EXPECT_EQ("world", tuple2.getText());
}
-// The purpose of this test is to verify creation of OPT_CUSTOM_TYPE option
+// The purpose of this test is to verify creation of OPT_INTERNAL_TYPE option
// definition. OptionFactory is used which takes vector of string values as
-// data for the option. This is special case for OPT_CUSTOM_TYPE because it means
-// that custom data is provided in string values. Custom parsing is verified in this test.
-TEST_F(OptionDefinitionTest, customOptionTypeString) {
+// data for the option. This is special case for OPT_INTERNAL_TYPE because it means
+// that convenient notation option config is provided as string that needs special parsing.
+// Custom parsing is verified in this test.
+TEST_F(OptionDefinitionTest, internalOptionTypeString) {
OptionDefinition opt_def("classless-static-route", DHO_CLASSLESS_STATIC_ROUTE,
- DHCP4_OPTION_SPACE, "custom", false);
+ DHCP4_OPTION_SPACE, "internal", false);
OptionPtr option;
option_cast->toText());
}
-// The purpose of this test is to verify creation of OPT_CUSTOM_TYPE option
+// The purpose of this test is to verify creation of OPT_INTERNAL_TYPE option
// definition. OptionFactory is used which takes OptionBuffer as
// data for the option. Binary data unpack is verified in this test.
-TEST_F(OptionDefinitionTest, customOptionTypeBinary) {
+TEST_F(OptionDefinitionTest, internalOptionTypeBinary) {
OptionDefinition opt_def("classless-static-route", DHO_CLASSLESS_STATIC_ROUTE,
- DHCP4_OPTION_SPACE, "custom", false);
+ DHCP4_OPTION_SPACE, "internal", false);
OptionPtr option;