Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ISC Open Source Projects
Kea
Commits
42de7b42
Commit
42de7b42
authored
Jul 11, 2013
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[1555] Trivial: whitespace cleanup.
parent
339d60a7
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
255 additions
and
256 deletions
+255
-256
src/bin/dhcp4/config_parser.cc
src/bin/dhcp4/config_parser.cc
+41
-41
src/bin/dhcp4/config_parser.h
src/bin/dhcp4/config_parser.h
+2
-2
src/bin/dhcp4/tests/config_parser_unittest.cc
src/bin/dhcp4/tests/config_parser_unittest.cc
+1
-1
src/bin/dhcp6/config_parser.cc
src/bin/dhcp6/config_parser.cc
+40
-40
src/bin/dhcp6/config_parser.h
src/bin/dhcp6/config_parser.h
+3
-3
src/lib/dhcpsrv/dhcp_parsers.cc
src/lib/dhcpsrv/dhcp_parsers.cc
+65
-65
src/lib/dhcpsrv/dhcp_parsers.h
src/lib/dhcpsrv/dhcp_parsers.h
+62
-63
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
+41
-41
No files found.
src/bin/dhcp4/config_parser.cc
View file @
42de7b42
...
...
@@ -53,10 +53,10 @@ public:
/// @param dummy first param, option names are always "Dhcp4/option-data[n]"
/// @param options is the option storage in which to store the parsed option
/// upon "commit".
/// @param global_context is a pointer to the global context which
/// @param global_context is a pointer to the global context which
/// stores global scope parameters, options, option defintions.
Dhcp4OptionDataParser
(
const
std
::
string
&
,
OptionStoragePtr
options
,
ParserContextPtr
global_context
)
Dhcp4OptionDataParser
(
const
std
::
string
&
,
OptionStoragePtr
options
,
ParserContextPtr
global_context
)
:
OptionDataParser
(
""
,
options
,
global_context
)
{
}
...
...
@@ -64,7 +64,7 @@ public:
///
/// @param param_name name of the parameter to be parsed.
/// @param options storage where the parameter value is to be stored.
/// @param global_context is a pointer to the global context which
/// @param global_context is a pointer to the global context which
/// stores global scope parameters, options, option defintions.
/// @return returns a pointer to a new OptionDataParser. Caller is
/// is responsible for deleting it when it is no longer needed.
...
...
@@ -75,16 +75,16 @@ public:
protected:
/// @brief Finds an option definition within the server's option space
///
/// Given an option space and an option code, find the correpsonding
///
/// Given an option space and an option code, find the correpsonding
/// option defintion within the server's option defintion storage.
///
/// @param option_space name of the parameter option space
/// @param option_code numeric value of the parameter to find
/// @return OptionDefintionPtr of the option defintion or an
/// @param option_space name of the parameter option space
/// @param option_code numeric value of the parameter to find
/// @return OptionDefintionPtr of the option defintion or an
/// empty OptionDefinitionPtr if not found.
/// @throw DhcpConfigError if the option space requested is not valid
/// for this server.
/// @throw DhcpConfigError if the option space requested is not valid
/// for this server.
virtual
OptionDefinitionPtr
findServerSpaceOptionDefinition
(
std
::
string
&
option_space
,
uint32_t
option_code
)
{
OptionDefinitionPtr
def
;
...
...
@@ -100,11 +100,11 @@ protected:
}
};
/// @brief Parser for IPv4 pool definitions.
/// @brief Parser for IPv4 pool definitions.
///
/// This is the IPv4 derivation of the PoolParser class and handles pool
/// definitions, i.e. a list of entries of one of two syntaxes: min-max and
/// prefix/len for IPv4 pools. Pool4 objects are created and stored in chosen
/// This is the IPv4 derivation of the PoolParser class and handles pool
/// definitions, i.e. a list of entries of one of two syntaxes: min-max and
/// prefix/len for IPv4 pools. Pool4 objects are created and stored in chosen
/// PoolStorage container.
///
/// It is useful for parsing Dhcp4/subnet4[X]/pool parameters.
...
...
@@ -126,9 +126,9 @@ protected:
///
/// @param addr is the IPv4 prefix of the pool.
/// @param len is the prefix length.
/// @param ignored dummy parameter to provide symmetry between the
/// @param ignored dummy parameter to provide symmetry between the
/// PoolParser derivations. The V6 derivation requires a third value.
/// @return returns a PoolPtr to the new Pool4 object.
/// @return returns a PoolPtr to the new Pool4 object.
PoolPtr
poolMaker
(
IOAddress
&
addr
,
uint32_t
len
,
int32_t
)
{
return
(
PoolPtr
(
new
Pool4
(
addr
,
len
)));
}
...
...
@@ -137,9 +137,9 @@ protected:
///
/// @param min is the first IPv4 address in the pool.
/// @param max is the last IPv4 address in the pool.
/// @param ignored dummy parameter to provide symmetry between the
/// @param ignored dummy parameter to provide symmetry between the
/// PoolParser derivations. The V6 derivation requires a third value.
/// @return returns a PoolPtr to the new Pool4 object.
/// @return returns a PoolPtr to the new Pool4 object.
PoolPtr
poolMaker
(
IOAddress
&
min
,
IOAddress
&
max
,
int32_t
)
{
return
(
PoolPtr
(
new
Pool4
(
min
,
max
)));
}
...
...
@@ -147,8 +147,8 @@ protected:
/// @brief This class parses a single IPv4 subnet.
///
/// This is the IPv4 derivation of the SubnetConfigParser class and it parses
/// the whole subnet definition. It creates parsersfor received configuration
/// This is the IPv4 derivation of the SubnetConfigParser class and it parses
/// the whole subnet definition. It creates parsersfor received configuration
/// parameters as needed.
class
Subnet4ConfigParser
:
public
SubnetConfigParser
{
public:
...
...
@@ -158,7 +158,7 @@ public:
/// stores global scope parameters, options, option defintions.
Subnet4ConfigParser
(
const
std
::
string
&
)
:
SubnetConfigParser
(
""
,
globalContext
())
{
}
}
/// @brief Adds the created subnet to a server's configuration.
/// @throw throws Unexpected if dynamic cast fails.
...
...
@@ -167,7 +167,7 @@ public:
Subnet4Ptr
sub4ptr
=
boost
::
dynamic_pointer_cast
<
Subnet4
>
(
subnet_
);
if
(
!
sub4ptr
)
{
// If we hit this, it is a programming error.
isc_throw
(
Unexpected
,
isc_throw
(
Unexpected
,
"Invalid cast in Subnet4ConfigParser::commit"
);
}
...
...
@@ -191,13 +191,13 @@ protected:
(
config_id
.
compare
(
"renew-timer"
)
==
0
)
||
(
config_id
.
compare
(
"rebind-timer"
)
==
0
))
{
parser
=
new
Uint32Parser
(
config_id
,
uint32_values_
);
}
else
if
((
config_id
.
compare
(
"subnet"
)
==
0
)
||
}
else
if
((
config_id
.
compare
(
"subnet"
)
==
0
)
||
(
config_id
.
compare
(
"interface"
)
==
0
))
{
parser
=
new
StringParser
(
config_id
,
string_values_
);
}
else
if
(
config_id
.
compare
(
"pool"
)
==
0
)
{
parser
=
new
Pool4Parser
(
config_id
,
pools_
);
}
else
if
(
config_id
.
compare
(
"option-data"
)
==
0
)
{
parser
=
new
OptionDataListParser
(
config_id
,
options_
,
parser
=
new
OptionDataListParser
(
config_id
,
options_
,
global_context_
,
Dhcp4OptionDataParser
::
factory
);
}
else
{
...
...
@@ -210,7 +210,7 @@ protected:
/// @brief Determines if the given option space name and code describe
/// a standard option for the DCHP4 server.
/// a standard option for the DCHP4 server.
///
/// @param option_space is the name of the option space to consider
/// @param code is the numeric option code to consider
...
...
@@ -230,12 +230,12 @@ protected:
}
/// @brief Issues a DHCP4 server specific warning regarding duplicate subnet
/// options.
///
/// options.
///
/// @param code is the numeric option code of the duplicate option
/// @param addr is the subnet address
/// @param addr is the subnet address
/// @todo a means to know the correct logger and perhaps a common
/// message would allow this method to be emitted by the base class.
/// message would allow this method to be emitted by the base class.
virtual
void
duplicate_option_warning
(
uint32_t
code
,
isc
::
asiolink
::
IOAddress
&
addr
)
{
LOG_WARN
(
dhcp4_logger
,
DHCP4_CONFIG_OPTION_DUPLICATE
)
...
...
@@ -243,10 +243,10 @@ protected:
}
/// @brief Instantiates the IPv4 Subnet based on a given IPv4 address
/// and prefix length.
///
/// and prefix length.
///
/// @param addr is IPv4 address of the subnet.
/// @param len is the prefix length
/// @param len is the prefix length
void
initSubnet
(
isc
::
asiolink
::
IOAddress
addr
,
uint8_t
len
)
{
// Get all 'time' parameters using inheritance.
// If the subnet-specific value is defined then use it, else
...
...
@@ -338,32 +338,32 @@ namespace dhcp {
///
/// @param config_id pointer to received global configuration entry
/// @return parser for specified global DHCPv4 parameter
/// @throw NotImplemented if trying to create a parser for unknown
/// @throw NotImplemented if trying to create a parser for unknown
/// config element
DhcpConfigParser
*
createGlobalDhcp4ConfigParser
(
const
std
::
string
&
config_id
)
{
DhcpConfigParser
*
parser
=
NULL
;
if
((
config_id
.
compare
(
"valid-lifetime"
)
==
0
)
||
(
config_id
.
compare
(
"renew-timer"
)
==
0
)
||
(
config_id
.
compare
(
"rebind-timer"
)
==
0
))
{
parser
=
new
Uint32Parser
(
config_id
,
parser
=
new
Uint32Parser
(
config_id
,
globalContext
()
->
uint32_values_
);
}
else
if
(
config_id
.
compare
(
"interfaces"
)
==
0
)
{
parser
=
new
InterfaceListConfigParser
(
config_id
);
}
else
if
(
config_id
.
compare
(
"subnet4"
)
==
0
)
{
parser
=
new
Subnets4ListConfigParser
(
config_id
);
}
else
if
(
config_id
.
compare
(
"option-data"
)
==
0
)
{
parser
=
new
OptionDataListParser
(
config_id
,
globalContext
()
->
options_
,
parser
=
new
OptionDataListParser
(
config_id
,
globalContext
()
->
options_
,
globalContext
(),
Dhcp4OptionDataParser
::
factory
);
}
else
if
(
config_id
.
compare
(
"option-def"
)
==
0
)
{
parser
=
new
OptionDefListParser
(
config_id
,
parser
=
new
OptionDefListParser
(
config_id
,
globalContext
()
->
option_defs_
);
}
else
if
(
config_id
.
compare
(
"version"
)
==
0
)
{
parser
=
new
StringParser
(
config_id
,
parser
=
new
StringParser
(
config_id
,
globalContext
()
->
string_values_
);
}
else
if
(
config_id
.
compare
(
"lease-database"
)
==
0
)
{
parser
=
new
DbAccessParser
(
config_id
);
parser
=
new
DbAccessParser
(
config_id
);
}
else
{
isc_throw
(
NotImplemented
,
"Parser error: Global configuration parameter not supported: "
...
...
@@ -384,7 +384,7 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
/// @todo: Append most essential info here (like "2 new subnets configured")
string
config_details
;
LOG_DEBUG
(
dhcp4_logger
,
DBG_DHCP4_COMMAND
,
LOG_DEBUG
(
dhcp4_logger
,
DBG_DHCP4_COMMAND
,
DHCP4_CONFIG_START
).
arg
(
config_set
->
str
());
// Some of the values specified in the configuration depend on
...
...
src/bin/dhcp4/config_parser.h
View file @
42de7b42
...
...
@@ -30,7 +30,7 @@ namespace dhcp {
class
Dhcpv4Srv
;
/// @brief Configure DHCPv4 server (@c Dhcpv4Srv) with a set of configuration
/// @brief Configure DHCPv4 server (@c Dhcpv4Srv) with a set of configuration
/// values.
///
/// This function parses configuration information stored in @c config_set
...
...
@@ -44,7 +44,7 @@ class Dhcpv4Srv;
/// (such as malformed configuration or invalid configuration parameter),
/// this function returns appropriate error code.
///
/// This function is called every time a new configuration is received. The
/// This function is called every time a new configuration is received. The
/// extra parameter is a reference to DHCPv4 server component. It is currently
/// not used and CfgMgr::instance() is accessed instead.
///
...
...
src/bin/dhcp4/tests/config_parser_unittest.cc
View file @
42de7b42
...
...
@@ -56,7 +56,7 @@ public:
// Checks if global parameter of name have expected_value
void
checkGlobalUint32
(
string
name
,
uint32_t
expected_value
)
{
const
Uint32StoragePtr
uint32_defaults
=
const
Uint32StoragePtr
uint32_defaults
=
globalContext
()
->
uint32_values_
;
try
{
uint32_t
actual_value
=
uint32_defaults
->
getParam
(
name
);
...
...
src/bin/dhcp6/config_parser.cc
View file @
42de7b42
...
...
@@ -67,10 +67,10 @@ public:
/// @param dummy first param, option names are always "Dhcp6/option-data[n]"
/// @param options is the option storage in which to store the parsed option
/// upon "commit".
/// @param global_context is a pointer to the global context which
/// @param global_context is a pointer to the global context which
/// stores global scope parameters, options, option defintions.
Dhcp6OptionDataParser
(
const
std
::
string
&
,
OptionStoragePtr
options
,
ParserContextPtr
global_context
)
Dhcp6OptionDataParser
(
const
std
::
string
&
,
OptionStoragePtr
options
,
ParserContextPtr
global_context
)
:
OptionDataParser
(
""
,
options
,
global_context
)
{
}
...
...
@@ -78,7 +78,7 @@ public:
///
/// @param param_name name of the parameter to be parsed.
/// @param options storage where the parameter value is to be stored.
/// @param global_context is a pointer to the global context which
/// @param global_context is a pointer to the global context which
/// stores global scope parameters, options, option defintions.
/// @return returns a pointer to a new OptionDataParser. Caller is
/// is responsible for deleting it when it is no longer needed.
...
...
@@ -90,16 +90,16 @@ public:
protected:
/// @brief Finds an option definition within the server's option space
///
/// Given an option space and an option code, find the correpsonding
///
/// Given an option space and an option code, find the correpsonding
/// option defintion within the server's option defintion storage.
///
/// @param option_space name of the parameter option space
/// @param option_code numeric value of the parameter to find
/// @return OptionDefintionPtr of the option defintion or an
/// @param option_space name of the parameter option space
/// @param option_code numeric value of the parameter to find
/// @return OptionDefintionPtr of the option defintion or an
/// empty OptionDefinitionPtr if not found.
/// @throw DhcpConfigError if the option space requested is not valid
/// for this server.
/// @throw DhcpConfigError if the option space requested is not valid
/// for this server.
virtual
OptionDefinitionPtr
findServerSpaceOptionDefinition
(
std
::
string
&
option_space
,
uint32_t
option_code
)
{
OptionDefinitionPtr
def
;
...
...
@@ -115,11 +115,11 @@ protected:
}
};
/// @brief Parser for IPv4 pool definitions.
/// @brief Parser for IPv4 pool definitions.
///
/// This is the IPv6 derivation of the PoolParser class and handles pool
/// definitions, i.e. a list of entries of one of two syntaxes: min-max and
/// prefix/len for IPv6 pools. Pool6 objects are created and stored in chosen
/// This is the IPv6 derivation of the PoolParser class and handles pool
/// definitions, i.e. a list of entries of one of two syntaxes: min-max and
/// prefix/len for IPv6 pools. Pool6 objects are created and stored in chosen
/// PoolStorage container.
///
/// It is useful for parsing Dhcp6/subnet6[X]/pool parameters.
...
...
@@ -142,9 +142,9 @@ protected:
/// @param addr is the IPv6 prefix of the pool.
/// @param len is the prefix length.
/// @param ptype is the type of IPv6 pool (Pool6::Pool6Type). Note this is
/// passed in as an int32_t and cast to Pool6Type to accommodate a
/// passed in as an int32_t and cast to Pool6Type to accommodate a
/// polymorphic interface.
/// @return returns a PoolPtr to the new Pool4 object.
/// @return returns a PoolPtr to the new Pool4 object.
PoolPtr
poolMaker
(
IOAddress
&
addr
,
uint32_t
len
,
int32_t
ptype
)
{
return
(
PoolPtr
(
new
Pool6
(
static_cast
<
isc
::
dhcp
::
Pool6
::
Pool6Type
>
...
...
@@ -156,9 +156,9 @@ protected:
/// @param min is the first IPv6 address in the pool.
/// @param max is the last IPv6 address in the pool.
/// @param ptype is the type of IPv6 pool (Pool6::Pool6Type). Note this is
/// passed in as an int32_t and cast to Pool6Type to accommodate a
/// passed in as an int32_t and cast to Pool6Type to accommodate a
/// polymorphic interface.
/// @return returns a PoolPtr to the new Pool4 object.
/// @return returns a PoolPtr to the new Pool4 object.
PoolPtr
poolMaker
(
IOAddress
&
min
,
IOAddress
&
max
,
int32_t
ptype
)
{
return
(
PoolPtr
(
new
Pool6
(
static_cast
<
isc
::
dhcp
::
Pool6
::
Pool6Type
>
...
...
@@ -168,8 +168,8 @@ protected:
/// @brief This class parses a single IPv6 subnet.
///
/// This is the IPv6 derivation of the SubnetConfigParser class and it parses
/// the whole subnet definition. It creates parsersfor received configuration
/// This is the IPv6 derivation of the SubnetConfigParser class and it parses
/// the whole subnet definition. It creates parsersfor received configuration
/// parameters as needed.
class
Subnet6ConfigParser
:
public
SubnetConfigParser
{
public:
...
...
@@ -178,7 +178,7 @@ public:
///
/// @param ignored first parameter
/// stores global scope parameters, options, option defintions.
Subnet6ConfigParser
(
const
std
::
string
&
)
Subnet6ConfigParser
(
const
std
::
string
&
)
:
SubnetConfigParser
(
""
,
globalContext
())
{
}
...
...
@@ -220,7 +220,7 @@ protected:
}
else
if
(
config_id
.
compare
(
"pool"
)
==
0
)
{
parser
=
new
Pool6Parser
(
config_id
,
pools_
);
}
else
if
(
config_id
.
compare
(
"option-data"
)
==
0
)
{
parser
=
new
OptionDataListParser
(
config_id
,
options_
,
parser
=
new
OptionDataListParser
(
config_id
,
options_
,
global_context_
,
Dhcp6OptionDataParser
::
factory
);
}
else
{
...
...
@@ -233,14 +233,14 @@ protected:
/// @brief Determines if the given option space name and code describe
/// a standard option for the DHCP6 server.
/// a standard option for the DHCP6 server.
///
/// @param option_space is the name of the option space to consider
/// @param code is the numeric option code to consider
/// @return returns true if the space and code are part of the server's
/// standard options.
bool
isServerStdOption
(
std
::
string
option_space
,
uint32_t
code
)
{
return
((
option_space
.
compare
(
"dhcp6"
)
==
0
)
return
((
option_space
.
compare
(
"dhcp6"
)
==
0
)
&&
LibDHCP
::
isStandardOption
(
Option
::
V6
,
code
));
}
...
...
@@ -253,23 +253,23 @@ protected:
}
/// @brief Issues a DHCP6 server specific warning regarding duplicate subnet
/// options.
///
/// options.
///
/// @param code is the numeric option code of the duplicate option
/// @param addr is the subnet address
/// @todo A means to know the correct logger and perhaps a common
/// message would allow this message to be emitted by the base class.
virtual
void
duplicate_option_warning
(
uint32_t
code
,
virtual
void
duplicate_option_warning
(
uint32_t
code
,
isc
::
asiolink
::
IOAddress
&
addr
)
{
LOG_WARN
(
dhcp6_logger
,
DHCP6_CONFIG_OPTION_DUPLICATE
)
.
arg
(
code
).
arg
(
addr
.
toText
());
}
/// @brief Instantiates the IPv6 Subnet based on a given IPv6 address
/// and prefix length.
///
/// and prefix length.
///
/// @param addr is IPv6 prefix of the subnet.
/// @param len is the prefix length
/// @param len is the prefix length
void
initSubnet
(
isc
::
asiolink
::
IOAddress
addr
,
uint8_t
len
)
{
// Get all 'time' parameters using inheritance.
// If the subnet-specific value is defined then use it, else
...
...
@@ -292,13 +292,13 @@ protected:
// Specifying both interface for locally reachable subnets and
// interface id for relays is mutually exclusive. Need to test for
// this condition.
// this condition.
if
(
!
ifaceid
.
empty
())
{
std
::
string
iface
;
try
{
iface
=
string_values_
->
getParam
(
"interface"
);
}
catch
(
const
DhcpConfigError
&
)
{
// iface not mandatory
// iface not mandatory
}
if
(
!
iface
.
empty
())
{
...
...
@@ -403,7 +403,7 @@ namespace dhcp {
///
/// @param config_id pointer to received global configuration entry
/// @return parser for specified global DHCPv6 parameter
/// @throw NotImplemented if trying to create a parser for unknown config
/// @throw NotImplemented if trying to create a parser for unknown config
/// element
DhcpConfigParser
*
createGlobal6DhcpConfigParser
(
const
std
::
string
&
config_id
)
{
DhcpConfigParser
*
parser
=
NULL
;
...
...
@@ -411,22 +411,22 @@ DhcpConfigParser* createGlobal6DhcpConfigParser(const std::string& config_id) {
(
config_id
.
compare
(
"valid-lifetime"
)
==
0
)
||
(
config_id
.
compare
(
"renew-timer"
)
==
0
)
||
(
config_id
.
compare
(
"rebind-timer"
)
==
0
))
{
parser
=
new
Uint32Parser
(
config_id
,
parser
=
new
Uint32Parser
(
config_id
,
globalContext
()
->
uint32_values_
);
}
else
if
(
config_id
.
compare
(
"interfaces"
)
==
0
)
{
parser
=
new
InterfaceListConfigParser
(
config_id
);
}
else
if
(
config_id
.
compare
(
"subnet6"
)
==
0
)
{
parser
=
new
Subnets6ListConfigParser
(
config_id
);
}
else
if
(
config_id
.
compare
(
"option-data"
)
==
0
)
{
parser
=
new
OptionDataListParser
(
config_id
,
globalContext
()
->
options_
,
parser
=
new
OptionDataListParser
(
config_id
,
globalContext
()
->
options_
,
globalContext
(),
Dhcp6OptionDataParser
::
factory
);
}
else
if
(
config_id
.
compare
(
"option-def"
)
==
0
)
{
parser
=
new
OptionDefListParser
(
config_id
,
parser
=
new
OptionDefListParser
(
config_id
,
globalContext
()
->
option_defs_
);
}
else
if
(
config_id
.
compare
(
"version"
)
==
0
)
{
parser
=
new
StringParser
(
config_id
,
parser
=
new
StringParser
(
config_id
,
globalContext
()
->
string_values_
);
}
else
if
(
config_id
.
compare
(
"lease-database"
)
==
0
)
{
parser
=
new
DbAccessParser
(
config_id
);
...
...
@@ -450,7 +450,7 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
/// @todo: Append most essential info here (like "2 new subnets configured")
string
config_details
;
LOG_DEBUG
(
dhcp6_logger
,
DBG_DHCP6_COMMAND
,
LOG_DEBUG
(
dhcp6_logger
,
DBG_DHCP6_COMMAND
,
DHCP6_CONFIG_START
).
arg
(
config_set
->
str
());
// Some of the values specified in the configuration depend on
...
...
src/bin/dhcp6/config_parser.h
View file @
42de7b42
...
...
@@ -31,8 +31,8 @@ class Dhcpv6Srv;
/// @brief Configures DHCPv6 server
///
/// This function is called every time a new configuration is received. The
/// extra parameter is a reference to DHCPv6 server component. It is currently
/// This function is called every time a new configuration is received. The
/// extra parameter is a reference to DHCPv6 server component. It is currently
/// not used and CfgMgr::instance() is accessed instead.
///
/// This method does not throw. It catches all exceptions and returns them as
...
...
@@ -53,7 +53,7 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set);
///
/// @returns a reference to the global context
ParserContextPtr
&
globalContext
();
};
// end of isc::dhcp namespace
};
// end of isc namespace
...
...
src/lib/dhcpsrv/dhcp_parsers.cc
View file @
42de7b42
...
...
@@ -57,17 +57,17 @@ ParserContext::ParserContext(const ParserContext& rhs):
universe_
(
rhs
.
universe_
)
{
}
ParserContext
&
ParserContext
&
ParserContext
::
operator
=
(
const
ParserContext
&
rhs
)
{
if
(
this
!=
&
rhs
)
{
boolean_values_
=
boolean_values_
=
BooleanStoragePtr
(
new
BooleanStorage
(
*
(
rhs
.
boolean_values_
)));
uint32_values_
=
uint32_values_
=
Uint32StoragePtr
(
new
Uint32Storage
(
*
(
rhs
.
uint32_values_
)));
string_values_
=
string_values_
=
StringStoragePtr
(
new
StringStorage
(
*
(
rhs
.
string_values_
)));
options_
=
OptionStoragePtr
(
new
OptionStorage
(
*
(
rhs
.
options_
)));
option_defs_
=
option_defs_
=
OptionDefStoragePtr
(
new
OptionDefStorage
(
*
(
rhs
.
option_defs_
)));
universe_
=
rhs
.
universe_
;
}
...
...
@@ -81,14 +81,14 @@ DebugParser::DebugParser(const std::string& param_name)
:
param_name_
(
param_name
)
{
}
void
void
DebugParser
::
build
(
ConstElementPtr
new_config
)
{
value_
=
new_config
;
std
::
cout
<<
"Build for token: ["
<<
param_name_
<<
"] = ["
<<
value_
->
str
()
<<
"]"
<<
std
::
endl
;
<<
value_
->
str
()
<<
"]"
<<
std
::
endl
;
}
void
void
DebugParser
::
commit
()
{
// Debug message. The whole DebugParser class is used only for parser
// debugging, and is not used in production code. It is very convenient
...
...
@@ -106,7 +106,7 @@ template<> void ValueParser<bool>::build(isc::data::ConstElementPtr value) {
try
{
value_
=
value
->
boolValue
();
}
catch
(
const
isc
::
data
::
TypeError
&
)
{
isc_throw
(
BadValue
,
" Wrong value type for "
<<
param_name_
isc_throw
(
BadValue
,
" Wrong value type for "
<<
param_name_
<<
" : build called with a non-boolean element."
);
}
}
...
...
@@ -233,22 +233,22 @@ OptionDataParser::OptionDataParser(const std::string&, OptionStoragePtr options,
}
}
void
void
OptionDataParser
::
build
(
ConstElementPtr
option_data_entries
)
{
BOOST_FOREACH
(
ConfigPair
param
,
option_data_entries
->
mapValue
())
{
ParserPtr
parser
;
if
(
param
.
first
==
"name"
||
param
.
first
==
"data"
||
param
.
first
==
"space"
)
{
StringParserPtr
name_parser
(
new
StringParser
(
param
.
first
,
string_values_
));
StringParserPtr
name_parser
(
new
StringParser
(
param
.
first
,
string_values_
));
parser
=
name_parser
;
}
else
if
(
param
.
first
==
"code"
)
{
Uint32ParserPtr
code_parser
(
new
Uint32Parser
(
param
.
first
,
uint32_values_
));
Uint32ParserPtr
code_parser
(
new
Uint32Parser
(
param
.
first
,
uint32_values_
));
parser
=
code_parser
;
}
else
if
(
param
.
first
==
"csv-format"
)
{
BooleanParserPtr
value_parser
(
new
BooleanParser
(
param
.
first
,
boolean_values_
));
BooleanParserPtr
value_parser
(
new
BooleanParser
(
param
.
first
,
boolean_values_
));
parser
=
value_parser
;
}
else
{
isc_throw
(
DhcpConfigError
,
...
...
@@ -270,12 +270,12 @@ OptionDataParser::build(ConstElementPtr option_data_entries) {
createOption
();
}
void
void
OptionDataParser
::
commit
()
{
if
(
!
option_descriptor_
.
option
)
{
// Before we can commit the new option should be configured. If it is
// Before we can commit the new option should be configured. If it is
// not than somebody must have called commit() before build().
isc_throw
(
isc
::
InvalidOperation
,
isc_throw
(
isc
::
InvalidOperation
,
"parser logic error: no option has been configured and"
" thus there is nothing to commit. Has build() been called?"
);
}
...
...
@@ -299,7 +299,7 @@ OptionDataParser::commit() {
options_
->
addItem
(
option_descriptor_
,
option_space_
);
}
void
void
OptionDataParser
::
createOption
()
{
// Option code is held in the uint32_t storage but is supposed to
// be uint16_t value. We need to check that value in the configuration
...
...
@@ -316,7 +316,7 @@ OptionDataParser::createOption() {
// Check that the option name has been specified, is non-empty and does not
// contain spaces
std
::
string
option_name
=
string_values_
->
getParam
(
"name"
);
std
::
string
option_name
=
string_values_
->
getParam
(
"name"
);
if
(
option_name
.
empty
())
{
isc_throw
(
DhcpConfigError
,
"name of the option with code '"
<<
option_code
<<
"' is empty"
);
...
...
@@ -325,7 +325,7 @@ OptionDataParser::createOption() {
<<
"', space character is not allowed"
);
}
std
::
string
option_space
=
string_values_
->
getParam
(
"space"
);
std
::
string
option_space
=
string_values_
->
getParam
(
"space"
);
if
(
!
OptionSpace
::
validateName
(
option_space
))
{
isc_throw
(
DhcpConfigError
,
"invalid option space name '"
<<
option_space
<<
"' specified for option '"
...
...
@@ -341,7 +341,7 @@ OptionDataParser::createOption() {
// need to search for its definition among user-configured
// options. They are expected to be in the global storage
// already.
OptionDefContainerPtr
defs
=
OptionDefContainerPtr
defs
=
global_context_
->
option_defs_
->
getItems
(
option_space
);
// The getItems() should never return the NULL pointer. If there are
...
...
@@ -395,16 +395,16 @@ OptionDataParser::createOption() {
<<
" does not have a definition."
);
}
// @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 an error will be issued if an option
// @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 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
(
global_context_
->
universe_
,
OptionPtr
option
(
new
Option
(
global_context_
->
universe_
,
static_cast
<
uint16_t
>
(
option_code
),
binary
));
// 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
// The created option is stored in option_descriptor_ class member