f6b909274159da7aaad8463c90f15018136cf6cbTinderbox User * Copyright (C) 2000, 2001, 2004, 2005, 2007, 2009, 2012, 2015-2017 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/.
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley * Principal Author: Bob Halley
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halleystatic void adb_callback(isc_task_t *task, isc_event_t *event);
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley * Setup a logging context.
6af51ff1a30dd977c4fc6c342a0661bb4f6501a5Bob Halley RUNTIME_CHECK(isc_log_create(mctx, &lctx, &lcfg) == ISC_R_SUCCESS);
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley * Create and install the default channel.
6af51ff1a30dd977c4fc6c342a0661bb4f6501a5Bob Halley RUNTIME_CHECK(isc_log_createchannel(lcfg, "_default",
6af51ff1a30dd977c4fc6c342a0661bb4f6501a5Bob Halley RUNTIME_CHECK(isc_log_usechannel(lcfg, "_default", NULL, NULL) ==
315879710704bbcf66df301664cd90df8ad31265David Lawrence isc_netaddr_fromsockaddr(&netaddr, &address->sockaddr);
bfa633fc0e5dea8f65676c5393993ba7053a9899Andreas Gustafsson isc_netaddr_format(&netaddr, text, sizeof(text));
bfa633fc0e5dea8f65676c5393993ba7053a9899Andreas Gustafsson dns_name_format(name, text, sizeof(text));
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley options |= DNS_ADBFIND_WANTEVENT | DNS_ADBFIND_EMPTYEVENT;
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley result = dns_adb_createfind(view->adb, task, adb_callback, NULL,
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley * We have at least some of the addresses for the
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley INSIST((find->options & DNS_ADBFIND_WANTEVENT) == 0);
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley * We don't know any of the addresses for this
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley if ((find->options & DNS_ADBFIND_WANTEVENT) == 0) {
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley * And ADB isn't going to send us any events
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley * either. This query loses.
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley * If the DNS_ADBFIND_WANTEVENT flag was set, we'll
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley * get an event when something happens.
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halleyadb_callback(isc_task_t *etask, isc_event_t *event) {
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
9297259c7abecc78470fdeca173c101137e4b5bbMark Andrews RUNTIME_CHECK(isc_entropy_create(mctx, &ectx) == ISC_R_SUCCESS);
9297259c7abecc78470fdeca173c101137e4b5bbMark Andrews RUNTIME_CHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE)
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley while ((ch = isc_commandline_parse(argc, argv, "d:vw:")) != -1) {
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley level = (unsigned int)atoi(isc_commandline_argument);
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley workers = (unsigned int)atoi(isc_commandline_argument);
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley printf("IPv4: %s\n", isc_result_totext(isc_net_probeipv4()));
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley printf("IPv6: %s\n", isc_result_totext(isc_net_probeipv6()));
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &taskmgr) ==
738b9aa3ded1ef724922d6695cb04ec2e721bdd1Bob Halley RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) ==
4e21e54a0394d0f87798620a95c1f675c0b0d09cMichael Graff RUNTIME_CHECK(dns_dispatchmgr_create(mctx, NULL, &dispatchmgr)
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley RUNTIME_CHECK(dns_cache_create(mctx, taskmgr, timermgr,
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley RUNTIME_CHECK(dns_view_create(mctx, dns_rdataclass_in, "default",
7cbfebb762d0d9ba77699e2c15530278e0e4980eAndreas Gustafsson if (isc_net_probeipv4() == ISC_R_SUCCESS) {
7cbfebb762d0d9ba77699e2c15530278e0e4980eAndreas Gustafsson attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP;
7cbfebb762d0d9ba77699e2c15530278e0e4980eAndreas Gustafsson RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr,
7cbfebb762d0d9ba77699e2c15530278e0e4980eAndreas Gustafsson if (isc_net_probeipv6() == ISC_R_SUCCESS) {
7cbfebb762d0d9ba77699e2c15530278e0e4980eAndreas Gustafsson attrs = DNS_DISPATCHATTR_IPV6 | DNS_DISPATCHATTR_UDP;
7cbfebb762d0d9ba77699e2c15530278e0e4980eAndreas Gustafsson RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr,
4e8fe357a619ae2b789b15df7e3d6abf782b4a71Evan Hunt RUNTIME_CHECK(dns_view_createresolver(view, taskmgr, 10, 1,
de4ef688d73a449d4c1218adbb35a4f70a71e672Brian Wellington RUNTIME_CHECK(dns_fwdtable_add(view->fwdtable, dns_rootname,
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley printf("name = %s\n", argv[isc_commandline_index]);
99a9539ccde4a3769fd890bdae5bcce3a3492fbaBob Halley isc_buffer_add(&b, strlen(argv[isc_commandline_index]));
c2687b0594673a6e2b8558cc92d9936af069edacMark Andrews RUNTIME_CHECK(dns_name_fromtext(dns_fixedname_name(&fixed), &b,