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
e9f4d7e5
Commit
e9f4d7e5
authored
Oct 21, 2013
by
Marcin Siodelski
Browse files
[3200] Respond with requested options only if lease has been assigned.
Conflicts: src/bin/dhcp4/dhcp4_srv.cc src/lib/dhcp/libdhcp++.cc
parent
beac4c1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/dhcp4_srv.cc
View file @
e9f4d7e5
...
...
@@ -754,13 +754,6 @@ Dhcpv4Srv::assignLease(const Pkt4Ptr& question, Pkt4Ptr& answer) {
opt
->
setUint32
(
lease
->
valid_lft_
);
answer
->
addOption
(
opt
);
// Router (type 3)
Subnet
::
OptionDescriptor
opt_routers
=
subnet
->
getOptionDescriptor
(
"dhcp4"
,
DHO_ROUTERS
);
if
(
opt_routers
.
option
)
{
answer
->
addOption
(
opt_routers
.
option
);
}
// Subnet mask (type 1)
answer
->
addOption
(
getNetmaskOption
(
subnet
));
...
...
@@ -857,14 +850,17 @@ Dhcpv4Srv::processDiscover(Pkt4Ptr& discover) {
copyDefaultFields
(
discover
,
offer
);
appendDefaultOptions
(
offer
,
DHCPOFFER
);
appendRequestedOptions
(
discover
,
offer
);
assignLease
(
discover
,
offer
);
// There are a few basic options that we always want to
// include in the response. If client did not request
// them we append them for him.
appendBasicOptions
(
discover
,
offer
);
// Adding any other options makes sense only when we got the lease.
if
(
offer
->
getYiaddr
()
!=
IOAddress
(
"0.0.0.0"
))
{
appendRequestedOptions
(
discover
,
offer
);
// There are a few basic options that we always want to
// include in the response. If client did not request
// them we append them for him.
appendBasicOptions
(
discover
,
offer
);
}
return
(
offer
);
}
...
...
@@ -880,17 +876,20 @@ Dhcpv4Srv::processRequest(Pkt4Ptr& request) {
copyDefaultFields
(
request
,
ack
);
appendDefaultOptions
(
ack
,
DHCPACK
);
appendRequestedOptions
(
request
,
ack
);
// Note that we treat REQUEST message uniformly, regardless if this is a
// first request (requesting for new address), renewing existing address
// or even rebinding.
assignLease
(
request
,
ack
);
// There are a few basic options that we always want to
// include in the response. If client did not request
// them we append them for him.
appendBasicOptions
(
request
,
ack
);
// Adding any other options makes sense only when we got the lease.
if
(
ack
->
getYiaddr
()
!=
IOAddress
(
"0.0.0.0"
))
{
appendRequestedOptions
(
request
,
ack
);
// There are a few basic options that we always want to
// include in the response. If client did not request
// them we append them for him.
appendBasicOptions
(
request
,
ack
);
}
return
(
ack
);
}
...
...
src/bin/dhcp4/tests/dhcp4_test_utils.cc
View file @
e9f4d7e5
...
...
@@ -321,7 +321,7 @@ void Dhcpv4SrvTest::testDiscoverRequest(const uint8_t msg_type) {
if
(
msg_type
==
DHCPDISCOVER
)
{
ASSERT_NO_THROW
(
rsp
=
srv
->
processDiscover
(
req
);
);
);
// Should return OFFER
ASSERT_TRUE
(
rsp
);
...
...
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