builtin.c revision 55cfbf322d6051d7cf5c0ec4998aab9291dfee39
/*
* Copyright (C) 2004, 2005, 2007, 2009-2015 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2001-2003 Internet Software Consortium.
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: builtin.c,v 1.26 2012/01/21 19:44:18 each Exp $ */
/*! \file
* \brief
* The built-in "version", "hostname", "id", "authors" and "empty" databases.
*/
#include <config.h>
#include <string.h>
#include <stdio.h>
/*
* We can't use function pointers as the db_data directly
* because ANSI C does not guarantee that function pointers
* can safely be cast to void pointers and back.
*/
struct builtin {
char *server;
char *contact;
};
static dns_sdbimplementation_t *builtin_impl;
static dns_sdbimplementation_t *dns64_impl;
/*
* Pre computed HEX * 16 or 1 table.
*/
static const unsigned char hex16[256] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*00*/
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*10*/
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*20*/
0, 16, 32, 48, 64, 80, 96,112,128,144, 1, 1, 1, 1, 1, 1, /*30*/
1,160,176,192,208,224,240, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*40*/
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*50*/
1,160,176,192,208,224,240, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*60*/
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*70*/
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*80*/
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*90*/
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*A0*/
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*B0*/
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*C0*/
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*D0*/
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*E0*/
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 /*F0*/
};
const unsigned char decimal[] = "0123456789";
static size_t
size_t i, j = 0;
for (i = 0; i < 4U; i++) {
unsigned char c = v[start++];
if (start == 7U)
start++;
if (c > 99) {
rdata[j++] = 3;
} else if (c > 9) {
rdata[j++] = 2;
} else {
rdata[j++] = 1;
}
}
return (j + 14);
}
static isc_result_t
{
unsigned char v[16], n;
unsigned int i;
unsigned char rdata[sizeof("123.123.123.123.in-addr.arpa.")];
unsigned char *ndata;
/*
* The combined length of the zone and name is 74.
*
* The minimum zone length is 10 ((3)ip6(4)arpa(0)).
*
* The length of name should always be even as we are expecting
* a series of nibbles.
*/
return (ISC_R_NOTFOUND);
/*
* We assume the zone name is well formed.
*/
/*
* XXXMPA We could check the dns64 suffix here if we need to.
*/
/*
* Check that name is a series of nibbles.
* Compute the byte values that correspond to the nibbles as we go.
*
* Shift the final result 4 bits, by setting 'i' to 1, if we if we
* have a odd number of nibbles so that "must be zero" tests below
* are byte aligned and we correctly return ISC_R_NOTFOUND or
* ISC_R_SUCCESS. We will not generate a CNAME in this case.
*/
j = nlen;
memset(v, 0, sizeof(v));
while (j != 0U) {
INSIST((i/2) < sizeof(v));
if (ndata[0] != 1)
return (ISC_R_NOTFOUND);
if (n == 1)
return (ISC_R_NOTFOUND);
v[i/2] = n | (v[i/2]>>4);
j -= 2;
ndata += 2;
i++;
}
/*
* If we get here then we know name only consisted of nibbles.
* Now we need to determine if the name exists or not and whether
* it corresponds to a empty node in the zone or there should be
* a CNAME.
*/
switch (zlen) {
/*
* The nibbles that map to this byte must be zero for 'name'
* to exist in the zone.
*/
return (ISC_R_NOTFOUND);
/*
* If the total length is not 74 then this is a empty node
* so return success.
*/
return (ISC_R_SUCCESS);
break;
/*
* The nibbles that map to this byte must be zero for 'name'
* to exist in the zone.
*/
return (ISC_R_NOTFOUND);
/*
* If the total length is not 74 then this is a empty node
* so return success.
*/
return (ISC_R_SUCCESS);
break;
/*
* The nibbles that map to this byte must be zero for 'name'
* to exist in the zone.
*/
return (ISC_R_NOTFOUND);
/*
* If the total length is not 74 then this is a empty node
* so return success.
*/
return (ISC_R_SUCCESS);
break;
/*
* The nibbles that map to this byte must be zero for 'name'
* to exist in the zone.
*/
return (ISC_R_NOTFOUND);
/*
* If the total length is not 74 then this is a empty node
* so return success.
*/
return (ISC_R_SUCCESS);
break;
/*
* The nibbles that map to this byte must be zero for 'name'
* to exist in the zone.
*/
return (ISC_R_NOTFOUND);
/*
* If the total length is not 74 then this is a empty node
* so return success.
*/
return (ISC_R_SUCCESS);
break;
/*
* If the total length is not 74 then this is a empty node
* so return success.
*/
return (ISC_R_SUCCESS);
break;
default:
/*
* This should never be reached unless someone adds a
* zone declaration with this internal type to named.conf.
*/
return (ISC_R_NOTFOUND);
}
}
static isc_result_t
{
else
return (ISC_R_NOTFOUND);
}
static isc_result_t
{
else
}
static isc_result_t
unsigned char buf[256];
if (len > 255)
}
static isc_result_t
if (ns_g_server->version_set) {
return (ISC_R_SUCCESS);
else
} else {
}
}
static isc_result_t
if (ns_g_server->hostname_set) {
return (ISC_R_SUCCESS);
else
} else {
char buf[256];
if (result != ISC_R_SUCCESS)
return (result);
}
}
static isc_result_t
const char **p;
static const char *authors[] = {
"Mark Andrews",
"Curtis Blackburn",
"James Brister",
"Ben Cottrell",
"John H. DuBois III",
"Francis Dupont",
"Michael Graff",
"Andreas Gustafsson",
"Bob Halley",
"Evan Hunt",
"JINMEI Tatuya",
"Witold Krecicki",
"David Lawrence",
"Scott Mann",
"Danny Mayer",
"Damien Neil",
"Matt Nelson",
"Jeremy C. Reed",
"Michael Sawyer",
"Brian Wellington",
};
/*
* If a version string is specified, disable the authors.bind zone.
*/
if (ns_g_server->version_set)
return (ISC_R_SUCCESS);
if (result != ISC_R_SUCCESS)
return (result);
}
return (ISC_R_SUCCESS);
}
static isc_result_t
if (ns_g_server->server_usehostname) {
char buf[256];
if (result != ISC_R_SUCCESS)
return (result);
}
return (ISC_R_SUCCESS);
else
}
static isc_result_t
return (ISC_R_SUCCESS);
}
static isc_result_t
return (ISC_R_SUCCESS);
}
static isc_result_t
const char *contact = "hostmaster";
const char *server = "@";
if (b == &empty_builtin) {
server = ".";
contact = ".";
} else {
}
if (result != ISC_R_SUCCESS)
return (ISC_R_FAILURE);
if (result != ISC_R_SUCCESS)
return (ISC_R_FAILURE);
return (ISC_R_SUCCESS);
}
static isc_result_t
void *driverdata, void **dbdata)
{
if (argc != 3)
return (DNS_R_SYNTAX);
} else if (argc != 1)
return (DNS_R_SYNTAX);
*dbdata = &version_builtin;
*dbdata = &hostname_builtin;
*dbdata = &authors_builtin;
*dbdata = &id_builtin;
char *server;
char *contact;
/*
* We don't want built-in zones to fail. Fallback to
* the static configuration if memory allocation fails.
*/
*dbdata = &empty_builtin;
else
*dbdata = &dns64_builtin;
} else {
sizeof (empty_builtin));
else
sizeof (empty_builtin));
}
} else
return (ISC_R_NOTIMPLEMENTED);
return (ISC_R_SUCCESS);
}
static void
/*
* Don't free the static versions.
*/
return;
isc_mem_put(ns_g_mctx, b, sizeof (*b));
}
static dns_sdbmethods_t builtin_methods = {
NULL, /* allnodes */
};
static dns_sdbmethods_t dns64_methods = {
NULL,
NULL, /* allnodes */
};
ns_builtin_init(void) {
== ISC_R_SUCCESS);
== ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
}
void
ns_builtin_deinit(void) {
}