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
Sebastian Schrader
Kea
Commits
8d8d0b5e
Commit
8d8d0b5e
authored
Apr 24, 2014
by
Thomas Markwalder
Browse files
[master] Merge branch 'trac3328'
Adds sender_ip,sender_port,max_queue_size to D2 client config
parents
5306438e
fab3d4c3
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
doc/guide/bind10-guide.xml
View file @
8d8d0b5e
This diff is collapsed.
Click to expand it.
src/bin/dhcp4/dhcp4.spec
View file @
8d8d0b5e
...
...
@@ -355,6 +355,27 @@
"item_default": 53001,
"item_description" : "port number of b10-dhcp-ddns"
},
{
"item_name": "sender-ip",
"item_type": "string",
"item_optional": true,
"item_default": "",
"item_description" : "IP address from which to send to b10-dhcp-ddns (IPv4 or IPv6)"
},
{
"item_name": "sender-port",
"item_type": "integer",
"item_optional": true,
"item_default": 0,
"item_description" : "port number from which to send to b10-dhcp-ddns"
},
{
"item_name": "max-queue-size",
"item_type": "integer",
"item_optional": true,
"item_default": 1024,
"item_description" : "maximum number of requests allowed in the send queue"
},
{
"item_name": "ncr-protocol",
"item_type": "string",
...
...
src/bin/dhcp4/tests/config_parser_unittest.cc
View file @
8d8d0b5e
...
...
@@ -2856,6 +2856,9 @@ TEST_F(Dhcp4ParserTest, d2ClientConfig) {
"
\"
enable-updates
\"
: true, "
"
\"
server-ip
\"
:
\"
192.168.2.1
\"
, "
"
\"
server-port
\"
: 777, "
"
\"
sender-ip
\"
:
\"
192.168.2.2
\"
, "
"
\"
sender-port
\"
: 778, "
"
\"
max-queue-size
\"
: 2048, "
"
\"
ncr-protocol
\"
:
\"
UDP
\"
, "
"
\"
ncr-format
\"
:
\"
JSON
\"
, "
"
\"
always-include-fqdn
\"
: true, "
...
...
@@ -2888,6 +2891,9 @@ TEST_F(Dhcp4ParserTest, d2ClientConfig) {
EXPECT_TRUE
(
d2_client_config
->
getEnableUpdates
());
EXPECT_EQ
(
"192.168.2.1"
,
d2_client_config
->
getServerIp
().
toText
());
EXPECT_EQ
(
777
,
d2_client_config
->
getServerPort
());
EXPECT_EQ
(
"192.168.2.2"
,
d2_client_config
->
getSenderIp
().
toText
());
EXPECT_EQ
(
778
,
d2_client_config
->
getSenderPort
());
EXPECT_EQ
(
2048
,
d2_client_config
->
getMaxQueueSize
());
EXPECT_EQ
(
dhcp_ddns
::
NCR_UDP
,
d2_client_config
->
getNcrProtocol
());
EXPECT_EQ
(
dhcp_ddns
::
FMT_JSON
,
d2_client_config
->
getNcrFormat
());
EXPECT_TRUE
(
d2_client_config
->
getAlwaysIncludeFqdn
());
...
...
src/bin/dhcp4/tests/d2_unittest.cc
View file @
8d8d0b5e
...
...
@@ -88,8 +88,11 @@ Dhcp4SrvD2Test::reset() {
void
Dhcp4SrvD2Test
::
configureD2
(
bool
enable_d2
,
const
bool
exp_result
,
const
std
::
string
&
ip_address
,
const
uint32_t
port
)
{
const
std
::
string
&
server_ip
,
const
size_t
port
,
const
std
::
string
&
sender_ip
,
const
size_t
sender_port
,
const
size_t
max_queue_size
)
{
std
::
ostringstream
config
;
config
<<
"{
\"
interfaces
\"
: [
\"
*
\"
],"
...
...
@@ -100,8 +103,11 @@ Dhcp4SrvD2Test::configureD2(bool enable_d2, const bool exp_result,
"
\"
subnet
\"
:
\"
192.0.2.0/24
\"
} ],"
"
\"
dhcp-ddns
\"
: {"
"
\"
enable-updates
\"
: "
<<
(
enable_d2
?
"true"
:
"false"
)
<<
", "
"
\"
server-ip
\"
:
\"
"
<<
ip_address
<<
"
\"
, "
"
\"
server-ip
\"
:
\"
"
<<
server_ip
<<
"
\"
, "
"
\"
server-port
\"
: "
<<
port
<<
", "
"
\"
sender-ip
\"
:
\"
"
<<
sender_ip
<<
"
\"
, "
"
\"
sender-port
\"
: "
<<
sender_port
<<
", "
"
\"
max-queue-size
\"
: "
<<
max_queue_size
<<
", "
"
\"
ncr-protocol
\"
:
\"
UDP
\"
, "
"
\"
ncr-format
\"
:
\"
JSON
\"
, "
"
\"
always-include-fqdn
\"
: true, "
...
...
@@ -165,10 +171,10 @@ TEST_F(Dhcp4SrvD2Test, enableDisable) {
ASSERT_FALSE
(
mgr
.
amSending
());
}
// Tests Dhcp4 server's ability to correctly handle a flawed dhcp-ddns
configuration.
// It does so by first enabling updates by submitting a valid
configuration and then
// ensuring they remain on after submitting a flawed
configuration.
// and then invoking its startD2() method.
// Tests Dhcp4 server's ability to correctly handle a flawed dhcp-ddns
//
configuration.
It does so by first enabling updates by submitting a valid
//
configuration and then
ensuring they remain on after submitting a flawed
//
configuration
and then invoking its startD2() method.
TEST_F
(
Dhcp4SrvD2Test
,
badConfig
)
{
// Grab the manager and verify that be default ddns is off
// and a sender was not started.
...
...
@@ -293,7 +299,10 @@ TEST_F(Dhcp4SrvD2Test, forceUDPSendFailure) {
// Configure it enabled and start it.
// Using server address of 0.0.0.0/0 should induce failure on send.
ASSERT_NO_FATAL_FAILURE
(
configureD2
(
true
,
SHOULD_PASS
,
"0.0.0.0"
,
0
));
// Pass in a non-zero sender port to avoid validation error when
// server-ip/port are same as sender-ip/port
ASSERT_NO_FATAL_FAILURE
(
configureD2
(
true
,
SHOULD_PASS
,
"0.0.0.0"
,
0
,
"0.0.0.0"
,
53001
));
ASSERT_TRUE
(
mgr
.
ddnsEnabled
());
ASSERT_NO_THROW
(
srv_
.
startD2
());
ASSERT_TRUE
(
mgr
.
amSending
());
...
...
src/bin/dhcp4/tests/d2_unittest.h
View file @
8d8d0b5e
...
...
@@ -77,11 +77,17 @@ public:
///
/// @param enable_updates value to assign to the enable-updates parameter
/// @param exp_result indicates if configuration should pass or fail
/// @param
ip_address
IP address for the D2 server
/// @param
server_ip
IP address for the D2 server
/// @param port port for the D2 server
/// @param sender_ip NCR sender's IP address
/// @param sender_port NCR sender port
/// @param max_queue_size maximum number of NCRs allowed in sender's queue
void
configureD2
(
bool
enable_updates
,
bool
exp_result
=
SHOULD_PASS
,
const
std
::
string
&
ip_address
=
"127.0.0.1"
,
const
uint32_t
port
=
53001
);
const
std
::
string
&
server_ip
=
"127.0.0.1"
,
const
size_t
port
=
53001
,
const
std
::
string
&
sender_ip
=
"0.0.0.0"
,
const
size_t
sender_port
=
0
,
const
size_t
max_queue_size
=
1024
);
/// @brief Configures the server with the given configuration
///
...
...
src/bin/dhcp4/tests/fqdn_unittest.cc
View file @
8d8d0b5e
...
...
@@ -77,6 +77,7 @@ public:
ASSERT_NO_THROW
(
cfg
.
reset
(
new
D2ClientConfig
(
true
,
isc
::
asiolink
::
IOAddress
(
"127.0.0.1"
),
53001
,
isc
::
asiolink
::
IOAddress
(
"0.0.0.0"
),
0
,
1024
,
dhcp_ddns
::
NCR_UDP
,
dhcp_ddns
::
FMT_JSON
,
(
mask
&
ALWAYS_INCLUDE_FQDN
),
(
mask
&
OVERRIDE_NO_UPDATE
),
...
...
src/bin/dhcp6/dhcp6.spec
View file @
8d8d0b5e
...
...
@@ -392,6 +392,27 @@
"item_default": 53001,
"item_description" : "port number of b10-dhcp-ddns"
},
{
"item_name": "sender-ip",
"item_type": "string",
"item_optional": true,
"item_default": "",
"item_description" : "IP address from which to send to b10-dhcp-ddns (IPv4 or IPv6)"
},
{
"item_name": "sender-port",
"item_type": "integer",
"item_optional": true,
"item_default": 0,
"item_description" : "port number from which to send to b10-dhcp-ddns"
},
{
"item_name": "max-queue-size",
"item_type": "integer",
"item_optional": true,
"item_default": 1024,
"item_description" : "maximum number of requests allowed in the send queue"
},
{
"item_name": "ncr-protocol",
"item_type": "string",
...
...
src/bin/dhcp6/tests/config_parser_unittest.cc
View file @
8d8d0b5e
...
...
@@ -3213,8 +3213,11 @@ TEST_F(Dhcp6ParserTest, d2ClientConfig) {
"
\"
subnet
\"
:
\"
2001:db8:1::/64
\"
} ], "
"
\"
dhcp-ddns
\"
: {"
"
\"
enable-updates
\"
: true, "
"
\"
server-ip
\"
:
\"
192.168.2.
1
\"
, "
"
\"
server-ip
\"
:
\"
3001::
1
\"
, "
"
\"
server-port
\"
: 777, "
"
\"
sender-ip
\"
:
\"
3001::2
\"
, "
"
\"
sender-port
\"
: 778, "
"
\"
max-queue-size
\"
: 2048, "
"
\"
ncr-protocol
\"
:
\"
UDP
\"
, "
"
\"
ncr-format
\"
:
\"
JSON
\"
, "
"
\"
always-include-fqdn
\"
: true, "
...
...
@@ -3245,8 +3248,11 @@ TEST_F(Dhcp6ParserTest, d2ClientConfig) {
// Verify that the configuration values are correct.
EXPECT_TRUE
(
d2_client_config
->
getEnableUpdates
());
EXPECT_EQ
(
"
192.168.2.
1"
,
d2_client_config
->
getServerIp
().
toText
());
EXPECT_EQ
(
"
3001::
1"
,
d2_client_config
->
getServerIp
().
toText
());
EXPECT_EQ
(
777
,
d2_client_config
->
getServerPort
());
EXPECT_EQ
(
"3001::2"
,
d2_client_config
->
getSenderIp
().
toText
());
EXPECT_EQ
(
778
,
d2_client_config
->
getSenderPort
());
EXPECT_EQ
(
2048
,
d2_client_config
->
getMaxQueueSize
());
EXPECT_EQ
(
dhcp_ddns
::
NCR_UDP
,
d2_client_config
->
getNcrProtocol
());
EXPECT_EQ
(
dhcp_ddns
::
FMT_JSON
,
d2_client_config
->
getNcrFormat
());
EXPECT_TRUE
(
d2_client_config
->
getAlwaysIncludeFqdn
());
...
...
src/bin/dhcp6/tests/d2_unittest.cc
View file @
8d8d0b5e
...
...
@@ -90,8 +90,11 @@ Dhcp6SrvD2Test::reset() {
void
Dhcp6SrvD2Test
::
configureD2
(
bool
enable_d2
,
const
bool
exp_result
,
const
std
::
string
&
ip_address
,
const
uint32_t
port
)
{
const
std
::
string
&
server_ip
,
const
size_t
port
,
const
std
::
string
&
sender_ip
,
const
size_t
sender_port
,
const
size_t
max_queue_size
)
{
std
::
ostringstream
config
;
config
<<
"{
\"
interfaces
\"
: [
\"
*
\"
],"
...
...
@@ -104,8 +107,11 @@ Dhcp6SrvD2Test::configureD2(bool enable_d2, const bool exp_result,
"
\"
subnet
\"
:
\"
2001:db8:1::/64
\"
} ],"
"
\"
dhcp-ddns
\"
: {"
"
\"
enable-updates
\"
: "
<<
(
enable_d2
?
"true"
:
"false"
)
<<
", "
"
\"
server-ip
\"
:
\"
"
<<
ip_address
<<
"
\"
, "
"
\"
server-ip
\"
:
\"
"
<<
server_ip
<<
"
\"
, "
"
\"
server-port
\"
: "
<<
port
<<
", "
"
\"
sender-ip
\"
:
\"
"
<<
sender_ip
<<
"
\"
, "
"
\"
sender-port
\"
: "
<<
sender_port
<<
", "
"
\"
max-queue-size
\"
: "
<<
max_queue_size
<<
", "
"
\"
ncr-protocol
\"
:
\"
UDP
\"
, "
"
\"
ncr-format
\"
:
\"
JSON
\"
, "
"
\"
always-include-fqdn
\"
: true, "
...
...
@@ -169,10 +175,10 @@ TEST_F(Dhcp6SrvD2Test, enableDisable) {
ASSERT_FALSE
(
mgr
.
amSending
());
}
// Tests Dhcp6 server's ability to correctly handle a flawed dhcp-ddns
configuration.
// It does so by first enabling updates by submitting a valid
configuration and then
// ensuring they remain on after submitting a flawed
configuration.
// and then invoking its startD2() method.
// Tests Dhcp6 server's ability to correctly handle a flawed dhcp-ddns
//
configuration.
It does so by first enabling updates by submitting a valid
//
configuration and then
ensuring they remain on after submitting a flawed
//
configuration
and then invoking its startD2() method.
TEST_F
(
Dhcp6SrvD2Test
,
badConfig
)
{
// Grab the manager and verify that be default ddns is off
// and a sender was not started.
...
...
@@ -244,7 +250,7 @@ TEST_F(Dhcp6SrvD2Test, differentConfig) {
ASSERT_TRUE
(
mgr
.
amSending
());
// Now enable it on a different port.
ASSERT_NO_FATAL_FAILURE
(
configureD2
(
true
,
SHOULD_PASS
,
"
127.0.0.
1"
,
54001
));
ASSERT_NO_FATAL_FAILURE
(
configureD2
(
true
,
SHOULD_PASS
,
"
::
1"
,
54001
));
// Configuration was altered, so ddns should still enabled but not sending.
ASSERT_TRUE
(
mgr
.
ddnsEnabled
());
...
...
@@ -297,7 +303,10 @@ TEST_F(Dhcp6SrvD2Test, forceUDPSendFailure) {
// Configure it enabled and start it.
// Using server address of 0.0.0.0/0 should induce failure on send.
ASSERT_NO_FATAL_FAILURE
(
configureD2
(
true
,
SHOULD_PASS
,
"0.0.0.0"
,
0
));
// Pass in a non-zero sender port to avoid validation error when
// server-ip/port are same as sender-ip/port
ASSERT_NO_FATAL_FAILURE
(
configureD2
(
true
,
SHOULD_PASS
,
"::"
,
0
,
"::"
,
53001
));
ASSERT_TRUE
(
mgr
.
ddnsEnabled
());
ASSERT_NO_THROW
(
srv_
.
startD2
());
ASSERT_TRUE
(
mgr
.
amSending
());
...
...
src/bin/dhcp6/tests/d2_unittest.h
View file @
8d8d0b5e
...
...
@@ -76,12 +76,17 @@ public:
/// parameters given and passes it into the server's configuration handler.
///
/// @param enable_updates value to assign to the enable-updates parameter
/// @param exp_result indicates if configuration should pass or fail
/// @param ip_address IP address for the D2 server
/// @param server_ip IP address for the D2 server
/// @param port port for the D2 server
/// @param sender_ip NCR sender's IP address
/// @param sender_port NCR sender port
/// @param max_queue_size maximum number of NCRs allowed in sender's queue
void
configureD2
(
bool
enable_updates
,
bool
exp_result
=
SHOULD_PASS
,
const
std
::
string
&
ip_address
=
"127.0.0.1"
,
const
uint32_t
port
=
53001
);
const
std
::
string
&
server_ip
=
"::1"
,
const
size_t
port
=
53001
,
const
std
::
string
&
sender_ip
=
"::"
,
const
size_t
sender_port
=
0
,
const
size_t
max_queue_size
=
1024
);
/// @brief Configures the server with the given configuration
///
...
...
src/bin/dhcp6/tests/fqdn_unittest.cc
View file @
8d8d0b5e
...
...
@@ -109,7 +109,9 @@ public:
D2ClientConfigPtr
cfg
;
ASSERT_NO_THROW
(
cfg
.
reset
(
new
D2ClientConfig
(
true
,
isc
::
asiolink
::
IOAddress
(
"127.0.0.1"
),
53001
,
isc
::
asiolink
::
IOAddress
(
"::1"
),
53001
,
isc
::
asiolink
::
IOAddress
(
"::"
),
0
,
1024
,
dhcp_ddns
::
NCR_UDP
,
dhcp_ddns
::
FMT_JSON
,
(
mask
&
ALWAYS_INCLUDE_FQDN
),
(
mask
&
OVERRIDE_NO_UPDATE
),
...
...
src/lib/dhcpsrv/d2_client_cfg.cc
View file @
8d8d0b5e
...
...
@@ -25,6 +25,10 @@ namespace dhcp {
const
char
*
D2ClientConfig
::
DFT_SERVER_IP
=
"127.0.0.1"
;
const
size_t
D2ClientConfig
::
DFT_SERVER_PORT
=
53001
;
const
char
*
D2ClientConfig
::
DFT_V4_SENDER_IP
=
"0.0.0.0"
;
const
char
*
D2ClientConfig
::
DFT_V6_SENDER_IP
=
"::"
;
const
size_t
D2ClientConfig
::
DFT_SENDER_PORT
=
0
;
const
size_t
D2ClientConfig
::
DFT_MAX_QUEUE_SIZE
=
1024
;
const
char
*
D2ClientConfig
::
DFT_NCR_PROTOCOL
=
"UDP"
;
const
char
*
D2ClientConfig
::
DFT_NCR_FORMAT
=
"JSON"
;
const
bool
D2ClientConfig
::
DFT_ALWAYS_INCLUDE_FQDN
=
false
;
...
...
@@ -37,6 +41,9 @@ const char *D2ClientConfig::DFT_QUALIFYING_SUFFIX = "example.com";
D2ClientConfig
::
D2ClientConfig
(
const
bool
enable_updates
,
const
isc
::
asiolink
::
IOAddress
&
server_ip
,
const
size_t
server_port
,
const
isc
::
asiolink
::
IOAddress
&
sender_ip
,
const
size_t
sender_port
,
const
size_t
max_queue_size
,
const
dhcp_ddns
::
NameChangeProtocol
&
ncr_protocol
,
const
dhcp_ddns
::
...
...
@@ -48,31 +55,37 @@ D2ClientConfig::D2ClientConfig(const bool enable_updates,
const
std
::
string
&
generated_prefix
,
const
std
::
string
&
qualifying_suffix
)
:
enable_updates_
(
enable_updates
),
server_ip_
(
server_ip
),
server_port_
(
server_port
),
ncr_protocol_
(
ncr_protocol
),
ncr_format_
(
ncr_format
),
always_include_fqdn_
(
always_include_fqdn
),
override_no_update_
(
override_no_update
),
override_client_update_
(
override_client_update
),
replace_client_name_
(
replace_client_name
),
generated_prefix_
(
generated_prefix
),
qualifying_suffix_
(
qualifying_suffix
)
{
server_ip_
(
server_ip
),
server_port_
(
server_port
),
sender_ip_
(
sender_ip
),
sender_port_
(
sender_port
),
max_queue_size_
(
max_queue_size
),
ncr_protocol_
(
ncr_protocol
),
ncr_format_
(
ncr_format
),
always_include_fqdn_
(
always_include_fqdn
),
override_no_update_
(
override_no_update
),
override_client_update_
(
override_client_update
),
replace_client_name_
(
replace_client_name
),
generated_prefix_
(
generated_prefix
),
qualifying_suffix_
(
qualifying_suffix
)
{
validateContents
();
}
D2ClientConfig
::
D2ClientConfig
()
:
enable_updates_
(
false
),
server_ip_
(
isc
::
asiolink
::
IOAddress
(
"0.0.0.0"
)),
server_port_
(
0
),
ncr_protocol_
(
dhcp_ddns
::
NCR_UDP
),
ncr_format_
(
dhcp_ddns
::
FMT_JSON
),
always_include_fqdn_
(
false
),
override_no_update_
(
false
),
override_client_update_
(
false
),
replace_client_name_
(
false
),
generated_prefix_
(
"myhost"
),
qualifying_suffix_
(
"example.com"
)
{
server_ip_
(
isc
::
asiolink
::
IOAddress
(
DFT_SERVER_IP
)),
server_port_
(
DFT_SERVER_PORT
),
sender_ip_
(
isc
::
asiolink
::
IOAddress
(
DFT_V4_SENDER_IP
)),
sender_port_
(
DFT_SENDER_PORT
),
max_queue_size_
(
DFT_MAX_QUEUE_SIZE
),
ncr_protocol_
(
dhcp_ddns
::
stringToNcrProtocol
(
DFT_NCR_PROTOCOL
)),
ncr_format_
(
dhcp_ddns
::
stringToNcrFormat
(
DFT_NCR_FORMAT
)),
always_include_fqdn_
(
DFT_ALWAYS_INCLUDE_FQDN
),
override_no_update_
(
DFT_OVERRIDE_NO_UPDATE
),
override_client_update_
(
DFT_OVERRIDE_CLIENT_UPDATE
),
replace_client_name_
(
DFT_REPLACE_CLIENT_NAME
),
generated_prefix_
(
DFT_GENERATED_PREFIX
),
qualifying_suffix_
(
DFT_QUALIFYING_SUFFIX
)
{
validateContents
();
}
...
...
@@ -93,8 +106,22 @@ D2ClientConfig::validateContents() {
if
(
ncr_protocol_
!=
dhcp_ddns
::
NCR_UDP
)
{
isc_throw
(
D2ClientError
,
"D2ClientConfig: NCR Protocol:"
<<
dhcp_ddns
::
ncrProtocolToString
(
ncr_protocol_
)
<<
" is not yet supported"
);
<<
dhcp_ddns
::
ncrProtocolToString
(
ncr_protocol_
)
<<
" is not yet supported"
);
}
if
(
sender_ip_
.
getFamily
()
!=
server_ip_
.
getFamily
())
{
isc_throw
(
D2ClientError
,
"D2ClientConfig: address family mismatch: "
<<
"server-ip: "
<<
server_ip_
.
toText
()
<<
" is: "
<<
(
server_ip_
.
isV4
()
?
"IPv4"
:
"IPv6"
)
<<
" while sender-ip: "
<<
sender_ip_
.
toText
()
<<
" is: "
<<
(
sender_ip_
.
isV4
()
?
"IPv4"
:
"IPv6"
));
}
if
(
server_ip_
==
sender_ip_
&&
server_port_
==
sender_port_
)
{
isc_throw
(
D2ClientError
,
"D2ClientConfig: server and sender cannot"
" share the exact same IP address/port: "
<<
server_ip_
.
toText
()
<<
"/"
<<
server_port_
);
}
/// @todo perhaps more validation we should do yet?
...
...
@@ -106,6 +133,9 @@ D2ClientConfig::operator == (const D2ClientConfig& other) const {
return
((
enable_updates_
==
other
.
enable_updates_
)
&&
(
server_ip_
==
other
.
server_ip_
)
&&
(
server_port_
==
other
.
server_port_
)
&&
(
sender_ip_
==
other
.
sender_ip_
)
&&
(
sender_port_
==
other
.
sender_port_
)
&&
(
max_queue_size_
==
other
.
max_queue_size_
)
&&
(
ncr_protocol_
==
other
.
ncr_protocol_
)
&&
(
ncr_format_
==
other
.
ncr_format_
)
&&
(
always_include_fqdn_
==
other
.
always_include_fqdn_
)
&&
...
...
@@ -129,6 +159,9 @@ D2ClientConfig::toText() const {
if
(
enable_updates_
)
{
stream
<<
", server_ip: "
<<
server_ip_
.
toText
()
<<
", server_port: "
<<
server_port_
<<
", sender_ip: "
<<
sender_ip_
.
toText
()
<<
", sender_port: "
<<
sender_port_
<<
", max_queue_size: "
<<
max_queue_size_
<<
", ncr_protocol: "
<<
ncr_protocol_
<<
", ncr_format: "
<<
ncr_format_
<<
", always_include_fqdn: "
<<
(
always_include_fqdn_
?
...
...
src/lib/dhcpsrv/d2_client_cfg.h
View file @
8d8d0b5e
...
...
@@ -62,6 +62,10 @@ public:
/// readily provide them (see Trac #3358).
static
const
char
*
DFT_SERVER_IP
;
static
const
size_t
DFT_SERVER_PORT
;
static
const
char
*
DFT_V4_SENDER_IP
;
static
const
char
*
DFT_V6_SENDER_IP
;
static
const
size_t
DFT_SENDER_PORT
;
static
const
size_t
DFT_MAX_QUEUE_SIZE
;
static
const
char
*
DFT_NCR_PROTOCOL
;
static
const
char
*
DFT_NCR_FORMAT
;
static
const
bool
DFT_ALWAYS_INCLUDE_FQDN
;
...
...
@@ -76,6 +80,9 @@ public:
/// @param enable_updates Enables DHCP-DDNS updates
/// @param server_ip IP address of the b10-dhcp-ddns server (IPv4 or IPv6)
/// @param server_port IP port of the b10-dhcp-ddns server
/// @param sender_ip IP address of the b10-dhcp-ddns server (IPv4 or IPv6)
/// @param sender_port IP port of the b10-dhcp-ddns server
/// @param max_queue_size maximum NCRs allowed in sender's queue
/// @param ncr_protocol Socket protocol to use with b10-dhcp-ddns
/// Currently only UDP is supported.
/// @param ncr_format Format of the b10-dhcp-ddns requests.
...
...
@@ -95,6 +102,9 @@ public:
D2ClientConfig
(
const
bool
enable_updates
,
const
isc
::
asiolink
::
IOAddress
&
server_ip
,
const
size_t
server_port
,
const
isc
::
asiolink
::
IOAddress
&
sender_ip
,
const
size_t
sender_port
,
const
size_t
max_queue_size
,
const
dhcp_ddns
::
NameChangeProtocol
&
ncr_protocol
,
const
dhcp_ddns
::
NameChangeFormat
&
ncr_format
,
const
bool
always_include_fqdn
,
...
...
@@ -126,6 +136,21 @@ public:
return
(
server_port_
);
}
/// @brief Return the IP address client should use to send
const
isc
::
asiolink
::
IOAddress
&
getSenderIp
()
const
{
return
(
sender_ip_
);
}
/// @brief Return the IP port client should use to send
size_t
getSenderPort
()
const
{
return
(
sender_port_
);
}
/// @brief Return Maximun sender queue size
size_t
getMaxQueueSize
()
const
{
return
(
max_queue_size_
);
}
/// @brief Return the socket protocol to use with b10-dhcp-ddns.
const
dhcp_ddns
::
NameChangeProtocol
&
getNcrProtocol
()
const
{
return
(
ncr_protocol_
);
...
...
@@ -202,6 +227,15 @@ private:
/// @brief IP port of the b10-dhcp-ddns server.
size_t
server_port_
;
/// @brief IP address on which the client should send
isc
::
asiolink
::
IOAddress
sender_ip_
;
/// @brief IP port on which the client should send
size_t
sender_port_
;
/// @brief Maxium number of NCRs allowed to queue waiting to send
size_t
max_queue_size_
;
/// @brief The socket protocol to use with b10-dhcp-ddns.
/// Currently only UDP is supported.
dhcp_ddns
::
NameChangeProtocol
ncr_protocol_
;
...
...
src/lib/dhcpsrv/d2_client_mgr.cc
View file @
8d8d0b5e
...
...
@@ -68,21 +68,15 @@ D2ClientMgr::setD2ClientConfig(D2ClientConfigPtr& new_config) {
dhcp_ddns
::
NameChangeSenderPtr
new_sender
;
switch
(
new_config
->
getNcrProtocol
())
{
case
dhcp_ddns
::
NCR_UDP
:
{
/// @todo Should we be able to configure a sender's client
/// side ip and port? We should certainly be able to
/// configure a maximum queue size. These were overlooked
/// but are covered in Trac# 3328.
isc
::
asiolink
::
IOAddress
any_addr
(
"0.0.0.0"
);
uint32_t
any_port
=
0
;
uint32_t
queue_max
=
1024
;
// Instantiate a new sender.
new_sender
.
reset
(
new
dhcp_ddns
::
NameChangeUDPSender
(
any_addr
,
any_port
,
new_config
->
getSenderIp
(),
new_config
->
getSenderPort
(),
new_config
->
getServerIp
(),
new_config
->
getServerPort
(),
new_config
->
getNcrFormat
(),
*
this
,
queue_max
));
*
this
,
new_config
->
getMaxQueueSize
()));
break
;
}
default:
...
...
src/lib/dhcpsrv/dhcp_parsers.cc
View file @
8d8d0b5e
...
...
@@ -1281,6 +1281,23 @@ D2ClientConfigParser::build(isc::data::ConstElementPtr client_config) {
uint32_t
server_port
=
uint32_values_
->
getOptionalParam
(
"server-port"
,
D2ClientConfig
::
DFT_SERVER_PORT
);
// The default sender IP depends on the server IP family
asiolink
::
IOAddress
sender_ip
(
string_values_
->
getOptionalParam
(
"sender-ip"
,
(
server_ip
.
isV4
()
?
D2ClientConfig
::
DFT_V4_SENDER_IP
:
D2ClientConfig
::
DFT_V6_SENDER_IP
)));
uint32_t
sender_port
=
uint32_values_
->
getOptionalParam
(
"sender-port"
,
D2ClientConfig
::
DFT_SENDER_PORT
);
uint32_t
max_queue_size
=
uint32_values_
->
getOptionalParam
(
"max-queue-size"
,
D2ClientConfig
::
DFT_MAX_QUEUE_SIZE
);
dhcp_ddns
::
NameChangeProtocol
ncr_protocol
=
dhcp_ddns
::
stringToNcrProtocol
(
string_values_
->
getOptionalParam
(
"ncr-protocol"
,
...
...
@@ -1302,8 +1319,8 @@ D2ClientConfigParser::build(isc::data::ConstElementPtr client_config) {
bool
always_include_fqdn
=
boolean_values_
->
getOptionalParam
(
"always-include-fqdn"
,
D2ClientConfig
::
DFT_ALWAYS_INCLUDE_FQDN
);
D2ClientConfig
::
DFT_ALWAYS_INCLUDE_FQDN
);
bool
override_no_update
=
boolean_values_
->
getOptionalParam
(
"override-no-update"
,
...
...
@@ -1320,8 +1337,13 @@ D2ClientConfigParser::build(isc::data::ConstElementPtr client_config) {
DFT_REPLACE_CLIENT_NAME
);
// Attempt to create the new client config.
local_client_config_
.
reset
(
new
D2ClientConfig
(
enable_updates
,
server_ip
,
server_port
,
ncr_protocol
,
local_client_config_
.
reset
(
new
D2ClientConfig
(
enable_updates
,
server_ip
,
server_port
,
sender_ip
,
sender_port
,
max_queue_size
,
ncr_protocol
,
ncr_format
,
always_include_fqdn
,
override_no_update
,
...
...
@@ -1334,12 +1356,15 @@ D2ClientConfigParser::build(isc::data::ConstElementPtr client_config) {
isc
::
dhcp
::
ParserPtr
D2ClientConfigParser
::
createConfigParser
(
const
std
::
string
&
config_id
)
{
DhcpConfigParser
*
parser
=
NULL
;
if
(
config_id
.
compare
(
"server-port"
)
==
0
)
{
if
((
config_id
.
compare
(
"server-port"
)
==
0
)
||
(
config_id
.
compare
(
"sender-port"
)
==
0
)
||
(
config_id
.
compare
(
"max-queue-size"
)
==
0
))
{
parser
=
new
Uint32Parser
(
config_id
,
uint32_values_
);
}
else
if
((
config_id
.
compare
(
"server-ip"
)
==
0
)
||
(
config_id
.
compare
(
"ncr-protocol"
)
==
0
)
||
(
config_id
.
compare
(
"ncr-format"
)
==
0
)
||
(
config_id
.
compare
(
"generated-prefix"
)
==
0
)
||
(
config_id
.
compare
(
"sender-ip"
)
==
0
)
||
(
config_id
.
compare
(
"qualifying-suffix"
)
==
0
))
{
parser
=
new
StringParser
(
config_id
,
string_values_
);
}
else
if
((
config_id
.
compare
(
"enable-updates"
)
==
0
)
||
...
...
src/lib/dhcpsrv/tests/cfgmgr_unittest.cc
View file @
8d8d0b5e
...
...
@@ -991,6 +991,8 @@ TEST_F(CfgMgrTest, d2ClientConfig) {
// Create a new, enabled configuration.
ASSERT_NO_THROW
(
new_cfg
.
reset
(
new
D2ClientConfig
(
true
,
isc
::
asiolink
::
IOAddress
(
"127.0.0.1"
),
477
,
isc
::
asiolink
::
IOAddress
(
"127.0.0.1"
),
478
,
1024
,
dhcp_ddns
::
NCR_UDP
,
dhcp_ddns
::
FMT_JSON
,
true
,
true
,
true
,
true
,
"pre-fix"
,
"suf-fix"
)));
...
...
src/lib/dhcpsrv/tests/d2_client_unittest.cc
View file @
8d8d0b5e
...
...
@@ -47,6 +47,9 @@ TEST(D2ClientConfigTest, constructorsAndAccessors) {
bool
enable_updates
=
true
;
isc
::
asiolink
::
IOAddress
server_ip
(
"127.0.0.1"
);
size_t
server_port
=
477
;
isc
::
asiolink
::
IOAddress
sender_ip
(
"127.0.0.1"
);
size_t
sender_port
=
478
;
size_t
max_queue_size
=
2048
;
dhcp_ddns
::
NameChangeProtocol
ncr_protocol
=
dhcp_ddns
::
NCR_UDP
;
dhcp_ddns
::
NameChangeFormat
ncr_format
=
dhcp_ddns
::
FMT_JSON
;
bool
always_include_fqdn
=
true
;
...
...
@@ -61,6 +64,9 @@ TEST(D2ClientConfigTest, constructorsAndAccessors) {
D2ClientConfig
(
enable_updates
,
server_ip
,
server_port
,
sender_ip
,
sender_port
,
max_queue_size
,
ncr_protocol
,
ncr_format
,
always_include_fqdn
,
...
...
@@ -77,6 +83,9 @@ TEST(D2ClientConfigTest, constructorsAndAccessors) {
EXPECT_EQ
(
d2_client_config
->
getServerIp
(),
server_ip
);
EXPECT_EQ
(
d2_client_config
->
getServerPort
(),
server_port
);