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
890e0b0b
Commit
890e0b0b
authored
Jan 04, 2013
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2545] Moved DhcpConfigParser abstract class to common header file.
parent
d83fc2a1
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
149 additions
and
210 deletions
+149
-210
src/bin/dhcp4/config_parser.cc
src/bin/dhcp4/config_parser.cc
+28
-28
src/bin/dhcp4/config_parser.h
src/bin/dhcp4/config_parser.h
+1
-91
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
+2
-1
src/bin/dhcp6/config_parser.h
src/bin/dhcp6/config_parser.h
+1
-88
src/bin/dhcp6/tests/config_parser_unittest.cc
src/bin/dhcp6/tests/config_parser_unittest.cc
+1
-1
src/lib/dhcpsrv/Makefile.am
src/lib/dhcpsrv/Makefile.am
+1
-0
src/lib/dhcpsrv/dhcp_config_parser.h
src/lib/dhcpsrv/dhcp_config_parser.h
+114
-0
No files found.
src/bin/dhcp4/config_parser.cc
View file @
890e0b0b
// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012
-2013
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
@@ -18,6 +18,7 @@
#include <dhcp/libdhcp++.h>
#include <dhcp/option_definition.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/dhcp_config_parser.h>
#include <util/encode/hex.h>
#include <util/strutil.h>
#include <boost/foreach.hpp>
...
...
@@ -36,12 +37,11 @@ using namespace isc::asiolink;
namespace
{
/// @brief auxiliary type used for storing element name and its parser
typedef
pair
<
string
,
ConstElementPtr
>
ConfigPair
;
/// @brief a factory method that will create a parser for a given element name
typedef
isc
::
dhcp
::
Dhcp
4
ConfigParser
*
ParserFactory
(
const
std
::
string
&
config_id
);
typedef
isc
::
dhcp
::
DhcpConfigParser
*
ParserFactory
(
const
std
::
string
&
config_id
);
/// @brief a collection of factories that creates parsers for specified element names
typedef
std
::
map
<
std
::
string
,
ParserFactory
*>
FactoryMap
;
...
...
@@ -81,12 +81,12 @@ OptionStorage option_defaults;
/// will accept any configuration and will just print it out
/// on commit. Useful for debugging existing configurations and
/// adding new ones.
class
DebugParser
:
public
Dhcp
4
ConfigParser
{
class
DebugParser
:
public
DhcpConfigParser
{
public:
/// @brief Constructor
///
/// See @ref Dhcp
4
ConfigParser class for details.
/// See @ref DhcpConfigParser class for details.
///
/// @param param_name name of the parsed parameter
DebugParser
(
const
std
::
string
&
param_name
)
...
...
@@ -95,7 +95,7 @@ public:
/// @brief builds parameter value
///
/// See @ref Dhcp
4
ConfigParser class for details.
/// See @ref DhcpConfigParser class for details.
///
/// @param new_config pointer to the new configuration
virtual
void
build
(
ConstElementPtr
new_config
)
{
...
...
@@ -109,7 +109,7 @@ public:
/// This is a method required by base class. It pretends to apply the
/// configuration, but in fact it only prints the parameter out.
///
/// See @ref Dhcp
4
ConfigParser class for details.
/// See @ref DhcpConfigParser class for details.
virtual
void
commit
()
{
// Debug message. The whole DebugParser class is used only for parser
// debugging, and is not used in production code. It is very convenient
...
...
@@ -121,7 +121,7 @@ public:
/// @brief factory that constructs DebugParser objects
///
/// @param param_name name of the parameter to be parsed
static
Dhcp
4
ConfigParser
*
Factory
(
const
std
::
string
&
param_name
)
{
static
DhcpConfigParser
*
Factory
(
const
std
::
string
&
param_name
)
{
return
(
new
DebugParser
(
param_name
));
}
...
...
@@ -138,7 +138,7 @@ private:
/// This parser handles configuration values of the boolean type.
/// Parsed values are stored in a provided storage. If no storage
/// is provided then the build function throws an exception.
class
BooleanParser
:
public
Dhcp
4
ConfigParser
{
class
BooleanParser
:
public
DhcpConfigParser
{
public:
/// @brief Constructor.
///
...
...
@@ -189,7 +189,7 @@ public:
///
/// @param param_name name of the parameter for which the
/// parser is created.
static
Dhcp
4
ConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
static
DhcpConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
return
(
new
BooleanParser
(
param_name
));
}
...
...
@@ -219,11 +219,11 @@ private:
/// (uint32_defaults). If used in smaller scopes (e.g. to parse parameters
/// in subnet config), it can be pointed to a different storage, using
/// setStorage() method. This class follows the parser interface, laid out
/// in its base class, @ref Dhcp
4
ConfigParser.
/// in its base class, @ref DhcpConfigParser.
///
/// For overview of usability of this generic purpose parser, see
/// @ref dhcpv4ConfigInherit page.
class
Uint32Parser
:
public
Dhcp
4
ConfigParser
{
class
Uint32Parser
:
public
DhcpConfigParser
{
public:
/// @brief constructor for Uint32Parser
...
...
@@ -282,7 +282,7 @@ public:
/// @brief factory that constructs Uint32Parser objects
///
/// @param param_name name of the parameter to be parsed
static
Dhcp
4
ConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
static
DhcpConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
return
(
new
Uint32Parser
(
param_name
));
}
...
...
@@ -313,11 +313,11 @@ private:
/// (string_defaults). If used in smaller scopes (e.g. to parse parameters
/// in subnet config), it can be pointed to a different storage, using
/// setStorage() method. This class follows the parser interface, laid out
/// in its base class, @ref Dhcp
4
ConfigParser.
/// in its base class, @ref DhcpConfigParser.
///
/// For overview of usability of this generic purpose parser, see
/// @ref dhcpv4ConfigInherit page.
class
StringParser
:
public
Dhcp
4
ConfigParser
{
class
StringParser
:
public
DhcpConfigParser
{
public:
/// @brief constructor for StringParser
...
...
@@ -354,7 +354,7 @@ public:
/// @brief factory that constructs StringParser objects
///
/// @param param_name name of the parameter to be parsed
static
Dhcp
4
ConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
static
DhcpConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
return
(
new
StringParser
(
param_name
));
}
...
...
@@ -387,7 +387,7 @@ private:
/// designates all interfaces.
///
/// It is useful for parsing Dhcp4/interface parameter.
class
InterfaceListConfigParser
:
public
Dhcp
4
ConfigParser
{
class
InterfaceListConfigParser
:
public
DhcpConfigParser
{
public:
/// @brief constructor
...
...
@@ -425,7 +425,7 @@ public:
/// @brief factory that constructs InterfaceListConfigParser objects
///
/// @param param_name name of the parameter to be parsed
static
Dhcp
4
ConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
static
DhcpConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
return
(
new
InterfaceListConfigParser
(
param_name
));
}
...
...
@@ -444,7 +444,7 @@ private:
/// before build(). Otherwise exception will be thrown.
///
/// It is useful for parsing Dhcp4/subnet4[X]/pool parameters.
class
PoolParser
:
public
Dhcp
4
ConfigParser
{
class
PoolParser
:
public
DhcpConfigParser
{
public:
/// @brief constructor.
...
...
@@ -552,7 +552,7 @@ public:
/// @brief factory that constructs PoolParser objects
///
/// @param param_name name of the parameter to be parsed
static
Dhcp
4
ConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
static
DhcpConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
return
(
new
PoolParser
(
param_name
));
}
...
...
@@ -580,7 +580,7 @@ private:
/// (see tickets #2319, #2314). When option spaces are implemented
/// there will be a way to reference the particular option using
/// its type (code) or option name.
class
OptionDataParser
:
public
Dhcp
4
ConfigParser
{
class
OptionDataParser
:
public
DhcpConfigParser
{
public:
/// @brief Constructor.
...
...
@@ -884,7 +884,7 @@ private:
/// data for a particular subnet and creates a collection of options.
/// If parsing is successful, all these options are added to the Subnet
/// object.
class
OptionDataListParser
:
public
Dhcp
4
ConfigParser
{
class
OptionDataListParser
:
public
DhcpConfigParser
{
public:
/// @brief Constructor.
...
...
@@ -941,7 +941,7 @@ public:
/// @param param_name param name.
///
/// @return DhcpConfigParser object.
static
Dhcp
4
ConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
static
DhcpConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
return
(
new
OptionDataListParser
(
param_name
));
}
...
...
@@ -960,7 +960,7 @@ public:
///
/// This class parses the whole subnet definition. It creates parsers
/// for received configuration parameters as needed.
class
Subnet4ConfigParser
:
public
Dhcp
4
ConfigParser
{
class
Subnet4ConfigParser
:
public
DhcpConfigParser
{
public:
/// @brief constructor
...
...
@@ -1159,7 +1159,7 @@ private:
/// @param config_id name od the entry
/// @return parser object for specified entry name
/// @throw NotImplemented if trying to create a parser for unknown config element
Dhcp
4
ConfigParser
*
createSubnet4ConfigParser
(
const
std
::
string
&
config_id
)
{
DhcpConfigParser
*
createSubnet4ConfigParser
(
const
std
::
string
&
config_id
)
{
FactoryMap
factories
;
factories
[
"valid-lifetime"
]
=
Uint32Parser
::
factory
;
...
...
@@ -1238,7 +1238,7 @@ private:
/// This is a wrapper parser that handles the whole list of Subnet4
/// definitions. It iterates over all entries and creates Subnet4ConfigParser
/// for each entry.
class
Subnets4ListConfigParser
:
public
Dhcp
4
ConfigParser
{
class
Subnets4ListConfigParser
:
public
DhcpConfigParser
{
public:
/// @brief constructor
...
...
@@ -1286,7 +1286,7 @@ public:
/// @brief Returns Subnet4ListConfigParser object
/// @param param_name name of the parameter
/// @return Subnets4ListConfigParser object
static
Dhcp
4
ConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
static
DhcpConfigParser
*
factory
(
const
std
::
string
&
param_name
)
{
return
(
new
Subnets4ListConfigParser
(
param_name
));
}
...
...
@@ -1308,7 +1308,7 @@ 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 config element
Dhcp
4
ConfigParser
*
createGlobalDhcp4ConfigParser
(
const
std
::
string
&
config_id
)
{
DhcpConfigParser
*
createGlobalDhcp4ConfigParser
(
const
std
::
string
&
config_id
)
{
FactoryMap
factories
;
factories
[
"valid-lifetime"
]
=
Uint32Parser
::
factory
;
...
...
src/bin/dhcp4/config_parser.h
View file @
890e0b0b
// Copyright (C) 2012
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012
-2013
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
@@ -42,96 +42,6 @@ public:
:
isc
::
Exception
(
file
,
line
,
what
)
{}
};
/// @brief Forward declaration to Dhcp4ConfigParser class.
///
/// It is only needed here to define types that are
/// based on this class before the class definition.
class
Dhcp4ConfigParser
;
/// @brief a pointer to configuration parser
typedef
boost
::
shared_ptr
<
Dhcp4ConfigParser
>
ParserPtr
;
/// @brief a collection of parsers
///
/// This container is used to store pointer to parsers for a given scope.
typedef
std
::
vector
<
ParserPtr
>
ParserCollection
;
/// @brief Base abstract class for all DHCPv4 parsers
///
/// Each instance of a class derived from this class parses one specific config
/// element. Sometimes elements are simple (e.g. a string) and sometimes quite
/// complex (e.g. a subnet). In such case, it is likely that a parser will
/// spawn child parsers to parse child elements in the configuration.
/// @todo: Merge this class with DhcpConfigParser in src/bin/dhcp6
class
Dhcp4ConfigParser
{
///
/// @name Constructors and Destructor
///
/// Note: The copy constructor and the assignment operator are
/// intentionally defined as private to make it explicit that this is a
/// pure base class.
//@{
private:
// Private construtor and assignment operator assures that nobody
// will be able to copy or assign a parser. There are no defined
// bodies for them.
Dhcp4ConfigParser
(
const
Dhcp4ConfigParser
&
source
);
Dhcp4ConfigParser
&
operator
=
(
const
Dhcp4ConfigParser
&
source
);
protected:
/// @brief The default constructor.
///
/// This is intentionally defined as @c protected as this base class should
/// never be instantiated (except as part of a derived class).
Dhcp4ConfigParser
()
{}
public:
/// The destructor.
virtual
~
Dhcp4ConfigParser
()
{}
//@}
/// @brief Prepare configuration value.
///
/// This method parses the "value part" of the configuration identifier
/// that corresponds to this derived class and prepares a new value to
/// apply to the server.
///
/// This method must validate the given value both in terms of syntax
/// and semantics of the configuration, so that the server will be
/// validly configured at the time of @c commit(). Note: the given
/// configuration value is normally syntactically validated, but the
/// @c build() implementation must also expect invalid input. If it
/// detects an error it may throw an exception of a derived class
/// of @c isc::Exception.
///
/// Preparing a configuration value will often require resource
/// allocation. If it fails, it may throw a corresponding standard
/// exception.
///
/// This method is not expected to be called more than once in the
/// life of the object. Although multiple calls are not prohibited
/// by the interface, the behavior is undefined.
///
/// @param config_value The configuration value for the identifier
/// corresponding to the derived class.
virtual
void
build
(
isc
::
data
::
ConstElementPtr
config_value
)
=
0
;
/// @brief Apply the prepared configuration value to the server.
///
/// This method is expected to be exception free, and, as a consequence,
/// it should normally not involve resource allocation.
/// Typically it would simply perform exception free assignment or swap
/// operation on the value prepared in @c build().
/// In some cases, however, it may be very difficult to meet this
/// condition in a realistic way, while the failure case should really
/// be very rare. In such a case it may throw, and, if the parser is
/// called via @c configureDhcp4Server(), the caller will convert the
/// exception as a fatal error.
///
/// This method is expected to be called after @c build(), and only once.
/// The result is undefined otherwise.
virtual
void
commit
()
=
0
;
};
/// @brief Configure DHCPv4 server (@c Dhcpv4Srv) with a set of configuration values.
///
/// This function parses configuration information stored in @c config_set
...
...
src/bin/dhcp4/tests/config_parser_unittest.cc
View file @
890e0b0b
// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012
-2013
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
src/bin/dhcp6/config_parser.cc
View file @
890e0b0b
// Copyright (C) 2012
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012
-2013
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
@@ -19,6 +19,7 @@
#include <dhcp6/config_parser.h>
#include <dhcp6/dhcp6_log.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/dhcp_config_parser.h>
#include <dhcpsrv/pool.h>
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/triplet.h>
...
...
src/bin/dhcp6/config_parser.h
View file @
890e0b0b
// Copyright (C) 2012
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012
-2013
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
@@ -41,93 +41,6 @@ public:
:
isc
::
Exception
(
file
,
line
,
what
)
{}
};
/// @brief Forward declaration to DhcpConfigParser class.
///
/// It is only needed here to define types that are
/// based on this class before the class definition.
class
DhcpConfigParser
;
/// @brief a pointer to configuration parser
typedef
boost
::
shared_ptr
<
DhcpConfigParser
>
ParserPtr
;
/// @brief Collection of parsers.
///
/// This container is used to store pointer to parsers for a given scope.
typedef
std
::
vector
<
ParserPtr
>
ParserCollection
;
/// @brief Base abstract class for all DHCPv6 parsers
///
/// Each instance of a class derived from this class parses one specific config
/// element. Sometimes elements are simple (e.g. a string) and sometimes quite
/// complex (e.g. a subnet). In such case, it is likely that a parser will
/// spawn child parsers to parse child elements in the configuration.
/// @todo: Merge this class with Dhcp4ConfigParser in src/bin/dhcp4
class
DhcpConfigParser
{
/// @name Constructors and Destructor
///
/// Note: The copy constructor and the assignment operator are
/// intentionally defined as private to make it explicit that this is a
/// pure base class.
//@{
private:
DhcpConfigParser
(
const
DhcpConfigParser
&
source
);
DhcpConfigParser
&
operator
=
(
const
DhcpConfigParser
&
source
);
protected:
/// @brief The default constructor.
///
/// This is intentionally defined as @c protected as this base class should
/// never be instantiated (except as part of a derived class).
DhcpConfigParser
()
{}
public:
/// The destructor.
virtual
~
DhcpConfigParser
()
{}
//@}
/// \brief Prepare configuration value.
///
/// This method parses the "value part" of the configuration identifier
/// that corresponds to this derived class and prepares a new value to
/// apply to the server.
///
/// This method must validate the given value both in terms of syntax
/// and semantics of the configuration, so that the server will be
/// validly configured at the time of @c commit(). Note: the given
/// configuration value is normally syntactically validated, but the
/// @c build() implementation must also expect invalid input. If it
/// detects an error it may throw an exception of a derived class
/// of @c isc::Exception.
///
/// Preparing a configuration value will often require resource
/// allocation. If it fails, it may throw a corresponding standard
/// exception.
///
/// This method is not expected to be called more than once in the
/// life of the object. Although multiple calls are not prohibited
/// by the interface, the behavior is undefined.
///
/// @param config_value The configuration value for the identifier
/// corresponding to the derived class.
virtual
void
build
(
isc
::
data
::
ConstElementPtr
config_value
)
=
0
;
/// @brief Apply the prepared configuration value to the server.
///
/// This method is expected to be exception free, and, as a consequence,
/// it should normally not involve resource allocation.
/// Typically it would simply perform exception free assignment or swap
/// operation on the value prepared in @c build().
/// In some cases, however, it may be very difficult to meet this
/// condition in a realistic way, while the failure case should really
/// be very rare. In such a case it may throw, and, if the parser is
/// called via @c configureDhcp6Server(), the caller will convert the
/// exception as a fatal error.
///
/// This method is expected to be called after @c build(), and only once.
/// The result is undefined otherwise.
virtual
void
commit
()
=
0
;
};
/// @brief Configures DHCPv6 server
///
/// This function is called every time a new configuration is received. The extra
...
...
src/bin/dhcp6/tests/config_parser_unittest.cc
View file @
890e0b0b
// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012
-2013
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
src/lib/dhcpsrv/Makefile.am
View file @
890e0b0b
...
...
@@ -21,6 +21,7 @@ libb10_dhcpsrv_la_SOURCES =
libb10_dhcpsrv_la_SOURCES
+=
addr_utilities.cc addr_utilities.h
libb10_dhcpsrv_la_SOURCES
+=
alloc_engine.cc alloc_engine.h
libb10_dhcpsrv_la_SOURCES
+=
cfgmgr.cc cfgmgr.h
libb10_dhcpsrv_la_SOURCES
+=
dhcp_config_parser.h
libb10_dhcpsrv_la_SOURCES
+=
lease_mgr.cc lease_mgr.h
libb10_dhcpsrv_la_SOURCES
+=
lease_mgr_factory.cc lease_mgr_factory.h
libb10_dhcpsrv_la_SOURCES
+=
memfile_lease_mgr.cc memfile_lease_mgr.h
...
...
src/lib/dhcpsrv/dhcp_config_parser.h
0 → 100644
View file @
890e0b0b
// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#ifndef DHCP_CONFIG_PARSER_H
#define DHCP_CONFIG_PARSER_H
namespace
isc
{
namespace
dhcp
{
/// @brief Forward declaration to DhcpConfigParser class.
///
/// It is only needed here to define types that are
/// based on this class before the class definition.
class
DhcpConfigParser
;
/// @brief a pointer to configuration parser
typedef
boost
::
shared_ptr
<
DhcpConfigParser
>
ParserPtr
;
/// @brief Collection of parsers.
///
/// This container is used to store pointer to parsers for a given scope.
typedef
std
::
vector
<
ParserPtr
>
ParserCollection
;
/// @brief Base abstract class for all DHCP parsers
///
/// Each instance of a class derived from this class parses one specific config
/// element. Sometimes elements are simple (e.g. a string) and sometimes quite
/// complex (e.g. a subnet). In such case, it is likely that a parser will
/// spawn child parsers to parse child elements in the configuration.
class
DhcpConfigParser
{
///
/// @name Constructors and Destructor
///
/// Note: The copy constructor and the assignment operator are
/// intentionally defined as private to make it explicit that this is a
/// pure base class.
//@{
private:
// Private construtor and assignment operator assures that nobody
// will be able to copy or assign a parser. There are no defined
// bodies for them.
DhcpConfigParser
(
const
DhcpConfigParser
&
source
);
DhcpConfigParser
&
operator
=
(
const
DhcpConfigParser
&
source
);
protected:
/// @brief The default constructor.
///
/// This is intentionally defined as @c protected as this base class should
/// never be instantiated (except as part of a derived class).
DhcpConfigParser
()
{}
public:
/// The destructor.
virtual
~
DhcpConfigParser
()
{}
//@}
/// @brief Prepare configuration value.
///
/// This method parses the "value part" of the configuration identifier
/// that corresponds to this derived class and prepares a new value to
/// apply to the server.
///
/// This method must validate the given value both in terms of syntax
/// and semantics of the configuration, so that the server will be
/// validly configured at the time of @c commit(). Note: the given
/// configuration value is normally syntactically validated, but the
/// @c build() implementation must also expect invalid input. If it
/// detects an error it may throw an exception of a derived class
/// of @c isc::Exception.
///
/// Preparing a configuration value will often require resource
/// allocation. If it fails, it may throw a corresponding standard
/// exception.
///
/// This method is not expected to be called more than once in the
/// life of the object. Although multiple calls are not prohibited
/// by the interface, the behavior is undefined.
///
/// @param config_value The configuration value for the identifier
/// corresponding to the derived class.
virtual
void
build
(
isc
::
data
::
ConstElementPtr
config_value
)
=
0
;
/// @brief Apply the prepared configuration value to the server.
///
/// This method is expected to be exception free, and, as a consequence,
/// it should normally not involve resource allocation.
/// Typically it would simply perform exception free assignment or swap
/// operation on the value prepared in @c build().
/// In some cases, however, it may be very difficult to meet this
/// condition in a realistic way, while the failure case should really
/// be very rare. In such a case it may throw, and, if the parser is
/// called via @c configureDhcp4Server(), the caller will convert the
/// exception as a fatal error.
///
/// This method is expected to be called after @c build(), and only once.
/// The result is undefined otherwise.
virtual
void
commit
()
=
0
;
};
}
// end of isc::dhcp namespace
}
// end of isc namespace
#endif // DHCP_CONFIG_PARSER_H
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