server.c revision 6d9ae6b3a89de2dad5813b4f1020dbe7d78f66f2
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
842920c7db2db1de1a0f9571f77aee5ea92ae5bbAutomatic Updater * Copyright (C) 1999 Internet Software Consortium.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews *
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * Permission to use, copy, modify, and distribute this software for any
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * purpose with or without fee is hereby granted, provided that the above
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * copyright notice and this permission notice appear in all copies.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews *
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * SOFTWARE.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
8d31dd9ab62d91b5f23ac687657c966d44074a3fMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <config.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <stdio.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <stdlib.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <unistd.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <string.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <isc/assertions.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <isc/error.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <isc/mem.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <isc/task.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <isc/thread.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <isc/result.h>
8d31dd9ab62d91b5f23ac687657c966d44074a3fMark Andrews#include <isc/socket.h>
28479307225582ad0b2e11441d85fcf5169551d0Mark Andrews#include <isc/timer.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <dns/types.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <dns/result.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <dns/name.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <dns/rdata.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <dns/rdatalist.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <dns/rdataset.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <dns/compress.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <dns/db.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <dns/message.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <sys/types.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <sys/socket.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <netinet/in.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <arpa/inet.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include "confparser.h"
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include "udpclient.h"
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include "tcpclient.h"
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsisc_mem_t *mctx = NULL;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsisc_boolean_t want_stats = ISC_FALSE;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsdns_db_t *db;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic ISC_inline isc_boolean_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark AndrewsCHECKRESULT(dns_result_t result, char *msg)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews{
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if ((result) != DNS_R_SUCCESS) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews printf("%s: %s\n", (msg), dns_result_totext(result));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (ISC_TRUE);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (ISC_FALSE);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic void
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsmakename(isc_mem_t *mctx, char *text, dns_name_t *name, dns_name_t *origin) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews char b[255];
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_buffer_t source, target;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews size_t len;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_region_t r1, r2;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_result_t result;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (origin == NULL)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews origin = dns_rootname;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_name_init(name, NULL);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews len = strlen(text);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_buffer_init(&source, text, len, ISC_BUFFERTYPE_TEXT);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_buffer_add(&source, len);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_buffer_init(&target, b, sizeof b, ISC_BUFFERTYPE_BINARY);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_name_fromtext(name, &source, origin, ISC_FALSE, &target);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(result == DNS_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_name_toregion(name, &r1);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews r2.base = isc_mem_get(mctx, r1.length);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(r2.base != NULL);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews r2.length = r1.length;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews memcpy(r2.base, r1.base, r1.length);
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews dns_name_fromregion(name, &r2);
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * This is in bin/tests/wire_test.c, but should be in a debugging library.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsextern dns_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsprintmessage(dns_message_t *);
dd14c953a8a42b60ea86a2a630529014fc3d14ddMark Andrews
dd14c953a8a42b60ea86a2a630529014fc3d14ddMark Andrewsdns_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsresolve_packet(isc_mem_t *mctx, dns_db_t *, dns_message_t *, isc_buffer_t *);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsdns_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsresolve_packet(isc_mem_t *mctx, dns_db_t *db, dns_message_t *query,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_buffer_t *target)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews{
3398334b3acda24b086957286288ca9852662b12Automatic Updater dns_message_t *message;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_result_t result;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_name_t *name, name2;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_rdataset_t *rds, rdataset;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_dbnode_t *node;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_message_create(mctx, &message, DNS_MESSAGE_INTENT_RENDER);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECKRESULT(result, "dns_message_create failed");
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews message->id = query->id;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews message->rcode = dns_rcode_noerror;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews message->flags = query->flags;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews message->flags |= DNS_MESSAGEFLAG_QR;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews /*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * XXX This is a total and disgusting hack. We need a way to add
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * a copy of a rdataset and a name to the new message, but for now
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * I'll just steal the one from the existing query message, and
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * make certain the query is not destroyed before our message is.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_message_firstname(query, DNS_SECTION_QUESTION);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (result != DNS_R_SUCCESS)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews name = NULL;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_message_currentname(query, DNS_SECTION_QUESTION, &name);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews rds = ISC_LIST_HEAD(name->list);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (rds == NULL)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (DNS_R_UNEXPECTED);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_message_addname(message, name, DNS_SECTION_QUESTION);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = printmessage(message);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews INSIST(result == DNS_R_SUCCESS); /* XXX not in a real server */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews /*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * Pull the name out of the database.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews if (!dns_name_issubdomain(name, dns_db_origin(db))) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews message->rcode = dns_rcode_nxdomain;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews goto render;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_name_init(&name2, NULL);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_name_clone(name, &name2);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews node = NULL;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_db_findnode(db, &name2, ISC_FALSE, &node);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (result == DNS_R_NOTFOUND) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews message->flags |= DNS_MESSAGEFLAG_AA;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews message->rcode = dns_rcode_nxdomain;
126dce8ebf94ba4084befd82dd75e19b0c1d3f69Automatic Updater goto render;
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews }
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews if (result != DNS_R_SUCCESS) {
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews message->rcode = dns_rcode_servfail;
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews printf("Foo\n");
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews goto render;
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews }
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews dns_rdataset_init(&rdataset);
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews result = dns_db_findrdataset(db, node, NULL, rds->type, 0, &rdataset);
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews dns_db_detachnode(db, &node);
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews if (result == DNS_R_NOTFOUND) {
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews message->flags |= DNS_MESSAGEFLAG_AA;
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews message->rcode = dns_rcode_nxdomain;
126dce8ebf94ba4084befd82dd75e19b0c1d3f69Automatic Updater goto render;
e7ba4d8dc4559ff47f7f8298dad1469275ed0f1eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (result != DNS_R_SUCCESS) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews message->rcode = dns_rcode_servfail;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews printf("Foo2\n");
554d22d2deb8889bb16434176b5716ab79d15c50Mark Andrews goto render;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews ISC_LIST_APPEND(name2.list, &rdataset, link);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_message_addname(message, &name2, DNS_SECTION_ANSWER);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews message->flags |= DNS_MESSAGEFLAG_AA;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews render:
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_message_renderbegin(message, target);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (result != DNS_R_SUCCESS)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_message_rendersection(message, DNS_SECTION_QUESTION,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews 0, 0);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (result != DNS_R_SUCCESS)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_message_rendersection(message, DNS_SECTION_ANSWER,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews 0, 0);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (result != DNS_R_SUCCESS)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_message_rendersection(message, DNS_SECTION_AUTHORITY,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews 0, 0);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (result != DNS_R_SUCCESS)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_message_rendersection(message, DNS_SECTION_ADDITIONAL,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews 0, 0);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (result != DNS_R_SUCCESS)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_message_rendersection(message, DNS_SECTION_OPT,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews 0, 0);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (result != DNS_R_SUCCESS)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_message_rendersection(message, DNS_SECTION_TSIG,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews 0, 0);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (result != DNS_R_SUCCESS)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_message_renderend(message);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_message_destroy(&message);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (DNS_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * Process the wire format message given in r, and return a new packet to
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * transmit.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews *
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * Return of DNS_R_SUCCESS means r->base is a newly allocated region of
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * memory, and r->length is its length. The actual for-transmit packet
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * begins at (r->length + reslen) to reserve (reslen) bytes at the front
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * of the packet for transmission specific details.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
3398334b3acda24b086957286288ca9852662b12Automatic Updaterstatic dns_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsdispatch(isc_mem_t *mctx, isc_region_t *rxr, unsigned int reslen)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews{
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews char t[512];
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_buffer_t source;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_buffer_t target;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_result_t result;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_region_t txr;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_message_t *message;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews /*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * Set up the input buffer from the contents of the region passed
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * to us.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_buffer_init(&source, rxr->base, rxr->length,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews ISC_BUFFERTYPE_BINARY);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_buffer_add(&source, rxr->length);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_message_create(mctx, &message, DNS_MESSAGE_INTENT_PARSE);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (CHECKRESULT(result, "dns_message_create failed")) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_message_parse(message, &source);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (CHECKRESULT(result, "dns_message_parsed failed")) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_message_destroy(&message);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECKRESULT(result, "dns_message_parse failed");
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = printmessage(message);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (CHECKRESULT(result, "printmessage failed")) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_message_destroy(&message);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_buffer_init(&target, t, sizeof(t), ISC_BUFFERTYPE_BINARY);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = resolve_packet(mctx, db, message, &target);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (result != DNS_R_SUCCESS) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_message_destroy(&message);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews /*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * Copy the reply out, adjusting for reslen
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_buffer_used(&target, &txr);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews txr.base = isc_mem_get(mctx, txr.length + reslen);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (txr.base == NULL) {
dd14c953a8a42b60ea86a2a630529014fc3d14ddMark Andrews dns_message_destroy(&message);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (DNS_R_NOMEMORY);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews memcpy(txr.base + reslen, t + reslen, txr.length);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews rxr->base = txr.base;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews rxr->length = txr.length + reslen;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews printf("Base == %p, length == %u\n", txr.base, txr.length);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews fflush(stdout);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (want_stats)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_mem_stats(mctx, stdout);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_message_destroy(&message);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (DNS_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsint
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsmain(int argc, char *argv[])
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews{
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_taskmgr_t *manager = NULL;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews unsigned int workers;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_socketmgr_t *socketmgr;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_socket_t *so0, *so1;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_sockaddr_t sockaddr;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews unsigned int addrlen;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews udp_listener_t *ludp;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews tcp_listener_t *ltcp;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_name_t base, *origin;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews int ch;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews char basetext[1000];
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_rdatatype_t type = 2;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_result_t result;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#if 0 /* brister */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_cfgctx_t *configctx = NULL;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews const char *conffile = "/etc/named.conf"; /* XXX hardwired */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#endif
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews /*+ XXX */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews strcpy(basetext, "");
3398334b3acda24b086957286288ca9852662b12Automatic Updater while ((ch = getopt(argc, argv, "z:t:s")) != -1) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews switch (ch) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews case 'z':
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews strcpy(basetext, optarg);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews break;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews case 't':
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews type = atoi(optarg);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews break;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews case 's':
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews want_stats = ISC_TRUE;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews break;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews argc -= optind;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews argv += optind;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (argc < 1) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews fprintf(stderr, "usage: named filename\n");
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews exit(1);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews /*- XXX */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews memset(&sockaddr, 0, sizeof(sockaddr));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews sockaddr.type.sin.sin_port = htons(5544);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews addrlen = sizeof(struct sockaddr_in);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews workers = 2;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews printf("%d workers\n", workers);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#if 0 /* brister */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews parser_init();
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(parse_configuration(conffile, mctx, &configctx) ==
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#endif
3398334b3acda24b086957286288ca9852662b12Automatic Updater
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews /*+ XXX */
3398334b3acda24b086957286288ca9852662b12Automatic Updater if (strcmp(basetext, "") == 0)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews strcpy(basetext, "vix.com.");
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews makename(mctx, basetext, &base, NULL);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews db = NULL;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_db_create(mctx, "rbt", &base, ISC_FALSE, 1, 0, NULL,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews &db);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(result == DNS_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews origin = &base;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews printf("loading %s\n", argv[0]);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = dns_db_load(db, argv[0]);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (result != DNS_R_SUCCESS) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews printf("couldn't load master file: %s\n",
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_result_totext(result));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews exit(1);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews /*- XXX */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &manager) ==
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews /*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * Open up a database.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews socketmgr = NULL;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews /*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * open up a UDP socket
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews so0 = NULL;
3398334b3acda24b086957286288ca9852662b12Automatic Updater memset(&sockaddr, 0, sizeof(sockaddr));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews sockaddr.type.sin.sin_family = AF_INET;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews sockaddr.type.sin.sin_port = htons(5544);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews addrlen = sizeof(struct sockaddr_in);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(isc_socket_create(socketmgr, isc_socket_udp, &so0) ==
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(isc_socket_bind(so0, &sockaddr,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews (int)addrlen) == ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews ludp = udp_listener_allocate(mctx, workers);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(udp_listener_start(ludp, so0, manager,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews workers, workers, 0,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dispatch) == ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (want_stats)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_mem_stats(mctx, stdout);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews /*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * open up a TCP socket
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews so1 = NULL;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews memset(&sockaddr, 0, sizeof(sockaddr));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews sockaddr.type.sin.sin_family = AF_INET;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews sockaddr.type.sin.sin_port = htons(5544);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews addrlen = sizeof(struct sockaddr_in);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(isc_socket_create(socketmgr, isc_socket_tcp, &so1) ==
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(isc_socket_bind(so1, &sockaddr,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews (int)addrlen) == ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews ltcp = tcp_listener_allocate(mctx, workers);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews RUNTIME_CHECK(tcp_listener_start(ltcp, so1, manager,
3398334b3acda24b086957286288ca9852662b12Automatic Updater workers, workers, 0,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dispatch) == ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (want_stats)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_mem_stats(mctx, stdout);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews /*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * XXX Need to set up a condition variable here, and wait on it.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * For now, just semi-busy loop.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews for (;;)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews sleep(10);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews printf("Destroying socket manager\n");
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_socketmgr_destroy(&socketmgr);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews printf("Destroying task manager\n");
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_taskmgr_destroy(&manager);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
3398334b3acda24b086957286288ca9852662b12Automatic Updater if (want_stats)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_mem_stats(mctx, stdout);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_mem_destroy(&mctx);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (0);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews