summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv/ncr_generator.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/dhcpsrv/ncr_generator.h')
-rw-r--r--src/lib/dhcpsrv/ncr_generator.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/lib/dhcpsrv/ncr_generator.h b/src/lib/dhcpsrv/ncr_generator.h
new file mode 100644
index 0000000..29b56a5
--- /dev/null
+++ b/src/lib/dhcpsrv/ncr_generator.h
@@ -0,0 +1,60 @@
+// Copyright (C) 2015-2021 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef NCR_GENERATOR_H
+#define NCR_GENERATOR_H
+
+#include <dhcp_ddns/ncr_msg.h>
+#include <dhcpsrv/lease.h>
+
+namespace isc {
+namespace dhcp {
+
+/// @brief Creates name change request from the DHCPv4 lease.
+///
+/// This function creates name change request from the information contained
+/// in the DHCPv4 lease. If the client identifier is present in the lease,
+/// this identifier is used to compute the DHCID, otherwise the HW address
+/// is used.
+///
+/// This function is exception safe. On failure, it logs an error.
+///
+/// @param chg_type Type of the name change request
+/// @param lease Pointer to the lease.
+void queueNCR(const dhcp_ddns::NameChangeType& chg_type, const Lease4Ptr& lease);
+
+/// @brief Creates name change request from the DHCPv6 lease.
+///
+/// This function creates name change request from the information contained
+/// in the DHCPv6 lease. The DUID is used to compute the DHCID for the name
+/// change request.
+///
+/// This function will skip sending the NCR if the lease type is a delegated
+/// prefix.
+///
+/// This function is exception safe. On failure, it logs an error.
+///
+/// @param chg_type Type of the name change request
+/// @param lease Pointer to the lease.
+void queueNCR(const dhcp_ddns::NameChangeType& chg_type, const Lease6Ptr& lease);
+
+/// @brief Calculates TTL for a DNS resource record based on lease life time.
+///
+/// Per RFC 4702 Section 5, the RR TTL should be calculated as:
+/// TTL = ((lease life time / 3) < 10 minutes) ? 10 minutes : (lease life time / 3)
+///
+/// This function may be expanded in the future to support configurable
+/// parameters.
+///
+/// @param lease_life_time valid life time of the lease
+///
+/// @return the calculated TTL.
+uint32_t calculateDdnsTtl(uint32_t lease_life_time);
+
+} // end of isc::dhcp namespace
+} // end of isc namespace
+
+#endif // NCR_GENERATOR_H