35template<
typename LeasePtrType,
typename IdentifierType>
37generateNCRCommon(
const NameChangeType& chg_type,
const LeasePtrType& lease,
41 if (lease->hostname_.empty() || (!lease->fqdn_fwd_ && !lease->fqdn_rev_)
54 static_cast<void>(ddns_params.setPoolFromAddress(lease->addr_));
56 auto mode = ddns_params.getConflictResolutionMode();
61 ddns_ttl_percent = ddns_params.getTtlPercent();
62 ddns_ttl = ddns_params.getTtl();
63 ddns_ttl_min = ddns_params.getTtlMin();
64 ddns_ttl_max = ddns_params.getTtlMax();
68 std::vector<uint8_t> hostname_wire;
74 ddns_ttl_percent, ddns_ttl,
75 ddns_ttl_min, ddns_ttl_max);
79 lease->hostname_, lease->addr_.toText(),
80 dhcid, ttl, conflict_resolution_mode));
100template<
typename LeasePtrType,
typename IdentifierType>
101void queueNCRCommon(
const NameChangeType& chg_type,
const LeasePtrType& lease,
110 .arg(lease->addr_.toText());
118 .arg(chg_type ==
CHG_ADD ?
"add" :
"remove")
120 }
catch (
const std::exception& ex) {
123 .arg(chg_type ==
CHG_ADD ?
"add" :
"remove")
124 .arg(lease->addr_.toText())
139 ->getCfgSubnets4()->getSubnet(lease->subnet_id_);
142 if (lease->client_id_) {
143 queueNCRCommon(chg_type, lease, lease->client_id_->getClientId(),
148 queueNCRCommon(chg_type, lease, lease->hwaddr_,
161 ->getCfgSubnets4()->getSubnet(lease->subnet_id_);
165 if (lease->client_id_) {
166 ncr = generateNCRCommon(chg_type, lease,
167 lease->client_id_->getClientId(), subnet);
171 ncr = generateNCRCommon(chg_type, lease, lease->hwaddr_, subnet);
173 }
catch (
const std::exception& ex) {
176 .arg(chg_type ==
CHG_ADD ?
"add" :
"remove")
177 .arg(lease->addr_.toText())
191 ->getCfgSubnets6()->getSubnet(lease->subnet_id_);
193 queueNCRCommon(chg_type, lease, *(lease->duid_),
206 ->getCfgSubnets6()->getSubnet(lease->subnet_id_);
208 ncr = generateNCRCommon(chg_type, lease, *(lease->duid_), subnet);
209 }
catch (
const std::exception& ex) {
212 .arg(chg_type ==
CHG_ADD ?
"add" :
"remove")
213 .arg(lease->addr_.toText())
228 return (ddns_ttl.
get());
232 double ttl_percent = (ddns_ttl_percent.
get() > 0.0 ?
233 ddns_ttl_percent.
get() : 0.33333);
236 uint32_t ttl =
static_cast<uint32_t
>(round(ttl_percent * lease_lft));
241 uint32_t ttl_min = (ddns_ttl_min.
get() > 0) ? ddns_ttl_min.
get() : 600;
253 uint32_t ttl_max = ddns_ttl_max.
get();
254 if (ttl_max && ttl > ttl_max) {
D2ClientMgr & getD2ClientMgr()
Fetches the DHCP-DDNS manager.
static CfgMgr & instance()
returns a single instance of Configuration Manager
SrvConfigPtr getCurrentCfg()
Returns a pointer to the current configuration.
void sendRequest(dhcp_ddns::NameChangeRequestPtr &ncr)
Send the given NameChangeRequests to kea-dhcp-ddns.
Convenience container for conveying DDNS behavioral parameters It is intended to be created per Packe...
static void writeFqdn(const std::string &fqdn, std::vector< uint8_t > &buf, const bool downcase=false)
Append FQDN into a buffer.
static std::string makeLabel(const HWAddrPtr &hwaddr, const ClientIdPtr &client_id, const uint32_t transid)
Returns text representation of the given packet identifiers.
static std::string makeLabel(const DuidPtr duid, const uint32_t transid, const HWAddrPtr &hwaddr)
Returns text representation of the given packet identifiers.
Container class for handling the DHCID value within a NameChangeRequest.
Represents a DHCP-DDNS client request.
A template representing an optional value.
T get() const
Retrieves the encapsulated value.
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
Defines the D2ClientMgr class.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
NameChangeType
Defines the types of DNS updates that can be requested.
ConflictResolutionMode StringToConflictResolutionMode(const std::string &mode_str)
Function which converts string to ConflictResolutionMode enum values.
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
const int DHCPSRV_DBG_TRACE_DETAIL_DATA
Additional information.
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
uint32_t calculateDdnsTtl(uint32_t lease_lft, const util::Optional< double > &ddns_ttl_percent, const util::Optional< uint32_t > &ddns_ttl, const util::Optional< uint32_t > &ddns_ttl_min, const util::Optional< uint32_t > &ddns_ttl_max)
Calculates TTL for a DNS resource record based on lease life time.
const isc::log::MessageID DHCPSRV_QUEUE_NCR
void queueNCR(const NameChangeType &chg_type, const Lease4Ptr &lease)
Creates NameChangeRequest from the DHCPv4 lease and queues it to be sent to D2.
boost::shared_ptr< const Subnet6 > ConstSubnet6Ptr
A const pointer to a Subnet6 object.
const isc::log::MessageID DHCPSRV_GENERATE_NCR4_FAILED
boost::shared_ptr< const Subnet4 > ConstSubnet4Ptr
A const pointer to a Subnet4 object.
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
const isc::log::MessageID DHCPSRV_DDNS_TTL_TOO_LARGE
const isc::log::MessageID DHCPSRV_QUEUE_NCR_FAILED
const int DHCPSRV_DBG_TRACE_DETAIL
Additional information.
const isc::log::MessageID DHCPSRV_GENERATE_NCR6_FAILED
const isc::log::MessageID DHCPSRV_QUEUE_NCR_SKIP
const isc::log::MessageID DHCPSRV_DDNS_TTL_TOO_SMALL
NameChangeRequestPtr generateNCR(const NameChangeType &chg_type, const Lease4Ptr &lease)
Creates NameChangeRequest from the DHCPv4 lease.
boost::shared_ptr< const Subnet > ConstSubnetPtr
A generic pointer to either const Subnet4 or const Subnet6 object.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
string dumpDouble(double val, size_t precision)
Converts a double to a string with given precision.
Defines the logger used by the top-level component of kea-lfc.
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)