adb_test.c revision 307d2084502eddc7ce921e5ce439aec3531d90e0
db69d5d53cbffd6cc7419807e767792eef3bc593Automatic Updater/*
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Copyright (C) 1999-2001 Internet Software Consortium.
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater *
4c1132f34493327abc632196f5876a89aa573687Bob Halley * Permission to use, copy, modify, and/or distribute this software for any
4c1132f34493327abc632196f5876a89aa573687Bob Halley * purpose with or without fee is hereby granted, provided that the above
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * copyright notice and this permission notice appear in all copies.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews *
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt */
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence
f41f183f628a148860a6d1f0070208cddd45b0c6Bob Halley/* $Id: adb_test.c,v 1.69 2009/09/01 00:22:25 jinmei Exp $ */
f41f183f628a148860a6d1f0070208cddd45b0c6Bob Halley
f41f183f628a148860a6d1f0070208cddd45b0c6Bob Halley/*! \file */
f41f183f628a148860a6d1f0070208cddd45b0c6Bob Halley
9a2127f8335bad323451d7825119cd9f72e32464Mark Andrews#include <config.h>
9a2127f8335bad323451d7825119cd9f72e32464Mark Andrews
9a2127f8335bad323451d7825119cd9f72e32464Mark Andrews#include <stdlib.h>
9a2127f8335bad323451d7825119cd9f72e32464Mark Andrews#include <string.h>
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#include <unistd.h>
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley#include <isc/app.h>
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley#include <isc/buffer.h>
c2bc56dc65b4b103a5600565680eb5f33fa4c90bMark Andrews#include <isc/entropy.h>
51917258dbb23cfe6069ae1cf2b7fc5aefc1e0c2Bob Halley#include <isc/hash.h>
c6b3c1984caa362359862e063e7b70dfb306db7eMark Andrews#include <isc/socket.h>
155a0ce6e3c9cef51b63789c34d83d9143ce01fdMark Andrews#include <isc/task.h>
494576ce20cfd98d74955698cf8f7b37dce2f740Mark Andrews#include <isc/timer.h>
494576ce20cfd98d74955698cf8f7b37dce2f740Mark Andrews#include <isc/util.h>
6d5dcd0dc9bdbd679282b1ffc47987d24c3a1346Bob Halley
12178c86525332bb0ab66155feb61fbf32eca6acEvan Hunt#include <dns/adb.h>
155a0ce6e3c9cef51b63789c34d83d9143ce01fdMark Andrews#include <dns/cache.h>
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#include <dns/dispatch.h>
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley#include <dns/db.h>
b6d52ee5bea1b9d9074698e693b49ce96edff47bMark Andrews#include <dns/log.h>
b6d52ee5bea1b9d9074698e693b49ce96edff47bMark Andrews#include <dns/rootns.h>
b6d52ee5bea1b9d9074698e693b49ce96edff47bMark Andrews#include <dns/result.h>
b6d52ee5bea1b9d9074698e693b49ce96edff47bMark Andrews
c45abd11bb68005d8a5c56c14b16f4184c3e057dMichael Grafftypedef struct client client_t;
c45abd11bb68005d8a5c56c14b16f4184c3e057dMichael Graffstruct client {
a685d9c3b608eb768d237f20e8e8b1c5d3902146David Lawrence dns_name_t name;
feb08cecf318bba330437cfcb725f48d999804d8James Brister const char *target;
76117ff568dc788ed24937cfea916a18db285960Mark Andrews ISC_LINK(client_t) link;
37dee1ff94960a61243f611c0f87f8c316815c53Mark Andrews dns_adbfind_t *find;
76117ff568dc788ed24937cfea916a18db285960Mark Andrews};
76117ff568dc788ed24937cfea916a18db285960Mark Andrews
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrewsstatic isc_mem_t *mctx = NULL;
76117ff568dc788ed24937cfea916a18db285960Mark Andrewsstatic isc_entropy_t *ectx = NULL;
65c4736d9c0ebc6d9b1d991593b55566909da9cdBrian Wellingtonstatic isc_mempool_t *cmp;
fc80027fb54b501cdd88461bf879d078259e0226David Lawrencestatic isc_log_t *lctx;
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉static isc_logconfig_t *lcfg;
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafssonstatic isc_taskmgr_t *taskmgr;
911ed0d3bee586b3bec42cb6c376d5cc6c0e1e24Brian Wellingtonstatic isc_socketmgr_t *socketmgr;
e334405421979688f2d838805ac67ee47bd62976Mark Andrewsstatic isc_timermgr_t *timermgr;
e334405421979688f2d838805ac67ee47bd62976Mark Andrewsstatic dns_dispatchmgr_t *dispatchmgr;
e334405421979688f2d838805ac67ee47bd62976Mark Andrewsstatic isc_task_t *t1, *t2;
911ed0d3bee586b3bec42cb6c376d5cc6c0e1e24Brian Wellingtonstatic dns_view_t *view;
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Huntstatic dns_db_t *rootdb;
28479307225582ad0b2e11441d85fcf5169551d0Mark Andrewsstatic ISC_LIST(client_t) clients;
28b863e609ff2d97b78663b46894494cfa2ea411Mark Andrewsstatic isc_mutex_t client_lock;
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrewsstatic isc_stdtime_t now;
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrewsstatic dns_adb_t *adb;
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews
3916872f379457fe344afb02398a009701c5016aEvan Huntstatic void
ce1f5b8d0ae5936fd187c1f414ff12a7e3b0aa37Andreas Gustafssoncheck_result(isc_result_t result, const char *format, ...)
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 ISC_FORMAT_PRINTF(2, 3);
5c6762838c9e423753723ec2a963164e3d66ac32Mark Andrews
5c6762838c9e423753723ec2a963164e3d66ac32Mark Andrewsstatic void
5c6762838c9e423753723ec2a963164e3d66ac32Mark Andrewscheck_result(isc_result_t result, const char *format, ...) {
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley va_list args;
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence
37dee1ff94960a61243f611c0f87f8c316815c53Mark Andrews if (result == ISC_R_SUCCESS)
37dee1ff94960a61243f611c0f87f8c316815c53Mark Andrews return;
76117ff568dc788ed24937cfea916a18db285960Mark Andrews
76117ff568dc788ed24937cfea916a18db285960Mark Andrews va_start(args, format);
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews vfprintf(stderr, format, args);
494576ce20cfd98d74955698cf8f7b37dce2f740Mark Andrews va_end(args);
76117ff568dc788ed24937cfea916a18db285960Mark Andrews fprintf(stderr, ": %s\n", isc_result_totext(result));
494576ce20cfd98d74955698cf8f7b37dce2f740Mark Andrews exit(1);
d0eb2cc33c5db3366a16b1cb0abcca6ec7c8ee3cTatuya JINMEI 神明達哉}
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
911ed0d3bee586b3bec42cb6c376d5cc6c0e1e24Brian Wellingtonstatic client_t *
e334405421979688f2d838805ac67ee47bd62976Mark Andrewsnew_client(void) {
cfb1587eb9a6dc6d1d36ea0344e1b20068b81e88Evan Hunt client_t *client;
911ed0d3bee586b3bec42cb6c376d5cc6c0e1e24Brian Wellington
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews client = isc_mempool_get(cmp);
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews INSIST(client != NULL);
3cd88f71b01833d5c2474638854dfa5c4244a22aBrian Wellington dns_name_init(&client->name, NULL);
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews ISC_LINK_INIT(client, link);
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews client->find = NULL;
ce1f5b8d0ae5936fd187c1f414ff12a7e3b0aa37Andreas Gustafsson
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 return (client);
18d110413cf6416eb339c169b99159d09f690da1Brian Wellington}
494576ce20cfd98d74955698cf8f7b37dce2f740Mark Andrews
4fd3e3482c7e4ce01e2cf28f13e0152c8e50d746Mark Andrewsstatic void
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntfree_client(client_t **c) {
4fd3e3482c7e4ce01e2cf28f13e0152c8e50d746Mark Andrews client_t *client;
4fd3e3482c7e4ce01e2cf28f13e0152c8e50d746Mark Andrews
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt INSIST(c != NULL);
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley client = *c;
d2b5fe92a4755ce67f2dd6050955782b4fd6b3f3Mark Andrews *c = NULL;
d2b5fe92a4755ce67f2dd6050955782b4fd6b3f3Mark Andrews INSIST(client != NULL);
d2b5fe92a4755ce67f2dd6050955782b4fd6b3f3Mark Andrews dns_name_free(&client->name, mctx);
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley INSIST(!ISC_LINK_LINKED(client, link));
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley INSIST(client->find == NULL);
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews isc_mempool_put(cmp, client);
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleystatic inline void
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob HalleyCLOCK(void) {
139154bd9894495042f4e748f554e9c8b98b7598Bob Halley RUNTIME_CHECK(isc_mutex_lock(&client_lock) == ISC_R_SUCCESS);
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley}
193738b819e3c699f9edd18864a6810fcfcec855Andreas Gustafsson
fd35453765c6494d077edca44f4d998af5fd4cfaDavid Lawrencestatic inline void
fd35453765c6494d077edca44f4d998af5fd4cfaDavid LawrenceCUNLOCK(void) {
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley RUNTIME_CHECK(isc_mutex_unlock(&client_lock) == ISC_R_SUCCESS);
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley}
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews
9f7d51ee3290e2a064d71016a6bd555b47134a7cMark Andrewsstatic void
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleylookup_callback(isc_task_t *task, isc_event_t *ev) {
881702c9c0079cd48a45054fd90d043f3a8b7e11Mark Andrews client_t *client;
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley client = ev->ev_arg;
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley INSIST(client->find == ev->ev_sender);
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley printf("NAME %s:\n\tTask %p got event %p type %08x from %p, client %p\n\terr4: %s err6: %s\n",
922e6a3c2ac4ef900dd9dc99f0cc137f18372583Andreas Gustafsson client->target,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley task, ev, ev->ev_type, client->find, client,
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley isc_result_totext(client->find->result_v4),
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews isc_result_totext(client->find->result_v6));
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley
4880900113e4d0f17884f3fbdbf4c302e3f9ea91Bob Halley isc_event_free(&ev);
fd35453765c6494d077edca44f4d998af5fd4cfaDavid Lawrence ev = NULL;
c8a42d6d81ff2fd9ad7fac94d4b85323554493c0Bob Halley
4fd3e3482c7e4ce01e2cf28f13e0152c8e50d746Mark Andrews CLOCK();
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
6ef838d427c1ea858d2f09194a369134babf8b98Mark Andrews dns_adb_dumpfind(client->find, stderr);
6ef838d427c1ea858d2f09194a369134babf8b98Mark Andrews dns_adb_destroyfind(&client->find);
6ef838d427c1ea858d2f09194a369134babf8b98Mark Andrews
6ef838d427c1ea858d2f09194a369134babf8b98Mark Andrews ISC_LIST_UNLINK(clients, client, link);
6d831cd0baf7dd2c133f7f9cbf295f3d80cf63a7David Lawrence free_client(&client);
6d831cd0baf7dd2c133f7f9cbf295f3d80cf63a7David Lawrence
dac2799ea19735503a4d27f517d821aea210e594Andreas Gustafsson CUNLOCK();
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
6d7585b3e948dd31bf78321d83ac0e024f44a71bMark Andrewsstatic void
6d5dcd0dc9bdbd679282b1ffc47987d24c3a1346Bob Halleycreate_managers(void) {
6d7585b3e948dd31bf78321d83ac0e024f44a71bMark Andrews isc_result_t result;
6d7585b3e948dd31bf78321d83ac0e024f44a71bMark Andrews
6d5dcd0dc9bdbd679282b1ffc47987d24c3a1346Bob Halley taskmgr = NULL;
6d7585b3e948dd31bf78321d83ac0e024f44a71bMark Andrews result = isc_taskmgr_create(mctx, 5, 0, &taskmgr);
1471a520e59ac12b413afa8d8b3158a87af97aa6Bob Halley check_result(result, "isc_taskmgr_create");
1471a520e59ac12b413afa8d8b3158a87af97aa6Bob Halley
1471a520e59ac12b413afa8d8b3158a87af97aa6Bob Halley timermgr = NULL;
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews result = isc_timermgr_create(mctx, &timermgr);
1471a520e59ac12b413afa8d8b3158a87af97aa6Bob Halley check_result(result, "isc_timermgr_create");
1471a520e59ac12b413afa8d8b3158a87af97aa6Bob Halley
4fd3e3482c7e4ce01e2cf28f13e0152c8e50d746Mark Andrews socketmgr = NULL;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews result = isc_socketmgr_create(mctx, &socketmgr);
6d5dcd0dc9bdbd679282b1ffc47987d24c3a1346Bob Halley check_result(result, "isc_socketmgr_create");
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews dispatchmgr = NULL;
118394ef2ec7cef253c55359a3d70d202ddc2fa0Mark Andrews result = dns_dispatchmgr_create(mctx, NULL, &dispatchmgr);
118394ef2ec7cef253c55359a3d70d202ddc2fa0Mark Andrews check_result(result, "dns_dispatchmgr_create");
bb556a9bf3a15c7160fa4f1b71773ce12b1bedf6Bob Halley}
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley
1471a520e59ac12b413afa8d8b3158a87af97aa6Bob Halleystatic void
1471a520e59ac12b413afa8d8b3158a87af97aa6Bob Halleycreate_view(void) {
1471a520e59ac12b413afa8d8b3158a87af97aa6Bob Halley dns_cache_t *cache;
fe37278859bce157001cca14cdfa3a761b0d5012Mark Andrews isc_result_t result;
1471a520e59ac12b413afa8d8b3158a87af97aa6Bob Halley
494576ce20cfd98d74955698cf8f7b37dce2f740Mark Andrews /*
798c83548f89091e3994ca5a9c8c7e9caaf89d10Mark Andrews * View.
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews */
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews view = NULL;
result = dns_view_create(mctx, dns_rdataclass_in, "_default", &view);
check_result(result, "dns_view_create");
/*
* Cache.
*/
cache = NULL;
result = dns_cache_create(mctx, taskmgr, timermgr, dns_rdataclass_in,
"rbt", 0, NULL, &cache);
check_result(result, "dns_cache_create");
dns_view_setcache(view, cache);
dns_cache_detach(&cache);
{
unsigned int attrs;
isc_sockaddr_t any4, any6;
dns_dispatch_t *disp4 = NULL;
dns_dispatch_t *disp6 = NULL;
isc_sockaddr_any(&any4);
isc_sockaddr_any6(&any6);
attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP;
RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr, socketmgr,
taskmgr, &any4, 512, 6, 1024,
17, 19, attrs, attrs, &disp4)
== ISC_R_SUCCESS);
INSIST(disp4 != NULL);
attrs = DNS_DISPATCHATTR_IPV6 | DNS_DISPATCHATTR_UDP;
RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr, socketmgr,
taskmgr, &any6, 512, 6, 1024,
17, 19, attrs, attrs, &disp6)
== ISC_R_SUCCESS);
INSIST(disp6 != NULL);
RUNTIME_CHECK(dns_view_createresolver(view, taskmgr, 10,
socketmgr,
timermgr, 0,
dispatchmgr,
disp4, disp6) ==
ISC_R_SUCCESS);
}
rootdb = NULL;
result = dns_rootns_create(mctx, dns_rdataclass_in, NULL, &rootdb);
check_result(result, "dns_rootns_create()");
dns_view_sethints(view, rootdb);
dns_db_detach(&rootdb);
dns_view_freeze(view);
}
static void
lookup(const char *target) {
dns_name_t name;
unsigned char namedata[256];
client_t *client;
isc_buffer_t t, namebuf;
isc_result_t result;
unsigned int options;
INSIST(target != NULL);
client = new_client();
isc_buffer_init(&t, target, strlen(target));
isc_buffer_add(&t, strlen(target));
isc_buffer_init(&namebuf, namedata, sizeof(namedata));
dns_name_init(&name, NULL);
result = dns_name_fromtext(&name, &t, dns_rootname, 0, &namebuf);
check_result(result, "dns_name_fromtext %s", target);
result = dns_name_dup(&name, mctx, &client->name);
check_result(result, "dns_name_dup %s", target);
options = 0;
options |= DNS_ADBFIND_INET;
options |= DNS_ADBFIND_INET6;
options |= DNS_ADBFIND_WANTEVENT;
options |= DNS_ADBFIND_HINTOK;
options |= DNS_ADBFIND_GLUEOK;
result = dns_adb_createfind(adb, t2, lookup_callback, client,
&client->name, dns_rootname, 0, options,
now, NULL, view->dstport, &client->find);
#if 0
check_result(result, "dns_adb_createfind()");
#endif
dns_adb_dumpfind(client->find, stderr);
if ((client->find->options & DNS_ADBFIND_WANTEVENT) != 0) {
client->target = target;
ISC_LIST_APPEND(clients, client, link);
} else {
printf("NAME %s: err4 %s, err6 %s\n",
target, isc_result_totext(client->find->result_v4),
isc_result_totext(client->find->result_v6));
dns_adb_destroyfind(&client->find);
free_client(&client);
}
}
int
main(int argc, char **argv) {
isc_result_t result;
isc_logdestination_t destination;
UNUSED(argc);
UNUSED(argv);
dns_result_register();
result = isc_app_start();
check_result(result, "isc_app_start()");
isc_stdtime_get(&now);
result = isc_mutex_init(&client_lock);
check_result(result, "isc_mutex_init(&client_lock)");
ISC_LIST_INIT(clients);
/*
* EVERYTHING needs a memory context.
*/
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
cmp = NULL;
RUNTIME_CHECK(isc_mempool_create(mctx, sizeof(client_t), &cmp)
== ISC_R_SUCCESS);
isc_mempool_setname(cmp, "adb test clients");
result = isc_entropy_create(mctx, &ectx);
check_result(result, "isc_entropy_create()");
result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
check_result(result, "isc_hash_create()");
result = isc_log_create(mctx, &lctx, &lcfg);
check_result(result, "isc_log_create()");
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_log_setcontext(lctx);
/*
* Create and install the default channel.
*/
destination.file.stream = stderr;
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
result = isc_log_createchannel(lcfg, "_default",
ISC_LOG_TOFILEDESC,
ISC_LOG_DYNAMIC,
&destination, ISC_LOG_PRINTTIME);
check_result(result, "isc_log_createchannel()");
result = isc_log_usechannel(lcfg, "_default", NULL, NULL);
check_result(result, "isc_log_usechannel()");
/*
* Set the initial debug level.
*/
isc_log_setdebuglevel(lctx, 2);
create_managers();
t1 = NULL;
result = isc_task_create(taskmgr, 0, &t1);
check_result(result, "isc_task_create t1");
t2 = NULL;
result = isc_task_create(taskmgr, 0, &t2);
check_result(result, "isc_task_create t2");
printf("task 1 = %p\n", t1);
printf("task 2 = %p\n", t2);
create_view();
adb = view->adb;
/*
* Lock the entire client list here. This will cause all events
* for found names to block as well.
*/
CLOCK();
lookup("f.root-servers.net."); /* Should be in hints */
lookup("www.iengines.com"); /* should fetch */
lookup("www.isc.org"); /* should fetch */
lookup("www.flame.org"); /* should fetch */
lookup("kechara.flame.org."); /* should fetch */
lookup("moghedien.flame.org."); /* should fetch */
lookup("mailrelay.flame.org."); /* should fetch */
lookup("ipv4v6.flame.org."); /* should fetch */
lookup("nonexistant.flame.org."); /* should fail to be found */
lookup("foobar.badns.flame.org."); /* should fail utterly (NS) */
lookup("i.root-servers.net."); /* Should be in hints */
lookup("www.firstcard.com.");
lookup("dns04.flame.org.");
CUNLOCK();
sleep(10);
dns_adb_dump(adb, stderr);
sleep(10);
CLOCK();
lookup("f.root-servers.net."); /* Should be in hints */
lookup("www.iengines.com"); /* should fetch */
lookup("www.isc.org"); /* should fetch */
lookup("www.flame.org"); /* should fetch */
lookup("kechara.flame.org."); /* should fetch */
lookup("moghedien.flame.org."); /* should fetch */
lookup("mailrelay.flame.org."); /* should fetch */
lookup("ipv4v6.flame.org."); /* should fetch */
lookup("nonexistant.flame.org."); /* should fail to be found */
lookup("foobar.badns.flame.org."); /* should fail utterly (NS) */
lookup("i.root-servers.net."); /* Should be in hints */
CUNLOCK();
sleep(20);
dns_adb_dump(adb, stderr);
isc_task_detach(&t1);
isc_task_detach(&t2);
isc_mem_stats(mctx, stdout);
dns_adb_dump(adb, stderr);
isc_app_run();
dns_adb_dump(adb, stderr);
dns_view_detach(&view);
adb = NULL;
isc_socketmgr_destroy(&socketmgr);
isc_timermgr_destroy(&timermgr);
fprintf(stderr, "Destroying task manager\n");
isc_taskmgr_destroy(&taskmgr);
isc_log_destroy(&lctx);
isc_hash_destroy();
isc_entropy_detach(&ectx);
isc_mempool_destroy(&cmp);
isc_mem_stats(mctx, stdout);
isc_mem_destroy(&mctx);
isc_app_finish();
return (0);
}