builtin.c revision 736cbba9528aba0366dc77ac863c9c0d8d0b0842
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 2004, 2005, 2007, 2009-2012 Internet Systems Consortium, Inc. ("ISC")
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * Copyright (C) 2001-2003 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and/or distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * copyright notice and this permission notice appear in all copies.
54968ae88e50f65fd14d01651596a76434589dd8Automatic Updater * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * PERFORMANCE OF THIS SOFTWARE.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt/* $Id: builtin.c,v 1.25 2012/01/11 18:27:45 ckb Exp $ */
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * The built-in "version", "hostname", "id", "authors" and "empty" databases.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntstatic isc_result_t do_version_lookup(dns_sdblookup_t *lookup);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntstatic isc_result_t do_hostname_lookup(dns_sdblookup_t *lookup);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntstatic isc_result_t do_authors_lookup(dns_sdblookup_t *lookup);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntstatic isc_result_t do_id_lookup(dns_sdblookup_t *lookup);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntstatic isc_result_t do_empty_lookup(dns_sdblookup_t *lookup);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntstatic isc_result_t do_dns64_lookup(dns_sdblookup_t *lookup);
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * We can't use function pointers as the db_data directly
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * because ANSI C does not guarantee that function pointers
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * can safely be cast to void pointers and back.
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt isc_result_t (*do_lookup)(dns_sdblookup_t *lookup);
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntstatic builtin_t version_builtin = { do_version_lookup, NULL, NULL };
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntstatic builtin_t hostname_builtin = { do_hostname_lookup, NULL, NULL };
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntstatic builtin_t authors_builtin = { do_authors_lookup, NULL, NULL };
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntstatic builtin_t id_builtin = { do_id_lookup, NULL, NULL };
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntstatic builtin_t empty_builtin = { do_empty_lookup, NULL, NULL };
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Huntstatic builtin_t dns64_builtin = { do_dns64_lookup, NULL, NULL };
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Huntdns64_cname(const char *zone, const char *name, dns_sdblookup_t *lookup) {
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt const char *s;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt unsigned char v[16];
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt unsigned int i;
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt char reverse[sizeof("123.123.123.123.in-addr.arpa.")];
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * The sum the length of the relative name and the length of the zone
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * name for a IPv6 reverse lookup comes to 71.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * The reverse of 2001::10.0.0.1 (dns64 2001::/96) has a zone of
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.2.ip6.arpa"
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * and a name of "1.0.0.0.0.0.a.0". The sum of the lengths of these
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * two strings is 71.
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * The minimum length for a ip6.arpa zone name is 8.
75b8de87879ad017c9cd2ffc328e5d2391d16e99Evan Hunt * The length of name should always be odd as we are expecting
e11a0c114cdaf8f7e7832e9f1a011138248093a6Evan Hunt * a series of nibbles.
return (ISC_R_NOTFOUND);
j = nlen;
memset(v, 0, sizeof(v));
return (ISC_R_NOTFOUND);
return (ISC_R_NOTFOUND);
switch (zlen) {
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
* zone declaration with this internal type to named.conf.
return (ISC_R_NOTFOUND);
static isc_result_t
return (ISC_R_NOTFOUND);
static isc_result_t
static isc_result_t
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
static const char *authors[] = {
return (ISC_R_SUCCESS);
return (result);
return (ISC_R_SUCCESS);
static isc_result_t
return (result);
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_SUCCESS);
static isc_result_t
if (b == &empty_builtin) {
return (ISC_R_FAILURE);
return (ISC_R_FAILURE);
return (ISC_R_SUCCESS);
static isc_result_t
return (DNS_R_SYNTAX);
return (DNS_R_SYNTAX);
char *server;
char *contact;
sizeof (empty_builtin));
sizeof (empty_builtin));
return (ISC_R_NOTIMPLEMENTED);
return (ISC_R_SUCCESS);
ns_builtin_init(void) {
== ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
ns_builtin_deinit(void) {