Skip to content
GitLab
Menu
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
08499ad4
Commit
08499ad4
authored
Dec 01, 2015
by
Tomek Mrugalski
🛰
Browse files
[3569_rebase] alternate_source renamed, added comments
parent
1e2e2274
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/host_mgr.cc
View file @
08499ad4
...
...
@@ -49,12 +49,20 @@ HostMgr::create(const std::string& access) {
getHostMgrPtr
().
reset
(
new
HostMgr
());
if
(
!
access
.
empty
())
{
// If the user specified parameters, let's pass them to the create
// method. It will destroy any prior instances and will create
// the new one.
HostDataSourceFactory
::
create
(
access
);
}
else
{
// Ok, no parameters were specified. We should destroy the existing
// insteance.
HostDataSourceFactory
::
destroy
();
}
// Now store the host data source pointer.
getHostMgrPtr
()
->
alternate_source
=
HostDataSourceFactory
::
getHostDataSourcePtr
();
// Now store the host data source pointer. It may be NULL. That's ok as
// NULL value indicates that there's no host data source configured.
getHostMgrPtr
()
->
alternate_source_
=
HostDataSourceFactory
::
getHostDataSourcePtr
();
}
HostMgr
&
...
...
@@ -69,8 +77,8 @@ HostMgr::instance() {
ConstHostCollection
HostMgr
::
getAll
(
const
HWAddrPtr
&
hwaddr
,
const
DuidPtr
&
duid
)
const
{
ConstHostCollection
hosts
=
getCfgHosts
()
->
getAll
(
hwaddr
,
duid
);
if
(
alternate_source
)
{
ConstHostCollection
hosts_plus
=
alternate_source
->
getAll
(
hwaddr
,
duid
);
if
(
alternate_source
_
)
{
ConstHostCollection
hosts_plus
=
alternate_source
_
->
getAll
(
hwaddr
,
duid
);
hosts
.
insert
(
hosts
.
end
(),
hosts_plus
.
begin
(),
hosts_plus
.
end
());
}
return
(
hosts
);
...
...
@@ -79,8 +87,8 @@ HostMgr::getAll(const HWAddrPtr& hwaddr, const DuidPtr& duid) const {
ConstHostCollection
HostMgr
::
getAll4
(
const
IOAddress
&
address
)
const
{
ConstHostCollection
hosts
=
getCfgHosts
()
->
getAll4
(
address
);
if
(
alternate_source
)
{
ConstHostCollection
hosts_plus
=
alternate_source
->
getAll4
(
address
);
if
(
alternate_source
_
)
{
ConstHostCollection
hosts_plus
=
alternate_source
_
->
getAll4
(
address
);
hosts
.
insert
(
hosts
.
end
(),
hosts_plus
.
begin
(),
hosts_plus
.
end
());
}
return
(
hosts
);
...
...
@@ -90,13 +98,13 @@ ConstHostPtr
HostMgr
::
get4
(
const
SubnetID
&
subnet_id
,
const
HWAddrPtr
&
hwaddr
,
const
DuidPtr
&
duid
)
const
{
ConstHostPtr
host
=
getCfgHosts
()
->
get4
(
subnet_id
,
hwaddr
,
duid
);
if
(
!
host
&&
alternate_source
)
{
if
(
!
host
&&
alternate_source
_
)
{
LOG_DEBUG
(
hosts_logger
,
HOSTS_DBG_TRACE
,
HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_HWADDR_DUID
)
.
arg
(
subnet_id
)
.
arg
(
hwaddr
?
hwaddr
->
toText
()
:
"(no-hwaddr)"
)
.
arg
(
duid
?
duid
->
toText
()
:
"(duid)"
);
host
=
alternate_source
->
get4
(
subnet_id
,
hwaddr
,
duid
);
host
=
alternate_source
_
->
get4
(
subnet_id
,
hwaddr
,
duid
);
}
return
(
host
);
}
...
...
@@ -105,12 +113,12 @@ ConstHostPtr
HostMgr
::
get4
(
const
SubnetID
&
subnet_id
,
const
asiolink
::
IOAddress
&
address
)
const
{
ConstHostPtr
host
=
getCfgHosts
()
->
get4
(
subnet_id
,
address
);
if
(
!
host
&&
alternate_source
)
{
if
(
!
host
&&
alternate_source
_
)
{
LOG_DEBUG
(
hosts_logger
,
HOSTS_DBG_TRACE
,
HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_ADDRESS4
)
.
arg
(
subnet_id
)
.
arg
(
address
.
toText
());
host
=
alternate_source
->
get4
(
subnet_id
,
address
);
host
=
alternate_source
_
->
get4
(
subnet_id
,
address
);
}
return
(
host
);
}
...
...
@@ -120,13 +128,13 @@ ConstHostPtr
HostMgr
::
get6
(
const
SubnetID
&
subnet_id
,
const
DuidPtr
&
duid
,
const
HWAddrPtr
&
hwaddr
)
const
{
ConstHostPtr
host
=
getCfgHosts
()
->
get6
(
subnet_id
,
duid
,
hwaddr
);
if
(
!
host
&&
alternate_source
)
{
if
(
!
host
&&
alternate_source
_
)
{
LOG_DEBUG
(
hosts_logger
,
HOSTS_DBG_TRACE
,
HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_DUID_HWADDR
)
.
arg
(
subnet_id
)
.
arg
(
duid
?
duid
->
toText
()
:
"(duid)"
)
.
arg
(
hwaddr
?
hwaddr
->
toText
()
:
"(no-hwaddr)"
);
host
=
alternate_source
->
get6
(
subnet_id
,
duid
,
hwaddr
);
host
=
alternate_source
_
->
get6
(
subnet_id
,
duid
,
hwaddr
);
}
return
(
host
);
}
...
...
@@ -134,12 +142,12 @@ HostMgr::get6(const SubnetID& subnet_id, const DuidPtr& duid,
ConstHostPtr
HostMgr
::
get6
(
const
IOAddress
&
prefix
,
const
uint8_t
prefix_len
)
const
{
ConstHostPtr
host
=
getCfgHosts
()
->
get6
(
prefix
,
prefix_len
);
if
(
!
host
&&
alternate_source
)
{
if
(
!
host
&&
alternate_source
_
)
{
LOG_DEBUG
(
hosts_logger
,
HOSTS_DBG_TRACE
,
HOSTS_MGR_ALTERNATE_GET6_PREFIX
)
.
arg
(
prefix
.
toText
())
.
arg
(
static_cast
<
int
>
(
prefix_len
));
host
=
alternate_source
->
get6
(
prefix
,
prefix_len
);
host
=
alternate_source
_
->
get6
(
prefix
,
prefix_len
);
}
return
(
host
);
}
...
...
@@ -148,12 +156,12 @@ ConstHostPtr
HostMgr
::
get6
(
const
SubnetID
&
subnet_id
,
const
asiolink
::
IOAddress
&
addr
)
const
{
ConstHostPtr
host
=
getCfgHosts
()
->
get6
(
subnet_id
,
addr
);
if
(
!
host
&&
alternate_source
)
{
if
(
!
host
&&
alternate_source
_
)
{
LOG_DEBUG
(
hosts_logger
,
HOSTS_DBG_TRACE
,
HOSTS_MGR_ALTERNATE_GET6_SUBNET_ID_ADDRESS6
)
.
arg
(
subnet_id
)
.
arg
(
addr
.
toText
());
host
=
alternate_source
->
get6
(
subnet_id
,
addr
);
host
=
alternate_source
_
->
get6
(
subnet_id
,
addr
);
}
return
(
host
);
}
...
...
src/lib/dhcpsrv/host_mgr.h
View file @
08499ad4
...
...
@@ -212,7 +212,7 @@ public:
/// May return NULL
/// @return pointer to the host data source (or NULL)
HostDataSourcePtr
getHostDataSource
()
const
{
return
(
alternate_source
);
return
(
alternate_source
_
);
}
private:
...
...
@@ -223,7 +223,7 @@ private:
/// @brief Pointer to an alternate host data source.
///
/// If this pointer is NULL, the source is not in use.
HostDataSourcePtr
alternate_source
;
HostDataSourcePtr
alternate_source
_
;
/// @brief Returns a pointer to the currently used instance of the
/// @c HostMgr.
...
...
src/lib/dhcpsrv/parsers/dbaccess_parser.cc
View file @
08499ad4
...
...
@@ -155,8 +155,9 @@ DbAccessParser::commit() {
case
HOSTS_DB
:
{
// Let's instantiate HostMgr with new parameters. Note that HostMgr's
// constructor will call HostDataSourceFactory::create() with appropriate
// parameters.
// create method will call HostDataSourceFactory::create() with
// appropriate parameters. It will also destroy a pre-existing
// instance, if it existed.
HostMgr
::
create
(
getDbAccessString
());
break
;
}
...
...
Write
Preview
Supports
Markdown
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