Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
426
Issues
426
List
Boards
Labels
Service Desk
Milestones
Merge Requests
66
Merge Requests
66
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
194f7617
Commit
194f7617
authored
Dec 19, 2018
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[
#99
,
!176
] Implemented test config backend for DHCPv4.
parent
7fbbfde2
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
398 additions
and
79 deletions
+398
-79
src/lib/cc/stamped_value.h
src/lib/cc/stamped_value.h
+41
-5
src/lib/dhcp/option_definition.h
src/lib/dhcp/option_definition.h
+11
-0
src/lib/dhcpsrv/cfg_option.h
src/lib/dhcpsrv/cfg_option.h
+35
-0
src/lib/dhcpsrv/shared_network.h
src/lib/dhcpsrv/shared_network.h
+18
-1
src/lib/dhcpsrv/subnet.h
src/lib/dhcpsrv/subnet.h
+19
-1
src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc
src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc
+271
-72
src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.h
src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.h
+3
-0
No files found.
src/lib/cc/stamped_value.h
View file @
194f7617
...
...
@@ -8,6 +8,10 @@
#define STAMPED_VALUE_H
#include <cc/stamped_element.h>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/mem_fun.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/shared_ptr.hpp>
#include <cstdint>
#include <string>
...
...
@@ -20,9 +24,6 @@ class StampedValue;
/// @brief Pointer to the stamped value.
typedef
boost
::
shared_ptr
<
StampedValue
>
StampedValuePtr
;
/// @brief Collection of pointers to values.
typedef
std
::
vector
<
StampedValuePtr
>
StampedValueCollection
;
/// @brief This class represents string or signed integer configuration
/// element associated with the modification timestamp.
///
...
...
@@ -91,8 +92,43 @@ private:
std
::
string
value_
;
};
/// @brief Pointer to the stamped value.
typedef
boost
::
shared_ptr
<
StampedValue
>
StampedValuePtr
;
/// @name Definition of the multi index container for @c StampedValue.
///
//@{
/// @brief Tag for the index for access by value name.
struct
StampedValueNameIndexTag
{
};
/// @brief Tag for the index for access by modification time.
struct
StampedValueModificationTimeIndexTag
{
};
/// @brief Multi index container for @c StampedValue.
typedef
boost
::
multi_index_container
<
StampedValuePtr
,
boost
::
multi_index
::
indexed_by
<
// Index used to access value by name.
boost
::
multi_index
::
hashed_non_unique
<
boost
::
multi_index
::
tag
<
StampedValueNameIndexTag
>
,
boost
::
multi_index
::
const_mem_fun
<
StampedValue
,
std
::
string
,
&
StampedValue
::
getName
>
>
,
// Index used to access value by modification time.
boost
::
multi_index
::
ordered_non_unique
<
boost
::
multi_index
::
tag
<
StampedValueModificationTimeIndexTag
>
,
boost
::
multi_index
::
const_mem_fun
<
StampedElement
,
boost
::
posix_time
::
ptime
,
&
StampedElement
::
getModificationTime
>
>
>
>
StampedValueCollection
;
//@}
}
// end of namespace isc::data
}
// end of namespace isc
...
...
src/lib/dhcp/option_definition.h
View file @
194f7617
...
...
@@ -15,6 +15,7 @@
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/mem_fun.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/shared_ptr.hpp>
...
...
@@ -811,6 +812,16 @@ typedef boost::multi_index_container<
std
::
string
,
&
OptionDefinition
::
getName
>
>
,
// Start definition of index #3
boost
::
multi_index
::
ordered_non_unique
<
// Use option definition modification time as the index key.
// This value is returned by the StampedElement::getModificationTime
boost
::
multi_index
::
const_mem_fun
<
data
::
StampedElement
,
boost
::
posix_time
::
ptime
,
&
data
::
StampedElement
::
getModificationTime
>
>
>
>
OptionDefContainer
;
...
...
src/lib/dhcpsrv/cfg_option.h
View file @
194f7617
...
...
@@ -15,6 +15,7 @@
#include <dhcpsrv/key_from_key.h>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/mem_fun.hpp>
#include <boost/multi_index/member.hpp>
...
...
@@ -198,6 +199,15 @@ typedef boost::multi_index_container<
bool
,
&
OptionDescriptor
::
persistent_
>
>
,
// Start definition of index #3.
// Use StampedElement::getModificationTime as a key.
boost
::
multi_index
::
ordered_non_unique
<
boost
::
multi_index
::
const_mem_fun
<
data
::
StampedElement
,
boost
::
posix_time
::
ptime
,
&
data
::
StampedElement
::
getModificationTime
>
>
>
>
OptionContainer
;
...
...
@@ -404,6 +414,31 @@ public:
return
(
*
od_itr
);
}
/// @brief Deletes option for the specified key and option code.
///
/// The key should be a string, in which case it specifies an option space
/// name, or an uint32_t value, in which case it specifies a vendor
/// identifier.
///
/// @param key Option space name or vendor identifier.
/// @param option_code Code of the option to be returned.
/// @tparam Selector one of: @c std::string or @c uint32_t
///
/// @return Number of deleted options.
template
<
typename
Selector
>
size_t
del
(
const
Selector
&
key
,
const
uint16_t
option_code
)
{
// Check for presence of options.
OptionContainerPtr
options
=
getAll
(
key
);
if
(
!
options
||
options
->
empty
())
{
// There are no options, so there is nothing to do.
return
(
0
);
}
// Some options present, locate the one we are interested in.
auto
&
idx
=
options
->
get
<
1
>
();
return
(
idx
.
erase
(
option_code
));
}
/// @brief Returns a list of configured option space names.
///
/// The returned option space names exclude vendor option spaces,
...
...
src/lib/dhcpsrv/shared_network.h
View file @
194f7617
...
...
@@ -34,6 +34,10 @@ struct SharedNetworkNameIndexTag { };
/// @brief A tag for accessing index by server identifier.
struct
SharedNetworkServerIdIndexTag
{
};
/// @brief Tag for the index for searching by shared network modification
/// time.
struct
SharedNetworkModificationTimeIndexTag
{
};
/// @brief Shared network holding IPv4 subnets.
///
/// Specialization of the @ref Network4 class for IPv4 shared networks.
...
...
@@ -188,8 +192,14 @@ typedef boost::multi_index_container<
boost
::
multi_index
::
tag
<
SharedNetworkServerIdIndexTag
>
,
boost
::
multi_index
::
const_mem_fun
<
Network4
,
asiolink
::
IOAddress
,
&
Network4
::
getServerId
>
>
,
// Fourth index allows for searching using subnet modification time.
boost
::
multi_index
::
ordered_non_unique
<
boost
::
multi_index
::
tag
<
SharedNetworkModificationTimeIndexTag
>
,
boost
::
multi_index
::
const_mem_fun
<
data
::
StampedElement
,
boost
::
posix_time
::
ptime
,
&
data
::
StampedElement
::
getModificationTime
>
>
>
>
SharedNetwork4Collection
;
...
...
@@ -340,6 +350,13 @@ typedef boost::multi_index_container<
boost
::
multi_index
::
tag
<
SharedNetworkNameIndexTag
>
,
boost
::
multi_index
::
const_mem_fun
<
SharedNetwork6
,
std
::
string
,
&
SharedNetwork6
::
getName
>
>
,
// Third index allows for searching using subnet modification time.
boost
::
multi_index
::
ordered_non_unique
<
boost
::
multi_index
::
tag
<
SharedNetworkModificationTimeIndexTag
>
,
boost
::
multi_index
::
const_mem_fun
<
data
::
StampedElement
,
boost
::
posix_time
::
ptime
,
&
data
::
StampedElement
::
getModificationTime
>
>
>
>
SharedNetwork6Collection
;
...
...
src/lib/dhcpsrv/subnet.h
View file @
194f7617
...
...
@@ -744,6 +744,9 @@ struct SubnetPrefixIndexTag { };
/// @brief Tag for the index for searching by server identifier.
struct
SubnetServerIdIndexTag
{
};
/// @brief Tag for the index for searching by subnet modification time.
struct
SubnetModificationTimeIndexTag
{
};
/// @brief A collection of @c Subnet4 objects
///
/// This container provides a set of indexes which can be used to retrieve
...
...
@@ -788,11 +791,19 @@ typedef boost::multi_index_container<
boost
::
multi_index
::
const_mem_fun
<
Subnet
,
std
::
string
,
&
Subnet
::
toText
>
>
,
// Fourth index allows for searching using an output from getServerId
// Fourth index allows for searching using an output from getServerId
.
boost
::
multi_index
::
ordered_non_unique
<
boost
::
multi_index
::
tag
<
SubnetServerIdIndexTag
>
,
boost
::
multi_index
::
const_mem_fun
<
Network4
,
asiolink
::
IOAddress
,
&
Network4
::
getServerId
>
>
,
// Fifth index allows for searching using subnet modification time.
boost
::
multi_index
::
ordered_non_unique
<
boost
::
multi_index
::
tag
<
SubnetModificationTimeIndexTag
>
,
boost
::
multi_index
::
const_mem_fun
<
data
::
StampedElement
,
boost
::
posix_time
::
ptime
,
&
data
::
StampedElement
::
getModificationTime
>
>
>
>
Subnet4Collection
;
...
...
@@ -838,6 +849,13 @@ typedef boost::multi_index_container<
boost
::
multi_index
::
ordered_unique
<
boost
::
multi_index
::
tag
<
SubnetPrefixIndexTag
>
,
boost
::
multi_index
::
const_mem_fun
<
Subnet
,
std
::
string
,
&
Subnet
::
toText
>
>
,
// Fourth index allows for searching using subnet modification time.
boost
::
multi_index
::
ordered_non_unique
<
boost
::
multi_index
::
tag
<
SubnetModificationTimeIndexTag
>
,
boost
::
multi_index
::
const_mem_fun
<
data
::
StampedElement
,
boost
::
posix_time
::
ptime
,
&
data
::
StampedElement
::
getModificationTime
>
>
>
>
Subnet6Collection
;
...
...
src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc
View file @
194f7617
This diff is collapsed.
Click to expand it.
src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.h
View file @
194f7617
...
...
@@ -16,6 +16,9 @@
#include <boost/shared_ptr.hpp>
#include <boost/lexical_cast.hpp>
#include <map>
#include <string>
namespace
isc
{
namespace
dhcp
{
namespace
test
{
...
...
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