diff --git a/lib/dns/include/dns/xfrin.h b/lib/dns/include/dns/xfrin.h index 2d956a38b2..f140c534ac 100644 --- a/lib/dns/include/dns/xfrin.h +++ b/lib/dns/include/dns/xfrin.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -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); /*%< diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 0ee5d3ac57..23de072e0e 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -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));