]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Implement various dns_xfrin_get*() functions
authorAram Sargsyan <aram@isc.org>
Tue, 30 May 2023 14:56:32 +0000 (14:56 +0000)
committerAram Sargsyan <aram@isc.org>
Fri, 22 Sep 2023 08:51:45 +0000 (08:51 +0000)
The information provided by those function will be needed and
used by the statistics channel in a follow-up commit.

lib/dns/include/dns/xfrin.h
lib/dns/xfrin.c

index 2d956a38b2524788b7d583dde3a19826c4f8fbb2..f140c534ac35462becc4f8f3cddc3c6c155386c9 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <isc/lang.h>
 #include <isc/refcount.h>
+#include <isc/sockaddr.h>
 #include <isc/tls.h>
 
 #include <dns/transport.h>
@@ -82,6 +83,109 @@ dns_xfrin_create(dns_zone_t *zone, dns_rdatatype_t xfrtype,
  *     the zone has a database.
  */
 
+isc_time_t
+dns_xfrin_getstarttime(const dns_xfrin_t *xfr);
+/*%<
+ * Get the start time of the xfrin object.
+ *
+ * Requires:
+ *\li  'xfr' is a valid dns_xfrin_t.
+ *
+ * Returns:
+ *\li  Transfer start time
+ *
+ */
+
+void
+dns_xfrin_getstate(const dns_xfrin_t *xfr, const char **statestr,
+                  bool *is_first_data_received, bool *is_ixfr);
+/*%<
+ * Get the current state of the xfrin object as a character string, and whether
+ * it's currently known to be an IXFR transfer as a boolean value.
+ *
+ * Notes:
+ *\li  The 'is_ixfr' value is valid only if 'is_first_data_received' is true.
+ *
+ * Requires:
+ *\li  'xfr' is a valid dns_xfrin_t.
+ *
+ */
+
+uint32_t
+dns_xfrin_getendserial(const dns_xfrin_t *xfr);
+/*%<
+ * Get the 'end_serial' of the xfrin object.
+ *
+ * Requires:
+ *\li  'xfr' is a valid dns_xfrin_t.
+ *
+ * Returns:
+ *\li  Serial number of the new version zone (if it's already known), or 0.
+ *
+ */
+
+void
+dns_xfrin_getstats(const dns_xfrin_t *xfr, unsigned int *nmsgp,
+                  unsigned int *nrecsp, uint64_t *nbytesp);
+/*%<
+ * Get various statistics values of the xfrin object: number of the received
+ * messages, number of the received records, number of the received bytes.
+ *
+ * Requires:
+ *\li  'xfr' is a valid dns_xfrin_t.
+ *
+ */
+
+const isc_sockaddr_t *
+dns_xfrin_getsourceaddr(const dns_xfrin_t *xfr);
+/*%<
+ * Get the source socket address of the xfrin object.
+ *
+ * Requires:
+ *\li  'xfr' is a valid dns_xfrin_t.
+ *
+ * Returns:
+ *\li  const pointer to the zone transfer's source socket address
+ */
+
+const isc_sockaddr_t *
+dns_xfrin_getprimaryaddr(const dns_xfrin_t *xfr);
+/*%<
+ * Get the socket address of the primary server of the xfrin object.
+ *
+ * Requires:
+ *\li  'xfr' is a valid dns_xfrin_t.
+ *
+ * Returns:
+ *\li  const pointer to the zone transfer's primary server's socket address
+ */
+
+const dns_transport_t *
+dns_xfrin_gettransport(const dns_xfrin_t *xfr);
+/*%<
+ * Get the trnasport of the xfrin object.
+ *
+ * Requires:
+ *\li  'xfr' is a valid dns_xfrin_t.
+ *
+ * Returns:
+ *\li  const pointer to the zone transfer's transport
+ *
+ */
+
+const dns_name_t *
+dns_xfrin_gettsigkeyname(const dns_xfrin_t *xfr);
+/*%<
+ * Get the name of the xfrin object's TSIG key.
+ *
+ * Requires:
+ *\li  'xfr' is a valid dns_xfrin_t.
+ *
+ * Returns:
+ *\li  const pointer to the zone transfer's TSIG key's name or NULL
+ *
+ */
+
 void
 dns_xfrin_shutdown(dns_xfrin_t *xfr);
 /*%<
index 0ee5d3ac57ffba824188b941475d2d32c017de58..23de072e0edaf9cdb392d77ef5842c0b20a69dd6 100644 (file)
@@ -762,6 +762,108 @@ xfrin_idledout(void *xfr) {
        xfrin_fail(xfr, ISC_R_TIMEDOUT, "maximum idle time exceeded");
 }
 
+isc_time_t
+dns_xfrin_getstarttime(const dns_xfrin_t *xfr) {
+       REQUIRE(VALID_XFRIN(xfr));
+
+       return (xfr->start);
+}
+
+void
+dns_xfrin_getstate(const dns_xfrin_t *xfr, const char **statestr,
+                  bool *is_first_data_received, bool *is_ixfr) {
+       xfrin_state_t state;
+
+       REQUIRE(VALID_XFRIN(xfr));
+       REQUIRE(statestr != NULL && *statestr == NULL);
+       REQUIRE(is_ixfr != NULL);
+
+       state = xfr->state;
+       *statestr = "";
+       *is_first_data_received = (state > XFRST_FIRSTDATA);
+       *is_ixfr = xfr->is_ixfr;
+
+       switch (state) {
+       case XFRST_SOAQUERY:
+               *statestr = "SOA Query";
+               break;
+       case XFRST_GOTSOA:
+               *statestr = "Got SOA";
+               break;
+       case XFRST_INITIALSOA:
+               *statestr = "Initial SOA";
+               break;
+       case XFRST_FIRSTDATA:
+               *statestr = "First Data";
+               break;
+       case XFRST_IXFR_DELSOA:
+       case XFRST_IXFR_DEL:
+       case XFRST_IXFR_ADDSOA:
+       case XFRST_IXFR_ADD:
+               *statestr = "Receiving IXFR Data";
+               break;
+       case XFRST_IXFR_END:
+               *statestr = "Finalizing IXFR";
+               break;
+       case XFRST_AXFR:
+               *statestr = "Receiving AXFR Data";
+               break;
+       case XFRST_AXFR_END:
+               *statestr = "Finalizing AXFR";
+               break;
+       }
+}
+
+uint32_t
+dns_xfrin_getendserial(const dns_xfrin_t *xfr) {
+       REQUIRE(VALID_XFRIN(xfr));
+
+       return (xfr->end_serial);
+}
+
+void
+dns_xfrin_getstats(const dns_xfrin_t *xfr, unsigned int *nmsgp,
+                  unsigned int *nrecsp, uint64_t *nbytesp) {
+       REQUIRE(VALID_XFRIN(xfr));
+       REQUIRE(nmsgp != NULL && nrecsp != NULL && nbytesp != NULL);
+
+       *nmsgp = xfr->nmsg;
+       *nrecsp = xfr->nrecs;
+       *nbytesp = xfr->nbytes;
+}
+
+const isc_sockaddr_t *
+dns_xfrin_getsourceaddr(const dns_xfrin_t *xfr) {
+       REQUIRE(VALID_XFRIN(xfr));
+
+       return (&xfr->sourceaddr);
+}
+
+const isc_sockaddr_t *
+dns_xfrin_getprimaryaddr(const dns_xfrin_t *xfr) {
+       REQUIRE(VALID_XFRIN(xfr));
+
+       return (&xfr->primaryaddr);
+}
+
+const dns_transport_t *
+dns_xfrin_gettransport(const dns_xfrin_t *xfr) {
+       REQUIRE(VALID_XFRIN(xfr));
+
+       return (xfr->transport);
+}
+
+const dns_name_t *
+dns_xfrin_gettsigkeyname(const dns_xfrin_t *xfr) {
+       REQUIRE(VALID_XFRIN(xfr));
+
+       if (xfr->tsigkey == NULL || xfr->tsigkey->key == NULL) {
+               return (NULL);
+       }
+
+       return (dst_key_name(xfr->tsigkey->key));
+}
+
 void
 dns_xfrin_shutdown(dns_xfrin_t *xfr) {
        REQUIRE(VALID_XFRIN(xfr));