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
847cada3
Commit
847cada3
authored
Aug 28, 2013
by
Marcin Siodelski
Browse files
[3035] Implemented DHCPv4 Client FQDN option processing.
parent
41c4d829
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/dhcp4_srv.cc
View file @
847cada3
...
...
@@ -18,7 +18,6 @@
#include
<dhcp/hwaddr.h>
#include
<dhcp/iface_mgr.h>
#include
<dhcp/option4_addrlst.h>
#include
<dhcp/option4_client_fqdn.h>
#include
<dhcp/option_custom.h>
#include
<dhcp/option_int.h>
#include
<dhcp/option_int_array.h>
...
...
@@ -672,7 +671,7 @@ Dhcpv4Srv::processClientName(const Pkt4Ptr& query, Pkt4Ptr& answer) {
Option4ClientFqdnPtr
fqdn
=
boost
::
dynamic_pointer_cast
<
Option4ClientFqdn
>
(
query
->
getOption
(
DHO_FQDN
));
if
(
fqdn
)
{
processClientFqdnOption
(
query
,
answer
);
processClientFqdnOption
(
fqdn
,
answer
);
}
else
{
OptionCustomPtr
hostname
=
boost
::
dynamic_pointer_cast
<
OptionCustom
>
...
...
@@ -685,7 +684,18 @@ Dhcpv4Srv::processClientName(const Pkt4Ptr& query, Pkt4Ptr& answer) {
}
void
Dhcpv4Srv
::
processClientFqdnOption
(
const
Pkt4Ptr
&
,
Pkt4Ptr
&
)
{
Dhcpv4Srv
::
processClientFqdnOption
(
const
Option4ClientFqdnPtr
&
fqdn
,
Pkt4Ptr
&
answer
)
{
// Create the DHCPv4 Client FQDN Option to be included in the server's
// response to a client.
Option4ClientFqdnPtr
fqdn_resp
(
new
Option4ClientFqdn
(
*
fqdn
));
// RFC4702, section 4 - set 'NOS' flags to 0.
fqdn_resp
->
setFlag
(
Option4ClientFqdn
::
FLAG_S
,
0
);
fqdn_resp
->
setFlag
(
Option4ClientFqdn
::
FLAG_O
,
0
);
fqdn_resp
->
setFlag
(
Option4ClientFqdn
::
FLAG_N
,
0
);
answer
->
addOption
(
fqdn_resp
);
}
void
...
...
src/bin/dhcp4/dhcp4_srv.h
View file @
847cada3
...
...
@@ -18,6 +18,7 @@
#include
<dhcp/dhcp4.h>
#include
<dhcp/pkt4.h>
#include
<dhcp/option.h>
#include
<dhcp/option4_client_fqdn.h>
#include
<dhcpsrv/subnet.h>
#include
<dhcpsrv/alloc_engine.h>
#include
<hooks/callout_handle.h>
...
...
@@ -289,9 +290,10 @@ protected:
private:
/// @brief Process Client FQDN %Option sent by a client.
///
/// @param
query
A D
ISCOVER or REQUEST message from
a cient.
/// @param
fqdn
A
n
D
HCPv4 Client FQDN %Option sent by
a c
l
ient.
/// @param [out] answer A response message to be sent to a client.
void
processClientFqdnOption
(
const
Pkt4Ptr
&
query
,
Pkt4Ptr
&
answer
);
void
processClientFqdnOption
(
const
Option4ClientFqdnPtr
&
fqdn
,
Pkt4Ptr
&
answer
);
/// @brief Process Hostname %Option sent by a client.
///
...
...
src/bin/dhcp4/tests/fqdn_unittest.cc
View file @
847cada3
...
...
@@ -126,7 +126,9 @@ private:
};
TEST_F
(
FqdnDhcpv4SrvTest
,
basic
)
{
// Test that server confirms to perform the forward and reverse DNS update,
// when client asks for it.
TEST_F
(
FqdnDhcpv4SrvTest
,
serverUpdateForward
)
{
Pkt4Ptr
query
=
generatePktWithFqdn
(
DHCPREQUEST
,
Option4ClientFqdn
::
FLAG_E
|
Option4ClientFqdn
::
FLAG_S
,
...
...
@@ -140,4 +142,53 @@ TEST_F(FqdnDhcpv4SrvTest, basic) {
}
// Test that server generates the fully qualified domain name for the client
// if client supplies the partial name.
TEST_F
(
FqdnDhcpv4SrvTest
,
serverUpdateForwardPartialName
)
{
Pkt4Ptr
query
=
generatePktWithFqdn
(
DHCPREQUEST
,
Option4ClientFqdn
::
FLAG_E
|
Option4ClientFqdn
::
FLAG_S
,
"myhost"
,
Option4ClientFqdn
::
PARTIAL
,
true
);
testProcessFqdn
(
query
,
Option4ClientFqdn
::
FLAG_E
|
Option4ClientFqdn
::
FLAG_S
,
"myhost.example.com."
);
}
// Test that server generates the fully qualified domain name for the client
// if clietn supplies empty domain name.
TEST_F
(
FqdnDhcpv4SrvTest
,
serverUpdateForwardNoName
)
{
Pkt4Ptr
query
=
generatePktWithFqdn
(
DHCPREQUEST
,
Option4ClientFqdn
::
FLAG_E
|
Option4ClientFqdn
::
FLAG_S
,
""
,
Option4ClientFqdn
::
PARTIAL
,
true
);
testProcessFqdn
(
query
,
Option4ClientFqdn
::
FLAG_E
|
Option4ClientFqdn
::
FLAG_S
,
"myhost.example.com."
);
}
// Test that server does not accept delegation of the forward DNS update
// to a client.
TEST_F
(
FqdnDhcpv4SrvTest
,
clientUpdateNotAllowed
)
{
Pkt4Ptr
query
=
generatePktWithFqdn
(
DHCPREQUEST
,
Option4ClientFqdn
::
FLAG_E
,
"myhost.example.com."
,
Option4ClientFqdn
::
PARTIAL
,
true
);
testProcessFqdn
(
query
,
Option4ClientFqdn
::
FLAG_E
|
Option4ClientFqdn
::
FLAG_S
|
Option4ClientFqdn
::
FLAG_O
,
"myhost.example.com."
);
}
}
// end of anonymous namespace
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