BIND 10 trac2313, updated. 810c95b11f458b18c196a39cba8f3d47ac1d6cb2 [2313] Improved comments for OptionSpace class.
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jan 2 16:08:08 UTC 2013
The branch, trac2313 has been updated
via 810c95b11f458b18c196a39cba8f3d47ac1d6cb2 (commit)
from 85da7d68f1eff606608bd46df43a8f57436a0131 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 810c95b11f458b18c196a39cba8f3d47ac1d6cb2
Author: Marcin Siodelski <marcin at isc.org>
Date: Wed Jan 2 17:07:58 2013 +0100
[2313] Improved comments for OptionSpace class.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dhcpsrv/option_space.cc | 3 +++
src/lib/dhcpsrv/option_space.h | 16 ++++++++++++----
src/lib/dhcpsrv/tests/option_space_unittest.cc | 3 +++
3 files changed, 18 insertions(+), 4 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dhcpsrv/option_space.cc b/src/lib/dhcpsrv/option_space.cc
index 2b81b2a..671245e 100644
--- a/src/lib/dhcpsrv/option_space.cc
+++ b/src/lib/dhcpsrv/option_space.cc
@@ -21,6 +21,7 @@ namespace dhcp {
OptionSpace::OptionSpace(const std::string& name, const bool vendor_space)
: name_(name), vendor_space_(vendor_space) {
+ // Check that provided option space name is valid.
if (!validateName(name_)) {
isc_throw(InvalidOptionSpace, "Invalid option space name "
<< name_);
@@ -29,6 +30,8 @@ OptionSpace::OptionSpace(const std::string& name, const bool vendor_space)
bool
OptionSpace::validateName(const std::string& name) {
+ // Allowed digits are: lower or upper case letters, digits,
+ // underscores and dashes. Empty option spaces are not allowed.
if (boost::algorithm::all(name, boost::is_from_range('a', 'z') ||
boost::is_from_range('A', 'Z') ||
boost::is_digit() ||
diff --git a/src/lib/dhcpsrv/option_space.h b/src/lib/dhcpsrv/option_space.h
index d05317f..c722f4d 100644
--- a/src/lib/dhcpsrv/option_space.h
+++ b/src/lib/dhcpsrv/option_space.h
@@ -56,6 +56,11 @@ public:
/// @param name option space name.
/// @param vendor_space boolean value that indicates that the object
/// describes the vendor space.
+ ///
+ /// @throw isc::dhcp::InvalidOptionSpace if given option space name
+ /// contains invalid characters or is empty. This constructor uses
+ /// \ref validateName function to check that the specified name is
+ /// correct.
OptionSpace(const std::string& name, const bool vendor_space = false);
/// @brief Return option space name.
@@ -71,8 +76,8 @@ public:
/// @brief Mark option space as vendor space or non-vendor space.
///
- /// @param a boolean value indicating that this option space is
- /// a vendor space (true) or non-vendor space (false).
+ /// @param vendor_space a boolean value indicating that this option
+ /// space is a vendor space (true) or non-vendor space (false).
void setVendorSpace(const bool vendor_space) {
vendor_space_ = vendor_space;
}
@@ -80,10 +85,13 @@ public:
/// @brief Checks that the provided option space name is valid.
///
/// It is expected that option space name consists of upper or
- /// lower case letters or digits. All other characters are
- /// prohibited.
+ /// lower case letters or digits. Also, it may contain underscores
+ /// or dashes. Other characters are prohibited. The empty option
+ /// space names are invalid.
///
/// @param name option space name to be validated.
+ ///
+ /// @return true if the option space is valid, else it returns false.
static bool validateName(const std::string& name);
private:
diff --git a/src/lib/dhcpsrv/tests/option_space_unittest.cc b/src/lib/dhcpsrv/tests/option_space_unittest.cc
index 0c520e0..92e188d 100644
--- a/src/lib/dhcpsrv/tests/option_space_unittest.cc
+++ b/src/lib/dhcpsrv/tests/option_space_unittest.cc
@@ -83,6 +83,9 @@ TEST(OptionSpaceTest, validateName) {
'\\', '|', '<','>', ',', '.', '?', '~', '`' };
for (int i = 0; i < sizeof(specials); ++i) {
std::ostringstream stream;
+ // Concatenate valid option space name: "abc" with an invalid character.
+ // That way we get option space names like: "abc!", "abc$" etc. It is
+ // expected that the validating function fails form them.
stream << "abc" << specials[i];
EXPECT_FALSE(OptionSpace::validateName(stream.str()))
<< "Test failed for special character '" << specials[i] << "'.";
More information about the bind10-changes
mailing list