mdig.c revision 832f5803f69f4548ba3777f8b5741768bbbf5f75
9bff67898d55cddfcec9ce30cc2b1bb6211ec691David Lawrence * Copyright (C) 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence * This Source Code Form is subject to the terms of the Mozilla Public
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence * License, v. 2.0. If a copy of the MPL was not distributed with this
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence * file, You can obtain one at http://mozilla.org/MPL/2.0/.
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence if ((x) != ISC_R_SUCCESS) { \
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence fprintf(stderr, "mdig: %s failed with %s\n", \
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence#define RUNCHECK(x) RUNTIME_CHECK((x) == ISC_R_SUCCESS)
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence#define ADD_STRING(b, s) { \
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence if (strlen(s) >= isc_buffer_availablelength(b)) \
f8a95eb9127a97e81ad4f1295a9d1abce993ef63David Lawrencestatic const char *batchname;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_boolean_t display_short_form = ISC_FALSE;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_boolean_t display_headers = ISC_TRUE;
f8a95eb9127a97e81ad4f1295a9d1abce993ef63David Lawrencestatic isc_boolean_t display_comments = ISC_TRUE;
f8a95eb9127a97e81ad4f1295a9d1abce993ef63David Lawrencestatic isc_boolean_t display_rrcomments = ISC_TRUE;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_boolean_t display_ttlunits = ISC_TRUE;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_boolean_t display_class = ISC_TRUE;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_boolean_t display_crypto = ISC_TRUE;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_boolean_t display_multiline = ISC_FALSE;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_boolean_t display_question = ISC_TRUE;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_boolean_t display_answer = ISC_TRUE;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_boolean_t display_authority = ISC_TRUE;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_boolean_t display_additional = ISC_TRUE;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_boolean_t display_unknown_format = ISC_FALSE;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_boolean_t continue_on_error = ISC_FALSE;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic isc_uint32_t display_splitwidth = 0xffffffff;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencestatic int onfly = 0;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence char textname[MXNAME]; /*% Name we're going to be looking up */
static const char * const opcodetext[] = {
static const char * const rcodetext[] = {
const char *consttext;
char *deconsttext;
} totext;
unsigned int parseflags = 0;
unsigned int styleflags = 0;
if (continue_on_error)
goto cleanup;
if (besteffort) {
if (display_comments)
if (display_rrcomments)
if (display_ttlunits)
if (!display_ttl)
if (!display_class)
if (!display_crypto)
if (display_multiline) {
flags = 0;
if (!display_headers) {
if (!display_comments)
if (display_headers) {
goto repopulate_buffer;
goto cleanup;
goto buftoosmall;
goto buftoosmall;
} else if (display_answer) {
unsigned int answerstyleflags = 0;
if (!display_crypto)
&name);
&rdata,
NULL,
goto buftoosmall;
goto buftoosmall;
goto buftoosmall;
goto buftoosmall;
result =
goto buftoosmall;
result =
goto buftoosmall;
if (--onfly == 0)
static isc_result_t
unsigned int options;
onfly++;
unsigned int flags;
isc_buffer_t b;
isc_buffer_putuint8(&b, 0);
if (addrl > 0)
(unsigned)addrl);
isc_buffer_t b;
options = 0;
if (tcp_mode)
return ISC_R_SUCCESS;
if (onfly == 0)
ISC_PLATFORM_NORETURN_PRE static void
usage(void) {
stderr);
stderr);
help(void) {
stdout);
stdout);
char *res;
return (res);
ISC_PLATFORM_NORETURN_PRE static void
static isc_result_t
isc_uint32_t n;
return (result);
*uip = n;
return (ISC_R_SUCCESS);
static isc_result_t
const char *desc) {
static isc_result_t
const char *desc) {
static unsigned char ednsoptscnt = 0;
isc_buffer_t b;
char *buf;
ednsoptscnt++;
static isc_result_t
netmask = 0;
if (!parsed)
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_NOSPACE);
*p += len;
return (ISC_R_SUCCESS);
static isc_result_t
int len;
unsigned int options = 0;
if (ip6_int)
char *p = reverse;
size_t n;
#define FULLCHECK(A) \
goto invalid_option; \
#define FULLCHECK2(A, B) \
goto invalid_option; \
#define GLOBAL() \
if (!global) \
goto global_option; \
switch (cmd[0]) {
goto invalid_option;
GLOBAL();
GLOBAL();
GLOBAL();
goto invalid_option;
GLOBAL();
goto need_value;
if (!state)
goto invalid_option;
goto invalid_option;
goto invalid_option;
GLOBAL();
GLOBAL();
GLOBAL();
sizeof(hexcookie));
if (n >= sizeof(hexcookie))
goto invalid_option;
GLOBAL();
goto invalid_option;
GLOBAL();
if (!state) {
goto need_value;
goto invalid_option;
if (!state) {
result);
if (!state) {
result);
if (!state) {
goto invalid_option;
goto invalid_option;
goto invalid_option;
goto invalid_option;
GLOBAL();
GLOBAL();
goto need_value;
if (!state)
goto invalid_option;
goto invalid_option;
GLOBAL();
goto invalid_option;
GLOBAL();
if (state) {
GLOBAL();
goto invalid_option;
if (!state) {
display_splitwidth = 0;
if (display_splitwidth)
goto need_value;
if (!state) {
goto invalid_option;
GLOBAL();
goto need_value;
if (!state)
goto invalid_option;
goto need_value;
if (!state)
goto invalid_option;
GLOBAL();
GLOBAL();
goto invalid_option;
goto invalid_option;
goto invalid_option;
goto need_value;
if (!state)
goto invalid_option;
goto invalid_option;
GLOBAL();
usage();
static isc_boolean_t
char opt;
const char *value;
char *hash;
switch (opt) {
GLOBAL();
if (have_ipv4) {
return (ISC_FALSE);
GLOBAL();
if (have_ipv6) {
return (ISC_FALSE);
help();
exit(0);
exit(0);
return (ISC_FALSE);
goto invalid_option;
switch (opt) {
GLOBAL();
srcport = 0;
return (value_from_next);
return (value_from_next);
return (value_from_next);
GLOBAL();
return (value_from_next);
return (value_from_next);
return (value_from_next);
usage();
usage();
return (ISC_FALSE);
static struct query *
return query;
int rc;
char **rv;
char *option;
switch (option[0]) {
int bargc;
int rc;
char **rv;
char *input;
if (!is_batchfile) {
if (is_batchfile) {
rc--;
rv++;
rc--;
rv++;
if (setname) {
bargc++;
int ns;
ns = 0;
if (have_ipv4) {
&requestmgr));
(void)isc_app_run();