mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 13:37:55 +00:00
[#35,!517] Added getDdnsParams() to AllocEngine::ClientContext4/6
src/lib/dhcpsrv/alloc_engine.* AllocEngine::ClientContext6::getDdnsParams() AllocEngine::ClientContext4::getDdnsParams() - new methods which return a DdnsParams instance scoped by currently selected subnet Replaced direct references to context::ddns_params_ with new getter methods. src/lib/dhcpsrv/parsers/simple_parser4.cc src/lib/dhcpsrv/parsers/simple_parser6.cc Removed global defaults for hostname-char-set/replacement
This commit is contained in:
@@ -446,7 +446,7 @@ AllocEngine::ClientContext6::ClientContext6(const Subnet6Ptr& subnet,
|
|||||||
duid_(duid), hwaddr_(), host_identifiers_(), hosts_(),
|
duid_(duid), hwaddr_(), host_identifiers_(), hosts_(),
|
||||||
fwd_dns_update_(fwd_dns), rev_dns_update_(rev_dns), hostname_(hostname),
|
fwd_dns_update_(fwd_dns), rev_dns_update_(rev_dns), hostname_(hostname),
|
||||||
callout_handle_(callout_handle), allocated_resources_(), new_leases_(),
|
callout_handle_(callout_handle), allocated_resources_(), new_leases_(),
|
||||||
ias_(), ddns_params_(new DdnsParams()) {
|
ias_(), ddns_params_() {
|
||||||
|
|
||||||
// Initialize host identifiers.
|
// Initialize host identifiers.
|
||||||
if (duid) {
|
if (duid) {
|
||||||
@@ -538,6 +538,26 @@ AllocEngine::ClientContext6::hasGlobalReservation(const IPv6Resrv& resv) const {
|
|||||||
return (ghost && ghost->hasReservation(resv));
|
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) {
|
void AllocEngine::findReservation(ClientContext6& ctx) {
|
||||||
ctx.hosts_.clear();
|
ctx.hosts_.clear();
|
||||||
|
|
||||||
@@ -1157,7 +1177,7 @@ AllocEngine::allocateReservedLeases6(ClientContext6& ctx,
|
|||||||
// the hostname as it is specified for the reservation.
|
// the hostname as it is specified for the reservation.
|
||||||
OptionPtr fqdn = ctx.query_->getOption(D6O_CLIENT_FQDN);
|
OptionPtr fqdn = ctx.query_->getOption(D6O_CLIENT_FQDN);
|
||||||
ctx.hostname_ = CfgMgr::instance().getD2ClientMgr().
|
ctx.hostname_ = CfgMgr::instance().getD2ClientMgr().
|
||||||
qualifyName(host->getHostname(), *ctx.ddns_params_,
|
qualifyName(host->getHostname(), *ctx.getDdnsParams(),
|
||||||
static_cast<bool>(fqdn));
|
static_cast<bool>(fqdn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1230,7 +1250,7 @@ AllocEngine::allocateReservedLeases6(ClientContext6& ctx,
|
|||||||
// the hostname as it is specified for the reservation.
|
// the hostname as it is specified for the reservation.
|
||||||
OptionPtr fqdn = ctx.query_->getOption(D6O_CLIENT_FQDN);
|
OptionPtr fqdn = ctx.query_->getOption(D6O_CLIENT_FQDN);
|
||||||
ctx.hostname_ = CfgMgr::instance().getD2ClientMgr().
|
ctx.hostname_ = CfgMgr::instance().getD2ClientMgr().
|
||||||
qualifyName(host->getHostname(), *ctx.ddns_params_,
|
qualifyName(host->getHostname(), *ctx.getDdnsParams(),
|
||||||
static_cast<bool>(fqdn));
|
static_cast<bool>(fqdn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1306,7 +1326,7 @@ AllocEngine::allocateGlobalReservedLeases6(ClientContext6& ctx,
|
|||||||
// the hostname as it is specified for the reservation.
|
// the hostname as it is specified for the reservation.
|
||||||
OptionPtr fqdn = ctx.query_->getOption(D6O_CLIENT_FQDN);
|
OptionPtr fqdn = ctx.query_->getOption(D6O_CLIENT_FQDN);
|
||||||
ctx.hostname_ = CfgMgr::instance().getD2ClientMgr().
|
ctx.hostname_ = CfgMgr::instance().getD2ClientMgr().
|
||||||
qualifyName(ghost->getHostname(), *ctx.ddns_params_,
|
qualifyName(ghost->getHostname(), *ctx.getDdnsParams(),
|
||||||
static_cast<bool>(fqdn));
|
static_cast<bool>(fqdn));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1357,7 +1377,7 @@ AllocEngine::allocateGlobalReservedLeases6(ClientContext6& ctx,
|
|||||||
// the hostname as it is specified for the reservation.
|
// the hostname as it is specified for the reservation.
|
||||||
OptionPtr fqdn = ctx.query_->getOption(D6O_CLIENT_FQDN);
|
OptionPtr fqdn = ctx.query_->getOption(D6O_CLIENT_FQDN);
|
||||||
ctx.hostname_ = CfgMgr::instance().getD2ClientMgr().
|
ctx.hostname_ = CfgMgr::instance().getD2ClientMgr().
|
||||||
qualifyName(ghost->getHostname(), *ctx.ddns_params_,
|
qualifyName(ghost->getHostname(), *ctx.getDdnsParams(),
|
||||||
static_cast<bool>(fqdn));
|
static_cast<bool>(fqdn));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3008,7 +3028,7 @@ AllocEngine::ClientContext4::ClientContext4()
|
|||||||
hostname_(""), callout_handle_(), fake_allocation_(false),
|
hostname_(""), callout_handle_(), fake_allocation_(false),
|
||||||
old_lease_(), new_lease_(), hosts_(), conflicting_lease_(),
|
old_lease_(), new_lease_(), hosts_(), conflicting_lease_(),
|
||||||
query_(), host_identifiers_(),
|
query_(), host_identifiers_(),
|
||||||
ddns_params_(new DdnsParams()) {
|
ddns_params_() {
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocEngine::ClientContext4::ClientContext4(const Subnet4Ptr& subnet,
|
AllocEngine::ClientContext4::ClientContext4(const Subnet4Ptr& subnet,
|
||||||
@@ -3047,6 +3067,26 @@ AllocEngine::ClientContext4::currentHost() const {
|
|||||||
return (ConstHostPtr());
|
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
|
Lease4Ptr
|
||||||
AllocEngine::allocateLease4(ClientContext4& ctx) {
|
AllocEngine::allocateLease4(ClientContext4& ctx) {
|
||||||
// The NULL pointer indicates that the old lease didn't exist. It may
|
// The NULL pointer indicates that the old lease didn't exist. It may
|
||||||
|
@@ -553,8 +553,14 @@ public:
|
|||||||
/// @brief Container holding IA specific contexts.
|
/// @brief Container holding IA specific contexts.
|
||||||
std::vector<IAContext> ias_;
|
std::vector<IAContext> ias_;
|
||||||
|
|
||||||
/// @brief Holds scoped DDNS behavioral parameters
|
/// @brief Returns the set of DDNS behavioral parameters based on
|
||||||
DdnsParamsPtr ddns_params_;
|
/// 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.
|
/// @brief Convenience method adding allocated prefix or address.
|
||||||
///
|
///
|
||||||
@@ -652,6 +658,12 @@ public:
|
|||||||
const Pkt6Ptr& query,
|
const Pkt6Ptr& query,
|
||||||
const hooks::CalloutHandlePtr& callout_handle =
|
const hooks::CalloutHandlePtr& callout_handle =
|
||||||
hooks::CalloutHandlePtr());
|
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
|
/// @brief Allocates IPv6 leases for a given IA container
|
||||||
@@ -1323,8 +1335,14 @@ public:
|
|||||||
/// received by the server.
|
/// received by the server.
|
||||||
IdentifierList host_identifiers_;
|
IdentifierList host_identifiers_;
|
||||||
|
|
||||||
/// @brief Holds scoped DDNS behavioral parameters
|
/// @brief Returns the set of DDNS behavioral parameters based on
|
||||||
DdnsParamsPtr ddns_params_;
|
/// 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
|
/// @brief Convenience function adding host identifier into
|
||||||
/// @ref host_identifiers_ list.
|
/// @ref host_identifiers_ list.
|
||||||
@@ -1364,6 +1382,11 @@ public:
|
|||||||
const bool fwd_dns_update, const bool rev_dns_update,
|
const bool fwd_dns_update, const bool rev_dns_update,
|
||||||
const std::string& hostname, const bool fake_allocation);
|
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.
|
/// @brief Pointer to the @c ClientContext4.
|
||||||
|
@@ -111,9 +111,7 @@ const SimpleDefaults SimpleParser4::GLOBAL4_DEFAULTS = {
|
|||||||
{ "ddns-replace-client-name", Element::string, "never" },
|
{ "ddns-replace-client-name", Element::string, "never" },
|
||||||
{ "ddns-generated-prefix", Element::string, "myhost" },
|
{ "ddns-generated-prefix", Element::string, "myhost" },
|
||||||
// TKM should this still be true? qualifying-suffix has no default ??
|
// TKM should this still be true? qualifying-suffix has no default ??
|
||||||
{ "ddns-qualifying-suffix", Element::string, "" },
|
{ "ddns-qualifying-suffix", Element::string, "" }
|
||||||
{ "hostname-char-set", Element::string, "" },
|
|
||||||
{ "hostname-char-replacement", Element::string, "" }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief This table defines all option definition parameters.
|
/// @brief This table defines all option definition parameters.
|
||||||
|
@@ -106,9 +106,7 @@ const SimpleDefaults SimpleParser6::GLOBAL6_DEFAULTS = {
|
|||||||
{ "ddns-replace-client-name", Element::string, "never" },
|
{ "ddns-replace-client-name", Element::string, "never" },
|
||||||
{ "ddns-generated-prefix", Element::string, "myhost" },
|
{ "ddns-generated-prefix", Element::string, "myhost" },
|
||||||
// TKM should this still be true? qualifying-suffix has no default ??
|
// TKM should this still be true? qualifying-suffix has no default ??
|
||||||
{ "ddns-qualifying-suffix", Element::string, "" },
|
{ "ddns-qualifying-suffix", Element::string, "" }
|
||||||
{ "hostname-char-set", Element::string, "" },
|
|
||||||
{ "hostname-char-replacement", Element::string, "" }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief This table defines all option definition parameters.
|
/// @brief This table defines all option definition parameters.
|
||||||
|
@@ -594,7 +594,7 @@ SrvConfig::getDdnsParams(const Subnet& subnet) const {
|
|||||||
DdnsParamsPtr params(new DdnsParams());
|
DdnsParamsPtr params(new DdnsParams());
|
||||||
|
|
||||||
params->enable_updates_ = (getD2ClientConfig()->getEnableUpdates() &&
|
params->enable_updates_ = (getD2ClientConfig()->getEnableUpdates() &&
|
||||||
subnet.getDdnsSendUpdates().get());
|
subnet.getDdnsSendUpdates().get());
|
||||||
|
|
||||||
params->override_no_update_ = subnet.getDdnsOverrideNoUpdate().get();
|
params->override_no_update_ = subnet.getDdnsOverrideNoUpdate().get();
|
||||||
params->override_client_update_ = subnet.getDdnsOverrideClientUpdate().get();
|
params->override_client_update_ = subnet.getDdnsOverrideClientUpdate().get();
|
||||||
|
Reference in New Issue
Block a user