duid_(duid), hwaddr_(), host_identifiers_(), hosts_(),
fwd_dns_update_(fwd_dns), rev_dns_update_(rev_dns), hostname_(hostname),
callout_handle_(callout_handle), allocated_resources_(), new_leases_(),
- ias_(), ddns_params_(new DdnsParams()) {
+ ias_(), ddns_params_() {
// Initialize host identifiers.
if (duid) {
return (ghost && ghost->hasReservation(resv));
}
+DdnsParamsPtr
+AllocEngine::ClientContext6::getDdnsParams() {
+ // We already have it, return it.
+ if (ddns_params_) {
+ return (ddns_params_);
+ }
+
+ // Haven't created it, so this is the first time we've needed it
+ // since being given a subnet.
+ if (subnet_) {
+ ddns_params_ = CfgMgr::instance().getCurrentCfg()->getDdnsParams(*subnet_);
+ return (ddns_params_);
+ }
+
+ // Asked for it without a subnet? This case really shouldn't occur but
+ // for now let's an instance with default values.
+ std::cout << "ClientContext6, Hey we're accessing this without a subnet!" << std::endl;
+ return (DdnsParamsPtr(new DdnsParams()));
+}
+
void AllocEngine::findReservation(ClientContext6& ctx) {
ctx.hosts_.clear();
// the hostname as it is specified for the reservation.
OptionPtr fqdn = ctx.query_->getOption(D6O_CLIENT_FQDN);
ctx.hostname_ = CfgMgr::instance().getD2ClientMgr().
- qualifyName(host->getHostname(), *ctx.ddns_params_,
+ qualifyName(host->getHostname(), *ctx.getDdnsParams(),
static_cast<bool>(fqdn));
}
}
// the hostname as it is specified for the reservation.
OptionPtr fqdn = ctx.query_->getOption(D6O_CLIENT_FQDN);
ctx.hostname_ = CfgMgr::instance().getD2ClientMgr().
- qualifyName(host->getHostname(), *ctx.ddns_params_,
+ qualifyName(host->getHostname(), *ctx.getDdnsParams(),
static_cast<bool>(fqdn));
}
}
// the hostname as it is specified for the reservation.
OptionPtr fqdn = ctx.query_->getOption(D6O_CLIENT_FQDN);
ctx.hostname_ = CfgMgr::instance().getD2ClientMgr().
- qualifyName(ghost->getHostname(), *ctx.ddns_params_,
+ qualifyName(ghost->getHostname(), *ctx.getDdnsParams(),
static_cast<bool>(fqdn));
}
// the hostname as it is specified for the reservation.
OptionPtr fqdn = ctx.query_->getOption(D6O_CLIENT_FQDN);
ctx.hostname_ = CfgMgr::instance().getD2ClientMgr().
- qualifyName(ghost->getHostname(), *ctx.ddns_params_,
+ qualifyName(ghost->getHostname(), *ctx.getDdnsParams(),
static_cast<bool>(fqdn));
}
hostname_(""), callout_handle_(), fake_allocation_(false),
old_lease_(), new_lease_(), hosts_(), conflicting_lease_(),
query_(), host_identifiers_(),
- ddns_params_(new DdnsParams()) {
+ ddns_params_() {
}
AllocEngine::ClientContext4::ClientContext4(const Subnet4Ptr& subnet,
return (ConstHostPtr());
}
+DdnsParamsPtr
+AllocEngine::ClientContext4::getDdnsParams() {
+ // We already have it, return it.
+ if (ddns_params_) {
+ return (ddns_params_);
+ }
+
+ // Haven't created it, so this is the first time we've needed it
+ // since being given a subnet.
+ if (subnet_) {
+ ddns_params_ = CfgMgr::instance().getCurrentCfg()->getDdnsParams(*subnet_);
+ return (ddns_params_);
+ }
+
+ // Asked for it without a subnet? This case really shouldn't occur but
+ // for now let's an instance with default values.
+ std::cout << "ClientContext4, Hey we're accessing this without a subnet!" << std::endl;
+ return (DdnsParamsPtr(new DdnsParams()));
+}
+
Lease4Ptr
AllocEngine::allocateLease4(ClientContext4& ctx) {
// The NULL pointer indicates that the old lease didn't exist. It may
/// @brief Container holding IA specific contexts.
std::vector<IAContext> ias_;
- /// @brief Holds scoped DDNS behavioral parameters
- DdnsParamsPtr ddns_params_;
+ /// @brief Returns the set of DDNS behavioral parameters based on
+ /// the selected subnet.
+ ///
+ /// If there is no selected subnet (i.e. subnet_ is empty), the
+ /// returned set will cotain default values.
+ ///
+ /// @return pointer to a DdnsParams instance
+ DdnsParamsPtr getDdnsParams();
/// @brief Convenience method adding allocated prefix or address.
///
const Pkt6Ptr& query,
const hooks::CalloutHandlePtr& callout_handle =
hooks::CalloutHandlePtr());
+
+ private:
+ /// @brief Contains a pointer to the DDNS parameters for selected
+ /// subnet. Set by the first call to getDdnsParams() made when
+ /// the context has a selected subnet (i.e. subnet_ is not empty).
+ DdnsParamsPtr ddns_params_;
};
/// @brief Allocates IPv6 leases for a given IA container
/// received by the server.
IdentifierList host_identifiers_;
- /// @brief Holds scoped DDNS behavioral parameters
- DdnsParamsPtr ddns_params_;
+ /// @brief Returns the set of DDNS behavioral parameters based on
+ /// the selected subnet.
+ ///
+ /// If there is no selected subnet (i.e. subnet_ is empty), the
+ /// returned set will cotain default values.
+ ///
+ /// @return pointer to a DdnsParams instance
+ DdnsParamsPtr getDdnsParams();
/// @brief Convenience function adding host identifier into
/// @ref host_identifiers_ list.
const bool fwd_dns_update, const bool rev_dns_update,
const std::string& hostname, const bool fake_allocation);
+ private:
+ /// @brief Contains a pointer to the DDNS parameters for selected
+ /// subnet. Set by the first call to getDdnsParams() made when
+ /// the context has a selected subnet (i.e. subnet_ is not empty).
+ DdnsParamsPtr ddns_params_;
};
/// @brief Pointer to the @c ClientContext4.