Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
19742f21
Commit
19742f21
authored
Mar 15, 2016
by
Francis Dupont
Browse files
[master] Merged trac4291 (empty option vs csv-format)
parents
b2e7801e
a288f27e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcp/option_definition.cc
View file @
19742f21
// Copyright (C) 2012-201
5
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-201
6
Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
...
...
@@ -228,9 +228,12 @@ OptionDefinition::optionFactory(Option::Universe u, uint16_t type,
OptionBuffer
buf
;
if
(
!
array_type_
&&
type_
!=
OPT_RECORD_TYPE
)
{
if
(
values
.
empty
())
{
isc_throw
(
InvalidOptionValue
,
"no option value specified"
);
if
(
type_
!=
OPT_EMPTY_TYPE
)
{
isc_throw
(
InvalidOptionValue
,
"no option value specified"
);
}
}
else
{
writeToBuffer
(
util
::
str
::
trim
(
values
[
0
]),
type_
,
buf
);
}
writeToBuffer
(
util
::
str
::
trim
(
values
[
0
]),
type_
,
buf
);
}
else
if
(
array_type_
&&
type_
!=
OPT_RECORD_TYPE
)
{
for
(
size_t
i
=
0
;
i
<
values
.
size
();
++
i
)
{
writeToBuffer
(
util
::
str
::
trim
(
values
[
i
]),
type_
,
buf
);
...
...
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
View file @
19742f21
// Copyright (C) 2012-201
5
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-201
6
Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
...
...
@@ -932,6 +932,26 @@ TEST_F(ParseConfigTest, emptyOptionData) {
ASSERT_EQ
(
0
,
opt
->
getAddresses
().
size
());
}
// This test verifies an option data without suboptions is supported
TEST_F
(
ParseConfigTest
,
optionDataNoSubOpion
)
{
// Configuration string.
const
std
::
string
config
=
"{
\"
option-data
\"
: [ {"
"
\"
name
\"
:
\"
vendor-encapsulated-options
\"
"
" } ]"
"}"
;
// The default universe is V6. We need to change it to use dhcp4 option
// space.
parser_context_
->
universe_
=
Option
::
V4
;
int
rcode
=
0
;
ASSERT_NO_THROW
(
rcode
=
parseConfiguration
(
config
));
EXPECT_EQ
(
0
,
rcode
);
const
OptionPtr
opt
=
getOptionPtr
(
"dhcp4"
,
DHO_VENDOR_ENCAPSULATED_OPTIONS
);
ASSERT_TRUE
(
opt
);
ASSERT_EQ
(
0
,
opt
->
getOptions
().
size
());
}
/// The next set of tests check basic operation of the HooksLibrariesParser.
//
// Convenience function to set a configuration of zero or more hooks
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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