Commit a0e73dd7 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[3152] Changes after review: assignIA_PD cleaned up

parent 988ee2ac
...@@ -1312,18 +1312,17 @@ Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid, ...@@ -1312,18 +1312,17 @@ Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
OptionPtr OptionPtr
Dhcpv6Srv::assignIA_PD(const Subnet6Ptr& subnet, const DuidPtr& duid, Dhcpv6Srv::assignIA_PD(const Subnet6Ptr& subnet, const DuidPtr& duid,
const Pkt6Ptr& query, boost::shared_ptr<Option6IA> ia) { const Pkt6Ptr& query, boost::shared_ptr<Option6IA> ia) {
// Create IA_PD that we will put in the response.
// Do not use OptionDefinition to create option's instance so
// as we can initialize IAID using a constructor.
boost::shared_ptr<Option6IA> ia_rsp(new Option6IA(D6O_IA_PD, ia->getIAID()));
// If there is no subnet selected for handling this IA_PD, the only thing to // If there is no subnet selected for handling this IA_PD, the only thing to
// do left is to say that we are sorry, but the user won't get an address. // do left is to say that we are sorry, but the user won't get an address.
// As a convenience, we use a different status text to indicate that // As a convenience, we use a different status text to indicate that
// (compare to the same status code, but different wording below) // (compare to the same status code, but different wording below)
if (!subnet) { if (!subnet) {
// Create empty IA_PD option with IAID matching the request.
// Note that we don't use OptionDefinition class to create this option.
// This is because we prefer using a constructor of Option6IA that
// initializes IAID. Otherwise we would have to use setIAID() after
// creation of the option which has some performance implications.
boost::shared_ptr<Option6IA> ia_rsp(new Option6IA(D6O_IA_PD,
ia->getIAID()));
// Insert status code NoAddrsAvail. // Insert status code NoAddrsAvail.
ia_rsp->addOption(createStatusCode(STATUS_NoPrefixAvail, ia_rsp->addOption(createStatusCode(STATUS_NoPrefixAvail,
...@@ -1351,11 +1350,7 @@ Dhcpv6Srv::assignIA_PD(const Subnet6Ptr& subnet, const DuidPtr& duid, ...@@ -1351,11 +1350,7 @@ Dhcpv6Srv::assignIA_PD(const Subnet6Ptr& subnet, const DuidPtr& duid,
// the user selects this server to do actual allocation (i.e. sends REQUEST) // the user selects this server to do actual allocation (i.e. sends REQUEST)
// it should include this hint. That will help us during the actual lease // it should include this hint. That will help us during the actual lease
// allocation. // allocation.
bool fake_allocation = false; bool fake_allocation = (query->getType() == DHCPV6_SOLICIT);
if (query->getType() == DHCPV6_SOLICIT) {
/// @todo: Check if we support rapid commit
fake_allocation = true;
}
CalloutHandlePtr callout_handle = getCalloutHandle(query); CalloutHandlePtr callout_handle = getCalloutHandle(query);
...@@ -1371,11 +1366,6 @@ Dhcpv6Srv::assignIA_PD(const Subnet6Ptr& subnet, const DuidPtr& duid, ...@@ -1371,11 +1366,6 @@ Dhcpv6Srv::assignIA_PD(const Subnet6Ptr& subnet, const DuidPtr& duid,
fake_allocation, fake_allocation,
callout_handle); callout_handle);
// Create IA_PD that we will put in the response.
// Do not use OptionDefinition to create option's instance so
// as we can initialize IAID using a constructor.
boost::shared_ptr<Option6IA> ia_rsp(new Option6IA(D6O_IA_PD, ia->getIAID()));
if (!leases.empty()) { if (!leases.empty()) {
ia_rsp->setT1(subnet->getT1()); ia_rsp->setT1(subnet->getT1());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment