Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
49f67aaf
Commit
49f67aaf
authored
Jun 09, 2016
by
Marcin Siodelski
Browse files
[master] Merge branch 'trac3572'
parents
d610482f
2487e1e2
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/dhcp4_srv.cc
View file @
49f67aaf
...
...
@@ -924,13 +924,21 @@ void
Dhcpv4Srv
::
buildCfgOptionList
(
Dhcpv4Exchange
&
ex
)
{
CfgOptionList
&
co_list
=
ex
.
getCfgOptionList
();
//
First subnet configured options
//
Retrieve subnet.
Subnet4Ptr
subnet
=
ex
.
getContext
()
->
subnet_
;
if
(
!
subnet
)
{
// All methods using the CfgOptionList object return soon when
// there is no subnet so do the same
return
;
}
// Firstly, host specific options.
const
ConstHostPtr
&
host
=
ex
.
getContext
()
->
host_
;
if
(
host
&&
!
host
->
getCfgOption4
()
->
empty
())
{
co_list
.
push_back
(
host
->
getCfgOption4
());
}
// Secondly, subnet configured options.
if
(
!
subnet
->
getCfgOption
()
->
empty
())
{
co_list
.
push_back
(
subnet
->
getCfgOption
());
}
...
...
src/bin/dhcp4/tests/Makefile.am
View file @
49f67aaf
...
...
@@ -89,6 +89,7 @@ dhcp4_unittests_SOURCES += dhcp4_client.cc dhcp4_client.h
dhcp4_unittests_SOURCES
+=
hooks_unittest.cc
dhcp4_unittests_SOURCES
+=
inform_unittest.cc
dhcp4_unittests_SOURCES
+=
dora_unittest.cc
dhcp4_unittests_SOURCES
+=
host_options_unittest.cc
dhcp4_unittests_SOURCES
+=
release_unittest.cc
dhcp4_unittests_SOURCES
+=
out_of_range_unittest.cc
dhcp4_unittests_SOURCES
+=
decline_unittest.cc
...
...
src/bin/dhcp4/tests/dhcp4_client.cc
View file @
49f67aaf
...
...
@@ -8,6 +8,7 @@
#include
<dhcp/dhcp4.h>
#include
<dhcp/option.h>
#include
<dhcp/option_int_array.h>
#include
<dhcp/option_vendor.h>
#include
<dhcpsrv/lease.h>
#include
<dhcp4/tests/dhcp4_client.h>
#include
<util/range_utilities.h>
...
...
@@ -163,13 +164,19 @@ Dhcp4Client::applyConfiguration() {
Option4AddrLstPtr
opt_log_servers
=
boost
::
dynamic_pointer_cast
<
Option4AddrLst
>
(
resp
->
getOption
(
DHO_LOG_SERVERS
));
if
(
opt_log_servers
)
{
config_
.
log_servers_
=
opt_
rout
ers
->
getAddresses
();
config_
.
log_servers_
=
opt_
log_serv
ers
->
getAddresses
();
}
// Quotes Servers
Option4AddrLstPtr
opt_quotes_servers
=
boost
::
dynamic_pointer_cast
<
Option4AddrLst
>
(
resp
->
getOption
(
DHO_COOKIE_SERVERS
));
if
(
opt_quotes_servers
)
{
config_
.
quotes_servers_
=
opt_dns_servers
->
getAddresses
();
config_
.
quotes_servers_
=
opt_quotes_servers
->
getAddresses
();
}
// Vendor Specific options
OptionVendorPtr
opt_vendor
=
boost
::
dynamic_pointer_cast
<
OptionVendor
>
(
resp
->
getOption
(
DHO_VIVSO_SUBOPTIONS
));
if
(
opt_vendor
)
{
config_
.
vendor_suboptions_
=
opt_vendor
->
getOptions
();
}
// Server Identifier
OptionCustomPtr
opt_serverid
=
boost
::
dynamic_pointer_cast
<
...
...
@@ -254,6 +261,8 @@ Dhcp4Client::doInform(const bool set_ciaddr) {
context_
.
query_
=
createMsg
(
DHCPINFORM
);
// Request options if any.
appendPRL
();
// Any other options to be sent by a client.
appendExtraOptions
();
// The client sending a DHCPINFORM message has an IP address obtained
// by some other means, e.g. static configuration. The lease which we
// are using here is most likely set by the createLease method.
...
...
@@ -368,6 +377,8 @@ Dhcp4Client::doRequest() {
appendName
();
// Include Client Identifier
appendClientId
();
// Any other options to be sent by a client.
appendExtraOptions
();
// Send the message to the server.
sendMsg
(
context_
.
query_
);
// Expect response.
...
...
src/bin/dhcp4/tests/dhcp4_client.h
View file @
49f67aaf
...
...
@@ -9,6 +9,7 @@
#include
<asiolink/io_address.h>
#include
<dhcp/hwaddr.h>
#include
<dhcp/option.h>
#include
<dhcp/pkt4.h>
#include
<dhcp4/tests/dhcp4_test_utils.h>
#include
<util/optional_value.h>
...
...
@@ -73,6 +74,8 @@ public:
Option4AddrLst
::
AddressContainer
log_servers_
;
/// @brief Holds IP addresses received in the Quotes Servers option.
Option4AddrLst
::
AddressContainer
quotes_servers_
;
/// @brief Vendor Specific options
OptionCollection
vendor_suboptions_
;
/// @brief Holds a lease obtained by the client.
Lease4
lease_
;
/// @brief Holds server id of the server which responded to the client's
...
...
src/bin/dhcp4/tests/host_options_unittest.cc
0 → 100644
View file @
49f67aaf
This diff is collapsed.
Click to expand it.
src/bin/dhcp4/tests/inform_unittest.cc
View file @
49f67aaf
// Copyright (C) 2014-201
5
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2014-201
6
Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
...
...
@@ -58,11 +58,11 @@ const char* INFORM_CONFIGS[] = {
" },"
" {"
"
\"
name
\"
:
\"
log-servers
\"
,"
"
\"
data
\"
:
\"
10.0.0.20
0
,10.0.0.20
1
\"
"
"
\"
data
\"
:
\"
10.0.0.20
2
,10.0.0.20
3
\"
"
" },"
" {"
"
\"
name
\"
:
\"
cookie-servers
\"
,"
"
\"
data
\"
:
\"
10.0.0.20
2
,10.0.0.20
3
\"
"
"
\"
data
\"
:
\"
10.0.0.20
0
,10.0.0.20
1
\"
"
" } ]"
" } ]"
"}"
,
...
...
@@ -159,12 +159,12 @@ TEST_F(InformTest, directClientBroadcast) {
EXPECT_EQ
(
"10.0.0.203"
,
client
.
config_
.
dns_servers_
[
1
].
toText
());
// Make sure that the Log Servers option has been received.
ASSERT_EQ
(
2
,
client
.
config_
.
quotes_servers_
.
size
());
EXPECT_EQ
(
"10.0.0.200"
,
client
.
config_
.
rout
ers_
[
0
].
toText
());
EXPECT_EQ
(
"10.0.0.201"
,
client
.
config_
.
rout
ers_
[
1
].
toText
());
EXPECT_EQ
(
"10.0.0.200"
,
client
.
config_
.
quotes_serv
ers_
[
0
].
toText
());
EXPECT_EQ
(
"10.0.0.201"
,
client
.
config_
.
quotes_serv
ers_
[
1
].
toText
());
// Make sure that the Quotes Servers option has been received.
ASSERT_EQ
(
2
,
client
.
config_
.
log_servers_
.
size
());
EXPECT_EQ
(
"10.0.0.202"
,
client
.
config_
.
dns
_servers_
[
0
].
toText
());
EXPECT_EQ
(
"10.0.0.203"
,
client
.
config_
.
dns
_servers_
[
1
].
toText
());
EXPECT_EQ
(
"10.0.0.202"
,
client
.
config_
.
log
_servers_
[
0
].
toText
());
EXPECT_EQ
(
"10.0.0.203"
,
client
.
config_
.
log
_servers_
[
1
].
toText
());
// Check that we can send another DHCPINFORM message using
// different ciaddr and we will get the configuration.
...
...
@@ -313,14 +313,14 @@ TEST_F(InformTest, relayedClient) {
ASSERT_EQ
(
2
,
client
.
config_
.
dns_servers_
.
size
());
EXPECT_EQ
(
"192.0.2.202"
,
client
.
config_
.
dns_servers_
[
0
].
toText
());
EXPECT_EQ
(
"192.0.2.203"
,
client
.
config_
.
dns_servers_
[
1
].
toText
());
// Make sure that the Log Servers option has been received.
ASSERT_EQ
(
2
,
client
.
config_
.
quotes_servers_
.
size
());
EXPECT_EQ
(
"192.0.2.200"
,
client
.
config_
.
routers_
[
0
].
toText
());
EXPECT_EQ
(
"192.0.2.201"
,
client
.
config_
.
routers_
[
1
].
toText
());
// Make sure that the Quotes Servers option has been received.
ASSERT_EQ
(
2
,
client
.
config_
.
quotes_servers_
.
size
());
EXPECT_EQ
(
"10.0.0.202"
,
client
.
config_
.
quotes_servers_
[
0
].
toText
());
EXPECT_EQ
(
"10.0.0.203"
,
client
.
config_
.
quotes_servers_
[
1
].
toText
());
// Make sure that the Log Servers option has been received.
ASSERT_EQ
(
2
,
client
.
config_
.
log_servers_
.
size
());
EXPECT_EQ
(
"1
92
.0.
2
.20
2
"
,
client
.
config_
.
dns
_servers_
[
0
].
toText
());
EXPECT_EQ
(
"1
92
.0.
2
.20
3
"
,
client
.
config_
.
dns
_servers_
[
1
].
toText
());
EXPECT_EQ
(
"1
0
.0.
0
.20
0
"
,
client
.
config_
.
log
_servers_
[
0
].
toText
());
EXPECT_EQ
(
"1
0
.0.
0
.20
1
"
,
client
.
config_
.
log
_servers_
[
1
].
toText
());
}
// This test checks that the server can respond to the DHCPINFORM message
...
...
src/lib/dhcp/std_option_defs.h
View file @
49f67aaf
...
...
@@ -211,7 +211,19 @@ const OptionDefParams OPTION_DEF_PARAMS4[] = {
{
"domain-search"
,
DHO_DOMAIN_SEARCH
,
OPT_BINARY_TYPE
,
false
,
NO_RECORD_DEF
,
""
},
{
"vivco-suboptions"
,
DHO_VIVCO_SUBOPTIONS
,
OPT_RECORD_TYPE
,
false
,
RECORD_DEF
(
VIVCO_RECORDS
),
""
},
{
"vivso-suboptions"
,
DHO_VIVSO_SUBOPTIONS
,
OPT_BINARY_TYPE
,
// Vendor-Identifying Vendor Specific Information option payload begins with a
// 32-bit log enterprise number, followed by a tuple of data-len/option-data.
// The format defined here includes 32-bit field holding enterprise number.
// This allows for specifying option-data information where the enterprise-id
// is represented by a uint32_t value. Previously we represented this option
// as a binary, but that would imply that enterprise number would have to be
// represented in binary format in the server configuration. That would be
// inconvenient and non-intuitive.
/// @todo We need to extend support for vendor options with ability to specify
/// multiple enterprise numbers for a single option. Perhaps it would be
/// ok to specify multiple instances of the "vivso-suboptions" which will be
/// combined in a single option by the server before responding to a client.
{
"vivso-suboptions"
,
DHO_VIVSO_SUBOPTIONS
,
OPT_UINT32_TYPE
,
false
,
NO_RECORD_DEF
,
""
}
// @todo add definitions for all remaning options.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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