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
69c2e41c
Commit
69c2e41c
authored
Aug 27, 2014
by
Marcin Siodelski
Browse files
[3512] Interface list config parser has separation of the commit and build.
parent
4bac0846
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/dhcp_parsers.cc
View file @
69c2e41c
...
...
@@ -189,12 +189,14 @@ InterfaceListConfigParser(const std::string& param_name)
void
InterfaceListConfigParser
::
build
(
ConstElementPtr
value
)
{
// Copy the current interface configuration.
ConfigurationPtr
config
=
CfgMgr
::
instance
().
getConfiguration
();
config
->
cfg_iface_
.
reset
();
cfg_iface_
=
config
->
cfg_iface_
;
cfg_iface_
.
reset
();
BOOST_FOREACH
(
ConstElementPtr
iface
,
value
->
listValue
())
{
std
::
string
iface_name
=
iface
->
stringValue
();
try
{
config
->
cfg_iface_
.
use
(
iface_name
);
cfg_iface_
.
use
(
iface_name
);
}
catch
(
const
std
::
exception
&
ex
)
{
isc_throw
(
DhcpConfigError
,
"Failed to select interface: "
...
...
@@ -205,7 +207,8 @@ InterfaceListConfigParser::build(ConstElementPtr value) {
void
InterfaceListConfigParser
::
commit
()
{
// Do nothing. CfgMgr has been updated during build.
// Use the new configuration created in a build time.
CfgMgr
::
instance
().
getConfiguration
()
->
cfg_iface_
=
cfg_iface_
;
}
bool
...
...
src/lib/dhcpsrv/dhcp_parsers.h
View file @
69c2e41c
...
...
@@ -20,6 +20,7 @@
#include
<dhcp/option_definition.h>
#include
<dhcpsrv/d2_client_cfg.h>
#include
<dhcpsrv/dhcp_config_parser.h>
#include
<dhcpsrv/cfg_iface.h>
#include
<dhcpsrv/option_space_container.h>
#include
<dhcpsrv/subnet.h>
#include
<exceptions/exceptions.h>
...
...
@@ -406,7 +407,9 @@ public:
/// @param value pointer to the content of parsed values
virtual
void
build
(
isc
::
data
::
ConstElementPtr
value
);
/// @brief Does nothing.
/// @brief Assignes a parsed list of interfaces to the configuration.
///
/// This is exception safe operation.
virtual
void
commit
();
private:
...
...
@@ -424,6 +427,9 @@ private:
// Parsed parameter name
std
::
string
param_name_
;
/// Holds the configuration created during
CfgIface
cfg_iface_
;
};
/// @brief Parser for hooks library list
...
...
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
View file @
69c2e41c
...
...
@@ -236,6 +236,7 @@ TEST_F(DhcpParserTest, interfaceListParserTest) {
// This should parse the configuration and add eth0 and eth1 to the list
// of interfaces that server should listen on.
parser
->
build
(
list_element
);
parser
->
commit
();
// Use CfgMgr instance to check if eth0 and eth1 was added, and that
// eth2 was not added.
...
...
@@ -257,6 +258,7 @@ TEST_F(DhcpParserTest, interfaceListParserTest) {
cfg
->
cfg_iface_
.
reset
();
parser
->
build
(
list_element
);
parser
->
commit
();
ASSERT_NO_THROW
(
cfg
->
cfg_iface_
.
openSockets
(
10000
));
EXPECT_TRUE
(
test_config
.
socketOpen
(
"eth0"
,
AF_INET
));
...
...
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