|
@@ -41,13 +41,13 @@ using namespace isc::asiolink;
|
|
|
namespace isc {
|
|
|
namespace dhcp {
|
|
|
|
|
|
-/// @brief auxiliary type used for storing element name and its parser
|
|
|
+/// @brief an auxiliary type used for storing an element name and its parser
|
|
|
typedef pair<string, ConstElementPtr> ConfigPair;
|
|
|
|
|
|
/// @brief a factory method that will create a parser for a given element name
|
|
|
typedef DhcpConfigParser* ParserFactory(const std::string& config_id);
|
|
|
|
|
|
-/// @brief a collection of factories that creates parsers for specified element names
|
|
|
+/// @brief a collection of factories that create parsers for specified element names
|
|
|
typedef std::map<std::string, ParserFactory*> FactoryMap;
|
|
|
|
|
|
/// @brief a collection of elements that store uint32 values (e.g. renew-timer = 900)
|
|
@@ -58,12 +58,12 @@ typedef std::map<string, string> StringStorage;
|
|
|
|
|
|
/// @brief a collection of pools
|
|
|
///
|
|
|
-/// That type is used as intermediate storage, when pools are parsed, but there is
|
|
|
+/// This type is used as intermediate storage, when pools are parsed, but there is
|
|
|
/// no subnet object created yet to store them.
|
|
|
typedef std::vector<Pool6Ptr> PoolStorage;
|
|
|
|
|
|
-/// @brief Collection of option descriptors. This container allows to search for
|
|
|
-/// options using option code or persistency flag. This is useful when merging
|
|
|
+/// @brief Collection of option descriptors. This container allows searching for
|
|
|
+/// options using the option code or persistency flag. This is useful when merging
|
|
|
/// existing options with newly configured options.
|
|
|
typedef Subnet::OptionContainer OptionStorage;
|
|
|
|
|
@@ -78,9 +78,9 @@ OptionStorage option_defaults;
|
|
|
|
|
|
/// @brief a dummy configuration parser
|
|
|
///
|
|
|
-/// It is a debugging parser. It does not configure anything,
|
|
|
+/// This is a debugging parser. It does not configure anything,
|
|
|
/// will accept any configuration and will just print it out
|
|
|
-/// on commit. Useful for debugging existing configurations and
|
|
|
+/// on commit. Useful for debugging existing configurations and
|
|
|
/// adding new ones.
|
|
|
class DebugParser : public DhcpConfigParser {
|
|
|
public:
|
|
@@ -107,7 +107,7 @@ public:
|
|
|
|
|
|
/// @brief pretends to apply the configuration
|
|
|
///
|
|
|
- /// This is a method required by base class. It pretends to apply the
|
|
|
+ /// This is a method required by the base class. It pretends to apply the
|
|
|
/// configuration, but in fact it only prints the parameter out.
|
|
|
///
|
|
|
/// See \ref DhcpConfigParser class for details.
|
|
@@ -171,7 +171,7 @@ public:
|
|
|
// Parsing the value as a int64 value allows to
|
|
|
// check if the provided value is within the range
|
|
|
// of uint32_t (is not negative or greater than
|
|
|
- // maximal uint32_t value.
|
|
|
+ // maximal uint32_t value).
|
|
|
int64value = boost::lexical_cast<int64_t>(value->str());
|
|
|
} catch (const boost::bad_lexical_cast&) {
|
|
|
parse_error = true;
|
|
@@ -196,13 +196,13 @@ public:
|
|
|
}
|
|
|
|
|
|
// If a given parameter already exists in the storage we override
|
|
|
- // its value. If it doesn't we insert new element.
|
|
|
+ // its value. If it doesn't we insert a new element.
|
|
|
(*storage_)[param_name_] = value_;
|
|
|
}
|
|
|
|
|
|
/// @brief does nothing
|
|
|
///
|
|
|
- /// This method is required for all parser. The value itself
|
|
|
+ /// This method is required for all parsers. The value itself
|
|
|
/// is not commited anywhere. Higher level parsers are expected to
|
|
|
/// use values stored in the storage, e.g. renew-timer for a given
|
|
|
/// subnet is stored in subnet-specific storage. It is not commited
|
|
@@ -240,9 +240,9 @@ protected:
|
|
|
/// @brief Configuration parser for string parameters
|
|
|
///
|
|
|
/// This class is a generic parser that is able to handle any string
|
|
|
-/// parameter. By default it stores the value in external global container
|
|
|
+/// parameter. By default it stores the value in an external global container
|
|
|
/// (string_defaults). If used in smaller scopes (e.g. to parse parameters
|
|
|
-/// in subnet config), it can be pointed to a different storage, using
|
|
|
+/// in subnet config), it can be pointed to a different storage, using the
|
|
|
/// setStorage() method. This class follows the parser interface, laid out
|
|
|
/// in its base class, \ref DhcpConfigParser.
|
|
|
///
|
|
@@ -259,7 +259,7 @@ public:
|
|
|
|
|
|
/// @brief parses parameter value
|
|
|
///
|
|
|
- /// Parses configuration entry and stored it in storage. See
|
|
|
+ /// Parses configuration entry and stores it in storage. See
|
|
|
/// \ref setStorage() for details.
|
|
|
///
|
|
|
/// @param value pointer to the content of parsed values
|
|
@@ -267,13 +267,13 @@ public:
|
|
|
value_ = value->str();
|
|
|
boost::erase_all(value_, "\"");
|
|
|
// If a given parameter already exists in the storage we override
|
|
|
- // its value. If it doesn't we insert new element.
|
|
|
+ // its value. If it doesn't we insert a new element.
|
|
|
(*storage_)[param_name_] = value_;
|
|
|
}
|
|
|
|
|
|
/// @brief does nothing
|
|
|
///
|
|
|
- /// This method is required for all parser. The value itself
|
|
|
+ /// This method is required for all parsers. The value itself
|
|
|
/// is not commited anywhere. Higher level parsers are expected to
|
|
|
/// use values stored in the storage, e.g. renew-timer for a given
|
|
|
/// subnet is stored in subnet-specific storage. It is not commited
|
|
@@ -370,7 +370,7 @@ protected:
|
|
|
/// and stored in chosen PoolStorage container.
|
|
|
///
|
|
|
/// As there are no default values for pool, setStorage() must be called
|
|
|
-/// before build(). Otherwise exception will be thrown.
|
|
|
+/// before build(). Otherwise an exception will be thrown.
|
|
|
///
|
|
|
/// It is useful for parsing Dhcp6/subnet6[X]/pool parameters.
|
|
|
class PoolParser : public DhcpConfigParser {
|
|
@@ -397,7 +397,7 @@ public:
|
|
|
BOOST_FOREACH(ConstElementPtr text_pool, pools_list->listValue()) {
|
|
|
|
|
|
// That should be a single pool representation. It should contain
|
|
|
- // text is form prefix/len or first - last. Note that spaces
|
|
|
+ // text in the form prefix/len or first - last. Note that spaces
|
|
|
// are allowed
|
|
|
string txt = text_pool->stringValue();
|
|
|
|
|
@@ -416,7 +416,7 @@ public:
|
|
|
// start with the first character after /
|
|
|
string prefix_len = txt.substr(pos + 1);
|
|
|
|
|
|
- // It is lexical cast to int and then downcast to uint8_t.
|
|
|
+ // It is lexically cast to int and then downcast to uint8_t.
|
|
|
// Direct cast to uint8_t (which is really an unsigned char)
|
|
|
// will result in interpreting the first digit as output
|
|
|
// value and throwing exception if length is written on two
|
|
@@ -465,7 +465,7 @@ public:
|
|
|
|
|
|
/// @brief does nothing.
|
|
|
///
|
|
|
- /// This method is required for all parser. The value itself
|
|
|
+ /// This method is required for all parsers. The value itself
|
|
|
/// is not commited anywhere. Higher level parsers (for subnet) are expected
|
|
|
/// to use values stored in the storage.
|
|
|
virtual void commit() {}
|
|
@@ -480,7 +480,7 @@ public:
|
|
|
protected:
|
|
|
/// @brief pointer to the actual Pools storage
|
|
|
///
|
|
|
- /// That is typically a storage somewhere in Subnet parser
|
|
|
+ /// This is typically a storage somewhere in Subnet parser
|
|
|
/// (an upper level parser).
|
|
|
PoolStorage* pools_;
|
|
|
};
|
|
@@ -489,11 +489,11 @@ protected:
|
|
|
///
|
|
|
/// This parser parses configuration entries that specify value of
|
|
|
/// a single option. These entries include option name, option code
|
|
|
-/// and data carried by the option. If parsing is successful than
|
|
|
+/// and data carried by the option. If parsing is successful than an
|
|
|
/// instance of an option is created and added to the storage provided
|
|
|
/// by the calling class.
|
|
|
///
|
|
|
-/// @todo This class parses and validates option name. However it is
|
|
|
+/// @todo This class parses and validates the option name. However it is
|
|
|
/// not used anywhere util support for option spaces is implemented
|
|
|
/// (see tickets #2319, #2314). When option spaces are implemented
|
|
|
/// there will be a way to reference the particular option using
|
|
@@ -567,12 +567,12 @@ public:
|
|
|
|
|
|
/// @brief Commits option value.
|
|
|
///
|
|
|
- /// This function adds new option to the storage or replaces existing option
|
|
|
+ /// This function adds a new option to the storage or replaces an existing option
|
|
|
/// with the same code.
|
|
|
///
|
|
|
/// @throw isc::InvalidOperation if failed to set pointer to storage or failed
|
|
|
/// to call build() prior to commit. If that happens data in the storage
|
|
|
- /// remain not modified.
|
|
|
+ /// remain un-modified.
|
|
|
virtual void commit() {
|
|
|
if (options_ == NULL) {
|
|
|
isc_throw(isc::InvalidOperation, "Parser logic error: storage must be set before "
|
|
@@ -616,11 +616,11 @@ private:
|
|
|
///
|
|
|
/// Creates an instance of an option and adds it to the provided
|
|
|
/// options storage. If the option data parsed by \ref build function
|
|
|
- /// are invalid or insufficient it emits exception.
|
|
|
+ /// are invalid or insufficient this function emits an exception.
|
|
|
///
|
|
|
/// @warning this function does not check if options_ storage pointer
|
|
|
- /// is intitialized but this is not needed here because it is checked in
|
|
|
- /// \ref build function.
|
|
|
+ /// is intitialized but this check is not needed here because it is done
|
|
|
+ /// in the \ref build function.
|
|
|
///
|
|
|
/// @throw Dhcp6ConfigError if parameters provided in the configuration
|
|
|
/// are invalid.
|
|
@@ -637,7 +637,7 @@ private:
|
|
|
isc_throw(Dhcp6ConfigError, "Parser error: value of 'code' must not"
|
|
|
<< " exceed " << std::numeric_limits<uint16_t>::max());
|
|
|
}
|
|
|
- // Check the option name has been specified, is non-empty and does not
|
|
|
+ // Check that the option name has been specified, is non-empty and does not
|
|
|
// contain spaces.
|
|
|
// @todo possibly some more restrictions apply here?
|
|
|
std::string option_name = getStringParam("name");
|
|
@@ -681,19 +681,19 @@ private:
|
|
|
} else if (num_defs == 0) {
|
|
|
// @todo We have a limited set of option definitions intiialized at the moment.
|
|
|
// In the future we want to initialize option definitions for all options.
|
|
|
- // Consequently error will be issued if option definition does not exist
|
|
|
+ // Consequently an error will be issued if an option definition does not exist
|
|
|
// for a particular option code. For now it is ok to create generic option
|
|
|
// if definition does not exist.
|
|
|
OptionPtr option(new Option(Option::V6, static_cast<uint16_t>(option_code),
|
|
|
binary));
|
|
|
- // Created option is stored in option_descriptor_ class member until commit
|
|
|
- // stage when it inserted into the main storage. If option with the same
|
|
|
- // code exists in main storage already it replaces old option.
|
|
|
+ // The created option is stored in option_descriptor_ class member until the
|
|
|
+ // commit stage when it is inserted into the main storage. If an option with the
|
|
|
+ // same code exists in main storage already the old option is replaced.
|
|
|
option_descriptor_.option = option;
|
|
|
option_descriptor_.persistent = false;
|
|
|
} else {
|
|
|
- // We have exactly one option definition for the particular option code.
|
|
|
- // use it to create option instance.
|
|
|
+ // We have exactly one option definition for the particular option code
|
|
|
+ // use it to create the option instance.
|
|
|
const OptionDefinitionPtr& def = *(range.first);
|
|
|
// getFactory should never return NULL pointer.
|
|
|
Option::Factory* factory = def->getFactory();
|
|
@@ -760,7 +760,7 @@ public:
|
|
|
/// @brief Constructor.
|
|
|
///
|
|
|
/// Unless otherwise specified, parsed options will be stored in
|
|
|
- /// a global option containers (option_default). That storage location
|
|
|
+ /// a global option container (option_default). That storage location
|
|
|
/// is overriden on a subnet basis.
|
|
|
OptionDataListParser(const std::string&)
|
|
|
: options_(&option_defaults), local_options_() { }
|
|
@@ -816,7 +816,7 @@ public:
|
|
|
}
|
|
|
|
|
|
/// Intermediate option storage. This storage is used by
|
|
|
- /// lower level parsers to add new options. Values held
|
|
|
+ /// lower level parsers to add new options. Values held
|
|
|
/// in this storage are assigned to main storage (options_)
|
|
|
/// if overall parsing was successful.
|
|
|
OptionStorage local_options_;
|
|
@@ -835,8 +835,8 @@ public:
|
|
|
|
|
|
/// @brief constructor
|
|
|
Subnet6ConfigParser(const std::string& ) {
|
|
|
- // The parameter should always be "subnet", but we don't check here
|
|
|
- // against it in case some wants to reuse this parser somewhere.
|
|
|
+ // The parameter should always be "subnet", but we don't check
|
|
|
+ // against that here in case some wants to reuse this parser somewhere.
|
|
|
}
|
|
|
|
|
|
/// @brief parses parameter value
|
|
@@ -847,8 +847,8 @@ public:
|
|
|
BOOST_FOREACH(ConfigPair param, subnet->mapValue()) {
|
|
|
ParserPtr parser(createSubnet6ConfigParser(param.first));
|
|
|
// The actual type of the parser is unknown here. We have to discover
|
|
|
- // parser type here to invoke corresponding setStorage function on it.
|
|
|
- // We discover parser type by trying to cast the parser to various
|
|
|
+ // the parser type here to invoke the corresponding setStorage function
|
|
|
+ // on it. We discover parser type by trying to cast the parser to various
|
|
|
// parser types and checking which one was successful. For this one
|
|
|
// a setStorage and build methods are invoked.
|
|
|
|
|
@@ -948,13 +948,13 @@ public:
|
|
|
// code equal to global option's code.
|
|
|
Subnet::OptionContainerTypeRange range = idx.equal_range(desc.option->getType());
|
|
|
// @todo: In the future we will be searching for options using either
|
|
|
- // option code or namespace. Currently we have only the option
|
|
|
+ // an option code or namespace. Currently we have only the option
|
|
|
// code available so if there is at least one option found with the
|
|
|
- // specific code we don't add globally configured option.
|
|
|
+ // specific code we don't add the globally configured option.
|
|
|
// @todo with this code the first globally configured option
|
|
|
// with the given code will be added to a subnet. We may
|
|
|
- // want to issue warning about dropping configuration of
|
|
|
- // global option if one already exsist.
|
|
|
+ // want to issue a warning about dropping the configuration of
|
|
|
+ // a global option if one already exsists.
|
|
|
if (std::distance(range.first, range.second) == 0) {
|
|
|
subnet->addOption(desc.option);
|
|
|
}
|
|
@@ -967,9 +967,9 @@ private:
|
|
|
|
|
|
/// @brief Set storage for a parser and invoke build.
|
|
|
///
|
|
|
- /// This helper method casts the provided parser pointer to specified
|
|
|
- /// type. If cast is successful it sets the corresponding storage for
|
|
|
- /// this parser, invokes build on it and save the parser.
|
|
|
+ /// This helper method casts the provided parser pointer to the specified
|
|
|
+ /// type. If the cast is successful it sets the corresponding storage for
|
|
|
+ /// this parser, invokes build on it and saves the parser.
|
|
|
///
|
|
|
/// @tparam T parser type to which parser argument should be cast.
|
|
|
/// @tparam Y storage type for the specified parser type.
|
|
@@ -1041,7 +1041,7 @@ private:
|
|
|
|
|
|
/// @brief returns value for a given parameter (after using inheritance)
|
|
|
///
|
|
|
- /// This method implements inheritance. For a given parameter name, it first
|
|
|
+ /// This method implements inheritance. For a given parameter name, it first
|
|
|
/// checks if there is a global value for it and overwrites it with specific
|
|
|
/// value if such value was defined in subnet.
|
|
|
///
|
|
@@ -1087,7 +1087,7 @@ private:
|
|
|
ParserCollection parsers_;
|
|
|
};
|
|
|
|
|
|
-/// @brief this class parses list of subnets
|
|
|
+/// @brief this class parses a list of subnets
|
|
|
///
|
|
|
/// This is a wrapper parser that handles the whole list of Subnet6
|
|
|
/// definitions. It iterates over all entries and creates Subnet6ConfigParser
|
|
@@ -1103,7 +1103,7 @@ public:
|
|
|
|
|
|
/// @brief parses contents of the list
|
|
|
///
|
|
|
- /// Iterates over all entries on the list and creates Subnet6ConfigParser
|
|
|
+ /// Iterates over all entries on the list and creates a Subnet6ConfigParser
|
|
|
/// for each entry.
|
|
|
///
|
|
|
/// @param subnets_list pointer to a list of IPv6 subnets
|