server.c revision 1b9d5f39251b89ccf8bd6c1c31a7a8706e267ce6
7d32c065c7bb56f281651ae3dd2888f32ce4f1d9Bob Halley * Copyright (C) 1999 Internet Software Consortium.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * Permission to use, copy, modify, and distribute this software for any
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * purpose with or without fee is hereby granted, provided that the above
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * copyright notice and this permission notice appear in all copies.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews printf("%s: %s\n", (msg), dns_result_totext(result));
d981ca645597116d227a48bf37cc5edc061c854dBob Halleymakename(isc_mem_t *mctx, char *text, dns_name_t *name, dns_name_t *origin) {
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews char b[255];
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_buffer_init(&source, text, len, ISC_BUFFERTYPE_TEXT);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews isc_buffer_init(&target, b, sizeof b, ISC_BUFFERTYPE_BINARY);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews result = dns_name_fromtext(name, &source, origin, ISC_FALSE, &target);
52637f592f705ca93fadc218e403fd55e8ce4aeaMark Andrews * This is in bin/tests/wire_test.c, but should be in a debugging library.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrewsresolve_packet(isc_mem_t *mctx, dns_db_t *, dns_message_t *, isc_buffer_t *);
940e4ef72b64a8a82a1038fdf08b324eec6e43a9Michael Graffresolve_packet(isc_mem_t *mctx, dns_db_t *db, dns_message_t *query,
f7b99290c31abeb20c55fc55391510450ce60423Mark Andrews result = dns_message_create(mctx, &message, DNS_MESSAGE_INTENT_RENDER);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews CHECKRESULT(result, "dns_message_create failed");
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * XXX This is a total and disgusting hack. We need a way to add
7c0539bea56022274da04263eb41fbb5b8835c38Mark Andrews * a copy of a rdataset and a name to the new message, but for now
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * I'll just steal the one from the existing query message, and
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * make certain the query is not destroyed before our message is.
d981ca645597116d227a48bf37cc5edc061c854dBob Halley result = dns_message_firstname(query, DNS_SECTION_QUESTION);
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson dns_message_currentname(query, DNS_SECTION_QUESTION, &name);
f7b99290c31abeb20c55fc55391510450ce60423Mark Andrews dns_message_addname(message, name, DNS_SECTION_QUESTION);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews INSIST(result == DNS_R_SUCCESS); /* XXX not in a real server */
940e4ef72b64a8a82a1038fdf08b324eec6e43a9Michael Graff * Pull the name out of the database.
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews if (!dns_name_issubdomain(name, dns_db_origin(db))) {
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews result = dns_db_findnode(db, &name2, ISC_FALSE, &node);
940e4ef72b64a8a82a1038fdf08b324eec6e43a9Michael Graff result = dns_db_findrdataset(db, node, NULL, rds->type, 0, &rdataset);
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff dns_message_addname(message, &name2, DNS_SECTION_ANSWER);
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson result = dns_message_renderbegin(message, target);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley result = dns_message_rendersection(message, DNS_SECTION_QUESTION,
940e4ef72b64a8a82a1038fdf08b324eec6e43a9Michael Graff result = dns_message_rendersection(message, DNS_SECTION_ANSWER,
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley result = dns_message_rendersection(message, DNS_SECTION_AUTHORITY,
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley result = dns_message_rendersection(message, DNS_SECTION_ADDITIONAL,
return (result);
return (result);
return (DNS_R_SUCCESS);
static dns_result_t
return (result);
return (result);
return (result);
return (result);
return (DNS_R_NOMEMORY);
if (want_stats)
return (DNS_R_SUCCESS);
unsigned int workers;
unsigned int addrlen;
int ch;
switch (ch) {
parser_init();
&db);
if (want_stats)
if (want_stats)
if (want_stats)