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
445
Issues
445
List
Boards
Labels
Service Desk
Milestones
Merge Requests
71
Merge Requests
71
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
55205943
Commit
55205943
authored
Nov 12, 2012
by
Stephen Morris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2342] Miscellaneous changes as a result of review
parent
4e7a8f75
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
49 additions
and
66 deletions
+49
-66
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
+12
-21
src/bin/dhcp6/dhcp6_srv.h
src/bin/dhcp6/dhcp6_srv.h
+4
-1
src/lib/dhcp/Makefile.am
src/lib/dhcp/Makefile.am
+1
-2
src/lib/dhcp/lease_mgr.cc
src/lib/dhcp/lease_mgr.cc
+0
-7
src/lib/dhcp/lease_mgr.h
src/lib/dhcp/lease_mgr.h
+5
-4
src/lib/dhcp/lease_mgr_factory.cc
src/lib/dhcp/lease_mgr_factory.cc
+11
-13
src/lib/dhcp/lease_mgr_factory.h
src/lib/dhcp/lease_mgr_factory.h
+4
-4
src/lib/dhcp/memfile_lease_mgr.h
src/lib/dhcp/memfile_lease_mgr.h
+2
-2
src/lib/dhcp/mysql_lease_mgr.h
src/lib/dhcp/mysql_lease_mgr.h
+1
-2
src/lib/dhcp/tests/alloc_engine_unittest.cc
src/lib/dhcp/tests/alloc_engine_unittest.cc
+6
-10
src/lib/dhcp/tests/lease_mgr_factory_unittest.cc
src/lib/dhcp/tests/lease_mgr_factory_unittest.cc
+3
-0
No files found.
src/bin/dhcp6/dhcp6_srv.cc
View file @
55205943
...
...
@@ -39,10 +39,6 @@
#include <dhcp/cfgmgr.h>
#include <dhcp/option6_iaaddr.h>
// @todo: Replace this with MySQL_LeaseMgr (or a LeaseMgr factory)
// once it is merged
#include <dhcp/memfile_lease_mgr.h>
#include <boost/foreach.hpp>
using
namespace
isc
;
...
...
@@ -54,8 +50,8 @@ using namespace std;
namespace
isc
{
namespace
dhcp
{
Dhcpv6Srv
::
Dhcpv6Srv
(
uint16_t
port
)
:
alloc_engine_
(),
serverid_
(),
shutdown_
(
fals
e
)
{
Dhcpv6Srv
::
Dhcpv6Srv
(
uint16_t
port
,
const
char
*
dbconfig
)
:
alloc_engine_
(),
serverid_
(),
shutdown_
(
tru
e
)
{
LOG_DEBUG
(
dhcp6_logger
,
DBG_DHCP6_START
,
DHCP6_OPEN_SOCKET
).
arg
(
port
);
...
...
@@ -74,7 +70,6 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port) : alloc_engine_(), serverid_(),
if
(
port
>
0
)
{
if
(
IfaceMgr
::
instance
().
countIfaces
()
==
0
)
{
LOG_ERROR
(
dhcp6_logger
,
DHCP6_NO_INTERFACES
);
shutdown_
=
true
;
return
;
}
IfaceMgr
::
instance
().
openSockets6
(
port
);
...
...
@@ -82,25 +77,21 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port) : alloc_engine_(), serverid_(),
setServerID
();
// Instantiate LeaseMgr
LeaseMgrFactory
::
create
(
dbconfig
);
LOG_INFO
(
dhcp6_logger
,
DHCP6_DB_BACKEND_STARTED
)
.
arg
(
LeaseMgrFactory
::
instance
().
getName
());
// Instantiate allocation engine
alloc_engine_
.
reset
(
new
AllocEngine
(
AllocEngine
::
ALLOC_ITERATIVE
,
100
));
}
catch
(
const
std
::
exception
&
e
)
{
LOG_ERROR
(
dhcp6_logger
,
DHCP6_SRV_CONSTRUCT_ERROR
).
arg
(
e
.
what
());
shutdown_
=
true
;
return
;
}
// Instantiate LeaseMgr
// @todo: Replace this with MySQL_LeaseMgr (or a LeaseMgr factory)
// once it is merged
#ifdef HAVE_MYSQL
LeaseMgrFactory
::
create
(
"type=mysql user=kea password=kea name=kea host=localhost"
);
#else
LeaseMgrFactory
::
create
(
"type=memfile"
);
#endif
LOG_INFO
(
dhcp6_logger
,
DHCP6_DB_BACKEND_STARTED
)
.
arg
(
LeaseMgrFactory
::
instance
().
getName
());
// Instantiate allocation engine
alloc_engine_
.
reset
(
new
AllocEngine
(
AllocEngine
::
ALLOC_ITERATIVE
,
100
));
// All done, so can proceed
shutdown_
=
false
;
}
Dhcpv6Srv
::~
Dhcpv6Srv
()
{
...
...
src/bin/dhcp6/dhcp6_srv.h
View file @
55205943
...
...
@@ -57,7 +57,10 @@ public:
/// old or create new DUID.
///
/// @param port port on will all sockets will listen
Dhcpv6Srv
(
uint16_t
port
=
DHCP6_SERVER_PORT
);
/// @param dbconfig Lease manager configuration string. The default
/// of the "memfile" manager is used for testing.
Dhcpv6Srv
(
uint16_t
port
=
DHCP6_SERVER_PORT
,
const
char
*
dbconfig
=
"type=memfile"
);
/// @brief Destructor. Used during DHCPv6 service shutdown.
virtual
~
Dhcpv6Srv
();
...
...
src/lib/dhcp/Makefile.am
View file @
55205943
...
...
@@ -59,8 +59,7 @@ libb10_dhcpsrv_la_SOURCES += triplet.h
libb10_dhcpsrv_la_CXXFLAGS
=
$(AM_CXXFLAGS)
libb10_dhcpsrv_la_CPPFLAGS
=
$(AM_CPPFLAGS)
$(LOG4CPLUS_INCLUDES)
libb10_dhcpsrv_la_LIBADD
=
$(top_builddir)
/src/lib/dhcp/libb10-dhcp++.la
libb10_dhcpsrv_la_LIBADD
+=
$(top_builddir)
/src/lib/asiolink/libb10-asiolink.la
libb10_dhcpsrv_la_LIBADD
=
$(top_builddir)
/src/lib/asiolink/libb10-asiolink.la
libb10_dhcpsrv_la_LIBADD
+=
$(top_builddir)
/src/lib/util/libb10-util.la
libb10_dhcpsrv_la_LDFLAGS
=
-no-undefined
-version-info
2:0:0
if
HAVE_MYSQL
...
...
src/lib/dhcp/lease_mgr.cc
View file @
55205943
...
...
@@ -96,10 +96,3 @@ Lease6::operator==(const Lease6& other) const {
subnet_id_
==
other
.
subnet_id_
);
}
LeaseMgr
::
LeaseMgr
(
const
LeaseMgr
::
ParameterMap
&
parameters
)
:
parameters_
(
parameters
)
{
}
LeaseMgr
::~
LeaseMgr
()
{
}
src/lib/dhcp/lease_mgr.h
View file @
55205943
...
...
@@ -179,7 +179,7 @@ struct Lease4 {
/// @brief Constructor
///
/// Initialize fields that don't have a default constructor.
/// @
TODO
Remove this
/// @
todo
Remove this
Lease4
()
:
addr_
(
0
)
{}
};
...
...
@@ -345,10 +345,12 @@ public:
///
/// @param parameters A data structure relating keywords and values
/// concerned with the database.
LeaseMgr
(
const
ParameterMap
&
parameters
);
LeaseMgr
(
const
ParameterMap
&
parameters
)
:
parameters_
(
parameters
)
{}
/// @brief Destructor
~
LeaseMgr
();
virtual
~
LeaseMgr
()
{}
/// @brief Adds an IPv4 lease.
///
...
...
@@ -389,7 +391,6 @@ public:
/// a single lease, not a container of leases.
///
/// @param addr address of the searched lease
/// @param subnet_id ID of the subnet the lease must belong to
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual
Lease4Ptr
getLease4
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
=
0
;
...
...
src/lib/dhcp/lease_mgr_factory.cc
View file @
55205943
...
...
@@ -14,25 +14,23 @@
#include "config.h"
#include <dhcp/lease_mgr_factory.h>
#include <dhcp/memfile_lease_mgr.h>
#ifdef HAVE_MYSQL
#include <dhcp/mysql_lease_mgr.h>
#endif
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <map>
#include <sstream>
#include <string>
#include <utility>
#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/algorithm/string.hpp>
#include <exceptions/exceptions.h>
#include <dhcp/lease_mgr_factory.h>
#include <dhcp/memfile_lease_mgr.h>
#ifdef HAVE_MYSQL
#include <dhcp/mysql_lease_mgr.h>
#endif
using
namespace
std
;
namespace
isc
{
...
...
@@ -48,7 +46,7 @@ LeaseMgr::ParameterMap
LeaseMgrFactory
::
parse
(
const
std
::
string
&
dbconfig
)
{
LeaseMgr
::
ParameterMap
mapped_tokens
;
if
(
!
dbconfig
.
empty
())
{
if
(
!
dbconfig
.
empty
())
{
vector
<
string
>
tokens
;
// We need to pass a string to is_any_of, not just char*. Otherwise
...
...
src/lib/dhcp/lease_mgr_factory.h
View file @
55205943
...
...
@@ -51,7 +51,7 @@ public:
/// Strictly speaking these functions could be stand-alone functions. However,
/// it is convenient to encapsulate them in a class for naming purposes.
///
/// @
TODO
: Will need to develop some form of registration mechanism for
/// @
todo
: Will need to develop some form of registration mechanism for
/// user-supplied backends (so that there is no need to modify the code).
class
LeaseMgrFactory
{
public:
...
...
@@ -62,8 +62,8 @@ public:
/// appropriate type. The actual lease manager is returned by the
/// "instance" method.
///
///
Note: when called, the current lease manager is *always*
destroyed
/// and a new one created - even if the parameters are the same.
///
@note When called, the current lease manager is <b>always</b>
destroyed
///
and a new one created - even if the parameters are the same.
///
/// dbconfig is a generic way of passing parameters. Parameters are passed
/// in the "name=value" format, separated by spaces. The data MUST include
...
...
@@ -104,7 +104,7 @@ public:
///
/// @param dbconfig Database configuration string
///
/// @return std::map<
>
std::string, std::string> Map of keyword/value pairs.
/// @return std::map<std::string, std::string> Map of keyword/value pairs.
static
LeaseMgr
::
ParameterMap
parse
(
const
std
::
string
&
dbconfig
);
private:
...
...
src/lib/dhcp/memfile_lease_mgr.h
View file @
55205943
...
...
@@ -169,7 +169,7 @@ public:
///
/// @todo Not implemented yet
///
/// @param lease
4
The lease to be updated.
/// @param lease
6
The lease to be updated.
///
/// If no such lease is present, an exception will be thrown.
void
updateLease6
(
const
Lease6Ptr
&
lease6
);
...
...
@@ -237,5 +237,5 @@ protected:
};
// end of isc::dhcp namespace
};
// end of isc namespace
#endif // MEMFILE_LEASE_MGR
_HSE4
#endif // MEMFILE_LEASE_MGR
src/lib/dhcp/mysql_lease_mgr.h
View file @
55205943
...
...
@@ -111,7 +111,6 @@ public:
/// a single lease, not a container of leases.
///
/// @param addr address of the searched lease
/// @param subnet_id ID of the subnet the lease must belong to
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual
Lease4Ptr
getLease4
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
;
...
...
@@ -327,7 +326,7 @@ public:
///
/// @param expire Reference to MYSQL_TIME object from where the expiry
/// time of the lease is taken.
/// @param
lease_
time lifetime of the lease.
/// @param
valid_life
time lifetime of the lease.
/// @param cltt Reference to location where client last transmit time
/// is put.
static
...
...
src/lib/dhcp/tests/alloc_engine_unittest.cc
View file @
55205943
...
...
@@ -95,15 +95,13 @@ public:
// This test checks if the Allocation Engine can be instantiated and that it
// parses parameters string properly.
TEST_F
(
AllocEngineTest
,
constructor
)
{
AllocEngine
*
x
=
NULL
;
boost
::
scoped_ptr
<
AllocEngine
>
x
;
// Hashed and random allocators are not supported yet
ASSERT_THROW
(
x
=
new
AllocEngine
(
AllocEngine
::
ALLOC_HASHED
,
5
),
NotImplemented
);
ASSERT_THROW
(
x
=
new
AllocEngine
(
AllocEngine
::
ALLOC_RANDOM
,
5
),
NotImplemented
);
ASSERT_THROW
(
x
.
reset
(
new
AllocEngine
(
AllocEngine
::
ALLOC_HASHED
,
5
)
),
NotImplemented
);
ASSERT_THROW
(
x
.
reset
(
new
AllocEngine
(
AllocEngine
::
ALLOC_RANDOM
,
5
)
),
NotImplemented
);
ASSERT_NO_THROW
(
x
=
new
AllocEngine
(
AllocEngine
::
ALLOC_ITERATIVE
,
100
));
delete
x
;
ASSERT_NO_THROW
(
x
.
reset
(
new
AllocEngine
(
AllocEngine
::
ALLOC_ITERATIVE
,
100
)));
}
/// @todo: This method is taken from mysql_lease_mgr_utilities.cc from ticket
...
...
@@ -269,15 +267,13 @@ TEST_F(AllocEngineTest, allocBogusHint) {
// This test verifies that the allocator picks addresses that belong to the
// pool
TEST_F
(
AllocEngineTest
,
IterativeAllocator
)
{
NakedAllocEngine
::
Allocator
*
alloc
=
new
NakedAllocEngine
::
IterativeAllocator
();
boost
::
scoped_ptr
<
NakedAllocEngine
::
Allocator
>
alloc
(
new
NakedAllocEngine
::
IterativeAllocator
());
for
(
int
i
=
0
;
i
<
1000
;
++
i
)
{
IOAddress
candidate
=
alloc
->
pickAddress
(
subnet_
,
duid_
,
IOAddress
(
"::"
));
EXPECT_TRUE
(
subnet_
->
inPool
(
candidate
));
}
delete
alloc
;
}
...
...
src/lib/dhcp/tests/lease_mgr_factory_unittest.cc
View file @
55205943
...
...
@@ -23,6 +23,9 @@
using
namespace
std
;
using
namespace
isc
::
dhcp
;
// This set of tests only check the parsing functions of LeaseMgrFactory.
// Tests of the LeaseMgr create/instance/destroy are implicitly carried out
// in the tests for the different concrete lease managers (e.g. MySqlLeaseMgr).
namespace
{
// empty class for now, but may be extended once Addr6 becomes bigger
...
...
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