0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 1999-2001, 2004, 2005, 2007, 2009, 2011-2013, 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4e68c7c87c30c28490c92937adc112dca5b5d5aeAutomatic Updater/* $Id: adb_test.c,v 1.73 2011/08/30 23:46:51 tbox Exp $ */
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafssoncheck_result(isc_result_t result, const char *format, ...)
1b6d529cb5ee0ad44f8518e1b8c2cbca54bbdf18David Lawrencecheck_result(isc_result_t result, const char *format, ...) {
306a93530536f05edfb477cac1c2667d90129a8fMichael Graff fprintf(stderr, ": %s\n", isc_result_totext(result));
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graffstatic inline void
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff RUNTIME_CHECK(isc_mutex_lock(&client_lock) == ISC_R_SUCCESS);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graffstatic inline void
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff RUNTIME_CHECK(isc_mutex_unlock(&client_lock) == ISC_R_SUCCESS);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrencelookup_callback(isc_task_t *task, isc_event_t *ev) {
306a93530536f05edfb477cac1c2667d90129a8fMichael Graff printf("NAME %s:\n\tTask %p got event %p type %08x from %p, client %p\n\terr4: %s err6: %s\n",
306a93530536f05edfb477cac1c2667d90129a8fMichael Graff result = isc_taskmgr_create(mctx, 5, 0, &taskmgr);
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff result = isc_timermgr_create(mctx, &timermgr);
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff result = isc_socketmgr_create(mctx, &socketmgr);
4e21e54a0394d0f87798620a95c1f675c0b0d09cMichael Graff result = dns_dispatchmgr_create(mctx, NULL, &dispatchmgr);
558ab0f6a8046499bfe3e39ea4789036313b72b3Michael Graff check_result(result, "dns_dispatchmgr_create");
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff result = dns_view_create(mctx, dns_rdataclass_in, "_default", &view);
fd15c8e32ed0c1cfd3ed737858a81966e7fbaeacAndreas Gustafsson result = dns_cache_create(mctx, taskmgr, timermgr, dns_rdataclass_in,
fd15c8e32ed0c1cfd3ed737858a81966e7fbaeacAndreas Gustafsson check_result(result, "dns_cache_create");
d98c74e2ec5b96bd22aa4ed6d893e8993787493bMichael Graff attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP;
d98c74e2ec5b96bd22aa4ed6d893e8993787493bMichael Graff RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr, socketmgr,
d98c74e2ec5b96bd22aa4ed6d893e8993787493bMichael Graff attrs = DNS_DISPATCHATTR_IPV6 | DNS_DISPATCHATTR_UDP;
d98c74e2ec5b96bd22aa4ed6d893e8993787493bMichael Graff RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr, socketmgr,
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt RUNTIME_CHECK(dns_view_createresolver(view, taskmgr, 10, 1,
e592dd7c344052ee51eb707cd744b48b34f4c74eBob Halley result = dns_rootns_create(mctx, dns_rdataclass_in, NULL, &rootdb);
efa4ebbff3c9f6f38ab8b55540fb696243c1172cAndreas Gustafsson check_result(result, "dns_rootns_create()");
ecf5a60f1e7d8886804becb5fafc765d18175edcMark Andrews isc_buffer_constinit(&t, target, strlen(target));
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence isc_buffer_init(&namebuf, namedata, sizeof(namedata));
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 result = dns_name_fromtext(&name, &t, dns_rootname, 0, &namebuf);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff check_result(result, "dns_name_fromtext %s", target);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff result = dns_name_dup(&name, mctx, &client->name);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff check_result(result, "dns_name_dup %s", target);
897c9ddb4d745b2bfecf98b17e5487bb6656299aMichael Graff result = dns_adb_createfind(adb, t2, lookup_callback, client,
837633db56089ad135a75282d796f0f0e92a4fadMark Andrews printf("DNS_ADB_CREATEFIND -> %s\n", dns_result_totext(result));
306a93530536f05edfb477cac1c2667d90129a8fMichael Graff if ((client->find->options & DNS_ADBFIND_WANTEVENT) != 0) {
306a93530536f05edfb477cac1c2667d90129a8fMichael Graff target, isc_result_totext(client->find->result_v4),
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff check_result(result, "isc_mutex_init(&client_lock)");
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * EVERYTHING needs a memory context.
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
2bcb48cfcae36398454c98e40c563e2cde748e07Michael Graff RUNTIME_CHECK(isc_mempool_create(mctx, sizeof(client_t), &cmp)
9297259c7abecc78470fdeca173c101137e4b5bbMark Andrews result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
ff9bb3fc5453bbf310b67c560fbf04a5c0fb60daMichael Graff * Create and install the default channel.
ff9bb3fc5453bbf310b67c560fbf04a5c0fb60daMichael Graff destination.file.versions = ISC_LOG_ROLLNEVER;
ff9bb3fc5453bbf310b67c560fbf04a5c0fb60daMichael Graff check_result(result, "isc_log_createchannel()");
e198cb953c1a5bc189ae21dc3f8d622f5a08bc34Bob Halley result = isc_log_usechannel(lcfg, "_default", NULL, NULL);
ff9bb3fc5453bbf310b67c560fbf04a5c0fb60daMichael Graff * Set the initial debug level.
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff * Lock the entire client list here. This will cause all events
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff * for found names to block as well.
cebd4498636d3d480f6f2a7aa2eb72bd2ed64010Michael Graff lookup("f.root-servers.net."); /* Should be in hints */
cebd4498636d3d480f6f2a7aa2eb72bd2ed64010Michael Graff lookup("www.iengines.com"); /* should fetch */
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff lookup("kechara.flame.org."); /* should fetch */
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff lookup("moghedien.flame.org."); /* should fetch */
1c3bc66ada38236cc81c41b7174a9f0a872c9ab6Michael Graff lookup("mailrelay.flame.org."); /* should fetch */
528829aa8ad69238e674cd81078bc14d4199691bMichael Graff lookup("ipv4v6.flame.org."); /* should fetch */
f942258b6380ba1f2c2f057a79ffc37bc3436488Michael Graff lookup("nonexistant.flame.org."); /* should fail to be found */
f942258b6380ba1f2c2f057a79ffc37bc3436488Michael Graff lookup("foobar.badns.flame.org."); /* should fail utterly (NS) */
f942258b6380ba1f2c2f057a79ffc37bc3436488Michael Graff lookup("i.root-servers.net."); /* Should be in hints */
f942258b6380ba1f2c2f057a79ffc37bc3436488Michael Graff lookup("f.root-servers.net."); /* Should be in hints */
f942258b6380ba1f2c2f057a79ffc37bc3436488Michael Graff lookup("www.iengines.com"); /* should fetch */
f942258b6380ba1f2c2f057a79ffc37bc3436488Michael Graff lookup("kechara.flame.org."); /* should fetch */
f942258b6380ba1f2c2f057a79ffc37bc3436488Michael Graff lookup("moghedien.flame.org."); /* should fetch */
f942258b6380ba1f2c2f057a79ffc37bc3436488Michael Graff lookup("mailrelay.flame.org."); /* should fetch */
f942258b6380ba1f2c2f057a79ffc37bc3436488Michael Graff lookup("ipv4v6.flame.org."); /* should fetch */
f942258b6380ba1f2c2f057a79ffc37bc3436488Michael Graff lookup("nonexistant.flame.org."); /* should fail to be found */
f942258b6380ba1f2c2f057a79ffc37bc3436488Michael Graff lookup("foobar.badns.flame.org."); /* should fail utterly (NS) */
78854e02c127f31ab90f56da0531542004b45377Michael Graff lookup("i.root-servers.net."); /* Should be in hints */
837633db56089ad135a75282d796f0f0e92a4fadMark Andrews fprintf(stderr, "Destroying socket manager\n");