/*
* Copyright (C) 2000-2002, 2004-2017 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: check-tool.c,v 1.44 2011/12/22 07:32:39 each Exp $ */
/*! \file */
#include <config.h>
#include <stdio.h>
#ifdef _WIN32
#include <Winsock2.h>
#endif
#include "check-tool.h"
#include <dns/dbiterator.h>
#include <dns/fixedname.h>
#include <dns/rdataclass.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/rdatatype.h>
#ifndef CHECK_SIBLING
#endif
#ifndef CHECK_LOCAL
#endif
#ifdef HAVE_ADDRINFO
#ifdef HAVE_GETADDRINFO
#ifdef HAVE_GAISTRERROR
#define USE_GETADDRINFO
#endif
#endif
#endif
#define CHECK(r) \
do { \
result = (r); \
if (result != ISC_R_SUCCESS) \
goto cleanup; \
} while (0)
int debug = 0;
#if CHECK_LOCAL
#else
#endif
#if CHECK_SIBLING
#endif
unsigned int zone_options2 = 0;
/*
*/
{ "", 0 },
{ "client", 0 },
{ "network", 0 },
{ "update", 0 },
{ "queries", 0 },
{ "unmatched", 0 },
{ "update-security", 0 },
{ "query-errors", 0 },
{ "trust-anchor-telemetry", 0 },
{ NULL, 0 }
};
static void
}
static void
if (result != ISC_R_SUCCESS)
return;
}
if (result != ISC_R_SUCCESS)
return;
}
return;
if (result != ISC_R_SUCCESS)
}
static isc_boolean_t
return (ISC_FALSE);
if (result == ISC_R_SUCCESS)
return (ISC_TRUE);
return (ISC_FALSE);
}
static isc_boolean_t
{
#ifdef USE_GETADDRINFO
const char *type;
int result;
a->type == dns_rdatatype_a);
return (answer);
/*
* Turn off search.
*/
}
switch (result) {
case 0:
/*
* Work around broken getaddrinfo() implementations that
* fail to set ai_canonname on first entry.
*/
"is a CNAME '%s' (illegal)",
cur->ai_canonname);
/* XXX950 make fatal for 9.5.0 */
/* answer = ISC_FALSE; */
}
break;
case EAI_NONAME:
case EAI_NODATA:
#endif
"has no addresses records (A or AAAA)",
}
/* XXX950 make fatal for 9.5.0 */
return (ISC_TRUE);
default:
"getaddrinfo(%s) failed: %s",
}
return (ISC_TRUE);
}
/*
* Check that all glue records really exist.
*/
if (!dns_rdataset_isassociated(a))
goto checkaaaa;
result = dns_rdataset_first(a);
while (result == ISC_R_SUCCESS) {
dns_rdataset_current(a, &rdata);
continue;
break;
}
}
"extra GLUE A record (%s)",
/* XXX950 make fatal for 9.5.0 */
/* answer = ISC_FALSE; */
}
result = dns_rdataset_next(a);
}
if (!dns_rdataset_isassociated(aaaa))
goto checkmissing;
while (result == ISC_R_SUCCESS) {
continue;
break;
}
}
"extra GLUE AAAA record (%s)",
/* XXX950 make fatal for 9.5.0. */
/* answer = ISC_FALSE; */
}
}
/*
* Check that all addresses appear in the glue.
*/
case AF_INET:
rdataset = a;
type = "A";
break;
case AF_INET6:
type = "AAAA";
break;
default:
continue;
}
else
}
if (!match) {
"missing GLUE %s record (%s)",
/* XXX950 make fatal for 9.5.0. */
/* answer = ISC_FALSE; */
}
}
if (missing_glue)
}
return (answer);
#else
return (ISC_TRUE);
#endif
}
static isc_boolean_t
#ifdef USE_GETADDRINFO
int result;
/*
* Turn off search.
*/
}
switch (result) {
case 0:
/*
* Work around broken getaddrinfo() implementations that
* fail to set ai_canonname on first entry.
*/
if ((zone_options & DNS_ZONEOPT_WARNMXCNAME) != 0)
if ((zone_options & DNS_ZONEOPT_IGNOREMXCNAME) == 0) {
" is a CNAME '%s' "
"(illegal)",
cur->ai_canonname);
}
if (level == ISC_LOG_ERROR)
}
}
return (answer);
case EAI_NONAME:
case EAI_NODATA:
#endif
"has no addresses records (A or AAAA)",
}
/* XXX950 make fatal for 9.5.0. */
return (ISC_TRUE);
default:
"getaddrinfo(%s) failed: %s",
}
return (ISC_TRUE);
}
#else
return (ISC_TRUE);
#endif
}
static isc_boolean_t
#ifdef USE_GETADDRINFO
int result;
/*
* Turn off search.
*/
}
switch (result) {
case 0:
/*
* Work around broken getaddrinfo() implementations that
* fail to set ai_canonname on first entry.
*/
if ((zone_options & DNS_ZONEOPT_WARNSRVCNAME) != 0)
if ((zone_options & DNS_ZONEOPT_IGNORESRVCNAME) == 0) {
" (out of zone) is a "
"CNAME '%s' (illegal)",
cur->ai_canonname);
}
if (level == ISC_LOG_ERROR)
}
}
return (answer);
case EAI_NONAME:
case EAI_NODATA:
#endif
"has no addresses records (A or AAAA)",
}
/* XXX950 make fatal for 9.5.0. */
return (ISC_TRUE);
default:
"getaddrinfo(%s) failed: %s",
}
return (ISC_TRUE);
}
#else
return (ISC_TRUE);
#endif
}
&destination, 0) == ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
}
/*% scan the zone for oversize TTLs */
static isc_result_t
result == ISC_R_SUCCESS;
if (result == DNS_R_NEWORIGIN)
result == ISC_R_SUCCESS;
isc_buffer_t b;
isc_region_t r;
isc_buffer_usedregion(&b, &r);
"%s/%s TTL %d exceeds "
"maximum TTL %d",
}
}
if (result == ISC_R_NOMORE)
}
if (result == ISC_R_NOMORE)
dns_db_detach(&db);
return (result);
}
/*% load the zone */
{
if (debug)
if (docheckmx)
if (docheckns)
if (dochecksrv)
/*
* When loading map files we can't catch oversize TTLs during
* load, so we check for them here.
*/
}
}
return (result);
}
/*% dump the zone */
const isc_uint32_t rawversion)
{
const char *flags;
if (debug) {
else
}
if (result != ISC_R_SUCCESS) {
"file \"%s\" for writing\n", filename);
return (ISC_R_FAILURE);
}
}
(void)isc_stdio_close(output);
return (result);
}
#ifdef _WIN32
void
InitSockets(void) {
int err;
if (err != 0) {
exit(1);
}
}
void
DestroySockets(void) {
WSACleanup();
}
#endif