Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ISC Open Source Projects
Kea
Commits
810c95b1
Commit
810c95b1
authored
Jan 02, 2013
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2313] Improved comments for OptionSpace class.
parent
85da7d68
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
src/lib/dhcpsrv/option_space.cc
src/lib/dhcpsrv/option_space.cc
+3
-0
src/lib/dhcpsrv/option_space.h
src/lib/dhcpsrv/option_space.h
+12
-4
src/lib/dhcpsrv/tests/option_space_unittest.cc
src/lib/dhcpsrv/tests/option_space_unittest.cc
+3
-0
No files found.
src/lib/dhcpsrv/option_space.cc
View file @
810c95b1
...
...
@@ -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
()
||
...
...
src/lib/dhcpsrv/option_space.h
View file @
810c95b1
...
...
@@ -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:
...
...
src/lib/dhcpsrv/tests/option_space_unittest.cc
View file @
810c95b1
...
...
@@ -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
]
<<
"'."
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment