Commit 3004ceae authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[master] Merge branch 'trac4320'

parents ad8881db de29ab0f
......@@ -284,12 +284,15 @@ Dhcpv6Srv::testUnicast(const Pkt6Ptr& pkt) const {
return (true);
}
AllocEngine::ClientContext6
Dhcpv6Srv::createContext(const Pkt6Ptr& pkt) {
AllocEngine::ClientContext6 ctx;
void
Dhcpv6Srv::initContext(const Pkt6Ptr& pkt, AllocEngine::ClientContext6& ctx) {
ctx.subnet_ = selectSubnet(pkt);
ctx.duid_ = pkt->getClientId(),
ctx.fwd_dns_update_ = false;
ctx.rev_dns_update_ = false;
ctx.hostname_ = "";
ctx.query_ = pkt;
ctx.duid_ = pkt->getClientId();
ctx.callout_handle_ = getCalloutHandle(pkt);
ctx.hwaddr_ = getMAC(pkt);
// Collect host identifiers if host reservations enabled. The identifiers
......@@ -322,8 +325,6 @@ Dhcpv6Srv::createContext(const Pkt6Ptr& pkt) {
// Find host reservations using specified identifiers.
alloc_engine_->findReservation(ctx);
}
return (ctx);
}
bool Dhcpv6Srv::run() {
......@@ -1282,7 +1283,7 @@ Dhcpv6Srv::getMAC(const Pkt6Ptr& pkt) {
OptionPtr
Dhcpv6Srv::assignIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
AllocEngine::ClientContext6& orig_ctx,
AllocEngine::ClientContext6& ctx,
boost::shared_ptr<Option6IA> ia) {
// Check if the client sent us a hint in his IA_NA. Clients may send an
......@@ -1301,8 +1302,7 @@ Dhcpv6Srv::assignIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
.arg(hint_opt ? hint.toText() : "(no hint)");
// convenience values
const Subnet6Ptr& subnet = orig_ctx.subnet_;
const DuidPtr& duid = orig_ctx.duid_;
const Subnet6Ptr& subnet = ctx.subnet_;
// If there is no subnet selected for handling this IA_NA, the only thing left to do is
// to say that we are sorry, but the user won't get an address. As a convenience, we
......@@ -1346,19 +1346,21 @@ Dhcpv6Srv::assignIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
do_rev);
}
// Update per-packet context values.
ctx.fwd_dns_update_ = do_fwd;
ctx.rev_dns_update_ = do_rev;
ctx.fake_allocation_ = fake_allocation;
// Set per-IA context values.
ctx.createIAContext();
ctx.currentIA().iaid_ = ia->getIAID();
ctx.currentIA().addHint(hint);
ctx.currentIA().type_ = Lease::TYPE_NA;
// Use allocation engine to pick a lease for this client. Allocation engine
// will try to honor the hint, but it is just a hint - some other address
// may be used instead. If fake_allocation is set to false, the lease will
// be inserted into the LeaseMgr as well.
AllocEngine::ClientContext6 ctx(subnet, duid, ia->getIAID(),
hint, Lease::TYPE_NA, do_fwd, do_rev,
orig_ctx.hostname_, fake_allocation);
ctx.callout_handle_ = getCalloutHandle(query);
ctx.hwaddr_ = orig_ctx.hwaddr_;
ctx.host_ = orig_ctx.host_;
ctx.query_ = orig_ctx.query_;
ctx.host_identifiers_ = orig_ctx.host_identifiers_;
Lease6Collection leases = alloc_engine_->allocateLeases6(ctx);
/// @todo: Handle more than one lease
......@@ -1416,7 +1418,7 @@ Dhcpv6Srv::assignIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
OptionPtr
Dhcpv6Srv::assignIA_PD(const Pkt6Ptr& query, const Pkt6Ptr& answer,
AllocEngine::ClientContext6& orig_ctx,
AllocEngine::ClientContext6& ctx,
boost::shared_ptr<Option6IA> ia) {
// Check if the client sent us a hint in his IA_PD. Clients may send an
......@@ -1436,8 +1438,7 @@ Dhcpv6Srv::assignIA_PD(const Pkt6Ptr& query, const Pkt6Ptr& answer,
.arg(hint_opt ? hint.toText() : "(no hint)");
const Subnet6Ptr& subnet = orig_ctx.subnet_;
const DuidPtr& duid = orig_ctx.duid_;
const Subnet6Ptr& subnet = ctx.subnet_;
// Create IA_PD that we will put in the response.
// Do not use OptionDefinition to create option's instance so
......@@ -1467,20 +1468,18 @@ Dhcpv6Srv::assignIA_PD(const Pkt6Ptr& query, const Pkt6Ptr& answer,
// Reply message it means that it is committing leases. Other message
// type (Advertise) means that server is not committing leases (fake
// allocation).
bool fake_allocation = (answer->getType() != DHCPV6_REPLY);
ctx.fake_allocation_ = (answer->getType() != DHCPV6_REPLY);
// Set per-IA context values.
ctx.createIAContext();
ctx.currentIA().iaid_ = ia->getIAID();
ctx.currentIA().addHint(hint);
ctx.currentIA().type_ = Lease::TYPE_PD;
// Use allocation engine to pick a lease for this client. Allocation engine
// will try to honor the hint, but it is just a hint - some other address
// may be used instead. If fake_allocation is set to false, the lease will
// be inserted into the LeaseMgr as well.
AllocEngine::ClientContext6 ctx(subnet, duid, ia->getIAID(), hint, Lease::TYPE_PD,
false, false, string(), fake_allocation);
ctx.callout_handle_ = getCalloutHandle(query);
ctx.hwaddr_ = orig_ctx.hwaddr_;
ctx.host_ = orig_ctx.host_;
ctx.query_ = orig_ctx.query_;
ctx.host_identifiers_ = orig_ctx.host_identifiers_;
Lease6Collection leases = alloc_engine_->allocateLeases6(ctx);
if (!leases.empty()) {
......@@ -1493,7 +1492,7 @@ Dhcpv6Srv::assignIA_PD(const Pkt6Ptr& query, const Pkt6Ptr& answer,
// We have a lease! Let's wrap its content into IA_PD option
// with IAADDR suboption.
LOG_INFO(lease6_logger, fake_allocation ?
LOG_INFO(lease6_logger, ctx.fake_allocation_ ?
DHCP6_PD_LEASE_ADVERT : DHCP6_PD_LEASE_ALLOC)
.arg(query->getLabel())
.arg((*l)->addr_.toText())
......@@ -1516,7 +1515,7 @@ Dhcpv6Srv::assignIA_PD(const Pkt6Ptr& query, const Pkt6Ptr& answer,
// cause of that failure. The only thing left is to insert
// status code to pass the sad news to the client.
LOG_DEBUG(lease6_logger, DBG_DHCP6_DETAIL, fake_allocation ?
LOG_DEBUG(lease6_logger, DBG_DHCP6_DETAIL, ctx.fake_allocation_ ?
DHCP6_PD_LEASE_ADVERT_FAIL : DHCP6_PD_LEASE_ALLOC_FAIL)
.arg(query->getLabel())
.arg(ia->getIAID());
......@@ -1531,7 +1530,7 @@ Dhcpv6Srv::assignIA_PD(const Pkt6Ptr& query, const Pkt6Ptr& answer,
OptionPtr
Dhcpv6Srv::extendIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
AllocEngine::ClientContext6& orig_ctx,
AllocEngine::ClientContext6& ctx,
boost::shared_ptr<Option6IA> ia) {
LOG_DEBUG(lease6_logger, DBG_DHCP6_DETAIL, DHCP6_PROCESS_IA_NA_EXTEND)
......@@ -1539,8 +1538,7 @@ Dhcpv6Srv::extendIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
.arg(ia->getIAID());
// convenience values
const Subnet6Ptr& subnet = orig_ctx.subnet_;
const DuidPtr& duid = orig_ctx.duid_;
const Subnet6Ptr& subnet = ctx.subnet_;
// Create empty IA_NA option with IAID matching the request.
Option6IAPtr ia_rsp(new Option6IA(D6O_IA_NA, ia->getIAID()));
......@@ -1574,16 +1572,15 @@ Dhcpv6Srv::extendIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
do_fwd, do_rev);
}
// Create client context for this renewal
AllocEngine::ClientContext6 ctx(subnet, duid, ia->getIAID(),
IOAddress::IPV6_ZERO_ADDRESS(), Lease::TYPE_NA,
do_fwd, do_rev, orig_ctx.hostname_, false);
// Set per-packet context values.
ctx.fwd_dns_update_ = do_fwd;
ctx.rev_dns_update_ = do_rev;
ctx.callout_handle_ = getCalloutHandle(query);
ctx.query_ = query;
ctx.ia_rsp_ = ia_rsp;
ctx.hwaddr_ = orig_ctx.hwaddr_;
ctx.host_ = orig_ctx.host_;
// Set per-IA context values.
ctx.createIAContext();
ctx.currentIA().iaid_ = ia->getIAID();
ctx.currentIA().type_ = Lease::TYPE_NA;
ctx.currentIA().ia_rsp_ = ia_rsp;
// Extract the addresses that the client is trying to obtain.
OptionCollection addrs = ia->getOptions();
......@@ -1600,7 +1597,7 @@ Dhcpv6Srv::extendIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
// There's no way to protect against this.
continue;
}
ctx.hints_.push_back(make_pair(iaaddr->getAddress(), 128));
ctx.currentIA().addHint(iaaddr->getAddress());
}
Lease6Collection leases = alloc_engine_->renewLeases6(ctx);
......@@ -1610,6 +1607,13 @@ Dhcpv6Srv::extendIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
// - what we actually assigned in leases
// - old leases that are no longer valid in ctx.old_leases_
// For each IA inserted by the client we have to determine what to do
// about included addresses and notify the client. We will iterate over
// those prefixes and remove those that we have already processed. We
// don't want to remove them from the context, so we need to copy them
// into temporary container.
AllocEngine::HintContainer hints = ctx.currentIA().hints_;
// For all leases we have now, add the IAADDR with non-zero lifetimes.
for (Lease6Collection::const_iterator l = leases.begin(); l != leases.end(); ++l) {
Option6IAAddrPtr iaaddr(new Option6IAAddr(D6O_IAADDR,
......@@ -1621,22 +1625,21 @@ Dhcpv6Srv::extendIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
.arg(ia_rsp->getIAID());
// Now remove this address from the hints list.
AllocEngine::HintType tmp((*l)->addr_, 128);
ctx.hints_.erase(std::remove(ctx.hints_.begin(), ctx.hints_.end(), tmp),
ctx.hints_.end());
AllocEngine::ResourceType hint_type((*l)->addr_, 128);
hints.erase(std::remove(hints.begin(), hints.end(), hint_type),
hints.end());
}
// For the leases that we just retired, send the addresses with 0 lifetimes.
for (Lease6Collection::const_iterator l = ctx.old_leases_.begin();
l != ctx.old_leases_.end(); ++l) {
for (Lease6Collection::const_iterator l = ctx.currentIA().old_leases_.begin();
l != ctx.currentIA().old_leases_.end(); ++l) {
Option6IAAddrPtr iaaddr(new Option6IAAddr(D6O_IAADDR,
(*l)->addr_, 0, 0));
ia_rsp->addOption(iaaddr);
// Now remove this address from the hints list.
AllocEngine::HintType tmp((*l)->addr_, 128);
ctx.hints_.erase(std::remove(ctx.hints_.begin(), ctx.hints_.end(), tmp),
ctx.hints_.end());
AllocEngine::ResourceType hint_type((*l)->addr_, 128);
hints.erase(std::remove(hints.begin(), hints.end(), hint_type), hints.end());
// If the new FQDN settings have changed for the lease, we need to
// delete any existing FQDN records for this lease.
......@@ -1656,8 +1659,8 @@ Dhcpv6Srv::extendIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
// Finally, if there are any addresses requested that we haven't dealt with
// already, inform the client that he can't have them.
for (AllocEngine::HintContainer::const_iterator hint = ctx.hints_.begin();
hint != ctx.hints_.end(); ++hint) {
for (AllocEngine::HintContainer::const_iterator hint = hints.begin();
hint != hints.end(); ++hint) {
Option6IAAddrPtr iaaddr(new Option6IAAddr(D6O_IAADDR,
hint->first, 0, 0));
ia_rsp->addOption(iaaddr);
......@@ -1679,15 +1682,15 @@ Dhcpv6Srv::extendIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
OptionPtr
Dhcpv6Srv::extendIA_PD(const Pkt6Ptr& query,
AllocEngine::ClientContext6& orig_ctx,
AllocEngine::ClientContext6& ctx,
boost::shared_ptr<Option6IA> ia) {
LOG_DEBUG(lease6_logger, DBG_DHCP6_DETAIL, DHCP6_PROCESS_IA_PD_EXTEND)
.arg(query->getLabel())
.arg(ia->getIAID());
const Subnet6Ptr& subnet = orig_ctx.subnet_;
const DuidPtr& duid = orig_ctx.duid_;
const Subnet6Ptr& subnet = ctx.subnet_;
const DuidPtr& duid = ctx.duid_;
// Let's create a IA_PD response and fill it in later
Option6IAPtr ia_rsp(new Option6IA(D6O_IA_PD, ia->getIAID()));
......@@ -1726,16 +1729,11 @@ Dhcpv6Srv::extendIA_PD(const Pkt6Ptr& query,
ia_rsp->setT1(subnet->getT1());
ia_rsp->setT2(subnet->getT2());
// Create client context for this renewal
static const IOAddress none("::");
AllocEngine::ClientContext6 ctx(subnet, duid, ia->getIAID(), none,
Lease::TYPE_PD, false, false, string(""),
false);
ctx.callout_handle_ = getCalloutHandle(query);
ctx.query_ = query;
ctx.ia_rsp_ = ia_rsp;
ctx.hwaddr_ = orig_ctx.hwaddr_;
ctx.host_ = orig_ctx.host_;
// Set per-IA context values.
ctx.createIAContext();
ctx.currentIA().iaid_ = ia->getIAID();
ctx.currentIA().type_ = Lease::TYPE_PD;
ctx.currentIA().ia_rsp_ = ia_rsp;
// Extract prefixes that the client is trying to renew.
OptionCollection addrs = ia->getOptions();
......@@ -1754,7 +1752,7 @@ Dhcpv6Srv::extendIA_PD(const Pkt6Ptr& query,
}
// Put the client's prefix into the hints list.
ctx.hints_.push_back(make_pair(prf->getAddress(), prf->getLength()));
ctx.currentIA().addHint(prf->getAddress(), prf->getLength());
}
// Call Allocation Engine and attempt to renew leases. Number of things
......@@ -1767,6 +1765,13 @@ Dhcpv6Srv::extendIA_PD(const Pkt6Ptr& query,
// in PD context)
Lease6Collection leases = alloc_engine_->renewLeases6(ctx);
// For each IA inserted by the client we have to determine what to do
// about included prefixes and notify the client. We will iterate over
// those prefixes and remove those that we have already processed. We
// don't want to remove them from the context, so we need to copy them
// into temporary container.
AllocEngine::HintContainer hints = ctx.currentIA().hints_;
// For all the leases we have now, add the IAPPREFIX with non-zero lifetimes
for (Lease6Collection::const_iterator l = leases.begin(); l != leases.end(); ++l) {
Option6IAPrefixPtr prf(new Option6IAPrefix(D6O_IAPREFIX,
......@@ -1780,9 +1785,9 @@ Dhcpv6Srv::extendIA_PD(const Pkt6Ptr& query,
.arg(ia->getIAID());
// Now remove this address from the hints list.
AllocEngine::HintType tmp((*l)->addr_, (*l)->prefixlen_);
ctx.hints_.erase(std::remove(ctx.hints_.begin(), ctx.hints_.end(), tmp),
ctx.hints_.end());
AllocEngine::ResourceType hint_type((*l)->addr_, (*l)->prefixlen_);
hints.erase(std::remove(hints.begin(), hints.end(), hint_type),
hints.end());
}
/// @todo: Maybe we should iterate over ctx.old_leases_, i.e. the leases
......@@ -1792,8 +1797,8 @@ Dhcpv6Srv::extendIA_PD(const Pkt6Ptr& query,
// zero lifetimes
// Finally, if there are any addresses requested that we haven't dealt with
// already, inform the client that he can't have them.
for (AllocEngine::HintContainer::const_iterator prefix = ctx.hints_.begin();
prefix != ctx.hints_.end(); ++prefix) {
for (AllocEngine::HintContainer::const_iterator prefix = hints.begin();
prefix != hints.end(); ++prefix) {
// Send the prefix with the zero lifetimes only if the prefix
// contains non-zero value. A zero value indicates that the hint was
// for the prefix length.
......@@ -2233,7 +2238,8 @@ Dhcpv6Srv::processSolicit(const Pkt6Ptr& solicit) {
sanityCheck(solicit, MANDATORY, FORBIDDEN);
// Let's create a simplified client context here.
AllocEngine::ClientContext6 ctx = createContext(solicit);
AllocEngine::ClientContext6 ctx;
initContext(solicit, ctx);
Pkt6Ptr response(new Pkt6(DHCPV6_ADVERTISE, solicit->getTransid()));
......@@ -2277,7 +2283,8 @@ Dhcpv6Srv::processRequest(const Pkt6Ptr& request) {
sanityCheck(request, MANDATORY, MANDATORY);
// Let's create a simplified client context here.
AllocEngine::ClientContext6 ctx = createContext(request);
AllocEngine::ClientContext6 ctx;
initContext(request, ctx);
Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, request->getTransid()));
......@@ -2302,7 +2309,8 @@ Dhcpv6Srv::processRenew(const Pkt6Ptr& renew) {
sanityCheck(renew, MANDATORY, MANDATORY);
// Let's create a simplified client context here.
AllocEngine::ClientContext6 ctx = createContext(renew);
AllocEngine::ClientContext6 ctx;
initContext(renew, ctx);
Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, renew->getTransid()));
......@@ -2326,7 +2334,8 @@ Dhcpv6Srv::processRebind(const Pkt6Ptr& rebind) {
sanityCheck(rebind, MANDATORY, FORBIDDEN);
// Let's create a simplified client context here.
AllocEngine::ClientContext6 ctx = createContext(rebind);
AllocEngine::ClientContext6 ctx;
initContext(rebind, ctx);
Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, rebind->getTransid()));
......@@ -2350,7 +2359,8 @@ Dhcpv6Srv::processConfirm(const Pkt6Ptr& confirm) {
sanityCheck(confirm, MANDATORY, FORBIDDEN);
// Let's create a simplified client context here.
AllocEngine::ClientContext6 ctx = createContext(confirm);
AllocEngine::ClientContext6 ctx;
initContext(confirm, ctx);
// Get IA_NAs from the Confirm. If there are none, the message is
// invalid and must be discarded. There is nothing more to do.
......@@ -2440,7 +2450,8 @@ Dhcpv6Srv::processRelease(const Pkt6Ptr& release) {
sanityCheck(release, MANDATORY, MANDATORY);
// Let's create a simplified client context here.
AllocEngine::ClientContext6 ctx = createContext(release);
AllocEngine::ClientContext6 ctx;
initContext(release, ctx);
Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, release->getTransid()));
......@@ -2467,7 +2478,8 @@ Dhcpv6Srv::processDecline(const Pkt6Ptr& decline) {
Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, decline->getTransid()));
// Let's create a simplified client context here.
AllocEngine::ClientContext6 ctx = createContext(decline);
AllocEngine::ClientContext6 ctx;
initContext(decline, ctx);
// Copy client options (client-id, also relay information if present)
copyClientOptions(decline, reply);
......@@ -2743,7 +2755,8 @@ Dhcpv6Srv::processInfRequest(const Pkt6Ptr& inf_request) {
sanityCheck(inf_request, OPTIONAL, OPTIONAL);
// Let's create a simplified client context here.
AllocEngine::ClientContext6 ctx = createContext(inf_request);
AllocEngine::ClientContext6 ctx;
initContext(inf_request, ctx);
// Create a Reply packet, with the same trans-id as the client's.
Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, inf_request->getTransid()));
......
......@@ -307,13 +307,13 @@ protected:
/// @param answer server's response to the client's message. This
/// message should contain Client FQDN option being sent by the server
/// to the client (if the client sent this option to the server).
/// @param orig_ctx client context (contains subnet, duid and other parameters)
/// @param ctx client context (contains subnet, duid and other parameters)
/// @param ia pointer to client's IA_NA option (client's request)
///
/// @return IA_NA option (server's response)
OptionPtr assignIA_NA(const isc::dhcp::Pkt6Ptr& query,
const isc::dhcp::Pkt6Ptr& answer,
AllocEngine::ClientContext6& orig_ctx,
AllocEngine::ClientContext6& ctx,
Option6IAPtr ia);
/// @brief Processes IA_PD option (and assigns prefixes if necessary).
......@@ -326,12 +326,12 @@ protected:
///
/// @param query client's message (typically SOLICIT or REQUEST)
/// @param answer server's response to the client's message.
/// @param orig_ctx client context (contains subnet, duid and other parameters)
/// @param ctx client context (contains subnet, duid and other parameters)
/// @param ia pointer to client's IA_PD option (client's request)
/// @return IA_PD option (server's response)
OptionPtr assignIA_PD(const Pkt6Ptr& query,
const isc::dhcp::Pkt6Ptr& answer,
AllocEngine::ClientContext6& orig_ctx,
AllocEngine::ClientContext6& ctx,
boost::shared_ptr<Option6IA> ia);
/// @brief Extends lifetime of the specific IA_NA option.
......@@ -357,12 +357,12 @@ protected:
/// @param answer server's response to the client's message. This
/// message should contain Client FQDN option being sent by the server
/// to the client (if the client sent this option to the server).
/// @param orig_ctx client context (contains subnet, duid and other parameters)
/// @param ctx client context (contains subnet, duid and other parameters)
/// @param ia IA_NA option which carries address for which lease lifetime
/// will be extended.
/// @return IA_NA option (server's response)
OptionPtr extendIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
AllocEngine::ClientContext6& orig_ctx,
AllocEngine::ClientContext6& ctx,
Option6IAPtr ia);
/// @brief Extends lifetime of the prefix.
......@@ -377,14 +377,14 @@ protected:
/// (see RFC3633, section 12.2. for details).
///
/// @param query client's message
/// @param orig_ctx client context (contains subnet, duid and other parameters)
/// @param ctx client context (contains subnet, duid and other parameters)
/// @param ia IA_PD option that is being renewed
/// @return IA_PD option (server's response)
/// @throw DHCPv6DiscardMessageError when the message being processed should
/// be discarded by the server, i.e. there is no binding for the client doing
/// Rebind.
OptionPtr extendIA_PD(const Pkt6Ptr& query,
AllocEngine::ClientContext6& orig_ctx,
AllocEngine::ClientContext6& ctx,
Option6IAPtr ia);
/// @brief Releases specific IA_NA option
......@@ -638,9 +638,9 @@ protected:
/// - there is no such option provided by the server)
void processRSOO(const Pkt6Ptr& query, const Pkt6Ptr& rsp);
/// @brief Creates client context for specified packet
/// @brief Initializes client context for specified packet
///
/// Instantiates the ClientContext6 and then:
/// This method:
/// - Performs the subnet selection and stores the result in context
/// - Extracts the duid from the packet and saves it to the context
/// - Extracts the hardware address from the packet and saves it to
......@@ -648,8 +648,16 @@ protected:
/// - Performs host reservation lookup and stores the result in the
/// context
///
/// @return client context
AllocEngine::ClientContext6 createContext(const Pkt6Ptr& pkt);
/// Even though the incoming packet type is known to this method, it
/// doesn't set the @c fake_allocation flag, because of a possibility
/// that the Rapid Commit option is in use. The @c fake_allocation
/// flag is set appropriately after it has been determined whether
/// the Rapid Commit option was included and that the server respects
/// it.
///
/// @param pkt pointer to a packet for which context will be created.
/// @param [out] ctx reference to context object to be initialized.
void initContext(const Pkt6Ptr& pkt, AllocEngine::ClientContext6& ctx);
/// @brief this is a prefix added to the contend of vendor-class option
///
......
......@@ -130,7 +130,7 @@ public:
using Dhcpv6Srv::shutdown_;
using Dhcpv6Srv::name_change_reqs_;
using Dhcpv6Srv::VENDOR_CLASS_PREFIX;
using Dhcpv6Srv::createContext;
using Dhcpv6Srv::initContext;
/// @brief packets we pretend to receive
///
......
This diff is collapsed.
......@@ -24,6 +24,7 @@
#include <list>
#include <map>
#include <set>
#include <utility>
namespace isc {
......@@ -248,10 +249,13 @@ public:
/// This is an entry that represents what the client had requested,
/// either an address or a prefix. Prefix length is 128 for regular
/// addresses.
typedef std::pair<isc::asiolink::IOAddress, uint8_t> HintType;
typedef std::pair<isc::asiolink::IOAddress, uint8_t> ResourceType;
/// @brief Container for client's hints.
typedef std::vector<HintType> HintContainer;
typedef std::vector<ResourceType> HintContainer;
/// @brief Container holding allocated prefixes or addresses.
typedef std::set<ResourceType> ResourceContainer;
/// @brief A tuple holding host identifier type and value.
typedef std::pair<Host::IdentifierType, std::vector<uint8_t> > IdentifierPair;
......@@ -281,27 +285,40 @@ public:
/// that the big advantage of using the context structure to pass
/// information to the allocation engine methods is that adding
/// new information doesn't modify the API of the allocation engine.
struct ClientContext6 {
struct ClientContext6 : public boost::noncopyable {
/// @name Parameters pertaining to DHCPv6 message
//@{
/// @brief A pointer to the client's message
///
/// This is used exclusively for hook purposes.
Pkt6Ptr query_;
/// @brief Indicates if this is a real or fake allocation.
///
/// The real allocation is when the allocation engine is supposed
/// to make an update in a lease database: create new lease, or
/// update existing lease.
bool fake_allocation_;
/// @brief Subnet selected for the client by the server.
Subnet6Ptr subnet_;
/// @brief Client identifier
DuidPtr duid_;
/// @brief iaid IAID field from IA_NA or IA_PD that is being processed
uint32_t iaid_;
/// @brief Lease type (IA or PD)
Lease::Type type_;
/// @brief Hardware/MAC address (if available, may be NULL)
HWAddrPtr hwaddr_;
/// @brief client's hints
/// @brief A list holding host identifiers extracted from a message
/// received by the server.
IdentifierList host_identifiers_;
/// @brief A pointer to the object identifying host reservations.
///
/// There will typically be just one address, but the protocol allows
/// more than one address or prefix for each IA container.
HintContainer hints_;
/// May be NULL if there are no reservations.
ConstHostPtr host_;
/// @brief A boolean value which indicates that server takes
/// responsibility for the forward DNS Update for this lease
......@@ -322,45 +339,77 @@ public:
/// @brief Callout handle associated with the client's message.
hooks::CalloutHandlePtr callout_handle_;
/// @brief Indicates if this is a real or fake allocation.
///
/// The real allocation is when the allocation engine is supposed
/// to make an update in a lease database: create new lease, or
/// update existing lease.
bool fake_allocation_;
/// @brief A pointer to any old leases that the client had before update
/// but are no longer valid after the update/allocation.
///
/// This collection is typically empty, except cases when we are doing
/// address reassignment, e.g. because there is a host reservation that
/// gives this address to someone else, so we had to return the address,
/// and give a new one to this client.
Lease6Collection old_leases_;
/// @brief A pointer to any leases that have changed FQDN information.
/// @brief Holds addresses and prefixes allocated for all IAs.
ResourceContainer allocated_resources_;
//@}
/// @brief Parameters pertaining to individual IAs.
struct IAContext {
/// @brief iaid IAID field from IA_NA or IA_PD that is being
/// processed
uint32_t iaid_;