diff --git a/CHANGES b/CHANGES
index 87d43915ef..1250acefa5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+5622. [cleanup] Remove lib/samples, since export versions of libraries
+ are no longer maintained. [GL !4835]
+
5621. [placeholder]
5620. [bug] Named would overwrite a zone file unconditionally when
diff --git a/bin/delv/delv.c b/bin/delv/delv.c
index 3c92ebf2e5..ae8433f24e 100644
--- a/bin/delv/delv.c
+++ b/bin/delv/delv.c
@@ -1781,8 +1781,8 @@ main(int argc, char *argv[]) {
#endif /* ifndef WIN32 */
/* Create client */
- result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr, 0,
- &client, srcaddr4, srcaddr6);
+ result = dns_client_create(mctx, actx, taskmgr, socketmgr, timermgr, 0,
+ &client, srcaddr4, srcaddr6);
if (result != ISC_R_SUCCESS) {
delv_log(ISC_LOG_ERROR, "dns_client_create: %s",
isc_result_totext(result));
@@ -1802,7 +1802,7 @@ main(int argc, char *argv[]) {
CHECK(convert_name(&qfn, &query_name, qname));
/* Set up resolution options */
- resopt = DNS_CLIENTRESOPT_ALLOWRUN | DNS_CLIENTRESOPT_NOCDFLAG;
+ resopt = DNS_CLIENTRESOPT_NOCDFLAG;
if (no_sigs) {
resopt |= DNS_CLIENTRESOPT_NODNSSEC;
}
diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am
index bce2fb13e3..4ef54205a1 100644
--- a/bin/tests/system/Makefile.am
+++ b/bin/tests/system/Makefile.am
@@ -23,6 +23,7 @@ check_PROGRAMS = \
feature-test \
makejournal \
pipelined/pipequeries \
+ resolve \
rndc/gencheck \
rpz/dnsrps \
tkey/keycreate \
@@ -48,6 +49,14 @@ pipelined_pipequeries_LDADD = \
$(LDADD) \
$(LIBDNS_LIBS)
+resolve_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ $(LIBISC_CFLAGS) \
+ $(LIBDNS_CFLAGS) \
+ $(LIBIRS_CFLAGS)
+
+resolve_LDADD = $(LIBISC_LIBS) $(LIBIRS_LIBS) $(LIBDNS_LIBS)
+
tkey_keycreate_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(LIBDNS_CFLAGS)
diff --git a/bin/tests/system/conf.sh.common b/bin/tests/system/conf.sh.common
index cf1b5e6513..ac1845860f 100644
--- a/bin/tests/system/conf.sh.common
+++ b/bin/tests/system/conf.sh.common
@@ -730,7 +730,6 @@ export PYTHON
export RESOLVE
export RNDC
export RRCHECKER
-export SAMPLEUPDATE
export SIGNER
export SUBDIRS
export TMPDIR
diff --git a/bin/tests/system/conf.sh.in b/bin/tests/system/conf.sh.in
index 05f1a4fe71..9f4524b708 100644
--- a/bin/tests/system/conf.sh.in
+++ b/bin/tests/system/conf.sh.in
@@ -51,7 +51,7 @@ NZD2NZF=$TOP_BUILDDIR/bin/tools/named-nzd2nzf
PK11DEL="$TOP_BUILDDIR/bin/pkcs11/pkcs11-destroy -s ${SLOT:-0} -p ${HSMPIN:-1234} -w 0"
PK11GEN="$TOP_BUILDDIR/bin/pkcs11/pkcs11-keygen -q -s ${SLOT:-0} -p ${HSMPIN:-1234}"
PK11LIST="$TOP_BUILDDIR/bin/pkcs11/pkcs11-list -s ${SLOT:-0} -p ${HSMPIN:-1234}"
-RESOLVE=$TOP_BUILDDIR/lib/samples/resolve
+RESOLVE=$TOP_BUILDDIR/bin/tests/system/resolve
REVOKE=$TOP_BUILDDIR/bin/dnssec/dnssec-revoke
RNDC=$TOP_BUILDDIR/bin/rndc/rndc
RNDCCONFGEN=$TOP_BUILDDIR/bin/confgen/rndc-confgen
@@ -68,7 +68,6 @@ KEYCREATE=$TOP_BUILDDIR/bin/tests/system/tkey/keycreate
KEYDELETE=$TOP_BUILDDIR/bin/tests/system/tkey/keydelete
MAKEJOURNAL=$TOP_BUILDDIR/bin/tests/system/makejournal
PIPEQUERIES=$TOP_BUILDDIR/bin/tests/system/pipelined/pipequeries
-SAMPLEUPDATE=$TOP_BUILDDIR/lib/samples/sample-update
# we don't want a KRB5_CONFIG setting breaking the tests
KRB5_CONFIG=/dev/null
diff --git a/bin/tests/system/conf.sh.win32 b/bin/tests/system/conf.sh.win32
index 37e4379c84..bdebe0885c 100644
--- a/bin/tests/system/conf.sh.win32
+++ b/bin/tests/system/conf.sh.win32
@@ -51,12 +51,10 @@ NZD2NZF=$TOP_BUILDDIR/Build/$VSCONF/named-nzd2nzf@EXEEXT@
PK11DEL="$TOP_BUILDDIR/Build/$VSCONF/pkcs11-destroy@EXEEXT@ -s ${SLOT:-0} -p ${HSMPIN:-1234} -w 0"
PK11GEN="$TOP_BUILDDIR/Build/$VSCONF/pkcs11-keygen@EXEEXT@ -q -s ${SLOT:-0} -p ${HSMPIN:-1234}"
PK11LIST="$TOP_BUILDDIR/Build/$VSCONF/pkcs11-list@EXEEXT@ -s ${SLOT:-0} -p ${HSMPIN:-1234}"
-RESOLVE=$TOP_BUILDDIR/lib/samples/resolve
REVOKE=$TOP_BUILDDIR/Build/$VSCONF/dnssec-revoke@EXEEXT@
RNDC=$TOP_BUILDDIR/Build/$VSCONF/rndc@EXEEXT@
RNDCCONFGEN=$TOP_BUILDDIR/Build/$VSCONF/rndc-confgen@EXEEXT@
RRCHECKER=$TOP_BUILDDIR/Build/$VSCONF/named-rrchecker@EXEEXT@
-SAMPLEUPDATE=$TOP_BUILDDIR/Build/$VSCONF/update@EXEEXT@
SETTIME=$TOP_BUILDDIR/Build/$VSCONF/dnssec-settime@EXEEXT@
SIGNER=$TOP_BUILDDIR/Build/$VSCONF/dnssec-signzone@EXEEXT@
TSIGKEYGEN=$TOP_BUILDDIR/Build/$VSCONF/tsig-keygen@EXEEXT@
@@ -71,7 +69,7 @@ KEYCREATE=$TOP_BUILDDIR/Build/$VSCONF/keycreate@EXEEXT@
KEYDELETE=$TOP_BUILDDIR/Build/$VSCONF/keydelete@EXEEXT@
MAKEJOURNAL=$TOP_BUILDDIR/Build/$VSCONF/makejournal@EXEEXT@
PIPEQUERIES=$TOP_BUILDDIR/Build/$VSCONF/pipequeries@EXEEXT@
-# to port SAMPLEUPDATE=$TOP_BUILDDIR/lib/samples/sample-update
+RESOLVE=$TOP_BUILDDIR/Build/$VSCONF/resolve@EXEEXT@
# we don't want a KRB5_CONFIG setting breaking the tests
KRB5_CONFIG=NUL
diff --git a/bin/tests/system/nsupdate/tests.sh b/bin/tests/system/nsupdate/tests.sh
index 4274f86dd3..1bbb804584 100755
--- a/bin/tests/system/nsupdate/tests.sh
+++ b/bin/tests/system/nsupdate/tests.sh
@@ -1428,88 +1428,6 @@ EOF
[ $ret = 0 ] || { echo_i "failed"; status=1; }
fi
-#
-# Add client library tests here
-#
-
-if test unset != "${SAMPLEUPDATE:-unset}" -a -x "${SAMPLEUPDATE}"
-then
-
- n=`expr $n + 1`
- ret=0
- echo_i "check that dns_client_update handles prerequisite NXDOMAIN failure ($n)"
- $SAMPLEUPDATE -P ${PORT} -a 10.53.0.1 -a 10.53.0.2 -p "nxdomain exists.sample" \
- add "nxdomain-exists.sample 0 in a 1.2.3.4" > update.out.test$n 2>&1
- $SAMPLEUPDATE -P ${PORT} -a 10.53.0.2 -p "nxdomain exists.sample" \
- add "check-nxdomain-exists.sample 0 in a 1.2.3.4" > update.out.check$n 2>&1
- $DIG $DIGOPTS +tcp @10.53.0.1 a nxdomain-exists.sample > dig.out.ns1.test$n
- $DIG $DIGOPTS +tcp @10.53.0.2 a nxdomain-exists.sample > dig.out.ns2.test$n
- $DIG $DIGOPTS +tcp @10.53.0.2 a check-nxdomain-exists.sample > check.out.ns2.test$n
- grep "update failed: YXDOMAIN" update.out.test$n > /dev/null || ret=1
- grep "update succeeded" update.out.check$n > /dev/null || ret=1
- grep "status: NXDOMAIN" dig.out.ns1.test$n > /dev/null || ret=1
- grep "status: NXDOMAIN" dig.out.ns2.test$n > /dev/null || ret=1
- grep "status: NOERROR" check.out.ns2.test$n > /dev/null || ret=1
- [ $ret = 0 ] || { echo_i "failed"; status=1; }
-
- n=`expr $n + 1`
- ret=0
- echo_i "check that dns_client_update handles prerequisite YXDOMAIN failure ($n)"
- $SAMPLEUPDATE -P ${PORT} -a 10.53.0.1 -a 10.53.0.2 -p "yxdomain nxdomain.sample" \
- add "yxdomain-nxdomain.sample 0 in a 1.2.3.4" > update.out.test$n 2>&1
- $SAMPLEUPDATE -P ${PORT} -a 10.53.0.2 -p "yxdomain nxdomain.sample" \
- add "check-yxdomain-nxdomain.sample 0 in a 1.2.3.4" > update.out.check$n 2>&1
- $DIG $DIGOPTS +tcp @10.53.0.1 a nxdomain-exists.sample > dig.out.ns1.test$n
- $DIG $DIGOPTS +tcp @10.53.0.2 a nxdomain-exists.sample > dig.out.ns2.test$n
- $DIG $DIGOPTS +tcp @10.53.0.2 a check-nxdomain-exists.sample > check.out.ns2.test$n
- grep "update failed: NXDOMAIN" update.out.test$n > /dev/null || ret=1
- grep "update succeeded" update.out.check$n > /dev/null || ret=1
- grep "status: NXDOMAIN" dig.out.ns1.test$n > /dev/null || ret=1
- grep "status: NXDOMAIN" dig.out.ns2.test$n > /dev/null || ret=1
- grep "status: NOERROR" check.out.ns2.test$n > /dev/null || ret=1
- [ $ret = 0 ] || { echo_i "failed"; status=1; }
-
- n=`expr $n + 1`
- ret=0
- echo_i "check that dns_client_update handles prerequisite NXRRSET failure ($n)"
- $SAMPLEUPDATE -P ${PORT} -a 10.53.0.1 -a 10.53.0.2 -p "nxrrset exists.sample TXT This RRset exists." \
- add "nxrrset-exists.sample 0 in a 1.2.3.4" > update.out.test$n 2>&1
- $SAMPLEUPDATE -P ${PORT} -a 10.53.0.2 -p "nxrrset exists.sample TXT This RRset exists." \
- add "check-nxrrset-exists.sample 0 in a 1.2.3.4" > update.out.check$n 2>&1
- $DIG $DIGOPTS +tcp @10.53.0.1 a nxrrset-exists.sample > dig.out.ns1.test$n
- $DIG $DIGOPTS +tcp @10.53.0.2 a nxrrset-exists.sample > dig.out.ns2.test$n
- $DIG $DIGOPTS +tcp @10.53.0.2 a check-nxrrset-exists.sample > check.out.ns2.test$n
- grep "update failed: YXRRSET" update.out.test$n > /dev/null || ret=1
- grep "update succeeded" update.out.check$n > /dev/null || ret=1
- grep "status: NXDOMAIN" dig.out.ns1.test$n > /dev/null || ret=1
- grep "status: NXDOMAIN" dig.out.ns2.test$n > /dev/null || ret=1
- grep "status: NOERROR" check.out.ns2.test$n > /dev/null || ret=1
- [ $ret = 0 ] || { echo_i "failed"; status=1; }
-
- n=`expr $n + 1`
- ret=0
- echo_i "check that dns_client_update handles prerequisite YXRRSET failure ($n)"
- $SAMPLEUPDATE -s -P ${PORT} -a 10.53.0.1 -a 10.53.0.2 \
- -p "yxrrset no-txt.sample TXT" \
- add "yxrrset-nxrrset.sample 0 in a 1.2.3.4" > update.out.test$n 2>&1
- $SAMPLEUPDATE -P ${PORT} -a 10.53.0.2 -p "yxrrset no-txt.sample TXT" \
- add "check-yxrrset-nxrrset.sample 0 in a 1.2.3.4" > update.out.check$n 2>&1
- $DIG $DIGOPTS +tcp @10.53.0.1 a yxrrset-nxrrset.sample > dig.out.ns1.test$n
- $DIG $DIGOPTS +tcp @10.53.0.2 a yxrrset-nxrrset.sample > dig.out.ns2.test$n
- $DIG $DIGOPTS +tcp @10.53.0.2 a check-yxrrset-nxrrset.sample > check.out.ns2.test$n
- grep "update failed: NXRRSET" update.out.test$n > /dev/null || ret=1
- grep "update succeeded" update.out.check$n > /dev/null || ret=1
- grep "status: NXDOMAIN" dig.out.ns1.test$n > /dev/null || ret=1
- grep "status: NXDOMAIN" dig.out.ns2.test$n > /dev/null || ret=1
- grep "status: NOERROR" check.out.ns2.test$n > /dev/null || ret=1
- grep "2nd update failed: NXRRSET" update.out.test$n > /dev/null || ret=1
- [ $ret = 0 ] || { echo_i "failed"; status=1; }
-
-fi
-
-#
-# End client library tests here
-#
echo_i "exit status: $status"
[ $status -eq 0 ] || exit 1
diff --git a/lib/samples/resolve.c b/bin/tests/system/resolve.c
similarity index 98%
rename from lib/samples/resolve.c
rename to bin/tests/system/resolve.c
index bb0f1de525..bd2a947a8c 100644
--- a/lib/samples/resolve.c
+++ b/bin/tests/system/resolve.c
@@ -241,7 +241,7 @@ main(int argc, char *argv[]) {
dns_rdataset_t *rdataset;
dns_namelist_t namelist;
isc_mem_t *keymctx = NULL;
- unsigned int clientopt, resopt;
+ unsigned int clientopt, resopt = 0;
bool is_sep = false;
const char *port = "53";
isc_mem_t *mctx = NULL;
@@ -385,8 +385,8 @@ main(int argc, char *argv[]) {
}
clientopt = 0;
- result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr,
- clientopt, &client, addr4, addr6);
+ result = dns_client_create(mctx, actx, taskmgr, socketmgr, timermgr,
+ clientopt, &client, addr4, addr6);
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "dns_client_create failed: %u, %s\n", result,
isc_result_totext(result));
@@ -444,7 +444,6 @@ main(int argc, char *argv[]) {
}
/* Perform resolution */
- resopt = DNS_CLIENTRESOPT_ALLOWRUN;
if (keynamestr == NULL) {
resopt |= DNS_CLIENTRESOPT_NODNSSEC;
}
diff --git a/lib/samples/win32/resolve.vcxproj.filters.in b/bin/tests/system/win32/resolve.vcxproj.filters.in
similarity index 100%
rename from lib/samples/win32/resolve.vcxproj.filters.in
rename to bin/tests/system/win32/resolve.vcxproj.filters.in
diff --git a/lib/samples/win32/resolve.vcxproj.in b/bin/tests/system/win32/resolve.vcxproj.in
similarity index 100%
rename from lib/samples/win32/resolve.vcxproj.in
rename to bin/tests/system/win32/resolve.vcxproj.in
diff --git a/lib/samples/win32/resolve.vcxproj.user b/bin/tests/system/win32/resolve.vcxproj.user
similarity index 100%
rename from lib/samples/win32/resolve.vcxproj.user
rename to bin/tests/system/win32/resolve.vcxproj.user
diff --git a/bin/win32/BINDInstall/BINDInstall.vcxproj.in b/bin/win32/BINDInstall/BINDInstall.vcxproj.in
index 92de623ada..18f783ecbd 100644
--- a/bin/win32/BINDInstall/BINDInstall.vcxproj.in
+++ b/bin/win32/BINDInstall/BINDInstall.vcxproj.in
@@ -258,6 +258,9 @@
{E1478F40-786C-4738-8E99-E7A71DD98661}
+
+ {F66D8B7E-721D-4602-99AD-820D19AD1313}
+
@END STESTS
{91E60FDA-E48C-4DA0-92A2-97F963348E00}
@@ -298,26 +301,6 @@
{82ACD33C-E75F-45B8-BB6D-42643A10D7EE}
-@IF SAMPLES
-
- {9FC33CA3-CE4A-4EDF-BA99-EECA4B81AD06}
-
-
- {D42B8670-8DF6-4D90-90F7-DB5FB845AFAE}
-
-
- {CB2A29F6-E73B-40AB-8AC4-2C1AAE7280BD}
-
-
- {FF440E85-7450-439C-82EE-04C464512D0E}
-
-
- {F66D8B7E-721D-4602-99AD-820D19AD1313}
-
-
- {05682E12-523F-4DAE-8E6D-ADFDBC308AFD}
-
-@END SAMPLES
{0D745CD9-FC3B-49DC-99BE-1E6DF85593F0}
diff --git a/configure.ac b/configure.ac
index c05600872f..48fa826bae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1616,8 +1616,7 @@ AC_CONFIG_FILES([lib/Makefile
lib/irs/Makefile
lib/isccfg/Makefile
lib/isccc/Makefile
- lib/bind9/Makefile
- lib/samples/Makefile])
+ lib/bind9/Makefile])
# Documentation
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5cbaf3c895..39741a427f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,3 +1,3 @@
include $(top_srcdir)/Makefile.top
-SUBDIRS = isc dns isccc ns isccfg bind9 irs samples
+SUBDIRS = isc dns isccc ns isccfg bind9 irs
diff --git a/lib/dns/client.c b/lib/dns/client.c
index c1a9b95d87..2dafddea72 100644
--- a/lib/dns/client.c
+++ b/lib/dns/client.c
@@ -56,9 +56,6 @@
#define RCTX_MAGIC ISC_MAGIC('R', 'c', 't', 'x')
#define RCTX_VALID(c) ISC_MAGIC_VALID(c, RCTX_MAGIC)
-#define REQCTX_MAGIC ISC_MAGIC('R', 'q', 'c', 'x')
-#define REQCTX_VALID(c) ISC_MAGIC_VALID(c, REQCTX_MAGIC)
-
#define UCTX_MAGIC ISC_MAGIC('U', 'c', 't', 'x')
#define UCTX_VALID(c) ISC_MAGIC_VALID(c, UCTX_MAGIC)
@@ -95,9 +92,6 @@ struct dns_client {
dns_dispatch_t *dispatchv4;
dns_dispatch_t *dispatchv6;
- unsigned int update_timeout;
- unsigned int update_udptimeout;
- unsigned int update_udpretries;
unsigned int find_timeout;
unsigned int find_udpretries;
@@ -106,23 +100,11 @@ struct dns_client {
/* Locked */
dns_viewlist_t viewlist;
ISC_LIST(struct resctx) resctxs;
- ISC_LIST(struct reqctx) reqctxs;
- ISC_LIST(struct updatectx) updatectxs;
};
-/*%
- * Timeout/retry constants for dynamic update borrowed from nsupdate
- */
-#define DEF_UPDATE_TIMEOUT 300
-#define MIN_UPDATE_TIMEOUT 30
-#define DEF_UPDATE_UDPTIMEOUT 3
-#define DEF_UPDATE_UDPRETRIES 3
-
#define DEF_FIND_TIMEOUT 5
#define DEF_FIND_UDPRETRIES 3
-#define DNS_CLIENTATTR_OWNCTX 0x01
-
/*%
* Internal state for a single name resolution procedure
*/
@@ -169,98 +151,8 @@ typedef struct resarg {
bool canceled;
} resarg_t;
-/*%
- * Internal state for a single DNS request
- */
-typedef struct reqctx {
- /* Unlocked */
- unsigned int magic;
- isc_mutex_t lock;
- dns_client_t *client;
- unsigned int parseoptions;
-
- /* Locked */
- ISC_LINK(struct reqctx) link;
- bool canceled;
- dns_tsigkey_t *tsigkey;
- dns_request_t *request;
- dns_clientreqevent_t *event;
-} reqctx_t;
-
-/*%
- * Argument of an internal event for synchronous DNS request.
- */
-typedef struct reqarg {
- /* Unlocked */
- isc_appctx_t *actx;
- dns_client_t *client;
- isc_mutex_t lock;
-
- /* Locked */
- isc_result_t result;
- dns_clientreqtrans_t *trans;
- bool canceled;
-} reqarg_t;
-
-/*%
- * Argument of an internal event for synchronous name resolution.
- */
-typedef struct updatearg {
- /* Unlocked */
- isc_appctx_t *actx;
- dns_client_t *client;
- isc_mutex_t lock;
-
- /* Locked */
- isc_result_t result;
- dns_clientupdatetrans_t *trans;
- bool canceled;
-} updatearg_t;
-
-/*%
- * Internal state for a single dynamic update procedure
- */
-typedef struct updatectx {
- /* Unlocked */
- unsigned int magic;
- isc_mutex_t lock;
- dns_client_t *client;
- bool want_tcp;
-
- /* Locked */
- dns_request_t *updatereq;
- dns_request_t *soareq;
- dns_clientrestrans_t *restrans;
- dns_clientrestrans_t *restrans2;
- bool canceled;
-
- /* Task Locked */
- ISC_LINK(struct updatectx) link;
- dns_clientupdatestate_t state;
- dns_rdataclass_t rdclass;
- dns_view_t *view;
- dns_message_t *updatemsg;
- dns_message_t *soaquery;
- dns_clientupdateevent_t *event;
- dns_tsigkey_t *tsigkey;
- dst_key_t *sig0key;
- dns_name_t *firstname;
- dns_name_t soaqname;
- dns_fixedname_t zonefname;
- dns_name_t *zonename;
- isc_sockaddrlist_t servers;
- unsigned int nservers;
- isc_sockaddr_t *currentserver;
- struct updatectx *bp4;
- struct updatectx *bp6;
-} updatectx_t;
-
-static isc_result_t
-request_soa(updatectx_t *uctx);
static void
client_resfind(resctx_t *rctx, dns_fetchevent_t *event);
-static isc_result_t
-send_update(updatectx_t *uctx);
/*
* Try honoring the operating system's preferred ephemeral port range.
@@ -398,91 +290,13 @@ createview(isc_mem_t *mctx, dns_rdataclass_t rdclass, isc_taskmgr_t *taskmgr,
}
isc_result_t
-dns_client_create(dns_client_t **clientp, unsigned int options) {
- isc_result_t result;
- isc_mem_t *mctx = NULL;
- isc_appctx_t *actx = NULL;
- isc_taskmgr_t *taskmgr = NULL;
- isc_socketmgr_t *socketmgr = NULL;
- isc_timermgr_t *timermgr = NULL;
-#if 0
- /* XXXMPA add debug logging support */
- isc_log_t *lctx = NULL;
- isc_logconfig_t *logconfig = NULL;
- unsigned int logdebuglevel = 0;
-#endif /* if 0 */
-
- isc_mem_create(&mctx);
- result = isc_appctx_create(mctx, &actx);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = isc_app_ctxstart(actx);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = isc_taskmgr_createinctx(mctx, 1, 0, &taskmgr);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = isc_socketmgr_createinctx(mctx, &socketmgr);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = isc_timermgr_createinctx(mctx, &timermgr);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-#if 0
- isc_log_create(mctx, &lctx, &logconfig);
- isc_log_setcontext(lctx);
- dns_log_init(lctx);
- dns_log_setcontext(lctx);
- result = isc_log_usechannel(logconfig, "default_debug", NULL, NULL);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- isc_log_setdebuglevel(lctx, logdebuglevel);
-#endif /* if 0 */
- result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr,
- options, clientp, NULL, NULL);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- (*clientp)->attributes |= DNS_CLIENTATTR_OWNCTX;
-
- /* client has its own reference to mctx, so we can detach it here */
- isc_mem_detach(&mctx);
-
- return (ISC_R_SUCCESS);
-
-cleanup:
- if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
- }
- if (timermgr != NULL) {
- isc_timermgr_destroy(&timermgr);
- }
- if (socketmgr != NULL) {
- isc_socketmgr_destroy(&socketmgr);
- }
- if (actx != NULL) {
- isc_appctx_destroy(&actx);
- }
- isc_mem_detach(&mctx);
-
- return (result);
-}
-
-isc_result_t
-dns_client_createx(isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr,
- isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr,
- unsigned int options, dns_client_t **clientp,
- const isc_sockaddr_t *localaddr4,
- const isc_sockaddr_t *localaddr6) {
- dns_client_t *client;
+dns_client_create(isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr,
+ isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr,
+ unsigned int options, dns_client_t **clientp,
+ const isc_sockaddr_t *localaddr4,
+ const isc_sockaddr_t *localaddr6) {
isc_result_t result;
+ dns_client_t *client = NULL;
dns_dispatchmgr_t *dispatchmgr = NULL;
dns_dispatch_t *dispatchv4 = NULL;
dns_dispatch_t *dispatchv6 = NULL;
@@ -562,15 +376,10 @@ dns_client_createx(isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr,
dns_view_freeze(view); /* too early? */
ISC_LIST_INIT(client->resctxs);
- ISC_LIST_INIT(client->reqctxs);
- ISC_LIST_INIT(client->updatectxs);
client->mctx = NULL;
isc_mem_attach(mctx, &client->mctx);
- client->update_timeout = DEF_UPDATE_TIMEOUT;
- client->update_udptimeout = DEF_UPDATE_UDPTIMEOUT;
- client->update_udpretries = DEF_UPDATE_UDPRETRIES;
client->find_timeout = DEF_FIND_TIMEOUT;
client->find_udpretries = DEF_FIND_UDPRETRIES;
client->attributes = 0;
@@ -623,19 +432,6 @@ destroyclient(dns_client_t *client) {
isc_task_detach(&client->task);
- /*
- * If the client has created its own running environments,
- * destroy them.
- */
- if ((client->attributes & DNS_CLIENTATTR_OWNCTX) != 0) {
- isc_taskmgr_destroy(&client->taskmgr);
- isc_timermgr_destroy(&client->timermgr);
- isc_socketmgr_destroy(&client->socketmgr);
-
- isc_app_ctxfinish(client->actx);
- isc_appctx_destroy(&client->actx);
- }
-
isc_mutex_destroy(&client->lock);
client->magic = 0;
@@ -1231,35 +1027,22 @@ dns_client_resolve(dns_client_t *client, const dns_name_t *name,
dns_rdataclass_t rdclass, dns_rdatatype_t type,
unsigned int options, dns_namelist_t *namelist) {
isc_result_t result;
- isc_appctx_t *actx;
resarg_t *resarg;
REQUIRE(DNS_CLIENT_VALID(client));
+ REQUIRE(client->actx != NULL);
REQUIRE(namelist != NULL && ISC_LIST_EMPTY(*namelist));
- if ((client->attributes & DNS_CLIENTATTR_OWNCTX) == 0 &&
- (options & DNS_CLIENTRESOPT_ALLOWRUN) == 0)
- {
- /*
- * If the client is run under application's control, we need
- * to create a new running (sub)environment for this
- * particular resolution.
- */
- return (ISC_R_NOTIMPLEMENTED); /* XXXTBD */
- } else {
- actx = client->actx;
- }
-
resarg = isc_mem_get(client->mctx, sizeof(*resarg));
isc_mutex_init(&resarg->lock);
+ *resarg = (resarg_t){
+ .actx = client->actx,
+ .client = client,
+ .result = DNS_R_SERVFAIL,
+ .namelist = namelist,
+ };
- resarg->actx = actx;
- resarg->client = client;
- resarg->result = DNS_R_SERVFAIL;
- resarg->namelist = namelist;
- resarg->trans = NULL;
- resarg->canceled = false;
result = dns_client_startresolve(client, name, rdclass, type, options,
client->task, resolve_done, resarg,
&resarg->trans);
@@ -1273,7 +1056,7 @@ dns_client_resolve(dns_client_t *client, const dns_name_t *name,
* Start internal event loop. It blocks until the entire process
* is completed.
*/
- result = isc_app_ctxrun(actx);
+ result = isc_app_ctxrun(client->actx);
LOCK(&resarg->lock);
if (result == ISC_R_SUCCESS || result == ISC_R_SUSPEND) {
@@ -1555,1634 +1338,3 @@ cleanup:
}
return (result);
}
-
-/*%
- * Simple request routines
- */
-static void
-request_done(isc_task_t *task, isc_event_t *event) {
- dns_requestevent_t *reqev = NULL;
- dns_request_t *request;
- isc_result_t result, eresult;
- reqctx_t *ctx;
-
- UNUSED(task);
-
- REQUIRE(event->ev_type == DNS_EVENT_REQUESTDONE);
- reqev = (dns_requestevent_t *)event;
- request = reqev->request;
- result = eresult = reqev->result;
- ctx = reqev->ev_arg;
- REQUIRE(REQCTX_VALID(ctx));
-
- isc_event_free(&event);
-
- LOCK(&ctx->lock);
-
- if (eresult == ISC_R_SUCCESS) {
- result = dns_request_getresponse(request, ctx->event->rmessage,
- ctx->parseoptions);
- }
-
- if (ctx->tsigkey != NULL) {
- dns_tsigkey_detach(&ctx->tsigkey);
- }
-
- if (ctx->canceled) {
- ctx->event->result = ISC_R_CANCELED;
- } else {
- ctx->event->result = result;
- }
- task = ctx->event->ev_sender;
- ctx->event->ev_sender = ctx;
- isc_task_sendanddetach(&task, ISC_EVENT_PTR(&ctx->event));
-
- UNLOCK(&ctx->lock);
-}
-
-static void
-localrequest_done(isc_task_t *task, isc_event_t *event) {
- reqarg_t *reqarg = event->ev_arg;
- dns_clientreqevent_t *rev = (dns_clientreqevent_t *)event;
-
- UNUSED(task);
-
- REQUIRE(event->ev_type == DNS_EVENT_CLIENTREQDONE);
-
- LOCK(&reqarg->lock);
-
- reqarg->result = rev->result;
- dns_client_destroyreqtrans(&reqarg->trans);
- isc_event_free(&event);
-
- if (!reqarg->canceled) {
- UNLOCK(&reqarg->lock);
-
- /* Exit from the internal event loop */
- isc_app_ctxsuspend(reqarg->actx);
- } else {
- /*
- * We have already exited from the loop (due to some
- * unexpected event). Just clean the arg up.
- */
- UNLOCK(&reqarg->lock);
- isc_mutex_destroy(&reqarg->lock);
- isc_mem_put(reqarg->client->mctx, reqarg, sizeof(*reqarg));
- }
-}
-
-isc_result_t
-dns_client_request(dns_client_t *client, dns_message_t *qmessage,
- dns_message_t *rmessage, const isc_sockaddr_t *server,
- unsigned int options, unsigned int parseoptions,
- dns_tsec_t *tsec, unsigned int timeout,
- unsigned int udptimeout, unsigned int udpretries) {
- isc_appctx_t *actx;
- reqarg_t *reqarg;
- isc_result_t result;
-
- REQUIRE(DNS_CLIENT_VALID(client));
- REQUIRE(qmessage != NULL);
- REQUIRE(rmessage != NULL);
-
- if ((client->attributes & DNS_CLIENTATTR_OWNCTX) == 0 &&
- (options & DNS_CLIENTREQOPT_ALLOWRUN) == 0)
- {
- /*
- * If the client is run under application's control, we need
- * to create a new running (sub)environment for this
- * particular resolution.
- */
- return (ISC_R_NOTIMPLEMENTED); /* XXXTBD */
- } else {
- actx = client->actx;
- }
-
- reqarg = isc_mem_get(client->mctx, sizeof(*reqarg));
-
- isc_mutex_init(&reqarg->lock);
-
- reqarg->actx = actx;
- reqarg->client = client;
- reqarg->trans = NULL;
- reqarg->canceled = false;
-
- result = dns_client_startrequest(
- client, qmessage, rmessage, server, options, parseoptions, tsec,
- timeout, udptimeout, udpretries, client->task,
- localrequest_done, reqarg, &reqarg->trans);
- if (result != ISC_R_SUCCESS) {
- isc_mutex_destroy(&reqarg->lock);
- isc_mem_put(client->mctx, reqarg, sizeof(*reqarg));
- return (result);
- }
-
- /*
- * Start internal event loop. It blocks until the entire process
- * is completed.
- */
- result = isc_app_ctxrun(actx);
-
- LOCK(&reqarg->lock);
- if (result == ISC_R_SUCCESS || result == ISC_R_SUSPEND) {
- result = reqarg->result;
- }
- if (reqarg->trans != NULL) {
- /*
- * Unusual termination (perhaps due to signal). We need some
- * tricky cleanup process.
- */
- reqarg->canceled = true;
- dns_client_cancelresolve(reqarg->trans);
-
- UNLOCK(&reqarg->lock);
-
- /* reqarg will be freed in the event handler. */
- } else {
- UNLOCK(&reqarg->lock);
-
- isc_mutex_destroy(&reqarg->lock);
- isc_mem_put(client->mctx, reqarg, sizeof(*reqarg));
- }
-
- return (result);
-}
-
-isc_result_t
-dns_client_startrequest(dns_client_t *client, dns_message_t *qmessage,
- dns_message_t *rmessage, const isc_sockaddr_t *server,
- unsigned int options, unsigned int parseoptions,
- dns_tsec_t *tsec, unsigned int timeout,
- unsigned int udptimeout, unsigned int udpretries,
- isc_task_t *task, isc_taskaction_t action, void *arg,
- dns_clientreqtrans_t **transp) {
- isc_result_t result;
- dns_view_t *view = NULL;
- isc_task_t *tclone = NULL;
- dns_clientreqevent_t *event = NULL;
- reqctx_t *ctx = NULL;
- dns_tsectype_t tsectype = dns_tsectype_none;
- unsigned int reqoptions;
-
- REQUIRE(DNS_CLIENT_VALID(client));
- REQUIRE(qmessage != NULL);
- REQUIRE(rmessage != NULL);
- REQUIRE(transp != NULL && *transp == NULL);
-
- if (tsec != NULL) {
- tsectype = dns_tsec_gettype(tsec);
- if (tsectype != dns_tsectype_tsig) {
- return (ISC_R_NOTIMPLEMENTED); /* XXX */
- }
- }
-
- LOCK(&client->lock);
- result = dns_viewlist_find(&client->viewlist, DNS_CLIENTVIEW_NAME,
- qmessage->rdclass, &view);
- UNLOCK(&client->lock);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
-
- reqoptions = 0;
- if ((options & DNS_CLIENTREQOPT_TCP) != 0) {
- reqoptions |= DNS_REQUESTOPT_TCP;
- }
-
- tclone = NULL;
- isc_task_attach(task, &tclone);
- event = (dns_clientreqevent_t *)isc_event_allocate(
- client->mctx, tclone, DNS_EVENT_CLIENTREQDONE, action, arg,
- sizeof(*event));
-
- ctx = isc_mem_get(client->mctx, sizeof(*ctx));
- isc_mutex_init(&ctx->lock);
-
- ctx->client = client;
- ISC_LINK_INIT(ctx, link);
- ctx->parseoptions = parseoptions;
- ctx->canceled = false;
- ctx->event = event;
- ctx->event->rmessage = rmessage;
- ctx->tsigkey = NULL;
- if (tsec != NULL) {
- dns_tsec_getkey(tsec, &ctx->tsigkey);
- }
-
- ctx->magic = REQCTX_MAGIC;
-
- LOCK(&client->lock);
- ISC_LIST_APPEND(client->reqctxs, ctx, link);
- isc_refcount_increment(&client->references);
- UNLOCK(&client->lock);
-
- ctx->request = NULL;
- result = dns_request_createvia(view->requestmgr, qmessage, NULL, server,
- -1, reqoptions, ctx->tsigkey, timeout,
- udptimeout, udpretries, client->task,
- request_done, ctx, &ctx->request);
- if (result == ISC_R_SUCCESS) {
- dns_view_detach(&view);
- *transp = (dns_clientreqtrans_t *)ctx;
- return (ISC_R_SUCCESS);
- }
-
- isc_refcount_decrement1(&client->references);
-
- LOCK(&client->lock);
- ISC_LIST_UNLINK(client->reqctxs, ctx, link);
- UNLOCK(&client->lock);
- isc_mutex_destroy(&ctx->lock);
- isc_mem_put(client->mctx, ctx, sizeof(*ctx));
-
- isc_event_free(ISC_EVENT_PTR(&event));
- isc_task_detach(&tclone);
- dns_view_detach(&view);
-
- return (result);
-}
-
-void
-dns_client_cancelrequest(dns_clientreqtrans_t *trans) {
- reqctx_t *ctx;
-
- REQUIRE(trans != NULL);
- ctx = (reqctx_t *)trans;
- REQUIRE(REQCTX_VALID(ctx));
-
- LOCK(&ctx->lock);
-
- if (!ctx->canceled) {
- ctx->canceled = true;
- if (ctx->request != NULL) {
- dns_request_cancel(ctx->request);
- }
- }
-
- UNLOCK(&ctx->lock);
-}
-
-void
-dns_client_destroyreqtrans(dns_clientreqtrans_t **transp) {
- reqctx_t *ctx;
- isc_mem_t *mctx;
- dns_client_t *client;
-
- REQUIRE(transp != NULL);
- ctx = (reqctx_t *)*transp;
- *transp = NULL;
- REQUIRE(REQCTX_VALID(ctx));
- client = ctx->client;
- REQUIRE(DNS_CLIENT_VALID(client));
- REQUIRE(ctx->event == NULL);
- REQUIRE(ctx->request != NULL);
-
- dns_request_destroy(&ctx->request);
- mctx = client->mctx;
-
- LOCK(&client->lock);
-
- INSIST(ISC_LINK_LINKED(ctx, link));
- ISC_LIST_UNLINK(client->reqctxs, ctx, link);
-
- UNLOCK(&client->lock);
-
- isc_mutex_destroy(&ctx->lock);
- ctx->magic = 0;
-
- isc_mem_put(mctx, ctx, sizeof(*ctx));
-
- dns_client_destroy(&client);
-}
-
-/*%
- * Dynamic update routines
- */
-static isc_result_t
-rcode2result(dns_rcode_t rcode) {
- /* XXX: isn't there a similar function? */
- switch (rcode) {
- case dns_rcode_formerr:
- return (DNS_R_FORMERR);
- case dns_rcode_servfail:
- return (DNS_R_SERVFAIL);
- case dns_rcode_nxdomain:
- return (DNS_R_NXDOMAIN);
- case dns_rcode_notimp:
- return (DNS_R_NOTIMP);
- case dns_rcode_refused:
- return (DNS_R_REFUSED);
- case dns_rcode_yxdomain:
- return (DNS_R_YXDOMAIN);
- case dns_rcode_yxrrset:
- return (DNS_R_YXRRSET);
- case dns_rcode_nxrrset:
- return (DNS_R_NXRRSET);
- case dns_rcode_notauth:
- return (DNS_R_NOTAUTH);
- case dns_rcode_notzone:
- return (DNS_R_NOTZONE);
- case dns_rcode_badvers:
- return (DNS_R_BADVERS);
- }
-
- return (ISC_R_FAILURE);
-}
-
-static void
-update_sendevent(updatectx_t *uctx, isc_result_t result) {
- isc_task_t *task;
-
- dns_message_detach(&uctx->updatemsg);
- if (uctx->tsigkey != NULL) {
- dns_tsigkey_detach(&uctx->tsigkey);
- }
- if (uctx->sig0key != NULL) {
- dst_key_free(&uctx->sig0key);
- }
-
- if (uctx->canceled) {
- uctx->event->result = ISC_R_CANCELED;
- } else {
- uctx->event->result = result;
- }
- uctx->event->state = uctx->state;
- task = uctx->event->ev_sender;
- uctx->event->ev_sender = uctx;
- isc_task_sendanddetach(&task, ISC_EVENT_PTR(&uctx->event));
-}
-
-static void
-update_done(isc_task_t *task, isc_event_t *event) {
- isc_result_t result;
- dns_requestevent_t *reqev = NULL;
- dns_request_t *request;
- dns_message_t *answer = NULL;
- updatectx_t *uctx = event->ev_arg;
- dns_client_t *client;
- unsigned int timeout, reqoptions;
-
- UNUSED(task);
-
- REQUIRE(event->ev_type == DNS_EVENT_REQUESTDONE);
- reqev = (dns_requestevent_t *)event;
- request = reqev->request;
- REQUIRE(UCTX_VALID(uctx));
- client = uctx->client;
- REQUIRE(DNS_CLIENT_VALID(client));
-
- result = reqev->result;
- if (result != ISC_R_SUCCESS) {
- goto out;
- }
-
- dns_message_create(client->mctx, DNS_MESSAGE_INTENTPARSE, &answer);
- uctx->state = dns_clientupdatestate_done;
- result = dns_request_getresponse(request, answer,
- DNS_MESSAGEPARSE_PRESERVEORDER);
- if (result == ISC_R_SUCCESS && answer->rcode != dns_rcode_noerror) {
- result = rcode2result(answer->rcode);
- }
-
-out:
- if (answer != NULL) {
- dns_message_detach(&answer);
- }
- isc_event_free(&event);
-
- LOCK(&uctx->lock);
- uctx->currentserver = ISC_LIST_NEXT(uctx->currentserver, link);
- dns_request_destroy(&uctx->updatereq);
- /*
- * Moving on to the next server shouldn't change the result
- * for NXDOMAIN, YXDOMAIN, NXRRSET and YXRRSET as they
- * indicate a prerequisite failure. REFUSED should also
- * be consistent across all servers but often isn't as that
- * is policy rather that zone content driven (slaves that
- * aren't willing to forward should return NOTIMPL). NOTZONE
- * indicates that we stuffed up the request construction so
- * don't retry.
- */
- if (result != ISC_R_SUCCESS && result != DNS_R_NXDOMAIN &&
- result != DNS_R_YXDOMAIN && result != DNS_R_YXRRSET &&
- result != DNS_R_NXRRSET && result != DNS_R_NOTZONE &&
- !uctx->canceled && uctx->currentserver != NULL)
- {
- dns_message_renderreset(uctx->updatemsg);
- dns_message_settsigkey(uctx->updatemsg, NULL);
-
- timeout = client->update_timeout / uctx->nservers;
- if (timeout < MIN_UPDATE_TIMEOUT) {
- timeout = MIN_UPDATE_TIMEOUT;
- }
- reqoptions = 0;
- if (uctx->want_tcp) {
- reqoptions |= DNS_REQUESTOPT_TCP;
- }
- result = dns_request_createvia(
- uctx->view->requestmgr, uctx->updatemsg, NULL,
- uctx->currentserver, -1, reqoptions, uctx->tsigkey,
- timeout, client->update_udptimeout,
- client->update_udpretries, client->task, update_done,
- uctx, &uctx->updatereq);
- UNLOCK(&uctx->lock);
-
- if (result == ISC_R_SUCCESS) {
- /* XXX: should we keep the 'done' state here? */
- uctx->state = dns_clientupdatestate_sent;
- return;
- }
- } else {
- UNLOCK(&uctx->lock);
- }
-
- update_sendevent(uctx, result);
-}
-
-static isc_result_t
-send_update(updatectx_t *uctx) {
- isc_result_t result;
- dns_name_t *name = NULL;
- dns_rdataset_t *rdataset = NULL;
- dns_client_t *client = uctx->client;
- unsigned int timeout, reqoptions;
-
- REQUIRE(uctx->zonename != NULL && uctx->currentserver != NULL);
-
- result = dns_message_gettempname(uctx->updatemsg, &name);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
- dns_name_init(name, NULL);
- dns_name_clone(uctx->zonename, name);
- result = dns_message_gettemprdataset(uctx->updatemsg, &rdataset);
- if (result != ISC_R_SUCCESS) {
- dns_message_puttempname(uctx->updatemsg, &name);
- return (result);
- }
- dns_rdataset_makequestion(rdataset, uctx->rdclass, dns_rdatatype_soa);
- ISC_LIST_INIT(name->list);
- ISC_LIST_APPEND(name->list, rdataset, link);
- dns_message_addname(uctx->updatemsg, name, DNS_SECTION_ZONE);
- if (uctx->tsigkey == NULL && uctx->sig0key != NULL) {
- result = dns_message_setsig0key(uctx->updatemsg, uctx->sig0key);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
- }
- timeout = client->update_timeout / uctx->nservers;
- if (timeout < MIN_UPDATE_TIMEOUT) {
- timeout = MIN_UPDATE_TIMEOUT;
- }
- reqoptions = 0;
- if (uctx->want_tcp) {
- reqoptions |= DNS_REQUESTOPT_TCP;
- }
- result = dns_request_createvia(
- uctx->view->requestmgr, uctx->updatemsg, NULL,
- uctx->currentserver, -1, reqoptions, uctx->tsigkey, timeout,
- client->update_udptimeout, client->update_udpretries,
- client->task, update_done, uctx, &uctx->updatereq);
- if (result == ISC_R_SUCCESS &&
- uctx->state == dns_clientupdatestate_prepare) {
- uctx->state = dns_clientupdatestate_sent;
- }
-
- return (result);
-}
-
-static void
-resolveaddr_done(isc_task_t *task, isc_event_t *event) {
- isc_result_t result;
- int family;
- dns_rdatatype_t qtype;
- dns_clientresevent_t *rev = (dns_clientresevent_t *)event;
- dns_name_t *name;
- dns_rdataset_t *rdataset;
- updatectx_t *uctx;
- bool completed = false;
-
- UNUSED(task);
-
- REQUIRE(event->ev_arg != NULL);
- uctx = *(updatectx_t **)event->ev_arg;
- REQUIRE(UCTX_VALID(uctx));
-
- if (event->ev_arg == &uctx->bp4) {
- family = AF_INET;
- qtype = dns_rdatatype_a;
- LOCK(&uctx->lock);
- dns_client_destroyrestrans(&uctx->restrans);
- UNLOCK(&uctx->lock);
- } else {
- INSIST(event->ev_arg == &uctx->bp6);
- family = AF_INET6;
- qtype = dns_rdatatype_aaaa;
- LOCK(&uctx->lock);
- dns_client_destroyrestrans(&uctx->restrans2);
- UNLOCK(&uctx->lock);
- }
-
- result = rev->result;
- if (result != ISC_R_SUCCESS) {
- goto done;
- }
-
- for (name = ISC_LIST_HEAD(rev->answerlist); name != NULL;
- name = ISC_LIST_NEXT(name, link))
- {
- for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- if (!dns_rdataset_isassociated(rdataset)) {
- continue;
- }
- if (rdataset->type != qtype) {
- continue;
- }
-
- for (result = dns_rdataset_first(rdataset);
- result == ISC_R_SUCCESS;
- result = dns_rdataset_next(rdataset))
- {
- dns_rdata_t rdata;
- dns_rdata_in_a_t rdata_a;
- dns_rdata_in_aaaa_t rdata_aaaa;
- isc_sockaddr_t *sa;
-
- sa = isc_mem_get(uctx->client->mctx,
- sizeof(*sa));
-
- dns_rdata_init(&rdata);
- switch (family) {
- case AF_INET:
- dns_rdataset_current(rdataset, &rdata);
- result = dns_rdata_tostruct(
- &rdata, &rdata_a, NULL);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
- isc_sockaddr_fromin(
- sa, &rdata_a.in_addr, 53);
- dns_rdata_freestruct(&rdata_a);
- break;
- case AF_INET6:
- dns_rdataset_current(rdataset, &rdata);
- result = dns_rdata_tostruct(
- &rdata, &rdata_aaaa, NULL);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
- isc_sockaddr_fromin6(
- sa, &rdata_aaaa.in6_addr, 53);
- dns_rdata_freestruct(&rdata_aaaa);
- break;
- }
-
- ISC_LINK_INIT(sa, link);
- ISC_LIST_APPEND(uctx->servers, sa, link);
- uctx->nservers++;
- }
- }
- }
-
-done:
- dns_client_freeresanswer(uctx->client, &rev->answerlist);
- isc_event_free(&event);
-
- LOCK(&uctx->lock);
- if (uctx->restrans == NULL && uctx->restrans2 == NULL) {
- completed = true;
- }
- UNLOCK(&uctx->lock);
-
- if (completed) {
- INSIST(uctx->currentserver == NULL);
- uctx->currentserver = ISC_LIST_HEAD(uctx->servers);
- if (uctx->currentserver != NULL && !uctx->canceled) {
- send_update(uctx);
- } else {
- if (result == ISC_R_SUCCESS) {
- result = ISC_R_NOTFOUND;
- }
- update_sendevent(uctx, result);
- }
- }
-}
-
-static isc_result_t
-process_soa(updatectx_t *uctx, dns_rdataset_t *soaset,
- const dns_name_t *soaname) {
- isc_result_t result;
- dns_rdata_t soarr = DNS_RDATA_INIT;
- dns_rdata_soa_t soa;
- dns_name_t primary;
- unsigned int resoptions;
-
- result = dns_rdataset_first(soaset);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
- dns_rdata_init(&soarr);
- dns_rdataset_current(soaset, &soarr);
- result = dns_rdata_tostruct(&soarr, &soa, NULL);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
-
- dns_name_init(&primary, NULL);
- dns_name_clone(&soa.origin, &primary);
-
- if (uctx->zonename == NULL) {
- uctx->zonename = dns_fixedname_name(&uctx->zonefname);
- dns_name_copynf(soaname, uctx->zonename);
- }
-
- if (uctx->currentserver != NULL) {
- result = send_update(uctx);
- } else {
- /*
- * Get addresses of the primary server. We don't use the ADB
- * feature so that we could avoid caching data.
- */
- LOCK(&uctx->lock);
- uctx->bp4 = uctx;
- resoptions = 0;
- if (uctx->want_tcp) {
- resoptions |= DNS_CLIENTRESOPT_TCP;
- }
- result = dns_client_startresolve(
- uctx->client, &primary, uctx->rdclass, dns_rdatatype_a,
- resoptions, uctx->client->task, resolveaddr_done,
- &uctx->bp4, &uctx->restrans);
- if (result == ISC_R_SUCCESS) {
- uctx->bp6 = uctx;
- result = dns_client_startresolve(
- uctx->client, &primary, uctx->rdclass,
- dns_rdatatype_aaaa, resoptions,
- uctx->client->task, resolveaddr_done,
- &uctx->bp6, &uctx->restrans2);
- }
- UNLOCK(&uctx->lock);
- }
-
- dns_rdata_freestruct(&soa);
-
- return (result);
-}
-
-static void
-receive_soa(isc_task_t *task, isc_event_t *event) {
- dns_requestevent_t *reqev = NULL;
- updatectx_t *uctx;
- dns_client_t *client;
- isc_result_t result, eresult;
- dns_request_t *request;
- dns_message_t *rcvmsg = NULL;
- dns_section_t section;
- dns_rdataset_t *soaset = NULL;
- int pass = 0;
- dns_name_t *name;
- dns_message_t *soaquery = NULL;
- isc_sockaddr_t *addr;
- bool seencname = false;
- bool droplabel = false;
- dns_name_t tname;
- unsigned int nlabels, reqoptions;
-
- UNUSED(task);
-
- REQUIRE(event->ev_type == DNS_EVENT_REQUESTDONE);
- reqev = (dns_requestevent_t *)event;
- request = reqev->request;
- result = eresult = reqev->result;
- POST(result);
- uctx = reqev->ev_arg;
- client = uctx->client;
- soaquery = uctx->soaquery;
- addr = uctx->currentserver;
- INSIST(addr != NULL);
-
- isc_event_free(&event);
-
- if (eresult != ISC_R_SUCCESS) {
- result = eresult;
- goto out;
- }
-
- dns_message_create(uctx->client->mctx, DNS_MESSAGE_INTENTPARSE,
- &rcvmsg);
- result = dns_request_getresponse(request, rcvmsg,
- DNS_MESSAGEPARSE_PRESERVEORDER);
-
- if (result == DNS_R_TSIGERRORSET) {
- dns_request_t *newrequest = NULL;
-
- /* Retry SOA request without TSIG */
- dns_message_detach(&rcvmsg);
- dns_message_renderreset(uctx->soaquery);
- reqoptions = 0;
- if (uctx->want_tcp) {
- reqoptions |= DNS_REQUESTOPT_TCP;
- }
- result = dns_request_createvia(
- uctx->view->requestmgr, uctx->soaquery, NULL, addr, -1,
- reqoptions, NULL, client->find_timeout * 20,
- client->find_timeout, 3, uctx->client->task,
- receive_soa, uctx, &newrequest);
- if (result == ISC_R_SUCCESS) {
- LOCK(&uctx->lock);
- dns_request_destroy(&uctx->soareq);
- uctx->soareq = newrequest;
- UNLOCK(&uctx->lock);
-
- return;
- }
- goto out;
- }
-
- section = DNS_SECTION_ANSWER;
- POST(section);
-
- if (rcvmsg->rcode != dns_rcode_noerror &&
- rcvmsg->rcode != dns_rcode_nxdomain) {
- result = rcode2result(rcvmsg->rcode);
- goto out;
- }
-
-lookforsoa:
- if (pass == 0) {
- section = DNS_SECTION_ANSWER;
- } else if (pass == 1) {
- section = DNS_SECTION_AUTHORITY;
- } else {
- droplabel = true;
- goto out;
- }
-
- result = dns_message_firstname(rcvmsg, section);
- if (result != ISC_R_SUCCESS) {
- pass++;
- goto lookforsoa;
- }
- while (result == ISC_R_SUCCESS) {
- name = NULL;
- dns_message_currentname(rcvmsg, section, &name);
- soaset = NULL;
- result = dns_message_findtype(name, dns_rdatatype_soa, 0,
- &soaset);
- if (result == ISC_R_SUCCESS) {
- break;
- }
- if (section == DNS_SECTION_ANSWER) {
- dns_rdataset_t *tset = NULL;
- if (dns_message_findtype(name, dns_rdatatype_cname, 0,
- &tset) == ISC_R_SUCCESS ||
- dns_message_findtype(name, dns_rdatatype_dname, 0,
- &tset) == ISC_R_SUCCESS)
- {
- seencname = true;
- break;
- }
- }
-
- result = dns_message_nextname(rcvmsg, section);
- }
-
- if (soaset == NULL && !seencname) {
- pass++;
- goto lookforsoa;
- }
-
- if (seencname) {
- droplabel = true;
- goto out;
- }
-
- result = process_soa(uctx, soaset, name);
-
-out:
- if (droplabel) {
- result = dns_message_firstname(soaquery, DNS_SECTION_QUESTION);
- INSIST(result == ISC_R_SUCCESS);
- name = NULL;
- dns_message_currentname(soaquery, DNS_SECTION_QUESTION, &name);
- nlabels = dns_name_countlabels(name);
- if (nlabels == 1) {
- result = DNS_R_SERVFAIL; /* is there a better error? */
- } else {
- dns_name_init(&tname, NULL);
- dns_name_getlabelsequence(name, 1, nlabels - 1, &tname);
- dns_name_clone(&tname, name);
- dns_request_destroy(&request);
- LOCK(&uctx->lock);
- uctx->soareq = NULL;
- UNLOCK(&uctx->lock);
- dns_message_renderreset(soaquery);
- dns_message_settsigkey(soaquery, NULL);
- reqoptions = 0;
- if (uctx->want_tcp) {
- reqoptions |= DNS_REQUESTOPT_TCP;
- }
- result = dns_request_createvia(
- uctx->view->requestmgr, soaquery, NULL,
- uctx->currentserver, -1, reqoptions,
- uctx->tsigkey, client->find_timeout * 20,
- client->find_timeout, 3, client->task,
- receive_soa, uctx, &uctx->soareq);
- }
- }
-
- if (!droplabel || result != ISC_R_SUCCESS) {
- dns_message_detach(&uctx->soaquery);
- LOCK(&uctx->lock);
- dns_request_destroy(&uctx->soareq);
- UNLOCK(&uctx->lock);
- }
-
- if (rcvmsg != NULL) {
- dns_message_detach(&rcvmsg);
- }
-
- if (result != ISC_R_SUCCESS) {
- update_sendevent(uctx, result);
- }
-}
-
-static isc_result_t
-request_soa(updatectx_t *uctx) {
- isc_result_t result;
- dns_message_t *soaquery = uctx->soaquery;
- dns_name_t *name = NULL;
- dns_rdataset_t *rdataset = NULL;
- unsigned int reqoptions;
-
- if (soaquery == NULL) {
- dns_message_create(uctx->client->mctx, DNS_MESSAGE_INTENTRENDER,
- &soaquery);
- }
- soaquery->flags |= DNS_MESSAGEFLAG_RD;
- result = dns_message_gettempname(soaquery, &name);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
- result = dns_message_gettemprdataset(soaquery, &rdataset);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
- dns_rdataset_makequestion(rdataset, uctx->rdclass, dns_rdatatype_soa);
- dns_name_clone(uctx->firstname, name);
- ISC_LIST_APPEND(name->list, rdataset, link);
- dns_message_addname(soaquery, name, DNS_SECTION_QUESTION);
- rdataset = NULL;
- name = NULL;
- reqoptions = 0;
- if (uctx->want_tcp) {
- reqoptions |= DNS_REQUESTOPT_TCP;
- }
-
- result = dns_request_createvia(
- uctx->view->requestmgr, soaquery, NULL, uctx->currentserver, -1,
- reqoptions, uctx->tsigkey, uctx->client->find_timeout * 20,
- uctx->client->find_timeout, 3, uctx->client->task, receive_soa,
- uctx, &uctx->soareq);
- if (result == ISC_R_SUCCESS) {
- uctx->soaquery = soaquery;
- return (ISC_R_SUCCESS);
- }
-
-fail:
- if (rdataset != NULL) {
- ISC_LIST_UNLINK(name->list, rdataset, link); /* for safety */
- dns_message_puttemprdataset(soaquery, &rdataset);
- }
- if (name != NULL) {
- dns_message_puttempname(soaquery, &name);
- }
- dns_message_detach(&soaquery);
-
- return (result);
-}
-
-static void
-resolvesoa_done(isc_task_t *task, isc_event_t *event) {
- dns_clientresevent_t *rev = (dns_clientresevent_t *)event;
- updatectx_t *uctx;
- dns_name_t *name, tname;
- dns_rdataset_t *rdataset = NULL;
- isc_result_t result = rev->result;
- unsigned int nlabels, resoptions;
-
- UNUSED(task);
-
- uctx = event->ev_arg;
- REQUIRE(UCTX_VALID(uctx));
-
- LOCK(&uctx->lock);
- dns_client_destroyrestrans(&uctx->restrans);
- UNLOCK(&uctx->lock);
-
- uctx = event->ev_arg;
- if (result != ISC_R_SUCCESS && result != DNS_R_NCACHENXDOMAIN &&
- result != DNS_R_NCACHENXRRSET)
- {
- /* XXX: what about DNSSEC failure? */
- goto out;
- }
-
- for (name = ISC_LIST_HEAD(rev->answerlist); name != NULL;
- name = ISC_LIST_NEXT(name, link))
- {
- for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- if (dns_rdataset_isassociated(rdataset) &&
- rdataset->type == dns_rdatatype_soa) {
- break;
- }
- }
- }
-
- if (rdataset == NULL) {
- /* Drop one label and retry resolution. */
- nlabels = dns_name_countlabels(&uctx->soaqname);
- if (nlabels == 1) {
- result = DNS_R_SERVFAIL; /* is there a better error? */
- goto out;
- }
- dns_name_init(&tname, NULL);
- dns_name_getlabelsequence(&uctx->soaqname, 1, nlabels - 1,
- &tname);
- dns_name_clone(&tname, &uctx->soaqname);
- resoptions = 0;
- if (uctx->want_tcp) {
- resoptions |= DNS_CLIENTRESOPT_TCP;
- }
-
- result = dns_client_startresolve(
- uctx->client, &uctx->soaqname, uctx->rdclass,
- dns_rdatatype_soa, resoptions, uctx->client->task,
- resolvesoa_done, uctx, &uctx->restrans);
- } else {
- result = process_soa(uctx, rdataset, &uctx->soaqname);
- }
-
-out:
- dns_client_freeresanswer(uctx->client, &rev->answerlist);
- isc_event_free(&event);
-
- if (result != ISC_R_SUCCESS) {
- update_sendevent(uctx, result);
- }
-}
-
-static isc_result_t
-copy_name(isc_mem_t *mctx, dns_message_t *msg, const dns_name_t *name,
- dns_name_t **newnamep) {
- isc_result_t result;
- dns_name_t *newname = NULL;
- isc_region_t r;
- isc_buffer_t *namebuf = NULL, *rdatabuf = NULL;
- dns_rdatalist_t *rdatalist;
- dns_rdataset_t *rdataset, *newrdataset;
- dns_rdata_t rdata = DNS_RDATA_INIT, *newrdata;
-
- result = dns_message_gettempname(msg, &newname);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
- isc_buffer_allocate(mctx, &namebuf, DNS_NAME_MAXWIRE);
- dns_name_init(newname, NULL);
- dns_name_setbuffer(newname, namebuf);
- dns_message_takebuffer(msg, &namebuf);
- dns_name_copynf(name, newname);
-
- for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- rdatalist = NULL;
- result = dns_message_gettemprdatalist(msg, &rdatalist);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
- dns_rdatalist_init(rdatalist);
- rdatalist->type = rdataset->type;
- rdatalist->rdclass = rdataset->rdclass;
- rdatalist->covers = rdataset->covers;
- rdatalist->ttl = rdataset->ttl;
-
- result = dns_rdataset_first(rdataset);
- while (result == ISC_R_SUCCESS) {
- dns_rdata_reset(&rdata);
- dns_rdataset_current(rdataset, &rdata);
-
- newrdata = NULL;
- result = dns_message_gettemprdata(msg, &newrdata);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
- dns_rdata_toregion(&rdata, &r);
- rdatabuf = NULL;
- isc_buffer_allocate(mctx, &rdatabuf, r.length);
- isc_buffer_putmem(rdatabuf, r.base, r.length);
- isc_buffer_usedregion(rdatabuf, &r);
- dns_rdata_init(newrdata);
- dns_rdata_fromregion(newrdata, rdata.rdclass,
- rdata.type, &r);
- newrdata->flags = rdata.flags;
-
- ISC_LIST_APPEND(rdatalist->rdata, newrdata, link);
- dns_message_takebuffer(msg, &rdatabuf);
-
- result = dns_rdataset_next(rdataset);
- }
-
- newrdataset = NULL;
- result = dns_message_gettemprdataset(msg, &newrdataset);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
- dns_rdatalist_tordataset(rdatalist, newrdataset);
-
- ISC_LIST_APPEND(newname->list, newrdataset, link);
- }
-
- *newnamep = newname;
-
- return (ISC_R_SUCCESS);
-
-fail:
- dns_message_puttempname(msg, &newname);
-
- return (result);
-}
-
-static void
-internal_update_callback(isc_task_t *task, isc_event_t *event) {
- updatearg_t *uarg = event->ev_arg;
- dns_clientupdateevent_t *uev = (dns_clientupdateevent_t *)event;
-
- UNUSED(task);
-
- LOCK(&uarg->lock);
-
- uarg->result = uev->result;
-
- dns_client_destroyupdatetrans(&uarg->trans);
- isc_event_free(&event);
-
- if (!uarg->canceled) {
- UNLOCK(&uarg->lock);
-
- /* Exit from the internal event loop */
- isc_app_ctxsuspend(uarg->actx);
- } else {
- /*
- * We have already exited from the loop (due to some
- * unexpected event). Just clean the arg up.
- */
- UNLOCK(&uarg->lock);
- isc_mutex_destroy(&uarg->lock);
- isc_mem_put(uarg->client->mctx, uarg, sizeof(*uarg));
- }
-}
-
-isc_result_t
-dns_client_update(dns_client_t *client, dns_rdataclass_t rdclass,
- const dns_name_t *zonename, dns_namelist_t *prerequisites,
- dns_namelist_t *updates, isc_sockaddrlist_t *servers,
- dns_tsec_t *tsec, unsigned int options) {
- isc_result_t result;
- isc_appctx_t *actx;
- updatearg_t *uarg;
-
- REQUIRE(DNS_CLIENT_VALID(client));
-
- if ((client->attributes & DNS_CLIENTATTR_OWNCTX) == 0 &&
- (options & DNS_CLIENTUPDOPT_ALLOWRUN) == 0)
- {
- /*
- * If the client is run under application's control, we need
- * to create a new running (sub)environment for this
- * particular update.
- */
- return (ISC_R_NOTIMPLEMENTED); /* XXXTBD */
- } else {
- actx = client->actx;
- }
-
- uarg = isc_mem_get(client->mctx, sizeof(*uarg));
-
- isc_mutex_init(&uarg->lock);
-
- uarg->actx = actx;
- uarg->client = client;
- uarg->result = ISC_R_FAILURE;
- uarg->trans = NULL;
- uarg->canceled = false;
-
- result = dns_client_startupdate(
- client, rdclass, zonename, prerequisites, updates, servers,
- tsec, options, client->task, internal_update_callback, uarg,
- &uarg->trans);
- if (result != ISC_R_SUCCESS) {
- isc_mutex_destroy(&uarg->lock);
- isc_mem_put(client->mctx, uarg, sizeof(*uarg));
- return (result);
- }
-
- /*
- * Start internal event loop. It blocks until the entire process
- * is completed.
- */
- result = isc_app_ctxrun(actx);
-
- LOCK(&uarg->lock);
- if (result == ISC_R_SUCCESS || result == ISC_R_SUSPEND) {
- result = uarg->result;
- }
-
- if (uarg->trans != NULL) {
- /*
- * Unusual termination (perhaps due to signal). We need some
- * tricky cleanup process.
- */
- uarg->canceled = true;
- dns_client_cancelupdate(uarg->trans);
-
- UNLOCK(&uarg->lock);
-
- /* uarg will be freed in the event handler. */
- } else {
- UNLOCK(&uarg->lock);
-
- isc_mutex_destroy(&uarg->lock);
- isc_mem_put(client->mctx, uarg, sizeof(*uarg));
- }
-
- return (result);
-}
-
-static void
-startupdate(isc_task_t *task, isc_event_t *event) {
- updatectx_t *uctx;
- isc_result_t result;
- unsigned int resoptions;
-
- REQUIRE(event != NULL);
-
- UNUSED(task);
-
- uctx = event->ev_arg;
-
- if (uctx->zonename != NULL && uctx->currentserver != NULL) {
- result = send_update(uctx);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
- } else if (uctx->currentserver != NULL) {
- result = request_soa(uctx);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
- } else {
- resoptions = 0;
- if (uctx->want_tcp) {
- resoptions |= DNS_CLIENTRESOPT_TCP;
- }
- dns_name_clone(uctx->firstname, &uctx->soaqname);
- result = dns_client_startresolve(
- uctx->client, &uctx->soaqname, uctx->rdclass,
- dns_rdatatype_soa, resoptions, uctx->client->task,
- resolvesoa_done, uctx, &uctx->restrans);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
- }
-
- isc_event_free(&event);
-
-fail:
- if (result != ISC_R_SUCCESS) {
- update_sendevent(uctx, result);
- }
-}
-
-isc_result_t
-dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
- const dns_name_t *zonename,
- dns_namelist_t *prerequisites, dns_namelist_t *updates,
- isc_sockaddrlist_t *servers, dns_tsec_t *tsec,
- unsigned int options, isc_task_t *task,
- isc_taskaction_t action, void *arg,
- dns_clientupdatetrans_t **transp) {
- dns_view_t *view = NULL;
- isc_result_t result;
- dns_name_t *name, *newname;
- updatectx_t *uctx;
- isc_task_t *tclone = NULL;
- dns_section_t section = DNS_SECTION_UPDATE;
- isc_sockaddr_t *server, *sa = NULL;
- dns_tsectype_t tsectype = dns_tsectype_none;
- bool want_tcp;
-
- UNUSED(options);
-
- REQUIRE(DNS_CLIENT_VALID(client));
- REQUIRE(transp != NULL && *transp == NULL);
- REQUIRE(updates != NULL);
- REQUIRE(task != NULL);
-
- if (tsec != NULL) {
- tsectype = dns_tsec_gettype(tsec);
- if (tsectype != dns_tsectype_tsig) {
- return (ISC_R_NOTIMPLEMENTED); /* XXX */
- }
- }
-
- LOCK(&client->lock);
- result = dns_viewlist_find(&client->viewlist, DNS_CLIENTVIEW_NAME,
- rdclass, &view);
- UNLOCK(&client->lock);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
-
- want_tcp = ((options & DNS_CLIENTUPDOPT_TCP) != 0);
-
- /*
- * Create a context and prepare some resources.
- */
-
- uctx = isc_mem_get(client->mctx, sizeof(*uctx));
-
- isc_mutex_init(&uctx->lock);
-
- tclone = NULL;
- isc_task_attach(task, &tclone);
- uctx->client = client;
- ISC_LINK_INIT(uctx, link);
- uctx->state = dns_clientupdatestate_prepare;
- uctx->view = view;
- uctx->rdclass = rdclass;
- uctx->canceled = false;
- uctx->updatemsg = NULL;
- uctx->soaquery = NULL;
- uctx->updatereq = NULL;
- uctx->restrans = NULL;
- uctx->restrans2 = NULL;
- uctx->bp4 = NULL;
- uctx->bp6 = NULL;
- uctx->soareq = NULL;
- uctx->event = NULL;
- uctx->tsigkey = NULL;
- uctx->sig0key = NULL;
- uctx->zonename = NULL;
- uctx->want_tcp = want_tcp;
- dns_name_init(&uctx->soaqname, NULL);
- ISC_LIST_INIT(uctx->servers);
- uctx->nservers = 0;
- uctx->currentserver = NULL;
- dns_fixedname_init(&uctx->zonefname);
- if (tsec != NULL) {
- dns_tsec_getkey(tsec, &uctx->tsigkey);
- }
- uctx->event = (dns_clientupdateevent_t *)isc_event_allocate(
- client->mctx, tclone, DNS_EVENT_UPDATEDONE, action, arg,
- sizeof(*uctx->event));
- if (zonename != NULL) {
- uctx->zonename = dns_fixedname_name(&uctx->zonefname);
- dns_name_copynf(zonename, uctx->zonename);
- }
- if (servers != NULL) {
- for (server = ISC_LIST_HEAD(*servers); server != NULL;
- server = ISC_LIST_NEXT(server, link))
- {
- sa = isc_mem_get(client->mctx, sizeof(*sa));
- sa->type = server->type;
- sa->length = server->length;
- ISC_LINK_INIT(sa, link);
- ISC_LIST_APPEND(uctx->servers, sa, link);
- if (uctx->currentserver == NULL) {
- uctx->currentserver = sa;
- }
- uctx->nservers++;
- }
- }
-
- /* Make update message */
- dns_message_create(client->mctx, DNS_MESSAGE_INTENTRENDER,
- &uctx->updatemsg);
- uctx->updatemsg->opcode = dns_opcode_update;
-
- if (prerequisites != NULL) {
- for (name = ISC_LIST_HEAD(*prerequisites); name != NULL;
- name = ISC_LIST_NEXT(name, link))
- {
- newname = NULL;
- result = copy_name(client->mctx, uctx->updatemsg, name,
- &newname);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
- dns_message_addname(uctx->updatemsg, newname,
- DNS_SECTION_PREREQUISITE);
- }
- }
-
- for (name = ISC_LIST_HEAD(*updates); name != NULL;
- name = ISC_LIST_NEXT(name, link))
- {
- newname = NULL;
- result = copy_name(client->mctx, uctx->updatemsg, name,
- &newname);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
- dns_message_addname(uctx->updatemsg, newname,
- DNS_SECTION_UPDATE);
- }
-
- uctx->firstname = NULL;
- result = dns_message_firstname(uctx->updatemsg, section);
- if (result == ISC_R_NOMORE) {
- section = DNS_SECTION_PREREQUISITE;
- result = dns_message_firstname(uctx->updatemsg, section);
- }
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
- dns_message_currentname(uctx->updatemsg, section, &uctx->firstname);
-
- uctx->magic = UCTX_MAGIC;
-
- LOCK(&client->lock);
- ISC_LIST_APPEND(client->updatectxs, uctx, link);
- isc_refcount_increment(&client->references);
- UNLOCK(&client->lock);
-
- *transp = (dns_clientupdatetrans_t *)uctx;
- result = isc_app_ctxonrun(client->actx, client->mctx, client->task,
- startupdate, uctx);
- if (result == ISC_R_ALREADYRUNNING) {
- isc_event_t *event;
- event = isc_event_allocate(client->mctx, dns_client_startupdate,
- DNS_EVENT_STARTUPDATE, startupdate,
- uctx, sizeof(*event));
- result = ISC_R_SUCCESS;
- isc_task_send(task, &event);
- }
- if (result == ISC_R_SUCCESS) {
- return (result);
- }
-
- isc_refcount_decrement1(&client->references);
- *transp = NULL;
-
-fail:
- if (ISC_LINK_LINKED(uctx, link)) {
- LOCK(&client->lock);
- ISC_LIST_UNLINK(client->updatectxs, uctx, link);
- UNLOCK(&client->lock);
- }
- if (uctx->updatemsg != NULL) {
- dns_message_detach(&uctx->updatemsg);
- }
- while ((sa = ISC_LIST_HEAD(uctx->servers)) != NULL) {
- ISC_LIST_UNLINK(uctx->servers, sa, link);
- isc_mem_put(client->mctx, sa, sizeof(*sa));
- }
- if (uctx->event != NULL) {
- isc_event_free(ISC_EVENT_PTR(&uctx->event));
- }
- if (uctx->tsigkey != NULL) {
- dns_tsigkey_detach(&uctx->tsigkey);
- }
- isc_task_detach(&tclone);
- isc_mutex_destroy(&uctx->lock);
- uctx->magic = 0;
- isc_mem_put(client->mctx, uctx, sizeof(*uctx));
- dns_view_detach(&view);
-
- return (result);
-}
-
-void
-dns_client_cancelupdate(dns_clientupdatetrans_t *trans) {
- updatectx_t *uctx;
-
- REQUIRE(trans != NULL);
- uctx = (updatectx_t *)trans;
- REQUIRE(UCTX_VALID(uctx));
-
- LOCK(&uctx->lock);
-
- if (!uctx->canceled) {
- uctx->canceled = true;
- if (uctx->updatereq != NULL) {
- dns_request_cancel(uctx->updatereq);
- }
- if (uctx->soareq != NULL) {
- dns_request_cancel(uctx->soareq);
- }
- if (uctx->restrans != NULL) {
- dns_client_cancelresolve(uctx->restrans);
- }
- if (uctx->restrans2 != NULL) {
- dns_client_cancelresolve(uctx->restrans2);
- }
- }
-
- UNLOCK(&uctx->lock);
-}
-
-void
-dns_client_destroyupdatetrans(dns_clientupdatetrans_t **transp) {
- updatectx_t *uctx;
- isc_mem_t *mctx;
- dns_client_t *client;
- isc_sockaddr_t *sa;
-
- REQUIRE(transp != NULL);
- uctx = (updatectx_t *)*transp;
- *transp = NULL;
- REQUIRE(UCTX_VALID(uctx));
- client = uctx->client;
- REQUIRE(DNS_CLIENT_VALID(client));
- REQUIRE(uctx->updatereq == NULL && uctx->updatemsg == NULL &&
- uctx->soareq == NULL && uctx->soaquery == NULL &&
- uctx->event == NULL && uctx->tsigkey == NULL &&
- uctx->sig0key == NULL);
-
- mctx = client->mctx;
- dns_view_detach(&uctx->view);
- while ((sa = ISC_LIST_HEAD(uctx->servers)) != NULL) {
- ISC_LIST_UNLINK(uctx->servers, sa, link);
- isc_mem_put(mctx, sa, sizeof(*sa));
- }
-
- LOCK(&client->lock);
-
- INSIST(ISC_LINK_LINKED(uctx, link));
- ISC_LIST_UNLINK(client->updatectxs, uctx, link);
-
- UNLOCK(&client->lock);
-
- isc_mutex_destroy(&uctx->lock);
- uctx->magic = 0;
-
- isc_mem_put(mctx, uctx, sizeof(*uctx));
-
- dns_client_destroy(&client);
-}
-
-isc_mem_t *
-dns_client_mctx(dns_client_t *client) {
- REQUIRE(DNS_CLIENT_VALID(client));
- return (client->mctx);
-}
-
-typedef struct {
- isc_buffer_t buffer;
- dns_rdataset_t rdataset;
- dns_rdatalist_t rdatalist;
- dns_rdata_t rdata;
- size_t size;
- isc_mem_t *mctx;
- unsigned char data[];
-} dns_client_updaterec_t;
-
-isc_result_t
-dns_client_updaterec(dns_client_updateop_t op, const dns_name_t *owner,
- dns_rdatatype_t type, dns_rdata_t *source, dns_ttl_t ttl,
- dns_name_t *target, dns_rdataset_t *rdataset,
- dns_rdatalist_t *rdatalist, dns_rdata_t *rdata,
- isc_mem_t *mctx) {
- dns_client_updaterec_t *updaterec = NULL;
- size_t size = offsetof(dns_client_updaterec_t, data);
-
- REQUIRE(op < updateop_max);
- REQUIRE(owner != NULL);
- REQUIRE((rdataset != NULL && rdatalist != NULL && rdata != NULL) ||
- (rdataset == NULL && rdatalist == NULL && rdata == NULL &&
- mctx != NULL));
- if (op == updateop_add) {
- REQUIRE(source != NULL);
- }
- if (source != NULL) {
- REQUIRE(source->type == type);
- REQUIRE(op == updateop_add || op == updateop_delete ||
- op == updateop_exist);
- }
-
- size += owner->length;
- if (source != NULL) {
- size += source->length;
- }
-
- if (rdataset == NULL) {
- updaterec = isc_mem_get(mctx, size);
- rdataset = &updaterec->rdataset;
- rdatalist = &updaterec->rdatalist;
- rdata = &updaterec->rdata;
- dns_rdataset_init(rdataset);
- dns_rdatalist_init(&updaterec->rdatalist);
- dns_rdata_init(&updaterec->rdata);
- isc_buffer_init(
- &updaterec->buffer, updaterec->data,
- (unsigned int)(size -
- offsetof(dns_client_updaterec_t, data)));
- dns_name_copy(owner, target, &updaterec->buffer);
- if (source != NULL) {
- isc_region_t r;
- dns_rdata_clone(source, rdata);
- dns_rdata_toregion(rdata, &r);
- rdata->data = isc_buffer_used(&updaterec->buffer);
- isc_buffer_copyregion(&updaterec->buffer, &r);
- }
- updaterec->mctx = NULL;
- isc_mem_attach(mctx, &updaterec->mctx);
- } else if (source != NULL) {
- dns_rdata_clone(source, rdata);
- }
-
- switch (op) {
- case updateop_add:
- break;
- case updateop_delete:
- if (source != NULL) {
- ttl = 0;
- dns_rdata_makedelete(rdata);
- } else {
- dns_rdata_deleterrset(rdata, type);
- }
- break;
- case updateop_notexist:
- dns_rdata_notexist(rdata, type);
- break;
- case updateop_exist:
- if (source == NULL) {
- ttl = 0;
- dns_rdata_exists(rdata, type);
- }
- case updateop_none:
- break;
- default:
- INSIST(0);
- ISC_UNREACHABLE();
- }
-
- rdatalist->type = rdata->type;
- rdatalist->rdclass = rdata->rdclass;
- if (source != NULL) {
- rdatalist->covers = dns_rdata_covers(rdata);
- rdatalist->ttl = ttl;
- }
- ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
- dns_rdatalist_tordataset(rdatalist, rdataset);
- ISC_LIST_APPEND(target->list, rdataset, link);
- if (updaterec != NULL) {
- target->attributes |= DNS_NAMEATTR_HASUPDATEREC;
- dns_name_setbuffer(target, &updaterec->buffer);
- }
- if (op == updateop_add || op == updateop_delete) {
- target->attributes |= DNS_NAMEATTR_UPDATE;
- } else {
- target->attributes |= DNS_NAMEATTR_PREREQUISITE;
- }
- return (ISC_R_SUCCESS);
-}
-
-void
-dns_client_freeupdate(dns_name_t **namep) {
- dns_client_updaterec_t *updaterec;
- dns_rdatalist_t *rdatalist;
- dns_rdataset_t *rdataset;
- dns_rdata_t *rdata;
- dns_name_t *name;
-
- REQUIRE(namep != NULL && *namep != NULL);
-
- name = *namep;
- for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
- rdataset = ISC_LIST_HEAD(name->list))
- {
- ISC_LIST_UNLINK(name->list, rdataset, link);
- rdatalist = NULL;
- dns_rdatalist_fromrdataset(rdataset, &rdatalist);
- if (rdatalist == NULL) {
- dns_rdataset_disassociate(rdataset);
- continue;
- }
- for (rdata = ISC_LIST_HEAD(rdatalist->rdata); rdata != NULL;
- rdata = ISC_LIST_HEAD(rdatalist->rdata))
- {
- ISC_LIST_UNLINK(rdatalist->rdata, rdata, link);
- }
- dns_rdataset_disassociate(rdataset);
- }
-
- if ((name->attributes & DNS_NAMEATTR_HASUPDATEREC) != 0) {
- updaterec = (dns_client_updaterec_t *)name->buffer;
- INSIST(updaterec != NULL);
- isc_mem_putanddetach(&updaterec->mctx, updaterec,
- updaterec->size);
- *namep = NULL;
- }
-}
diff --git a/lib/dns/include/dns/client.h b/lib/dns/include/dns/client.h
index 82884c67b3..79fb13b5a1 100644
--- a/lib/dns/include/dns/client.h
+++ b/lib/dns/include/dns/client.h
@@ -67,7 +67,7 @@ ISC_LANG_BEGINDECLS
/*%< Do not return DNSSEC data (e.g. RRSIGS) with response. */
#define DNS_CLIENTRESOPT_NODNSSEC 0x01
/*%< Allow running external context. */
-#define DNS_CLIENTRESOPT_ALLOWRUN 0x02
+#define DNS_CLIENTRESOPT_RESERVED 0x02
/*%< Don't validate responses. */
#define DNS_CLIENTRESOPT_NOVALIDATE 0x04
/*%< Don't set the CD flag on upstream queries. */
@@ -79,7 +79,7 @@ ISC_LANG_BEGINDECLS
* Optional flags for dns_client_(start)request.
*/
/*%< Allow running external context. */
-#define DNS_CLIENTREQOPT_ALLOWRUN 0x01
+#define DNS_CLIENTREQOPT_RESERVED 0x01
/*%< Use TCP transport. */
#define DNS_CLIENTREQOPT_TCP 0x02
@@ -87,7 +87,7 @@ ISC_LANG_BEGINDECLS
* Optional flags for dns_client_(start)update.
*/
/*%< Allow running external context. */
-#define DNS_CLIENTUPDOPT_ALLOWRUN 0x01
+#define DNS_CLIENTUPDOPT_RESERVED 0x01
/*%< Use TCP transport. */
#define DNS_CLIENTUPDOPT_TCP 0x02
@@ -112,15 +112,6 @@ typedef struct dns_clientresevent {
dns_namelist_t answerlist;
} dns_clientresevent_t; /* too long? */
-/*%
- * Status of a dynamic update procedure.
- */
-typedef enum {
- dns_clientupdatestate_prepare, /*%< no updates have been sent */
- dns_clientupdatestate_sent, /*%< updates were sent, no response */
- dns_clientupdatestate_done /*%< update was sent and succeeded */
-} dns_clientupdatestate_t;
-
/*%
* A dns_clientreqevent_t is sent when a DNS request is completed by a client.
* 'result' stores the result code of the entire transaction.
@@ -135,49 +126,23 @@ typedef struct dns_clientreqevent {
dns_message_t *rmessage;
} dns_clientreqevent_t; /* too long? */
-/*%
- * A dns_clientupdateevent_t is sent when dynamic update performed by a client
- * completes. 'result' stores the result code of the entire update procedure.
- * 'state' specifies the status of the update procedure when this event is
- * sent. This can be used as a hint by the receiver to determine whether
- * the update attempt was ever made. In particular, if the state is
- * dns_clientupdatestate_prepare, the receiver can be sure that the requested
- * update was not applied.
- */
-typedef struct dns_clientupdateevent {
- ISC_EVENT_COMMON(struct dns_clientupdateevent);
- isc_result_t result;
- dns_clientupdatestate_t state;
-} dns_clientupdateevent_t; /* too long? */
-
isc_result_t
-dns_client_create(dns_client_t **clientp, unsigned int options);
-
-isc_result_t
-dns_client_createx(isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr,
- isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr,
- unsigned int options, dns_client_t **clientp,
- const isc_sockaddr_t *localaddr4,
- const isc_sockaddr_t *localaddr6);
+dns_client_create(isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr,
+ isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr,
+ unsigned int options, dns_client_t **clientp,
+ const isc_sockaddr_t *localaddr4,
+ const isc_sockaddr_t *localaddr6);
/*%<
- * Create a DNS client. These functions create a new client object with
- * minimal internal resources such as the default 'view' for the IN class and
- * IPv4/IPv6 dispatches for the view.
+ * Create a DNS client object with minimal internal resources, such as
+ * a default view for the IN class and IPv4/IPv6 dispatches for the view.
*
- * dns_client_createx() takes 'manager' arguments so that the caller can
+ * dns_client_create() takes 'manager' arguments so that the caller can
* control the behavior of the client through the underlying event framework.
- * On the other hand, dns_client_create() simplifies the interface and creates
- * the managers internally. A DNS client object created via
- * dns_client_create() is expected to be used by an application that only needs
- * simple synchronous services or by a thread-based application.
- *
- * dns_client_createx2 takes two additional parameters, 'localaddr4' and
- * 'localaddr6', to specify the local address to use for each family. If
- * both are set to NULL, then wildcard addresses will be used for both
- * families. If only one is NULL, then the other address will be used
- * as the local address, and the other protocol family will not be used.
- *
- * dns_client_create(x) will create a cache database with the view.
+ * 'localaddr4' and 'localaddr6' specify the local addresses to use for
+ * each address family; if both are set to NULL, then wildcard addresses
+ * will be used for both families. If only one is NULL, then the other
+ * address will be used as the local address, and the NULL protocol family
+ * will not be used.
*
* Requires:
*
@@ -296,11 +261,8 @@ dns_client_startresolve(dns_client_t *client, const dns_name_t *name,
* error. Otherwise, it returns the result code of the entire resolution
* process, either success or failure.
*
- * It is typically expected that the client object passed to
- * dns_client_resolve() was created via dns_client_create() and has its own
- * managers and contexts. However, if the DNS_CLIENTRESOPT_ALLOWRUN flag is
- * set in 'options', this function performs the synchronous service even if
- * it does not have its own manager and context structures.
+ * It is expected that the client object passed to dns_client_resolve() was
+ * created via dns_client_create() and has external managers and contexts.
*
* dns_client_startresolve() is an asynchronous version of dns_client_resolve()
* and does not block. When name resolution is completed, 'action' will be
@@ -436,11 +398,8 @@ dns_client_startrequest(dns_client_t *client, dns_message_t *qmessage,
* 'rmessage' will contain the response message. The caller must provide a
* valid initialized message.
*
- * It is usually expected that the client object passed to
- * dns_client_request() was created via dns_client_create() and has its own
- * managers and contexts. However, if the DNS_CLIENTREQOPT_ALLOWRUN flag is
- * set in 'options', this function performs the synchronous service even if
- * it does not have its own manager and context structures.
+ * It is expected that the client object passed to dns_client_request() was
+ * created via dns_client_create() and has external managers and contexts.
*
* dns_client_startrequest() is an asynchronous version of dns_client_request()
* and does not block. When the transaction is completed, 'action' will be
@@ -504,146 +463,6 @@ dns_client_destroyreqtrans(dns_clientreqtrans_t **transp);
*\li *transp == NULL.
*/
-isc_result_t
-dns_client_update(dns_client_t *client, dns_rdataclass_t rdclass,
- const dns_name_t *zonename, dns_namelist_t *prerequisites,
- dns_namelist_t *updates, isc_sockaddrlist_t *servers,
- dns_tsec_t *tsec, unsigned int options);
-
-isc_result_t
-dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
- const dns_name_t *zonename,
- dns_namelist_t *prerequisites, dns_namelist_t *updates,
- isc_sockaddrlist_t *servers, dns_tsec_t *tsec,
- unsigned int options, isc_task_t *task,
- isc_taskaction_t action, void *arg,
- dns_clientupdatetrans_t **transp);
-/*%<
- * Perform DNS dynamic update for 'updates' of the 'rdclass' class with
- * optional 'prerequisites'.
- *
- * 'updates' are a list of names with associated RRsets to be updated.
- *
- * 'prerequisites' are a list of names with associated RRsets corresponding to
- * the prerequisites of the updates. This is optional and can be NULL, in
- * which case the prerequisite section of the update message will be empty.
- *
- * Both 'updates' and 'prerequisites' must be constructed as specified in
- * RFC2136.
- *
- * 'zonename' is the name of the zone in which the updated names exist.
- * This is optional and can be NULL. In this case, these functions internally
- * identify the appropriate zone through some queries for the SOA RR starting
- * with the first name in prerequisites or updates.
- *
- * 'servers' is a list of authoritative servers to which the update message
- * should be sent. This is optional and can be NULL. In this case, these
- * functions internally identify the appropriate primary server name and its
- * addresses through some queries for the SOA RR (like the case of zonename)
- * and supplemental A/AAAA queries for the server name.
- * Note: The client module generally assumes the given addresses are of the
- * primary server of the corresponding zone. It will work even if a secondary
- * server address is specified as long as the server allows update forwarding,
- * it is generally discouraged to include secondary server addresses unless
- * there's strong reason to do so.
- *
- * 'tsec' is a transaction security object containing, e.g. a TSIG key for
- * authenticating the update transaction (and the supplemental query/response
- * transactions if the server is specified). This is optional and can be
- * NULL, in which case the library tries the update without any transaction
- * authentication.
- *
- * It is typically expected that the client object passed to
- * dns_client_update() was created via dns_client_create() and has its own
- * managers and contexts. However, if the DNS_CLIENTUPDOPT_ALLOWRUN flag is
- * set in 'options', this function performs the synchronous service even if
- * it does not have its own manager and context structures.
- *
- * dns_client_update() provides a synchronous service. This function blocks
- * until the entire update procedure completes, including the additional
- * queries when necessary.
- *
- * dns_client_startupdate() is an asynchronous version of dns_client_update().
- * It immediately returns (typically with *transp being set to a non-NULL
- * pointer), and performs the update procedure through a set of internal
- * events. All transactions including the additional query exchanges are
- * performed as a separate event, so none of these events cause blocking
- * operation. When the update procedure completes, the specified function
- * 'action' will be called with the argument of a 'dns_clientupdateevent_t'
- * structure. On return, '*transp' is set to an opaque transaction ID so that
- * the caller can cancel this update process.
- *
- * DNS_CLIENTUPDOPT_TCP switches to the TCP (vs. UDP) transport.
- *
- * Requires:
- *
- *\li 'client' is a valid client.
- *
- *\li 'updates' != NULL.
- *
- *\li 'task' is a valid task.
- *
- *\li 'transp' != NULL && *transp == NULL;
- *
- * Returns:
- *
- *\li #ISC_R_SUCCESS On success.
- *
- *\li Anything else Failure.
- */
-
-void
-dns_client_cancelupdate(dns_clientupdatetrans_t *trans);
-/*%<
- * Cancel an ongoing dynamic update procedure started via
- * dns_client_startupdate().
- *
- * Notes:
- *
- *\li If the update procedure has not completed, post its UPDATEDONE
- * event with a result code of #ISC_R_CANCELED.
- *
- * Requires:
- *
- *\li 'trans' is a valid transaction ID.
- */
-
-void
-dns_client_destroyupdatetrans(dns_clientupdatetrans_t **transp);
-/*%<
- * Destroy dynamic update transaction identified by '*transp'.
- *
- * Requires:
- *
- *\li '*transp' is a valid transaction ID.
- *
- *\li The caller has received the UPDATEDONE event (either because the
- * update completed or because dns_client_cancelupdate() was called).
- *
- * Ensures:
- *
- *\li *transp == NULL.
- */
-
-isc_result_t
-dns_client_updaterec(dns_client_updateop_t op, const dns_name_t *owner,
- dns_rdatatype_t type, dns_rdata_t *source, dns_ttl_t ttl,
- dns_name_t *target, dns_rdataset_t *rdataset,
- dns_rdatalist_t *rdatalist, dns_rdata_t *rdata,
- isc_mem_t *mctx);
-/*%<
- * TBD
- */
-
-void
-dns_client_freeupdate(dns_name_t **namep);
-/*%<
- * TBD
- */
-
-isc_mem_t *
-dns_client_mctx(dns_client_t *client);
-
ISC_LANG_ENDDECLS
#endif /* DNS_CLIENT_H */
diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in
index b4163d90eb..c22be8ee2b 100644
--- a/lib/dns/win32/libdns.def.in
+++ b/lib/dns/win32/libdns.def.in
@@ -133,27 +133,15 @@ dns_catz_zones_merge
dns_cert_fromtext
dns_cert_totext
dns_client_addtrustedkey
-dns_client_cancelrequest
dns_client_cancelresolve
-dns_client_cancelupdate
dns_client_clearservers
dns_client_create
-dns_client_createx
dns_client_destroy
-dns_client_destroyreqtrans
dns_client_destroyrestrans
-dns_client_destroyupdatetrans
dns_client_freeresanswer
-dns_client_freeupdate
-dns_client_mctx
-dns_client_request
dns_client_resolve
dns_client_setservers
-dns_client_startrequest
dns_client_startresolve
-dns_client_startupdate
-dns_client_update
-dns_client_updaterec
dns_clientinfo_init
dns_clientinfomethods_init
dns_compress_add
diff --git a/lib/samples/.gitignore b/lib/samples/.gitignore
deleted file mode 100644
index 3d14fb9600..0000000000
--- a/lib/samples/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-nsprobe
-process
-resolve
-sample-async
-sample-gai
-sample-request
-sample-update
diff --git a/lib/samples/Makefile.am b/lib/samples/Makefile.am
deleted file mode 100644
index 54e2b5fc5d..0000000000
--- a/lib/samples/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-include $(top_srcdir)/Makefile.top
-
-AM_CPPFLAGS += \
- $(LIBISC_CFLAGS) \
- $(LIBDNS_CFLAGS) \
- $(LIBIRS_CFLAGS)
-
-noinst_PROGRAMS = \
- resolve \
- sample-async \
- sample-update \
- sample-request \
- nsprobe
-
-resolve_SOURCES = resolve.c
-resolve_LDADD = $(LIBISC_LIBS) $(LIBIRS_LIBS) $(LIBDNS_LIBS)
-
-sample_async_SOURCES = sample-async.c
-sample_async_LDADD = $(LIBISC_LIBS) $(LIBDNS_LIBS)
-
-sample_update_SOURCES = sample-update.c
-sample_update_LDADD = $(LIBISC_LIBS) $(LIBDNS_LIBS)
-
-sample_request_SOURCES = sample-request.c
-sample_request_LDADD = $(LIBISC_LIBS) $(LIBDNS_LIBS)
-
-nsprobe_SOURCES = nsprobe.c
-nsprobe_LDADD = $(LIBISC_LIBS) $(LIBDNS_LIBS)
diff --git a/lib/samples/nsprobe.c b/lib/samples/nsprobe.c
deleted file mode 100644
index eb626086f0..0000000000
--- a/lib/samples/nsprobe.c
+++ /dev/null
@@ -1,1234 +0,0 @@
-/*
- * Copyright (C) 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 https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#ifndef WIN32
-#include
-#include
-#include
-#include
-#endif /* ifndef WIN32 */
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define MAX_PROBES 1000
-
-static dns_client_t *client = NULL;
-static isc_task_t *probe_task = NULL;
-static isc_appctx_t *actx = NULL;
-static isc_mem_t *mctx = NULL;
-static unsigned int outstanding_probes = 0;
-const char *cacheserver = "127.0.0.1";
-static FILE *input;
-
-typedef enum {
- none,
- exist,
- nxdomain,
- othererr,
- multiplesoa,
- multiplecname,
- brokenanswer,
- lame,
- timedout,
- notype,
- unexpected
-} query_result_t;
-
-struct server {
- ISC_LINK(struct server) link;
-
- isc_sockaddr_t address;
- query_result_t result_a;
- query_result_t result_aaaa;
-};
-
-struct probe_ns {
- ISC_LINK(struct probe_ns) link;
-
- dns_fixedname_t fixedname;
- dns_name_t *name;
- struct server *current_server;
- ISC_LIST(struct server) servers;
-};
-
-struct probe_trans {
- bool inuse;
- char *domain;
- dns_fixedname_t fixedname;
- dns_name_t *qname;
- const char **qlabel;
- bool qname_found;
- dns_clientrestrans_t *resid;
- dns_message_t *qmessage;
- dns_message_t *rmessage;
- dns_clientreqtrans_t *reqid;
-
- /* NS list */
- struct probe_ns *current_ns;
- ISC_LIST(struct probe_ns) nslist;
-};
-
-struct lcl_stat {
- unsigned long valid;
- unsigned long ignore;
- unsigned long nxdomain;
- unsigned long othererr;
- unsigned long multiplesoa;
- unsigned long multiplecname;
- unsigned long brokenanswer;
- unsigned long lame;
- unsigned long unknown;
-} server_stat, domain_stat;
-
-static unsigned long number_of_domains = 0;
-static unsigned long number_of_servers = 0;
-static unsigned long multiple_error_domains = 0;
-static bool debug_mode = false;
-static int verbose_level = 0;
-static const char *qlabels[] = { "www.", "ftp.", NULL };
-static struct probe_trans probes[MAX_PROBES];
-
-static isc_result_t
-probe_domain(struct probe_trans *trans);
-static void
-reset_probe(struct probe_trans *trans);
-static isc_result_t
-fetch_nsaddress(struct probe_trans *trans);
-static isc_result_t
-probe_name(struct probe_trans *trans, dns_rdatatype_t type);
-
-/* Dump an rdataset for debug */
-static isc_result_t
-print_rdataset(dns_rdataset_t *rdataset, dns_name_t *owner) {
- isc_buffer_t target;
- isc_result_t result;
- isc_region_t r;
- char t[4096];
-
- if (!debug_mode) {
- return (ISC_R_SUCCESS);
- }
-
- isc_buffer_init(&target, t, sizeof(t));
-
- if (!dns_rdataset_isassociated(rdataset)) {
- return (ISC_R_SUCCESS);
- }
- result = dns_rdataset_totext(rdataset, owner, false, false, &target);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
- isc_buffer_usedregion(&target, &r);
- printf("%.*s", (int)r.length, (char *)r.base);
-
- return (ISC_R_SUCCESS);
-}
-
-static isc_result_t
-print_name(dns_name_t *name) {
- isc_result_t result;
- isc_buffer_t target;
- isc_region_t r;
- char t[4096];
-
- isc_buffer_init(&target, t, sizeof(t));
- result = dns_name_totext(name, true, &target);
- if (result == ISC_R_SUCCESS) {
- isc_buffer_usedregion(&target, &r);
- printf("%.*s", (int)r.length, (char *)r.base);
- } else {
- printf("(invalid name)");
- }
-
- return (result);
-}
-
-static isc_result_t
-print_address(FILE *fp, isc_sockaddr_t *addr) {
- char buf[NI_MAXHOST];
-
- if (getnameinfo(&addr->type.sa, addr->length, buf, sizeof(buf), NULL, 0,
- NI_NUMERICHOST) == 0)
- {
- fprintf(fp, "%s", buf);
- } else {
- fprintf(fp, "(invalid address)");
- }
-
- return (ISC_R_SUCCESS);
-}
-
-static void
-ctxs_destroy(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
- isc_socketmgr_t **socketmgrp, isc_timermgr_t **timermgrp) {
- if (*taskmgrp != NULL) {
- isc_taskmgr_destroy(taskmgrp);
- }
-
- if (*timermgrp != NULL) {
- isc_timermgr_destroy(timermgrp);
- }
-
- if (*socketmgrp != NULL) {
- isc_socketmgr_destroy(socketmgrp);
- }
-
- if (*actxp != NULL) {
- isc_appctx_destroy(actxp);
- }
-
- if (*mctxp != NULL) {
- isc_mem_destroy(mctxp);
- }
-}
-
-static isc_result_t
-ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
- isc_socketmgr_t **socketmgrp, isc_timermgr_t **timermgrp) {
- isc_result_t result;
-
- isc_mem_create(mctxp);
-
- result = isc_appctx_create(*mctxp, actxp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_taskmgr_createinctx(*mctxp, 1, 0, taskmgrp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_socketmgr_createinctx(*mctxp, socketmgrp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_timermgr_createinctx(*mctxp, timermgrp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- return (ISC_R_SUCCESS);
-
-fail:
- ctxs_destroy(mctxp, actxp, taskmgrp, socketmgrp, timermgrp);
-
- return (result);
-}
-
-/*
- * Common routine to make query data
- */
-static isc_result_t
-make_querymessage(dns_message_t *message, dns_name_t *qname0,
- dns_rdatatype_t rdtype) {
- dns_name_t *qname = NULL;
- dns_rdataset_t *qrdataset = NULL;
- isc_result_t result;
-
- message->opcode = dns_opcode_query;
- message->rdclass = dns_rdataclass_in;
-
- result = dns_message_gettempname(message, &qname);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- result = dns_message_gettemprdataset(message, &qrdataset);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- dns_name_init(qname, NULL);
- dns_name_clone(qname0, qname);
- dns_rdataset_makequestion(qrdataset, message->rdclass, rdtype);
- ISC_LIST_APPEND(qname->list, qrdataset, link);
- dns_message_addname(message, qname, DNS_SECTION_QUESTION);
-
- return (ISC_R_SUCCESS);
-
-cleanup:
- if (qname != NULL) {
- dns_message_puttempname(message, &qname);
- }
- if (qrdataset != NULL) {
- dns_message_puttemprdataset(message, &qrdataset);
- }
- return (result);
-}
-
-/*
- * Update statistics
- */
-static inline void
-increment_entry(unsigned long *entryp) {
- (*entryp)++;
- INSIST(*entryp != 0U); /* check overflow */
-}
-
-static void
-update_stat(struct probe_trans *trans) {
- struct probe_ns *pns;
- struct server *server;
- struct lcl_stat local_stat;
- unsigned int err_count = 0;
- const char *stattype;
-
- increment_entry(&number_of_domains);
- memset(&local_stat, 0, sizeof(local_stat));
-
- /* Update per sever statistics */
- for (pns = ISC_LIST_HEAD(trans->nslist); pns != NULL;
- pns = ISC_LIST_NEXT(pns, link))
- {
- for (server = ISC_LIST_HEAD(pns->servers); server != NULL;
- server = ISC_LIST_NEXT(server, link))
- {
- increment_entry(&number_of_servers);
-
- if (server->result_aaaa == exist ||
- server->result_aaaa == notype) {
- /*
- * Don't care about the result of A query if
- * the answer to AAAA query was expected.
- */
- stattype = "valid";
- increment_entry(&server_stat.valid);
- increment_entry(&local_stat.valid);
- } else if (server->result_a == exist) {
- switch (server->result_aaaa) {
- case exist:
- case notype:
- stattype = "valid";
- increment_entry(&server_stat.valid);
- increment_entry(&local_stat.valid);
- break;
- case timedout:
- stattype = "ignore";
- increment_entry(&server_stat.ignore);
- increment_entry(&local_stat.ignore);
- break;
- case nxdomain:
- stattype = "nxdomain";
- increment_entry(&server_stat.nxdomain);
- increment_entry(&local_stat.nxdomain);
- break;
- case othererr:
- stattype = "othererr";
- increment_entry(&server_stat.othererr);
- increment_entry(&local_stat.othererr);
- break;
- case multiplesoa:
- stattype = "multiplesoa";
- increment_entry(
- &server_stat.multiplesoa);
- increment_entry(
- &local_stat.multiplesoa);
- break;
- case multiplecname:
- stattype = "multiplecname";
- increment_entry(
- &server_stat.multiplecname);
- increment_entry(
- &local_stat.multiplecname);
- break;
- case brokenanswer:
- stattype = "brokenanswer";
- increment_entry(
- &server_stat.brokenanswer);
- increment_entry(
- &local_stat.brokenanswer);
- break;
- case lame:
- stattype = "lame";
- increment_entry(&server_stat.lame);
- increment_entry(&local_stat.lame);
- break;
- default:
- stattype = "unknown";
- increment_entry(&server_stat.unknown);
- increment_entry(&local_stat.unknown);
- break;
- }
- } else {
- stattype = "unknown";
- increment_entry(&server_stat.unknown);
- increment_entry(&local_stat.unknown);
- }
-
- if (verbose_level > 1 ||
- (verbose_level == 1 &&
- strcmp(stattype, "valid") != 0 &&
- strcmp(stattype, "unknown") != 0))
- {
- print_name(pns->name);
- putchar('(');
- print_address(stdout, &server->address);
- printf(") for %s:%s\n", trans->domain,
- stattype);
- }
- }
- }
-
- /* Update per domain statistics */
- if (local_stat.ignore > 0U) {
- if (verbose_level > 0) {
- printf("%s:ignore\n", trans->domain);
- }
- increment_entry(&domain_stat.ignore);
- err_count++;
- }
- if (local_stat.nxdomain > 0U) {
- if (verbose_level > 0) {
- printf("%s:nxdomain\n", trans->domain);
- }
- increment_entry(&domain_stat.nxdomain);
- err_count++;
- }
- if (local_stat.othererr > 0U) {
- if (verbose_level > 0) {
- printf("%s:othererr\n", trans->domain);
- }
- increment_entry(&domain_stat.othererr);
- err_count++;
- }
- if (local_stat.multiplesoa > 0U) {
- if (verbose_level > 0) {
- printf("%s:multiplesoa\n", trans->domain);
- }
- increment_entry(&domain_stat.multiplesoa);
- err_count++;
- }
- if (local_stat.multiplecname > 0U) {
- if (verbose_level > 0) {
- printf("%s:multiplecname\n", trans->domain);
- }
- increment_entry(&domain_stat.multiplecname);
- err_count++;
- }
- if (local_stat.brokenanswer > 0U) {
- if (verbose_level > 0) {
- printf("%s:brokenanswer\n", trans->domain);
- }
- increment_entry(&domain_stat.brokenanswer);
- err_count++;
- }
- if (local_stat.lame > 0U) {
- if (verbose_level > 0) {
- printf("%s:lame\n", trans->domain);
- }
- increment_entry(&domain_stat.lame);
- err_count++;
- }
-
- if (err_count > 1U) {
- increment_entry(&multiple_error_domains);
- }
-
- /*
- * We regard the domain as valid if and only if no authoritative server
- * has a problem and at least one server is known to be valid.
- */
- if (local_stat.valid > 0U && err_count == 0U) {
- if (verbose_level > 1) {
- printf("%s:valid\n", trans->domain);
- }
- increment_entry(&domain_stat.valid);
- }
-
- /*
- * If the domain has no available server or all servers have the
- * 'unknown' result, the domain's result is also regarded as unknown.
- */
- if (local_stat.valid == 0U && err_count == 0U) {
- if (verbose_level > 1) {
- printf("%s:unknown\n", trans->domain);
- }
- increment_entry(&domain_stat.unknown);
- }
-}
-
-/*
- * Search for an existent name with an A RR
- */
-
-static isc_result_t
-set_nextqname(struct probe_trans *trans) {
- isc_result_t result;
- unsigned int domainlen;
- isc_buffer_t b;
- char buf[4096]; /* XXX ad-hoc constant, but should be enough */
-
- if (*trans->qlabel == NULL) {
- return (ISC_R_NOMORE);
- }
-
- if (strlcpy(buf, *trans->qlabel, sizeof(buf)) >= sizeof(buf)) {
- return (ISC_R_NOSPACE);
- }
-
- if ((domainlen = strlcat(buf, trans->domain, sizeof(buf))) >=
- sizeof(buf)) {
- return (ISC_R_NOSPACE);
- }
-
- isc_buffer_init(&b, buf, domainlen);
- isc_buffer_add(&b, domainlen);
- trans->qname = dns_fixedname_initname(&trans->fixedname);
- result = dns_name_fromtext(trans->qname, &b, dns_rootname, 0, NULL);
-
- trans->qlabel++;
-
- return (result);
-}
-
-static void
-request_done(isc_task_t *task, isc_event_t *event) {
- struct probe_trans *trans = event->ev_arg;
- dns_clientreqevent_t *rev = (dns_clientreqevent_t *)event;
- dns_message_t *rmessage;
- struct probe_ns *pns;
- struct server *server;
- isc_result_t result;
- query_result_t *resultp;
- dns_name_t *name;
- dns_rdataset_t *rdataset;
- dns_rdatatype_t type;
-
- REQUIRE(task == probe_task);
- REQUIRE(trans != NULL && trans->inuse);
- rmessage = rev->rmessage;
- REQUIRE(rmessage == trans->rmessage);
- INSIST(outstanding_probes > 0);
-
- server = trans->current_ns->current_server;
- INSIST(server != NULL);
-
- if (server->result_a == none) {
- type = dns_rdatatype_a;
- resultp = &server->result_a;
- } else {
- resultp = &server->result_aaaa;
- type = dns_rdatatype_aaaa;
- }
-
- if (rev->result == ISC_R_SUCCESS) {
- if ((rmessage->flags & DNS_MESSAGEFLAG_AA) == 0) {
- *resultp = lame;
- } else if (rmessage->rcode == dns_rcode_nxdomain) {
- *resultp = nxdomain;
- } else if (rmessage->rcode != dns_rcode_noerror) {
- *resultp = othererr;
- } else if (rmessage->counts[DNS_SECTION_ANSWER] == 0) {
- /* no error but empty answer */
- *resultp = notype;
- } else {
- result = dns_message_firstname(rmessage,
- DNS_SECTION_ANSWER);
- while (result == ISC_R_SUCCESS) {
- name = NULL;
- dns_message_currentname(
- rmessage, DNS_SECTION_ANSWER, &name);
- for (rdataset = ISC_LIST_HEAD(name->list);
- rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- (void)print_rdataset(rdataset, name);
-
- if (rdataset->type ==
- dns_rdatatype_cname ||
- rdataset->type ==
- dns_rdatatype_dname)
- {
- /* Should chase the chain? */
- *resultp = exist;
- goto found;
- } else if (rdataset->type == type) {
- *resultp = exist;
- goto found;
- }
- }
- result = dns_message_nextname(
- rmessage, DNS_SECTION_ANSWER);
- }
-
- /*
- * Something unexpected happened: the response
- * contained a non-empty authoritative answer, but we
- * could not find an expected result.
- */
- *resultp = unexpected;
- }
- } else if (rev->result == DNS_R_RECOVERABLE ||
- rev->result == DNS_R_BADLABELTYPE)
- {
- /* Broken response. Try identifying known cases. */
- *resultp = brokenanswer;
-
- if (rmessage->counts[DNS_SECTION_ANSWER] > 0) {
- result = dns_message_firstname(rmessage,
- DNS_SECTION_ANSWER);
- while (result == ISC_R_SUCCESS) {
- /*
- * Check to see if the response has multiple
- * CNAME RRs. Update the result code if so.
- */
- name = NULL;
- dns_message_currentname(
- rmessage, DNS_SECTION_ANSWER, &name);
- for (rdataset = ISC_LIST_HEAD(name->list);
- rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- if (rdataset->type ==
- dns_rdatatype_cname &&
- dns_rdataset_count(rdataset) > 1) {
- *resultp = multiplecname;
- goto found;
- }
- }
- result = dns_message_nextname(
- rmessage, DNS_SECTION_ANSWER);
- }
- }
-
- if (rmessage->counts[DNS_SECTION_AUTHORITY] > 0) {
- result = dns_message_firstname(rmessage,
- DNS_SECTION_AUTHORITY);
- while (result == ISC_R_SUCCESS) {
- /*
- * Check to see if the response has multiple
- * SOA RRs. Update the result code if so.
- */
- name = NULL;
- dns_message_currentname(
- rmessage, DNS_SECTION_AUTHORITY, &name);
- for (rdataset = ISC_LIST_HEAD(name->list);
- rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- if (rdataset->type ==
- dns_rdatatype_soa &&
- dns_rdataset_count(rdataset) > 1) {
- *resultp = multiplesoa;
- goto found;
- }
- }
- result = dns_message_nextname(
- rmessage, DNS_SECTION_AUTHORITY);
- }
- }
- } else if (rev->result == ISC_R_TIMEDOUT) {
- *resultp = timedout;
- } else {
- fprintf(stderr, "unexpected result: %u (domain=%s, server=",
- rev->result, trans->domain);
- print_address(stderr, &server->address);
- fputc('\n', stderr);
- *resultp = unexpected;
- }
-
-found:
- INSIST(*resultp != none);
- if (type == dns_rdatatype_a && *resultp == exist) {
- trans->qname_found = true;
- }
-
- dns_client_destroyreqtrans(&trans->reqid);
- isc_event_free(&event);
- dns_message_reset(trans->rmessage, DNS_MESSAGE_INTENTPARSE);
-
- result = probe_name(trans, type);
- if (result == ISC_R_NOMORE) {
- /* We've tried all addresses of all servers. */
- if (type == dns_rdatatype_a && trans->qname_found) {
- /*
- * If we've explored A RRs and found an existent
- * record, we can move to AAAA.
- */
- trans->current_ns = ISC_LIST_HEAD(trans->nslist);
- probe_name(trans, dns_rdatatype_aaaa);
- result = ISC_R_SUCCESS;
- } else if (type == dns_rdatatype_a) {
- /*
- * No server provided an existent A RR of this name.
- * Try next label.
- */
- dns_fixedname_invalidate(&trans->fixedname);
- trans->qname = NULL;
- result = set_nextqname(trans);
- if (result == ISC_R_SUCCESS) {
- trans->current_ns =
- ISC_LIST_HEAD(trans->nslist);
- for (pns = trans->current_ns; pns != NULL;
- pns = ISC_LIST_NEXT(pns, link)) {
- for (server = ISC_LIST_HEAD(
- pns->servers);
- server != NULL;
- server = ISC_LIST_NEXT(server,
- link))
- {
- INSIST(server->result_aaaa ==
- none);
- server->result_a = none;
- }
- }
- result = probe_name(trans, dns_rdatatype_a);
- }
- }
- if (result != ISC_R_SUCCESS) {
- /*
- * We've explored AAAA RRs or failed to find a valid
- * query label. Wrap up the result and move to the
- * next domain.
- */
- reset_probe(trans);
- }
- } else if (result != ISC_R_SUCCESS) {
- reset_probe(trans); /* XXX */
- }
-}
-
-static isc_result_t
-probe_name(struct probe_trans *trans, dns_rdatatype_t type) {
- isc_result_t result;
- struct probe_ns *pns;
- struct server *server;
-
- REQUIRE(trans->reqid == NULL);
- REQUIRE(type == dns_rdatatype_a || type == dns_rdatatype_aaaa);
-
- for (pns = trans->current_ns; pns != NULL;
- pns = ISC_LIST_NEXT(pns, link)) {
- for (server = ISC_LIST_HEAD(pns->servers); server != NULL;
- server = ISC_LIST_NEXT(server, link))
- {
- if ((type == dns_rdatatype_a &&
- server->result_a == none) ||
- (type == dns_rdatatype_aaaa &&
- server->result_aaaa == none))
- {
- pns->current_server = server;
- goto found;
- }
- }
- }
-
-found:
- trans->current_ns = pns;
- if (pns == NULL) {
- return (ISC_R_NOMORE);
- }
-
- INSIST(pns->current_server != NULL);
- dns_message_reset(trans->qmessage, DNS_MESSAGE_INTENTRENDER);
- result = make_querymessage(trans->qmessage, trans->qname, type);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
- result = dns_client_startrequest(
- client, trans->qmessage, trans->rmessage,
- &pns->current_server->address, 0, DNS_MESSAGEPARSE_BESTEFFORT,
- NULL, 120, 0, 4, probe_task, request_done, trans,
- &trans->reqid);
-
- return (result);
-}
-
-/*
- * Get IP addresses of NSes
- */
-
-static void
-resolve_nsaddress(isc_task_t *task, isc_event_t *event) {
- struct probe_trans *trans = event->ev_arg;
- dns_clientresevent_t *rev = (dns_clientresevent_t *)event;
- dns_name_t *name;
- dns_rdataset_t *rdataset;
- dns_rdata_t rdata = DNS_RDATA_INIT;
- struct probe_ns *pns = trans->current_ns;
- isc_result_t result;
-
- REQUIRE(task == probe_task);
- REQUIRE(trans->inuse);
- REQUIRE(pns != NULL);
- INSIST(outstanding_probes > 0);
-
- for (name = ISC_LIST_HEAD(rev->answerlist); name != NULL;
- name = ISC_LIST_NEXT(name, link))
- {
- for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- (void)print_rdataset(rdataset, name);
-
- if (rdataset->type != dns_rdatatype_a) {
- continue;
- }
-
- for (result = dns_rdataset_first(rdataset);
- result == ISC_R_SUCCESS;
- result = dns_rdataset_next(rdataset))
- {
- dns_rdata_in_a_t rdata_a;
- struct server *server;
-
- dns_rdataset_current(rdataset, &rdata);
- result = dns_rdata_tostruct(&rdata, &rdata_a,
- NULL);
- if (result != ISC_R_SUCCESS) {
- continue;
- }
-
- server = isc_mem_get(mctx, sizeof(*server));
- isc_sockaddr_fromin(&server->address,
- &rdata_a.in_addr, 53);
- ISC_LINK_INIT(server, link);
- server->result_a = none;
- server->result_aaaa = none;
- ISC_LIST_APPEND(pns->servers, server, link);
- }
- }
- }
-
- dns_client_freeresanswer(client, &rev->answerlist);
- dns_client_destroyrestrans(&trans->resid);
- isc_event_free(&event);
-
-next_ns:
- trans->current_ns = ISC_LIST_NEXT(pns, link);
- if (trans->current_ns == NULL) {
- trans->current_ns = ISC_LIST_HEAD(trans->nslist);
- dns_fixedname_invalidate(&trans->fixedname);
- trans->qname = NULL;
- result = set_nextqname(trans);
- if (result == ISC_R_SUCCESS) {
- result = probe_name(trans, dns_rdatatype_a);
- }
- } else {
- result = fetch_nsaddress(trans);
- if (result != ISC_R_SUCCESS) {
- goto next_ns; /* XXX: this is unlikely to succeed */
- }
- }
-
- if (result != ISC_R_SUCCESS) {
- reset_probe(trans);
- }
-}
-
-static isc_result_t
-fetch_nsaddress(struct probe_trans *trans) {
- struct probe_ns *pns;
-
- pns = trans->current_ns;
- REQUIRE(pns != NULL);
-
- return (dns_client_startresolve(
- client, pns->name, dns_rdataclass_in, dns_rdatatype_a, 0,
- probe_task, resolve_nsaddress, trans, &trans->resid));
-}
-
-/*
- * Get NS RRset for a given domain
- */
-
-static void
-reset_probe(struct probe_trans *trans) {
- struct probe_ns *pns;
- struct server *server;
- isc_result_t result;
-
- REQUIRE(trans->resid == NULL);
- REQUIRE(trans->reqid == NULL);
-
- update_stat(trans);
-
- dns_message_reset(trans->qmessage, DNS_MESSAGE_INTENTRENDER);
- dns_message_reset(trans->rmessage, DNS_MESSAGE_INTENTPARSE);
-
- trans->inuse = false;
- if (trans->domain != NULL) {
- isc_mem_free(mctx, trans->domain);
- }
- trans->domain = NULL;
- if (trans->qname != NULL) {
- dns_fixedname_invalidate(&trans->fixedname);
- }
- trans->qname = NULL;
- trans->qlabel = qlabels;
- trans->qname_found = false;
- trans->current_ns = NULL;
-
- while ((pns = ISC_LIST_HEAD(trans->nslist)) != NULL) {
- ISC_LIST_UNLINK(trans->nslist, pns, link);
- while ((server = ISC_LIST_HEAD(pns->servers)) != NULL) {
- ISC_LIST_UNLINK(pns->servers, server, link);
- isc_mem_put(mctx, server, sizeof(*server));
- }
- isc_mem_put(mctx, pns, sizeof(*pns));
- }
-
- outstanding_probes--;
-
- result = probe_domain(trans);
- if (result == ISC_R_NOMORE && outstanding_probes == 0) {
- isc_app_ctxshutdown(actx);
- }
-}
-
-static void
-resolve_ns(isc_task_t *task, isc_event_t *event) {
- struct probe_trans *trans = event->ev_arg;
- dns_clientresevent_t *rev = (dns_clientresevent_t *)event;
- dns_name_t *name;
- dns_rdataset_t *rdataset;
- isc_result_t result = ISC_R_SUCCESS;
- dns_rdata_t rdata = DNS_RDATA_INIT;
- struct probe_ns *pns;
-
- REQUIRE(task == probe_task);
- REQUIRE(trans->inuse);
- INSIST(outstanding_probes > 0);
-
- for (name = ISC_LIST_HEAD(rev->answerlist); name != NULL;
- name = ISC_LIST_NEXT(name, link))
- {
- for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- (void)print_rdataset(rdataset, name);
-
- if (rdataset->type != dns_rdatatype_ns) {
- continue;
- }
-
- for (result = dns_rdataset_first(rdataset);
- result == ISC_R_SUCCESS;
- result = dns_rdataset_next(rdataset))
- {
- dns_rdata_ns_t ns;
-
- dns_rdataset_current(rdataset, &rdata);
- /*
- * Extract the name from the NS record.
- */
- result = dns_rdata_tostruct(&rdata, &ns, NULL);
- if (result != ISC_R_SUCCESS) {
- continue;
- }
-
- pns = isc_mem_get(mctx, sizeof(*pns));
-
- pns->name =
- dns_fixedname_initname(&pns->fixedname);
- ISC_LINK_INIT(pns, link);
- ISC_LIST_APPEND(trans->nslist, pns, link);
- ISC_LIST_INIT(pns->servers);
-
- dns_name_copynf(&ns.name, pns->name);
- dns_rdata_reset(&rdata);
- dns_rdata_freestruct(&ns);
- }
- }
- }
-
- dns_client_freeresanswer(client, &rev->answerlist);
- dns_client_destroyrestrans(&trans->resid);
- isc_event_free(&event);
-
- if (!ISC_LIST_EMPTY(trans->nslist)) {
- /* Go get addresses of NSes */
- trans->current_ns = ISC_LIST_HEAD(trans->nslist);
- result = fetch_nsaddress(trans);
- } else {
- result = ISC_R_FAILURE;
- }
-
- if (result == ISC_R_SUCCESS) {
- return;
- }
-
- reset_probe(trans);
-}
-
-static isc_result_t
-probe_domain(struct probe_trans *trans) {
- isc_result_t result;
- unsigned int domainlen;
- isc_buffer_t b;
- char buf[4096]; /* XXX ad hoc constant, but should be enough */
- char *cp;
-
- REQUIRE(trans != NULL);
- REQUIRE(!trans->inuse);
- REQUIRE(outstanding_probes < MAX_PROBES);
-
- /* Construct domain */
- cp = fgets(buf, sizeof(buf), input);
- if (cp == NULL) {
- return (ISC_R_NOMORE);
- }
- if ((cp = strchr(buf, '\n')) != NULL) { /* zap NL if any */
- *cp = '\0';
- }
- trans->domain = isc_mem_strdup(mctx, buf);
-
- /* Start getting NS for the domain */
- domainlen = strlen(buf);
- isc_buffer_init(&b, buf, domainlen);
- isc_buffer_add(&b, domainlen);
- trans->qname = dns_fixedname_initname(&trans->fixedname);
- result = dns_name_fromtext(trans->qname, &b, dns_rootname, 0, NULL);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
- result = dns_client_startresolve(
- client, trans->qname, dns_rdataclass_in, dns_rdatatype_ns, 0,
- probe_task, resolve_ns, trans, &trans->resid);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- trans->inuse = true;
- outstanding_probes++;
-
- return (ISC_R_SUCCESS);
-
-cleanup:
- isc_mem_free(mctx, trans->domain);
- dns_fixedname_invalidate(&trans->fixedname);
-
- return (result);
-}
-
-ISC_NORETURN static void
-usage(void);
-
-static void
-usage(void) {
- fprintf(stderr, "usage: nsprobe [-d] [-v [-v...]] [-c cache_address] "
- "[input_file]\n");
-
- exit(1);
-}
-
-int
-main(int argc, char *argv[]) {
- int i, ch, error;
- struct addrinfo hints, *res;
- isc_result_t result;
- isc_sockaddr_t sa;
- isc_sockaddrlist_t servers;
- isc_taskmgr_t *taskmgr = NULL;
- isc_socketmgr_t *socketmgr = NULL;
- isc_timermgr_t *timermgr = NULL;
-
- while ((ch = isc_commandline_parse(argc, argv, "c:dhv")) != -1) {
- switch (ch) {
- case 'c':
- cacheserver = isc_commandline_argument;
- break;
- case 'd':
- debug_mode = true;
- break;
- case 'h':
- usage();
- break;
- case 'v':
- verbose_level++;
- break;
- default:
- usage();
- break;
- }
- }
-
- argc -= isc_commandline_index;
- argv += isc_commandline_index;
-
- /* Common set up */
- isc_lib_register();
- result = dns_lib_init();
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_lib_init failed: %u\n", result);
- exit(1);
- }
-
- result = ctxs_init(&mctx, &actx, &taskmgr, &socketmgr, &timermgr);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "ctx create failed: %u\n", result);
- exit(1);
- }
-
- isc_app_ctxstart(actx);
-
- result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr, 0,
- &client, NULL, NULL);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_client_createx failed: %u\n", result);
- exit(1);
- }
-
- /* Set local cache server */
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_DGRAM;
- error = getaddrinfo(cacheserver, "53", &hints, &res);
- if (error != 0) {
- fprintf(stderr, "failed to convert server name (%s): %s\n",
- cacheserver, gai_strerror(error));
- exit(1);
- }
-
- if (res->ai_addrlen > sizeof(sa.type)) {
- fprintf(stderr,
- "assumption failure: addrlen is too long: %ld\n",
- (long)res->ai_addrlen);
- exit(1);
- }
- memmove(&sa.type.sa, res->ai_addr, res->ai_addrlen);
- sa.length = (unsigned int)res->ai_addrlen;
- freeaddrinfo(res);
- ISC_LINK_INIT(&sa, link);
- ISC_LIST_INIT(servers);
- ISC_LIST_APPEND(servers, &sa, link);
- result = dns_client_setservers(client, dns_rdataclass_in, NULL,
- &servers);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to set server: %u\n", result);
- exit(1);
- }
-
- /* Create the main task */
- probe_task = NULL;
- result = isc_task_create(taskmgr, 0, &probe_task);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to create task: %u\n", result);
- exit(1);
- }
-
- /* Open input file */
- if (argc == 0) {
- input = stdin;
- } else {
- input = fopen(argv[0], "r");
- if (input == NULL) {
- fprintf(stderr, "failed to open input file: %s\n",
- argv[0]);
- exit(1);
- }
- }
-
- /* Set up and start probe */
- for (i = 0; i < MAX_PROBES; i++) {
- probes[i].inuse = false;
- probes[i].domain = NULL;
- dns_fixedname_init(&probes[i].fixedname);
- probes[i].qname = NULL;
- probes[i].qlabel = qlabels;
- probes[i].qname_found = false;
- probes[i].resid = NULL;
- ISC_LIST_INIT(probes[i].nslist);
- probes[i].reqid = NULL;
-
- probes[i].qmessage = NULL;
- dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER,
- &probes[i].qmessage);
- dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE,
- &probes[i].rmessage);
- }
- for (i = 0; i < MAX_PROBES; i++) {
- result = probe_domain(&probes[i]);
- if (result == ISC_R_NOMORE) {
- break;
- } else if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to issue an initial probe\n");
- exit(1);
- }
- }
-
- /* Start event loop */
- isc_app_ctxrun(actx);
-
- /* Dump results */
- printf("Per domain results (out of %lu domains):\n", number_of_domains);
- printf(" valid: %lu\n"
- " ignore: %lu\n"
- " nxdomain: %lu\n"
- " othererr: %lu\n"
- " multiplesoa: %lu\n"
- " multiplecname: %lu\n"
- " brokenanswer: %lu\n"
- " lame: %lu\n"
- " unknown: %lu\n"
- " multiple errors: %lu\n",
- domain_stat.valid, domain_stat.ignore, domain_stat.nxdomain,
- domain_stat.othererr, domain_stat.multiplesoa,
- domain_stat.multiplecname, domain_stat.brokenanswer,
- domain_stat.lame, domain_stat.unknown, multiple_error_domains);
- printf("Per server results (out of %lu servers):\n", number_of_servers);
- printf(" valid: %lu\n"
- " ignore: %lu\n"
- " nxdomain: %lu\n"
- " othererr: %lu\n"
- " multiplesoa: %lu\n"
- " multiplecname: %lu\n"
- " brokenanswer: %lu\n"
- " lame: %lu\n"
- " unknown: %lu\n",
- server_stat.valid, server_stat.ignore, server_stat.nxdomain,
- server_stat.othererr, server_stat.multiplesoa,
- server_stat.multiplecname, server_stat.brokenanswer,
- server_stat.lame, server_stat.unknown);
-
- /* Cleanup */
- for (i = 0; i < MAX_PROBES; i++) {
- dns_message_detach(&probes[i].qmessage);
- dns_message_detach(&probes[i].rmessage);
- }
- isc_task_detach(&probe_task);
- dns_client_destroy(&client);
- dns_lib_shutdown();
- isc_app_ctxfinish(actx);
- ctxs_destroy(&mctx, &actx, &taskmgr, &socketmgr, &timermgr);
-
- return (0);
-}
diff --git a/lib/samples/rootkey.sh b/lib/samples/rootkey.sh
deleted file mode 100644
index 5fddbca141..0000000000
--- a/lib/samples/rootkey.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 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 https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-# Fetch a copy of a current root signing key; used for testing
-# DNSSEC validation in 'sample'.
-#
-# After running this script, "sample `cat sample.key` " will
-# perform a lookup as specified in and validate the result
-# using the root key.
-#
-# (This is NOT a secure method of obtaining the root key; it is
-# included here for testing purposes only.)
-dig +noall +answer dnskey . | perl -n -e '
-local ($dn, $ttl, $class, $type, $flags, $proto, $alg, @rest) = split;
-next if ($flags != 257);
-local $key = join("", @rest);
-print "-a $alg -e -k $dn -K $key\n"
-' > sample.key
diff --git a/lib/samples/sample-async.c b/lib/samples/sample-async.c
deleted file mode 100644
index 59ff24cba1..0000000000
--- a/lib/samples/sample-async.c
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * Copyright (C) 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 https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#ifndef WIN32
-#include
-#include
-#include
-#include
-#include
-#endif /* ifndef WIN32 */
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define MAX_SERVERS 10
-#define MAX_QUERIES 100
-
-static dns_client_t *client = NULL;
-static isc_task_t *query_task = NULL;
-static isc_appctx_t *query_actx = NULL;
-static unsigned int outstanding_queries = 0;
-static const char *def_server = "127.0.0.1";
-static FILE *fp;
-
-struct query_trans {
- int id;
- bool inuse;
- dns_rdatatype_t type;
- dns_fixedname_t fixedname;
- dns_name_t *qname;
- dns_namelist_t answerlist;
- dns_clientrestrans_t *xid;
-};
-
-static struct query_trans query_array[MAX_QUERIES];
-
-static isc_result_t
-dispatch_query(struct query_trans *trans);
-
-static void
-ctxs_destroy(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
- isc_socketmgr_t **socketmgrp, isc_timermgr_t **timermgrp) {
- if (*taskmgrp != NULL) {
- isc_taskmgr_destroy(taskmgrp);
- }
-
- if (*timermgrp != NULL) {
- isc_timermgr_destroy(timermgrp);
- }
-
- if (*socketmgrp != NULL) {
- isc_socketmgr_destroy(socketmgrp);
- }
-
- if (*actxp != NULL) {
- isc_appctx_destroy(actxp);
- }
-
- if (*mctxp != NULL) {
- isc_mem_destroy(mctxp);
- }
-}
-
-static isc_result_t
-ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp, isc_taskmgr_t **taskmgrp,
- isc_socketmgr_t **socketmgrp, isc_timermgr_t **timermgrp) {
- isc_result_t result;
-
- isc_mem_create(mctxp);
-
- result = isc_appctx_create(*mctxp, actxp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_taskmgr_createinctx(*mctxp, 1, 0, taskmgrp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_socketmgr_createinctx(*mctxp, socketmgrp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_timermgr_createinctx(*mctxp, timermgrp);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- return (ISC_R_SUCCESS);
-
-fail:
- ctxs_destroy(mctxp, actxp, taskmgrp, socketmgrp, timermgrp);
-
- return (result);
-}
-
-static isc_result_t
-printdata(dns_rdataset_t *rdataset, dns_name_t *owner) {
- isc_buffer_t target;
- isc_result_t result;
- isc_region_t r;
- char t[4096];
-
- isc_buffer_init(&target, t, sizeof(t));
-
- if (!dns_rdataset_isassociated(rdataset)) {
- return (ISC_R_SUCCESS);
- }
- result = dns_rdataset_totext(rdataset, owner, false, false, &target);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
- isc_buffer_usedregion(&target, &r);
- printf(" %.*s", (int)r.length, (char *)r.base);
-
- return (ISC_R_SUCCESS);
-}
-
-static void
-process_answer(isc_task_t *task, isc_event_t *event) {
- struct query_trans *trans = event->ev_arg;
- dns_clientresevent_t *rev = (dns_clientresevent_t *)event;
- dns_name_t *name;
- dns_rdataset_t *rdataset;
- isc_result_t result;
-
- REQUIRE(task == query_task);
- REQUIRE(trans->inuse);
- REQUIRE(outstanding_queries > 0);
-
- printf("answer[%2d]\n", trans->id);
-
- if (rev->result != ISC_R_SUCCESS) {
- printf(" failed: %u(%s)\n", rev->result,
- dns_result_totext(rev->result));
- }
-
- for (name = ISC_LIST_HEAD(rev->answerlist); name != NULL;
- name = ISC_LIST_NEXT(name, link))
- {
- for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
- rdataset = ISC_LIST_NEXT(rdataset, link))
- {
- (void)printdata(rdataset, name);
- }
- }
-
- dns_client_freeresanswer(client, &rev->answerlist);
- dns_client_destroyrestrans(&trans->xid);
-
- isc_event_free(&event);
-
- trans->inuse = false;
- dns_fixedname_invalidate(&trans->fixedname);
- trans->qname = NULL;
- outstanding_queries--;
-
- result = dispatch_query(trans);
-#if 0 /* for cancel test */
- if (result == ISC_R_SUCCESS) {
- static int count = 0;
-
- if ((++count) % 10 == 0) {
- dns_client_cancelresolve(trans->xid);
- }
- }
-#endif /* if 0 */
- if (result == ISC_R_NOMORE && outstanding_queries == 0) {
- isc_app_ctxshutdown(query_actx);
- }
-}
-
-static isc_result_t
-dispatch_query(struct query_trans *trans) {
- isc_result_t result;
- unsigned int namelen;
- isc_buffer_t b;
- char buf[4096]; /* XXX ad hoc constant, but should be enough */
- char *cp;
-
- REQUIRE(trans != NULL);
- REQUIRE(!trans->inuse);
- REQUIRE(ISC_LIST_EMPTY(trans->answerlist));
- REQUIRE(outstanding_queries < MAX_QUERIES);
-
- /* Construct qname */
- cp = fgets(buf, sizeof(buf), fp);
- if (cp == NULL) {
- return (ISC_R_NOMORE);
- }
- /* zap NL if any */
- if ((cp = strchr(buf, '\n')) != NULL) {
- *cp = '\0';
- }
- namelen = strlen(buf);
- isc_buffer_init(&b, buf, namelen);
- isc_buffer_add(&b, namelen);
- trans->qname = dns_fixedname_initname(&trans->fixedname);
- result = dns_name_fromtext(trans->qname, &b, dns_rootname, 0, NULL);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- /* Start resolution */
- result = dns_client_startresolve(
- client, trans->qname, dns_rdataclass_in, trans->type, 0,
- query_task, process_answer, trans, &trans->xid);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- trans->inuse = true;
- outstanding_queries++;
-
- return (ISC_R_SUCCESS);
-
-cleanup:
- dns_fixedname_invalidate(&trans->fixedname);
-
- return (result);
-}
-
-ISC_NORETURN static void
-usage(void);
-
-static void
-usage(void) {
- fprintf(stderr, "usage: sample-async [-s server_address] [-t RR type] "
- "input_file\n");
-
- exit(1);
-}
-
-int
-main(int argc, char *argv[]) {
- int ch;
- isc_textregion_t tr;
- isc_mem_t *mctx = NULL;
- isc_taskmgr_t *taskmgr = NULL;
- isc_socketmgr_t *socketmgr = NULL;
- isc_timermgr_t *timermgr = NULL;
- int nservers = 0;
- const char *serveraddr[MAX_SERVERS];
- isc_sockaddr_t sa[MAX_SERVERS];
- isc_sockaddrlist_t servers;
- dns_rdatatype_t type = dns_rdatatype_a;
- struct in_addr inaddr;
- isc_result_t result;
- int i;
-
- while ((ch = isc_commandline_parse(argc, argv, "s:t:")) != -1) {
- switch (ch) {
- case 't':
- tr.base = isc_commandline_argument;
- tr.length = strlen(isc_commandline_argument);
- result = dns_rdatatype_fromtext(&type, &tr);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "invalid RRtype: %s\n",
- isc_commandline_argument);
- exit(1);
- }
- break;
- case 's':
- if (nservers == MAX_SERVERS) {
- fprintf(stderr, "too many servers (up to %d)\n",
- MAX_SERVERS);
- exit(1);
- }
- serveraddr[nservers++] =
- (const char *)isc_commandline_argument;
- break;
- default:
- usage();
- }
- }
-
- argc -= isc_commandline_index;
- argv += isc_commandline_index;
- if (argc < 1) {
- usage();
- }
-
- if (nservers == 0) {
- nservers = 1;
- serveraddr[0] = def_server;
- }
-
- for (i = 0; i < MAX_QUERIES; i++) {
- query_array[i].id = i;
- query_array[i].inuse = false;
- query_array[i].type = type;
- dns_fixedname_init(&query_array[i].fixedname);
- query_array[i].qname = NULL;
- ISC_LIST_INIT(query_array[i].answerlist);
- query_array[i].xid = NULL;
- }
-
- isc_lib_register();
- result = dns_lib_init();
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_lib_init failed: %u\n", result);
- exit(1);
- }
-
- result = ctxs_init(&mctx, &query_actx, &taskmgr, &socketmgr, &timermgr);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "ctx create failed: %u\n", result);
- exit(1);
- }
-
- isc_app_ctxstart(query_actx);
-
- result = dns_client_createx(mctx, query_actx, taskmgr, socketmgr,
- timermgr, 0, &client, NULL, NULL);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_client_createx failed: %u\n", result);
- exit(1);
- }
-
- /* Set nameservers */
- ISC_LIST_INIT(servers);
- for (i = 0; i < nservers; i++) {
- if (inet_pton(AF_INET, serveraddr[i], &inaddr) != 1) {
- fprintf(stderr, "failed to parse IPv4 address %s\n",
- serveraddr[i]);
- exit(1);
- }
- isc_sockaddr_fromin(&sa[i], &inaddr, 53);
- ISC_LIST_APPEND(servers, &sa[i], link);
- }
- result = dns_client_setservers(client, dns_rdataclass_in, NULL,
- &servers);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "set server failed: %u\n", result);
- exit(1);
- }
-
- /* Create the main task */
- query_task = NULL;
- result = isc_task_create(taskmgr, 0, &query_task);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to create task: %u\n", result);
- exit(1);
- }
-
- /* Open input file */
- fp = fopen(argv[0], "r");
- if (fp == NULL) {
- fprintf(stderr, "failed to open input file: %s\n", argv[1]);
- exit(1);
- }
-
- /* Dispatch initial queries */
- for (i = 0; i < MAX_QUERIES; i++) {
- result = dispatch_query(&query_array[i]);
- if (result == ISC_R_NOMORE) {
- break;
- }
- }
-
- /* Start event loop */
- isc_app_ctxrun(query_actx);
-
- /* Sanity check */
- for (i = 0; i < MAX_QUERIES; i++) {
- INSIST(!query_array[i].inuse);
- }
-
- /* Cleanup */
- isc_task_detach(&query_task);
- dns_client_destroy(&client);
- dns_lib_shutdown();
- isc_app_ctxfinish(query_actx);
- ctxs_destroy(&mctx, &query_actx, &taskmgr, &socketmgr, &timermgr);
-
- return (0);
-}
diff --git a/lib/samples/sample-request.c b/lib/samples/sample-request.c
deleted file mode 100644
index 00ff2d58d3..0000000000
--- a/lib/samples/sample-request.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright (C) 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 https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#ifndef WIN32
-#include
-#include
-#include
-#include
-#include
-#include
-#endif /* ifndef WIN32 */
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-static isc_mem_t *mctx;
-static dns_fixedname_t fixedqname;
-
-ISC_NORETURN static void
-usage(void);
-
-static void
-usage(void) {
- fprintf(stderr, "sample-request [-t RRtype] server_address hostname\n");
-
- exit(1);
-}
-
-static isc_result_t
-make_querymessage(dns_message_t *message, const char *namestr,
- dns_rdatatype_t rdtype) {
- dns_name_t *qname = NULL, *qname0;
- dns_rdataset_t *qrdataset = NULL;
- isc_result_t result;
- isc_buffer_t b;
- unsigned int namelen;
-
- REQUIRE(message != NULL);
- REQUIRE(namestr != NULL);
-
- /* Construct qname */
- namelen = strlen(namestr);
- isc_buffer_constinit(&b, namestr, namelen);
- isc_buffer_add(&b, namelen);
- qname0 = dns_fixedname_initname(&fixedqname);
- result = dns_name_fromtext(qname0, &b, dns_rootname, 0, NULL);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to convert qname: %u\n", result);
- return (result);
- }
-
- /* Construct query message */
- message->opcode = dns_opcode_query;
- message->rdclass = dns_rdataclass_in;
-
- result = dns_message_gettempname(message, &qname);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- result = dns_message_gettemprdataset(message, &qrdataset);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
-
- dns_name_init(qname, NULL);
- dns_name_clone(qname0, qname);
- dns_rdataset_makequestion(qrdataset, message->rdclass, rdtype);
- ISC_LIST_APPEND(qname->list, qrdataset, link);
- dns_message_addname(message, qname, DNS_SECTION_QUESTION);
-
- return (ISC_R_SUCCESS);
-
-cleanup:
- if (qname != NULL) {
- dns_message_puttempname(message, &qname);
- }
- if (qrdataset != NULL) {
- dns_message_puttemprdataset(message, &qrdataset);
- }
- dns_message_detach(&message);
- return (result);
-}
-
-static void
-print_section(dns_message_t *message, int section, isc_buffer_t *buf) {
- isc_result_t result;
- isc_region_t r;
-
- result = dns_message_sectiontotext(message, section,
- &dns_master_style_full, 0, buf);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- isc_buffer_usedregion(buf, &r);
- printf("%.*s", (int)r.length, (char *)r.base);
-
- return;
-
-fail:
- fprintf(stderr, "failed to convert a section\n");
-}
-
-int
-main(int argc, char *argv[]) {
- int ch, i, gaierror;
- struct addrinfo hints, *res;
- isc_textregion_t tr;
- dns_client_t *client = NULL;
- isc_result_t result;
- isc_sockaddr_t sa;
- dns_message_t *qmessage, *rmessage;
- dns_rdatatype_t type = dns_rdatatype_a;
- isc_buffer_t *outputbuf;
-
- while ((ch = isc_commandline_parse(argc, argv, "t:")) != -1) {
- switch (ch) {
- case 't':
- tr.base = isc_commandline_argument;
- tr.length = strlen(isc_commandline_argument);
- result = dns_rdatatype_fromtext(&type, &tr);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "invalid RRtype: %s\n",
- isc_commandline_argument);
- exit(1);
- }
- break;
- default:
- usage();
- }
- }
-
- argc -= isc_commandline_index;
- argv += isc_commandline_index;
- if (argc < 2) {
- usage();
- }
-
- isc_lib_register();
- result = dns_lib_init();
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_lib_init failed: %u\n", result);
- exit(1);
- }
-
- result = dns_client_create(&client, 0);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_client_create failed: %u\n", result);
- exit(1);
- }
-
- /* Prepare message structures */
- mctx = NULL;
- qmessage = NULL;
- rmessage = NULL;
-
- isc_mem_create(&mctx);
- dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &qmessage);
- dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &rmessage);
-
- /* Initialize the nameserver address */
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_protocol = IPPROTO_UDP;
-#ifdef AI_NUMERICHOST
- hints.ai_flags = AI_NUMERICHOST;
-#endif /* ifdef AI_NUMERICHOST */
- gaierror = getaddrinfo(argv[0], "53", &hints, &res);
- if (gaierror != 0) {
- fprintf(stderr, "getaddrinfo failed: %s\n",
- gai_strerror(gaierror));
- exit(1);
- }
- INSIST(res->ai_addrlen <= sizeof(sa.type));
- memmove(&sa.type, res->ai_addr, res->ai_addrlen);
- freeaddrinfo(res);
- sa.length = (unsigned int)res->ai_addrlen;
- ISC_LINK_INIT(&sa, link);
-
- /* Construct qname */
- result = make_querymessage(qmessage, argv[1], type);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to create a query\n");
- exit(1);
- }
-
- /* Send request and wait for a response */
- result = dns_client_request(client, qmessage, rmessage, &sa, 0, 0, NULL,
- 60, 0, 3);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to get a response: %s\n",
- dns_result_totext(result));
- }
-
- /* Dump the response */
- outputbuf = NULL;
- isc_buffer_allocate(mctx, &outputbuf, 65535);
- for (i = 0; i < DNS_SECTION_MAX; i++) {
- print_section(rmessage, i, outputbuf);
- isc_buffer_clear(outputbuf);
- }
- isc_buffer_free(&outputbuf);
-
- /* Cleanup */
- dns_message_detach(&qmessage);
- dns_message_detach(&rmessage);
- isc_mem_destroy(&mctx);
- dns_client_destroy(&client);
- dns_lib_shutdown();
-
- return (0);
-}
diff --git a/lib/samples/sample-update.c b/lib/samples/sample-update.c
deleted file mode 100644
index b3d8b73c71..0000000000
--- a/lib/samples/sample-update.c
+++ /dev/null
@@ -1,781 +0,0 @@
-/*
- * Copyright (C) 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 https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#ifndef WIN32
-#include
-#include
-#include
-#include
-#include
-#include
-#endif /* ifndef WIN32 */
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-static dns_tsec_t *tsec = NULL;
-static const dns_rdataclass_t default_rdataclass = dns_rdataclass_in;
-static isc_bufferlist_t usedbuffers;
-static ISC_LIST(dns_rdatalist_t) usedrdatalists;
-
-static const char *port = "53";
-
-static void
-setup_tsec(char *keyfile, isc_mem_t *mctx);
-static void
-update_addordelete(isc_mem_t *mctx, char *cmdline, bool isdelete,
- dns_name_t *name);
-static void
-evaluate_prereq(isc_mem_t *mctx, char *cmdline, dns_name_t *name);
-
-ISC_NORETURN static void
-usage(void);
-
-static void
-usage(void) {
- fprintf(stderr, "sample-update "
- "-s "
- "[-a auth_server] "
- "[-k keyfile] "
- "[-p prerequisite] "
- "[-r recursive_server] "
- "[-z zonename] "
- "(add|delete) \"name TTL RRtype RDATA\"\n");
- exit(1);
-}
-
-#ifdef _WIN32
-static void
-InitSockets(void) {
- WORD wVersionRequested;
- WSADATA wsaData;
- int err;
-
- wVersionRequested = MAKEWORD(2, 0);
-
- err = WSAStartup(wVersionRequested, &wsaData);
- if (err != 0) {
- fprintf(stderr, "WSAStartup() failed: %d\n", err);
- exit(1);
- }
-}
-
-static void
-DestroySockets(void) {
- WSACleanup();
-}
-#else /* ifdef _WIN32 */
-#define InitSockets() ((void)0)
-#define DestroySockets() ((void)0)
-#endif /* ifdef _WIN32 */
-
-static bool
-addserver(const char *server, isc_sockaddrlist_t *list,
- isc_sockaddr_t *sockaddr) {
- struct addrinfo hints, *res;
- int gaierror;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_protocol = IPPROTO_UDP;
-#ifdef AI_NUMERICHOST
- hints.ai_flags |= AI_NUMERICHOST;
-#endif /* ifdef AI_NUMERICHOST */
-#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
-#endif /* ifdef AI_NUMERICSERV */
- InitSockets();
- gaierror = getaddrinfo(server, port, &hints, &res);
- if (gaierror != 0) {
- fprintf(stderr, "getaddrinfo(%s) failed: %s\n", server,
- gai_strerror(gaierror));
- DestroySockets();
- return (false);
- }
- INSIST(res->ai_addrlen <= sizeof(sockaddr->type));
- memmove(&sockaddr->type, res->ai_addr, res->ai_addrlen);
- sockaddr->length = (unsigned int)res->ai_addrlen;
- ISC_LINK_INIT(sockaddr, link);
- ISC_LIST_APPEND(*list, sockaddr, link);
- freeaddrinfo(res);
- DestroySockets();
- return (true);
-}
-
-int
-main(int argc, char *argv[]) {
- int ch;
- dns_client_t *client = NULL;
- char *zonenamestr = NULL;
- char *keyfilename = NULL;
- char *prereqstr = NULL;
- isc_sockaddr_t sa_auth[10], sa_recursive[10];
- unsigned int nsa_auth = 0, nsa_recursive = 0;
- isc_sockaddrlist_t rec_servers;
- isc_sockaddrlist_t auth_servers, *auth_serversp = &auth_servers;
- isc_result_t result;
- bool isdelete;
- isc_buffer_t b, *buf;
- dns_fixedname_t zname0, pname0, uname0;
- unsigned int namelen;
- dns_name_t *zname = NULL, *uname, *pname;
- dns_rdataset_t *rdataset;
- dns_rdatalist_t *rdatalist;
- dns_rdata_t *rdata;
- dns_namelist_t updatelist, prereqlist, *prereqlistp = NULL;
- isc_mem_t *umctx = NULL;
- bool sendtwice = false;
-
- ISC_LIST_INIT(auth_servers);
- ISC_LIST_INIT(rec_servers);
-
- while ((ch = isc_commandline_parse(argc, argv, "a:k:p:P:r:sz:")) != EOF)
- {
- switch (ch) {
- case 'k':
- keyfilename = isc_commandline_argument;
- break;
- case 'a':
- if (nsa_auth < sizeof(sa_auth) / sizeof(*sa_auth) &&
- addserver(isc_commandline_argument, &auth_servers,
- &sa_auth[nsa_auth]))
- {
- nsa_auth++;
- }
- break;
- case 'p':
- prereqstr = isc_commandline_argument;
- break;
- case 'P':
- port = isc_commandline_argument;
- break;
- case 'r':
- if (nsa_recursive < sizeof(sa_recursive) /
- sizeof(*sa_recursive) &&
- addserver(isc_commandline_argument, &rec_servers,
- &sa_recursive[nsa_recursive]))
- {
- nsa_recursive++;
- }
- break;
- case 's':
- sendtwice = true;
- break;
- case 'z':
- zonenamestr = isc_commandline_argument;
- break;
- default:
- usage();
- }
- }
-
- argc -= isc_commandline_index;
- argv += isc_commandline_index;
- if (argc < 2) {
- usage();
- }
-
- /* command line argument validation */
- if (strcmp(argv[0], "delete") == 0) {
- isdelete = true;
- } else if (strcmp(argv[0], "add") == 0) {
- isdelete = false;
- } else {
- fprintf(stderr, "invalid update command: %s\n", argv[0]);
- exit(1);
- }
-
- if (ISC_LIST_HEAD(auth_servers) == NULL &&
- ISC_LIST_HEAD(rec_servers) == NULL) {
- fprintf(stderr, "authoritative or recursive servers "
- "must be specified\n");
- usage();
- }
-
- /* Initialization */
- ISC_LIST_INIT(usedbuffers);
- ISC_LIST_INIT(usedrdatalists);
- ISC_LIST_INIT(prereqlist);
- isc_lib_register();
- result = dns_lib_init();
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_lib_init failed: %u\n", result);
- exit(1);
- }
- isc_mem_create(&umctx);
-
- result = dns_client_create(&client, 0);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "dns_client_create failed: %u\n", result);
- exit(1);
- }
-
- /* Construct zone name */
- zname = NULL;
- if (zonenamestr != NULL) {
- namelen = strlen(zonenamestr);
- isc_buffer_init(&b, zonenamestr, namelen);
- isc_buffer_add(&b, namelen);
- zname = dns_fixedname_initname(&zname0);
- result = dns_name_fromtext(zname, &b, dns_rootname, 0, NULL);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "failed to convert zone name: %u\n",
- result);
- }
- }
-
- /* Construct prerequisite name (if given) */
- if (prereqstr != NULL) {
- pname = dns_fixedname_initname(&pname0);
- evaluate_prereq(umctx, prereqstr, pname);
- ISC_LIST_APPEND(prereqlist, pname, link);
- prereqlistp = &prereqlist;
- }
-
- /* Construct update name */
- ISC_LIST_INIT(updatelist);
- uname = dns_fixedname_initname(&uname0);
- update_addordelete(umctx, argv[1], isdelete, uname);
- ISC_LIST_APPEND(updatelist, uname, link);
-
- /* Set up TSIG/SIG(0) key (if given) */
- if (keyfilename != NULL) {
- setup_tsec(keyfilename, umctx);
- }
-
- if (ISC_LIST_HEAD(auth_servers) == NULL) {
- auth_serversp = NULL;
- }
-
- /* Perform update */
- result = dns_client_update(client, default_rdataclass, /* XXX: fixed */
- zname, prereqlistp, &updatelist,
- auth_serversp, tsec, 0);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "update failed: %s\n",
- dns_result_totext(result));
- } else {
- fprintf(stderr, "update succeeded\n");
- }
-
- if (sendtwice) {
- /* Perform 2nd update */
- result = dns_client_update(client, default_rdataclass, /* XXX:
- * fixed
- */
- zname, prereqlistp, &updatelist,
- auth_serversp, tsec, 0);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "2nd update failed: %s\n",
- dns_result_totext(result));
- } else {
- fprintf(stderr, "2nd update succeeded\n");
- }
- }
-
- /* Cleanup */
- while ((pname = ISC_LIST_HEAD(prereqlist)) != NULL) {
- while ((rdataset = ISC_LIST_HEAD(pname->list)) != NULL) {
- ISC_LIST_UNLINK(pname->list, rdataset, link);
- dns_rdataset_disassociate(rdataset);
- isc_mem_put(umctx, rdataset, sizeof(*rdataset));
- }
- ISC_LIST_UNLINK(prereqlist, pname, link);
- }
- while ((uname = ISC_LIST_HEAD(updatelist)) != NULL) {
- while ((rdataset = ISC_LIST_HEAD(uname->list)) != NULL) {
- ISC_LIST_UNLINK(uname->list, rdataset, link);
- dns_rdataset_disassociate(rdataset);
- isc_mem_put(umctx, rdataset, sizeof(*rdataset));
- }
- ISC_LIST_UNLINK(updatelist, uname, link);
- }
- while ((rdatalist = ISC_LIST_HEAD(usedrdatalists)) != NULL) {
- while ((rdata = ISC_LIST_HEAD(rdatalist->rdata)) != NULL) {
- ISC_LIST_UNLINK(rdatalist->rdata, rdata, link);
- isc_mem_put(umctx, rdata, sizeof(*rdata));
- }
- ISC_LIST_UNLINK(usedrdatalists, rdatalist, link);
- isc_mem_put(umctx, rdatalist, sizeof(*rdatalist));
- }
- while ((buf = ISC_LIST_HEAD(usedbuffers)) != NULL) {
- ISC_LIST_UNLINK(usedbuffers, buf, link);
- isc_buffer_free(&buf);
- }
- if (tsec != NULL) {
- dns_tsec_destroy(&tsec);
- }
- isc_mem_destroy(&umctx);
- dns_client_destroy(&client);
- dns_lib_shutdown();
-
- return (0);
-}
-
-/*
- * Subroutines borrowed from nsupdate.c
- */
-#define MAXWIRE (64 * 1024)
-#define TTL_MAX 2147483647U /* Maximum signed 32 bit integer. */
-
-static char *
-nsu_strsep(char **stringp, const char *delim) {
- char *string = *stringp;
- char *s;
- const char *d;
- char sc, dc;
-
- if (string == NULL) {
- return (NULL);
- }
-
- for (; *string != '\0'; string++) {
- sc = *string;
- for (d = delim; (dc = *d) != '\0'; d++) {
- if (sc == dc) {
- break;
- }
- }
- if (dc == 0) {
- break;
- }
- }
-
- for (s = string; *s != '\0'; s++) {
- sc = *s;
- for (d = delim; (dc = *d) != '\0'; d++) {
- if (sc == dc) {
- *s++ = '\0';
- *stringp = s;
- return (string);
- }
- }
- }
- *stringp = NULL;
- return (string);
-}
-
-static void
-fatal(const char *format, ...) {
- va_list args;
-
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
- fprintf(stderr, "\n");
- exit(1);
-}
-
-static inline void
-check_result(isc_result_t result, const char *msg) {
- if (result != ISC_R_SUCCESS) {
- fatal("%s: %s", msg, isc_result_totext(result));
- }
-}
-
-static void
-parse_name(char **cmdlinep, dns_name_t *name) {
- isc_result_t result;
- char *word;
- isc_buffer_t source;
-
- word = nsu_strsep(cmdlinep, " \t\r\n");
- if (word == NULL || *word == 0) {
- fprintf(stderr, "could not read owner name\n");
- exit(1);
- }
-
- isc_buffer_init(&source, word, strlen(word));
- isc_buffer_add(&source, strlen(word));
- result = dns_name_fromtext(name, &source, dns_rootname, 0, NULL);
- check_result(result, "dns_name_fromtext");
- isc_buffer_invalidate(&source);
-}
-
-static void
-parse_rdata(isc_mem_t *mctx, char **cmdlinep, dns_rdataclass_t rdataclass,
- dns_rdatatype_t rdatatype, dns_rdata_t *rdata) {
- char *cmdline = *cmdlinep;
- isc_buffer_t source, *buf = NULL, *newbuf = NULL;
- isc_region_t r;
- isc_lex_t *lex = NULL;
- dns_rdatacallbacks_t callbacks;
- isc_result_t result;
-
- while (cmdline != NULL && *cmdline != 0 &&
- isspace((unsigned char)*cmdline)) {
- cmdline++;
- }
-
- if (cmdline != NULL && *cmdline != 0) {
- dns_rdatacallbacks_init(&callbacks);
- result = isc_lex_create(mctx, strlen(cmdline), &lex);
- check_result(result, "isc_lex_create");
- isc_buffer_init(&source, cmdline, strlen(cmdline));
- isc_buffer_add(&source, strlen(cmdline));
- result = isc_lex_openbuffer(lex, &source);
- check_result(result, "isc_lex_openbuffer");
- isc_buffer_allocate(mctx, &buf, MAXWIRE);
- result = dns_rdata_fromtext(rdata, rdataclass, rdatatype, lex,
- dns_rootname, 0, mctx, buf,
- &callbacks);
- isc_lex_destroy(&lex);
- if (result == ISC_R_SUCCESS) {
- isc_buffer_usedregion(buf, &r);
- isc_buffer_allocate(mctx, &newbuf, r.length);
- isc_buffer_putmem(newbuf, r.base, r.length);
- isc_buffer_usedregion(newbuf, &r);
- dns_rdata_reset(rdata);
- dns_rdata_fromregion(rdata, rdataclass, rdatatype, &r);
- isc_buffer_free(&buf);
- ISC_LIST_APPEND(usedbuffers, newbuf, link);
- } else {
- fprintf(stderr, "invalid rdata format: %s\n",
- isc_result_totext(result));
- isc_buffer_free(&buf);
- exit(1);
- }
- } else {
- rdata->flags = DNS_RDATA_UPDATE;
- }
- *cmdlinep = cmdline;
-}
-
-static void
-update_addordelete(isc_mem_t *mctx, char *cmdline, bool isdelete,
- dns_name_t *name) {
- isc_result_t result;
- uint32_t ttl;
- char *word;
- dns_rdataclass_t rdataclass;
- dns_rdatatype_t rdatatype;
- dns_rdata_t *rdata = NULL;
- dns_rdatalist_t *rdatalist = NULL;
- dns_rdataset_t *rdataset = NULL;
- isc_textregion_t region;
-
- /*
- * Read the owner name.
- */
- parse_name(&cmdline, name);
-
- rdata = isc_mem_get(mctx, sizeof(*rdata));
- dns_rdata_init(rdata);
-
- /*
- * If this is an add, read the TTL and verify that it's in range.
- * If it's a delete, ignore a TTL if present (for compatibility).
- */
- word = nsu_strsep(&cmdline, " \t\r\n");
- if (word == NULL || *word == 0) {
- if (!isdelete) {
- fprintf(stderr, "could not read owner ttl\n");
- exit(1);
- } else {
- ttl = 0;
- rdataclass = dns_rdataclass_any;
- rdatatype = dns_rdatatype_any;
- rdata->flags = DNS_RDATA_UPDATE;
- goto doneparsing;
- }
- }
- result = isc_parse_uint32(&ttl, word, 10);
- if (result != ISC_R_SUCCESS) {
- if (isdelete) {
- ttl = 0;
- goto parseclass;
- } else {
- fprintf(stderr, "ttl '%s': %s\n", word,
- isc_result_totext(result));
- exit(1);
- }
- }
-
- if (isdelete) {
- ttl = 0;
- } else if (ttl > TTL_MAX) {
- fprintf(stderr, "ttl '%s' is out of range (0 to %u)\n", word,
- TTL_MAX);
- exit(1);
- }
-
- /*
- * Read the class or type.
- */
- word = nsu_strsep(&cmdline, " \t\r\n");
-parseclass:
- if (word == NULL || *word == 0) {
- if (isdelete) {
- rdataclass = dns_rdataclass_any;
- rdatatype = dns_rdatatype_any;
- rdata->flags = DNS_RDATA_UPDATE;
- goto doneparsing;
- } else {
- fprintf(stderr, "could not read class or type\n");
- exit(1);
- }
- }
- region.base = word;
- region.length = strlen(word);
- result = dns_rdataclass_fromtext(&rdataclass, ®ion);
- if (result == ISC_R_SUCCESS) {
- /*
- * Now read the type.
- */
- word = nsu_strsep(&cmdline, " \t\r\n");
- if (word == NULL || *word == 0) {
- if (isdelete) {
- rdataclass = dns_rdataclass_any;
- rdatatype = dns_rdatatype_any;
- rdata->flags = DNS_RDATA_UPDATE;
- goto doneparsing;
- } else {
- fprintf(stderr, "could not read type\n");
- exit(1);
- }
- }
- region.base = word;
- region.length = strlen(word);
- result = dns_rdatatype_fromtext(&rdatatype, ®ion);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "'%s' is not a valid type: %s\n", word,
- isc_result_totext(result));
- exit(1);
- }
- } else {
- rdataclass = default_rdataclass;
- result = dns_rdatatype_fromtext(&rdatatype, ®ion);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr,
- "'%s' is not a valid class or type: "
- "%s\n",
- word, isc_result_totext(result));
- exit(1);
- }
- }
-
- parse_rdata(mctx, &cmdline, rdataclass, rdatatype, rdata);
-
- if (isdelete) {
- if ((rdata->flags & DNS_RDATA_UPDATE) != 0) {
- rdataclass = dns_rdataclass_any;
- } else {
- rdataclass = dns_rdataclass_none;
- }
- } else {
- if ((rdata->flags & DNS_RDATA_UPDATE) != 0) {
- fprintf(stderr, "could not read rdata\n");
- exit(1);
- }
- }
-
-doneparsing:
-
- rdatalist = isc_mem_get(mctx, sizeof(*rdatalist));
- dns_rdatalist_init(rdatalist);
- rdatalist->type = rdatatype;
- rdatalist->rdclass = rdataclass;
- rdatalist->covers = rdatatype;
- rdatalist->ttl = (dns_ttl_t)ttl;
- ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
- ISC_LIST_APPEND(usedrdatalists, rdatalist, link);
-
- rdataset = isc_mem_get(mctx, sizeof(*rdataset));
- dns_rdataset_init(rdataset);
- dns_rdatalist_tordataset(rdatalist, rdataset);
- dns_rdataset_setownercase(rdataset, name);
- ISC_LIST_INIT(name->list);
- ISC_LIST_APPEND(name->list, rdataset, link);
-}
-
-static void
-make_prereq(isc_mem_t *mctx, char *cmdline, bool ispositive, bool isrrset,
- dns_name_t *name) {
- isc_result_t result;
- char *word;
- isc_textregion_t region;
- dns_rdataset_t *rdataset = NULL;
- dns_rdatalist_t *rdatalist = NULL;
- dns_rdataclass_t rdataclass;
- dns_rdatatype_t rdatatype;
- dns_rdata_t *rdata = NULL;
-
- /*
- * Read the owner name
- */
- parse_name(&cmdline, name);
-
- /*
- * If this is an rrset prereq, read the class or type.
- */
- if (isrrset) {
- word = nsu_strsep(&cmdline, " \t\r\n");
- if (word == NULL || *word == 0) {
- fprintf(stderr, "could not read class or type\n");
- exit(1);
- }
- region.base = word;
- region.length = strlen(word);
- result = dns_rdataclass_fromtext(&rdataclass, ®ion);
- if (result == ISC_R_SUCCESS) {
- /*
- * Now read the type.
- */
- word = nsu_strsep(&cmdline, " \t\r\n");
- if (word == NULL || *word == 0) {
- fprintf(stderr, "could not read type\n");
- exit(1);
- }
- region.base = word;
- region.length = strlen(word);
- result = dns_rdatatype_fromtext(&rdatatype, ®ion);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "invalid type: %s\n", word);
- exit(1);
- }
- } else {
- rdataclass = default_rdataclass;
- result = dns_rdatatype_fromtext(&rdatatype, ®ion);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "invalid type: %s\n", word);
- exit(1);
- }
- }
- } else {
- rdatatype = dns_rdatatype_any;
- }
-
- rdata = isc_mem_get(mctx, sizeof(*rdata));
- dns_rdata_init(rdata);
-
- if (isrrset && ispositive) {
- parse_rdata(mctx, &cmdline, rdataclass, rdatatype, rdata);
- } else {
- rdata->flags = DNS_RDATA_UPDATE;
- }
-
- rdatalist = isc_mem_get(mctx, sizeof(*rdatalist));
- dns_rdatalist_init(rdatalist);
- rdatalist->type = rdatatype;
- if (ispositive) {
- if (isrrset && rdata->data != NULL) {
- rdatalist->rdclass = rdataclass;
- } else {
- rdatalist->rdclass = dns_rdataclass_any;
- }
- } else {
- rdatalist->rdclass = dns_rdataclass_none;
- }
- rdata->rdclass = rdatalist->rdclass;
- rdata->type = rdatatype;
- ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
- ISC_LIST_APPEND(usedrdatalists, rdatalist, link);
-
- rdataset = isc_mem_get(mctx, sizeof(*rdataset));
- dns_rdataset_init(rdataset);
- dns_rdatalist_tordataset(rdatalist, rdataset);
- dns_rdataset_setownercase(rdataset, name);
- ISC_LIST_INIT(name->list);
- ISC_LIST_APPEND(name->list, rdataset, link);
-}
-
-static void
-evaluate_prereq(isc_mem_t *mctx, char *cmdline, dns_name_t *name) {
- char *word;
- bool ispositive, isrrset;
-
- word = nsu_strsep(&cmdline, " \t\r\n");
- if (word == NULL || *word == 0) {
- fprintf(stderr, "could not read operation code\n");
- exit(1);
- }
- if (strcasecmp(word, "nxdomain") == 0) {
- ispositive = false;
- isrrset = false;
- } else if (strcasecmp(word, "yxdomain") == 0) {
- ispositive = true;
- isrrset = false;
- } else if (strcasecmp(word, "nxrrset") == 0) {
- ispositive = false;
- isrrset = true;
- } else if (strcasecmp(word, "yxrrset") == 0) {
- ispositive = true;
- isrrset = true;
- } else {
- fprintf(stderr, "incorrect operation code: %s\n", word);
- exit(1);
- }
-
- make_prereq(mctx, cmdline, ispositive, isrrset, name);
-}
-
-static void
-setup_tsec(char *keyfile, isc_mem_t *mctx) {
- dst_key_t *dstkey = NULL;
- isc_result_t result;
- dns_tsectype_t tsectype;
-
- result = dst_key_fromnamedfile(
- keyfile, NULL, DST_TYPE_PRIVATE | DST_TYPE_KEY, mctx, &dstkey);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "could not read key from %s: %s\n", keyfile,
- isc_result_totext(result));
- exit(1);
- }
-
- if (dst_key_alg(dstkey) == DST_ALG_HMACMD5) {
- tsectype = dns_tsectype_tsig;
- } else {
- tsectype = dns_tsectype_sig0;
- }
-
- result = dns_tsec_create(mctx, tsectype, dstkey, &tsec);
- dst_key_free(&dstkey);
- if (result != ISC_R_SUCCESS) {
- fprintf(stderr, "could not create tsec: %s\n",
- isc_result_totext(result));
- exit(1);
- }
-}
diff --git a/lib/samples/win32/async.vcxproj.filters.in b/lib/samples/win32/async.vcxproj.filters.in
deleted file mode 100644
index 2698e21a4e..0000000000
--- a/lib/samples/win32/async.vcxproj.filters.in
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/lib/samples/win32/async.vcxproj.in b/lib/samples/win32/async.vcxproj.in
deleted file mode 100644
index 37a071bdf3..0000000000
--- a/lib/samples/win32/async.vcxproj.in
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
- Debug
- @PLATFORM@
-
-
- Release
- @PLATFORM@
-
-
-
- {9FC33CA3-CE4A-4EDF-BA99-EECA4B81AD06}
- Win32Proj
- async
- @WINDOWS_TARGET_PLATFORM_VERSION@
-
-
-
- Application
- true
- MultiByte
- @PLATFORM_TOOLSET@
-
-
- Application
- false
- true
- MultiByte
- @PLATFORM_TOOLSET@
-
-
-
-
-
-
-
-
-
-
-
-
- true
- ..\..\..\Build\$(Configuration)\
- .\$(Configuration)\
- None
-
-
- false
- ..\..\..\Build\$(Configuration)\
- .\$(Configuration)\
- None
-
-
-
-
-
- Level4
- false
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- .\$(Configuration)\$(TargetName).pch
- .\$(Configuration)\
- .\$(Configuration)\
- $(OutDir)$(TargetName).pdb
- true
- ..\..\..\config.h
- .\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)
- CompileAsC
-
-
- Console
- true
- ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)
- ..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);%(AdditionalLibraryDirectories)
- @OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;ws2_32.lib;%(AdditionalDependencies)
-
-
-
-
- Level1
- true
-
-
- MaxSpeed
- true
- @INTRINSIC@
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- OnlyExplicitInline
- false
- true
- .\$(Configuration)\$(TargetName).pch
- .\$(Configuration)\
- .\$(Configuration)\
- $(OutDir)$(TargetName).pdb
- ..\..\..\config.h
- .\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)
- CompileAsC
-
-
- Console
- false
- true
- true
- ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)
- Default
- ..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);%(AdditionalLibraryDirectories)
- @OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;ws2_32.lib;%(AdditionalDependencies)
-
-
-
-
-
-
-
- {3840E563-D180-4761-AA9C-E6155F02EAFF}
-
-
- {5FEBFD4E-CCB0-48B9-B733-E15EEB85C16A}
-
-
-
-
-
-
diff --git a/lib/samples/win32/async.vcxproj.user b/lib/samples/win32/async.vcxproj.user
deleted file mode 100644
index ace9a86acb..0000000000
--- a/lib/samples/win32/async.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/lib/samples/win32/nsprobe.vcxproj.filters.in b/lib/samples/win32/nsprobe.vcxproj.filters.in
deleted file mode 100644
index d7e313b183..0000000000
--- a/lib/samples/win32/nsprobe.vcxproj.filters.in
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/lib/samples/win32/nsprobe.vcxproj.in b/lib/samples/win32/nsprobe.vcxproj.in
deleted file mode 100644
index 4581683f27..0000000000
--- a/lib/samples/win32/nsprobe.vcxproj.in
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
- Debug
- @PLATFORM@
-
-
- Release
- @PLATFORM@
-
-
-
- {CB2A29F6-E73B-40AB-8AC4-2C1AAE7280BD}
- Win32Proj
- nsprobe
- @WINDOWS_TARGET_PLATFORM_VERSION@
-
-
-
- Application
- true
- MultiByte
- @PLATFORM_TOOLSET@
-
-
- Application
- false
- true
- MultiByte
- @PLATFORM_TOOLSET@
-
-
-
-
-
-
-
-
-
-
-
-
- true
- ..\..\..\Build\$(Configuration)\
- .\$(Configuration)\
- None
-
-
- false
- ..\..\..\Build\$(Configuration)\
- .\$(Configuration)\
- None
-
-
-
-
-
- Level4
- false
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- .\$(Configuration)\$(TargetName).pch
- .\$(Configuration)\
- .\$(Configuration)\
- $(OutDir)$(TargetName).pdb
- true
- ..\..\..\config.h
- .\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)
- CompileAsC
-
-
- Console
- true
- ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)
- ..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);%(AdditionalLibraryDirectories)
- @OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;ws2_32.lib;%(AdditionalDependencies)
-
-
-
-
- Level1
- true
-
-
- MaxSpeed
- true
- @INTRINSIC@
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- OnlyExplicitInline
- false
- true
- .\$(Configuration)\$(TargetName).pch
- .\$(Configuration)\
- .\$(Configuration)\
- $(OutDir)$(TargetName).pdb
- ..\..\..\config.h
- .\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)
- CompileAsC
-
-
- Console
- false
- true
- true
- ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)
- Default
- ..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);%(AdditionalLibraryDirectories)
- @OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;ws2_32.lib;%(AdditionalDependencies)
-
-
-
-
-
-
-
- {3840E563-D180-4761-AA9C-E6155F02EAFF}
-
-
- {5FEBFD4E-CCB0-48B9-B733-E15EEB85C16A}
-
-
-
-
-
-
diff --git a/lib/samples/win32/nsprobe.vcxproj.user b/lib/samples/win32/nsprobe.vcxproj.user
deleted file mode 100644
index ace9a86acb..0000000000
--- a/lib/samples/win32/nsprobe.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/lib/samples/win32/request.vcxproj.filters.in b/lib/samples/win32/request.vcxproj.filters.in
deleted file mode 100644
index 9edd41d41d..0000000000
--- a/lib/samples/win32/request.vcxproj.filters.in
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/lib/samples/win32/request.vcxproj.in b/lib/samples/win32/request.vcxproj.in
deleted file mode 100644
index 40045e3781..0000000000
--- a/lib/samples/win32/request.vcxproj.in
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
- Debug
- @PLATFORM@
-
-
- Release
- @PLATFORM@
-
-
-
- {FF440E85-7450-439C-82EE-04C464512D0E}
- Win32Proj
- request
- @WINDOWS_TARGET_PLATFORM_VERSION@
-
-
-
- Application
- true
- MultiByte
- @PLATFORM_TOOLSET@
-
-
- Application
- false
- true
- MultiByte
- @PLATFORM_TOOLSET@
-
-
-
-
-
-
-
-
-
-
-
-
- true
- ..\..\..\Build\$(Configuration)\
- .\$(Configuration)\
- None
-
-
- false
- ..\..\..\Build\$(Configuration)\
- .\$(Configuration)\
- None
-
-
-
-
-
- Level4
- false
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- .\$(Configuration)\$(TargetName).pch
- .\$(Configuration)\
- .\$(Configuration)\
- $(OutDir)$(TargetName).pdb
- true
- ..\..\..\config.h
- .\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)
- CompileAsC
-
-
- Console
- true
- ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)
- ..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);%(AdditionalLibraryDirectories)
- @OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;ws2_32.lib;%(AdditionalDependencies)
-
-
-
-
- Level1
- true
-
-
- MaxSpeed
- true
- @INTRINSIC@
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- OnlyExplicitInline
- false
- true
- .\$(Configuration)\$(TargetName).pch
- .\$(Configuration)\
- .\$(Configuration)\
- $(OutDir)$(TargetName).pdb
- ..\..\..\config.h
- .\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)
- CompileAsC
-
-
- Console
- false
- true
- true
- ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)
- Default
- ..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);%(AdditionalLibraryDirectories)
- @OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;ws2_32.lib;%(AdditionalDependencies)
-
-
-
-
-
-
-
- {3840E563-D180-4761-AA9C-E6155F02EAFF}
-
-
- {5FEBFD4E-CCB0-48B9-B733-E15EEB85C16A}
-
-
-
-
-
-
diff --git a/lib/samples/win32/request.vcxproj.user b/lib/samples/win32/request.vcxproj.user
deleted file mode 100644
index ace9a86acb..0000000000
--- a/lib/samples/win32/request.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/lib/samples/win32/update.vcxproj.filters.in b/lib/samples/win32/update.vcxproj.filters.in
deleted file mode 100644
index 8479fba535..0000000000
--- a/lib/samples/win32/update.vcxproj.filters.in
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/lib/samples/win32/update.vcxproj.in b/lib/samples/win32/update.vcxproj.in
deleted file mode 100644
index 7e125d77a4..0000000000
--- a/lib/samples/win32/update.vcxproj.in
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
- Debug
- @PLATFORM@
-
-
- Release
- @PLATFORM@
-
-
-
- {05682E12-523F-4DAE-8E6D-ADFDBC308AFD}
- Win32Proj
- update
- @WINDOWS_TARGET_PLATFORM_VERSION@
-
-
-
- Application
- true
- MultiByte
- @PLATFORM_TOOLSET@
-
-
- Application
- false
- true
- MultiByte
- @PLATFORM_TOOLSET@
-
-
-
-
-
-
-
-
-
-
-
-
- true
- ..\..\..\Build\$(Configuration)\
- .\$(Configuration)\
- None
-
-
- false
- ..\..\..\Build\$(Configuration)\
- .\$(Configuration)\
- None
-
-
-
-
-
- Level4
- false
- Disabled
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- .\$(Configuration)\$(TargetName).pch
- .\$(Configuration)\
- .\$(Configuration)\
- $(OutDir)$(TargetName).pdb
- true
- ..\..\..\config.h
- .\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)
- CompileAsC
-
-
- Console
- true
- ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)
- ..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);%(AdditionalLibraryDirectories)
- @OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;ws2_32.lib;%(AdditionalDependencies)
-
-
-
-
- Level1
- true
-
-
- MaxSpeed
- true
- @INTRINSIC@
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- OnlyExplicitInline
- false
- true
- .\$(Configuration)\$(TargetName).pch
- .\$(Configuration)\
- .\$(Configuration)\
- $(OutDir)$(TargetName).pdb
- ..\..\..\config.h
- .\;..\..\..\;@LIBXML2_INC@@OPENSSL_INC@..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\dns\win32\include;..\..\dns\include;%(AdditionalIncludeDirectories)
- CompileAsC
-
-
- Console
- false
- true
- true
- ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)
- Default
- ..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);%(AdditionalLibraryDirectories)
- @OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;ws2_32.lib;%(AdditionalDependencies)
-
-
-
-
-
-
-
- {3840E563-D180-4761-AA9C-E6155F02EAFF}
-
-
- {5FEBFD4E-CCB0-48B9-B733-E15EEB85C16A}
-
-
-
-
-
-
diff --git a/lib/samples/win32/update.vcxproj.user b/lib/samples/win32/update.vcxproj.user
deleted file mode 100644
index ace9a86acb..0000000000
--- a/lib/samples/win32/update.vcxproj.user
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/util/copyrights b/util/copyrights
index feb63b8979..c69312fe83 100644
--- a/util/copyrights
+++ b/util/copyrights
@@ -710,6 +710,7 @@
./bin/tests/system/redirect/ns5/sign.sh SH 2019,2020,2021
./bin/tests/system/redirect/setup.sh SH 2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
./bin/tests/system/redirect/tests.sh SH 2011,2012,2013,2014,2015,2016,2018,2019,2020,2021
+./bin/tests/system/resolve.c C 2009,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
./bin/tests/system/resolver/ans2/ans.pl PERL 2019,2020,2021
./bin/tests/system/resolver/ans3/ans.pl PERL 2000,2001,2004,2007,2009,2012,2016,2018,2019,2020,2021
./bin/tests/system/resolver/ans8/ans.pl PERL 2017,2018,2019,2020,2021
@@ -983,6 +984,9 @@
./bin/tests/system/win32/pipequeries.vcxproj.filters.in X 2016,2018,2019,2020
./bin/tests/system/win32/pipequeries.vcxproj.in X 2016,2017,2018,2019,2020
./bin/tests/system/win32/pipequeries.vcxproj.user X 2016,2018,2019,2020,2021
+./bin/tests/system/win32/resolve.vcxproj.filters.in X 2014,2015,2018,2019,2020
+./bin/tests/system/win32/resolve.vcxproj.in X 2014,2015,2016,2017,2018,2019,2020
+./bin/tests/system/win32/resolve.vcxproj.user X 2014,2018,2019,2020,2021
./bin/tests/system/xfer/ans5/badkeydata X 2011,2018,2019,2020,2021
./bin/tests/system/xfer/ans5/badmessageid X 2020,2021
./bin/tests/system/xfer/ans5/goodaxfr X 2011,2018,2019,2020,2021
@@ -2189,27 +2193,6 @@
./lib/ns/win32/libns.vcxproj.in X 2017,2018,2019,2020
./lib/ns/win32/libns.vcxproj.user X 2017,2018,2019,2020,2021
./lib/ns/xfrout.c C 2017,2018,2019,2020,2021
-./lib/samples/nsprobe.c C 2009,2010,2011,2012,2013,2014,2015,2016,2018,2019,2020,2021
-./lib/samples/resolve.c C 2009,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
-./lib/samples/rootkey.sh SH 2013,2016,2018,2019,2020,2021
-./lib/samples/sample-async.c C 2009,2013,2014,2015,2016,2018,2019,2020,2021
-./lib/samples/sample-request.c C 2009,2012,2013,2014,2015,2016,2018,2019,2020,2021
-./lib/samples/sample-update.c C 2009,2010,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
-./lib/samples/win32/async.vcxproj.filters.in X 2014,2015,2018,2019,2020
-./lib/samples/win32/async.vcxproj.in X 2014,2015,2016,2017,2018,2019,2020
-./lib/samples/win32/async.vcxproj.user X 2014,2018,2019,2020,2021
-./lib/samples/win32/nsprobe.vcxproj.filters.in X 2014,2015,2018,2019,2020
-./lib/samples/win32/nsprobe.vcxproj.in X 2014,2015,2016,2017,2018,2019,2020
-./lib/samples/win32/nsprobe.vcxproj.user X 2014,2018,2019,2020,2021
-./lib/samples/win32/request.vcxproj.filters.in X 2014,2015,2018,2019,2020
-./lib/samples/win32/request.vcxproj.in X 2014,2015,2016,2017,2018,2019,2020
-./lib/samples/win32/request.vcxproj.user X 2014,2018,2019,2020,2021
-./lib/samples/win32/resolve.vcxproj.filters.in X 2014,2015,2018,2019,2020
-./lib/samples/win32/resolve.vcxproj.in X 2014,2015,2016,2017,2018,2019,2020
-./lib/samples/win32/resolve.vcxproj.user X 2014,2018,2019,2020,2021
-./lib/samples/win32/update.vcxproj.filters.in X 2014,2015,2018,2019,2020
-./lib/samples/win32/update.vcxproj.in X 2014,2015,2016,2017,2018,2019,2020
-./lib/samples/win32/update.vcxproj.user X 2014,2018,2019,2020,2021
./lib/win32/bindevt/bindevt.c C 2000,2001,2004,2007,2016,2018,2019,2020,2021
./lib/win32/bindevt/bindevt.mc X 2001,2004,2007,2016,2018,2019,2020,2021
./lib/win32/bindevt/bindevt.vcxproj.filters.in X 2013,2015,2018,2019,2020
diff --git a/win32utils/Configure b/win32utils/Configure
index 57e94d70a4..c5870ea78a 100644
--- a/win32utils/Configure
+++ b/win32utils/Configure
@@ -112,6 +112,8 @@ my @projectlist = ("../bin/check/win32/checkconf.vcxproj",
"../bin/tests/system/win32/pipequeries.vcxproj.filters",
"../bin/tests/system/win32/makejournal.vcxproj",
"../bin/tests/system/win32/makejournal.vcxproj.filters",
+ "../bin/tests/system/win32/resolve.vcxproj",
+ "../bin/tests/system/win32/resolve.vcxproj.filters",
"../bin/win32/BINDInstall/BINDInstall.vcxproj",
"../bin/win32/BINDInstall/BINDInstall.vcxproj.filters",
"../lib/bind9/win32/libbind9.vcxproj",
@@ -129,16 +131,6 @@ my @projectlist = ("../bin/check/win32/checkconf.vcxproj",
"../lib/isccfg/win32/libisccfg.vcxproj",
"../lib/isccfg/win32/libisccfg.vcxproj.filters",
"../lib/ns/win32/libns.vcxproj",
- "../lib/samples/win32/resolve.vcxproj",
- "../lib/samples/win32/resolve.vcxproj.filters",
- "../lib/samples/win32/async.vcxproj",
- "../lib/samples/win32/async.vcxproj.filters",
- "../lib/samples/win32/update.vcxproj",
- "../lib/samples/win32/update.vcxproj.filters",
- "../lib/samples/win32/request.vcxproj",
- "../lib/samples/win32/request.vcxproj.filters",
- "../lib/samples/win32/nsprobe.vcxproj",
- "../lib/samples/win32/nsprobe.vcxproj.filters",
"../lib/win32/bindevt/bindevt.vcxproj",
"../lib/win32/bindevt/bindevt.vcxproj.filters",
"bind9.sln");
@@ -308,7 +300,6 @@ my @substcond = ("ATOMIC",
"OPENSSL",
"PKCS11",
"PYTHON",
- "SAMPLES",
"STESTS",
"TESTS",
"ZLIB");
@@ -349,7 +340,6 @@ my @withlist = ("aes",
"pssuspend",
"python",
"readline",
- "samples",
"system-tests",
"tests",
"tuning",
@@ -390,7 +380,6 @@ my @help = (
" with-tests build with test suite\n",
" with-extra-tests build with extra test suite\n",
" with-system-tests build with system test suite\n",
-" with-samples build with sample programs\n",
" with-openssl[=PATH] build with OpenSSL yes|path (mandatory)\n",
" with-libuv[=PATH] build with libuv yes|path (mandatory)\n",
" with-nghttp2[=PATH] build with nghttp2 yes|path (mandatory)\n",
@@ -433,7 +422,6 @@ my $enable_rpz_nsip = "yes";
my $enable_rpz_nsdname = "yes";
my $use_tests = "no";
my $use_stests = "no";
-my $use_samples = "no";
my $use_libuv = "auto";
my $libuv_path = "../../";
my $nghttp2_path = "../../";
@@ -725,7 +713,6 @@ if ($enable_developer eq "yes") {
# TODO: dlz filesystem
$use_tests = "yes";
$use_stests = "yes";
- $use_samples = "yes";
}
# parse with/without
@@ -747,10 +734,6 @@ sub mywith {
$use_tests = "yes";
$use_stests = "yes";
}
- } elsif ($key =~ /^samples$/i) {
- if ($val =~ /^yes$/i) {
- $use_samples = "yes";
- }
} elsif ($key =~ /^openssl$/i) {
if ($val =~ /^no$/i) {
die "OpenSSL support is now mandatory\n";
@@ -971,9 +954,6 @@ if ($verbose) {
if ($use_stests eq "yes") {
print "system tests: enabled\n";
}
- if ($use_samples eq "yes") {
- print "sample programs: enabled\n";
- }
if ($use_pkcs11 eq "no") {
print "pkcs11: disabled\n";
} else {
@@ -1265,11 +1245,6 @@ if ($use_stests eq "yes") {
$configcond{"STESTS"} = 1;
}
-# with-samples
-if ($use_samples eq "yes") {
- $configcond{"SAMPLES"} = 1;
-}
-
# with-libuv
if ($use_libuv eq "auto") {
if ($verbose) {
diff --git a/win32utils/bind9.sln.in b/win32utils/bind9.sln.in
index fe004aece3..60c4db82cc 100644
--- a/win32utils/bind9.sln.in
+++ b/win32utils/bind9.sln.in
@@ -22,20 +22,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libirs", "..\lib\irs\win32\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bindevt", "..\lib\win32\bindevt\bindevt.vcxproj", "{0D745CD9-FC3B-49DC-99BE-1E6DF85593F0}"
EndProject
-@IF SAMPLES
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "resolve", "..\lib\samples\win32\resolve.vcxproj", "{F66D8B7E-721D-4602-99AD-820D19AD1313}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "async", "..\lib\samples\win32\async.vcxproj", "{9FC33CA3-CE4A-4EDF-BA99-EECA4B81AD06}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gai", "..\lib\samples\win32\gai.vcxproj", "{D42B8670-8DF6-4D90-90F7-DB5FB845AFAE}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "update", "..\lib\samples\win32\update.vcxproj", "{05682E12-523F-4DAE-8E6D-ADFDBC308AFD}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "request", "..\lib\samples\win32\request.vcxproj", "{FF440E85-7450-439C-82EE-04C464512D0E}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nsprobe", "..\lib\samples\win32\nsprobe.vcxproj", "{CB2A29F6-E73B-40AB-8AC4-2C1AAE7280BD}"
-EndProject
-@END SAMPLES
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "named", "..\bin\named\win32\named.vcxproj", "{723C65DA-A96C-4BA3-A34E-44F11CA346F9}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rndc", "..\bin\rndc\win32\rndc.vcxproj", "{39721F26-8B80-4AA9-9826-2AEF7322C3D5}"
@@ -107,6 +93,8 @@ EndProject
@IF STESTS
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "makejournal", "..\bin\tests\system\win32\makejournal.vcxproj", "{31715139-2C27-47D2-8394-71B71A8AC3D5}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "resolve", "..\bin\tests\system\win32\resolve.vcxproj", "{F66D8B7E-721D-4602-99AD-820D19AD1313}"
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gencheck", "..\bin\tests\system\win32\gencheck.vcxproj", "{764DBE24-C8B3-46E8-BE73-196431353A5D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bigkey", "..\bin\tests\system\win32\bigkey.vcxproj", "{61F9D673-EB5C-47A5-8907-24E034C75EF8}"
@@ -166,32 +154,6 @@ Global
{0D745CD9-FC3B-49DC-99BE-1E6DF85593F0}.Debug|@PLATFORM@.Build.0 = Debug|@PLATFORM@
{0D745CD9-FC3B-49DC-99BE-1E6DF85593F0}.Release|@PLATFORM@.ActiveCfg = Release|@PLATFORM@
{0D745CD9-FC3B-49DC-99BE-1E6DF85593F0}.Release|@PLATFORM@.Build.0 = Release|@PLATFORM@
-@IF SAMPLES
- {F66D8B7E-721D-4602-99AD-820D19AD1313}.Debug|@PLATFORM@.ActiveCfg = Debug|@PLATFORM@
- {F66D8B7E-721D-4602-99AD-820D19AD1313}.Debug|@PLATFORM@.Build.0 = Debug|@PLATFORM@
- {F66D8B7E-721D-4602-99AD-820D19AD1313}.Release|@PLATFORM@.ActiveCfg = Release|@PLATFORM@
- {F66D8B7E-721D-4602-99AD-820D19AD1313}.Release|@PLATFORM@.Build.0 = Release|@PLATFORM@
- {9FC33CA3-CE4A-4EDF-BA99-EECA4B81AD06}.Debug|@PLATFORM@.ActiveCfg = Debug|@PLATFORM@
- {9FC33CA3-CE4A-4EDF-BA99-EECA4B81AD06}.Debug|@PLATFORM@.Build.0 = Debug|@PLATFORM@
- {9FC33CA3-CE4A-4EDF-BA99-EECA4B81AD06}.Release|@PLATFORM@.ActiveCfg = Release|@PLATFORM@
- {9FC33CA3-CE4A-4EDF-BA99-EECA4B81AD06}.Release|@PLATFORM@.Build.0 = Release|@PLATFORM@
- {D42B8670-8DF6-4D90-90F7-DB5FB845AFAE}.Debug|@PLATFORM@.ActiveCfg = Debug|@PLATFORM@
- {D42B8670-8DF6-4D90-90F7-DB5FB845AFAE}.Debug|@PLATFORM@.Build.0 = Debug|@PLATFORM@
- {D42B8670-8DF6-4D90-90F7-DB5FB845AFAE}.Release|@PLATFORM@.ActiveCfg = Release|@PLATFORM@
- {D42B8670-8DF6-4D90-90F7-DB5FB845AFAE}.Release|@PLATFORM@.Build.0 = Release|@PLATFORM@
- {05682E12-523F-4DAE-8E6D-ADFDBC308AFD}.Debug|@PLATFORM@.ActiveCfg = Debug|@PLATFORM@
- {05682E12-523F-4DAE-8E6D-ADFDBC308AFD}.Debug|@PLATFORM@.Build.0 = Debug|@PLATFORM@
- {05682E12-523F-4DAE-8E6D-ADFDBC308AFD}.Release|@PLATFORM@.ActiveCfg = Release|@PLATFORM@
- {05682E12-523F-4DAE-8E6D-ADFDBC308AFD}.Release|@PLATFORM@.Build.0 = Release|@PLATFORM@
- {FF440E85-7450-439C-82EE-04C464512D0E}.Debug|@PLATFORM@.ActiveCfg = Debug|@PLATFORM@
- {FF440E85-7450-439C-82EE-04C464512D0E}.Debug|@PLATFORM@.Build.0 = Debug|@PLATFORM@
- {FF440E85-7450-439C-82EE-04C464512D0E}.Release|@PLATFORM@.ActiveCfg = Release|@PLATFORM@
- {FF440E85-7450-439C-82EE-04C464512D0E}.Release|@PLATFORM@.Build.0 = Release|@PLATFORM@
- {CB2A29F6-E73B-40AB-8AC4-2C1AAE7280BD}.Debug|@PLATFORM@.ActiveCfg = Debug|@PLATFORM@
- {CB2A29F6-E73B-40AB-8AC4-2C1AAE7280BD}.Debug|@PLATFORM@.Build.0 = Debug|@PLATFORM@
- {CB2A29F6-E73B-40AB-8AC4-2C1AAE7280BD}.Release|@PLATFORM@.ActiveCfg = Release|@PLATFORM@
- {CB2A29F6-E73B-40AB-8AC4-2C1AAE7280BD}.Release|@PLATFORM@.Build.0 = Release|@PLATFORM@
-@END SAMPLES
{723C65DA-A96C-4BA3-A34E-44F11CA346F9}.Debug|@PLATFORM@.ActiveCfg = Debug|@PLATFORM@
{723C65DA-A96C-4BA3-A34E-44F11CA346F9}.Debug|@PLATFORM@.Build.0 = Debug|@PLATFORM@
{723C65DA-A96C-4BA3-A34E-44F11CA346F9}.Release|@PLATFORM@.ActiveCfg = Release|@PLATFORM@