/*
* Copyright (c) 1985
* The Regents of the University of California. All rights reserved.
*
* Portions copyright (c) 1999, 2000
* Intel Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by the University of
* California, Berkeley, Intel Corporation, and its contributors.
*
* 4. Neither the name of University, Intel Corporation, or their respective
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS, INTEL CORPORATION AND
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS,
* INTEL CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
* CORPORATION 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.
*/
/*
* Portions Copyright (c) 1995 by International Business Machines, Inc.
*
* International Business Machines, Inc. (hereinafter called IBM) grants
* permission under its copyrights to use, copy, modify, and distribute this
* Software with or without fee, provided that the above copyright notice and
* all paragraphs of this notice appear in all copies, and that the name of IBM
* not be used in connection with the marketing of any product incorporating
* the Software or modifications thereof, without specific, written prior
* permission.
*
* To the extent it has a right to do so, IBM grants an immunity from suit
* under its patents, if any, for the use, sale or manufacture of products to
* the extent that such products are used for performing Domain Name System
* granted for any product per se or for any other function of any product.
*
* THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
* DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
/*
* Portions Copyright (c) 1996 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#endif /* LIBC_SCCS and not lint */
#include <ctype.h>
#include <errno.h>
#include <math.h>
#include <netdb.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
extern const char *_res_opcodes[];
extern const char *_res_resultcodes[];
extern const char *_res_sectioncodes[];
/*
* Print the current options.
*/
void
if (!statp)
}
static void
/*
* Print answer records.
*/
return;
rrnum = 0;
for (;;) {
return;
}
ns_rr_name(rr),
else {
char *buf;
if (buf) {
if (n < 0) {
return;
}
}
}
rrnum++;
}
}
void
}
void
}
/*
* Print the contents of a query.
* This is intended to be primarily a debugging routine.
*/
void
return;
return;
}
/*
* Print header fields.
*/
";; ->>HEADER<<- opcode: %s, status: %s, id: %d\n",
}
}
}
/*
* Print the various sections.
*/
}
const u_char *
int n;
return (NULL);
if (name[0] == '\0')
else
return (cp + n);
}
const u_char *
}
/* Return a fully-qualified domain name from a compressed name (with
length supplied). */
const u_char *
int msglen,
char *name,
int namelen
)
{
int n, newlen;
return (NULL);
return (NULL);
else
}
return (cp + n);
}
/* XXX: the rest of these functions need to become length-limited, too. */
const u_char *
const u_char *n;
if (n == NULL)
return (NULL);
return (n);
}
/*
* Names of RR classes and qclasses. Classes and qclasses are the same, except
* that C_ANY is a qclass but not a class. (You can ask for records of class
* C_ANY, but you can't have any records of that class in the database.)
*/
{C_IN, "IN"},
{C_CHAOS, "CHAOS"},
{C_HS, "HS"},
{C_HS, "HESIOD"},
{C_ANY, "ANY"},
{C_NONE, "NONE"},
{C_IN, (char *)0}
};
/*
* Names of message sections.
*/
{ns_s_qd, "QUERY"},
{ns_s_an, "ANSWER"},
{ns_s_ns, "AUTHORITY"},
{ns_s_ar, "ADDITIONAL"},
{0, (char *)0}
};
{S_ZONE, "ZONE"},
{S_PREREQ, "PREREQUISITE"},
{S_UPDATE, "UPDATE"},
{S_ADDT, "ADDITIONAL"},
{0, (char *)0}
};
/*
* Names of RR types and qtypes. Types and qtypes are the same, except
* that T_ANY is a qtype but not a type. (You can ask for records of type
* T_ANY, but you can't have any records of that type in the database.)
*/
};
int
if (success)
*success = 1;
}
}
if (success)
*success = 0;
}
const char *
if (success)
*success = 1;
}
}
if (success)
*success = 0;
return (unname);
}
const char *
if (success)
*success = 1;
}
}
if (success)
*success = 0;
return (unname);
}
/*
* Return a string for the type.
*/
const char *
}
/*
* Return a string for the type.
*/
const char *
switch (opcode) {
case ns_o_update:
break;
default:
break;
}
}
/*
* Return a mnemonic for class.
*/
const char *
}
/*
* Return a mnemonic for an option
*/
const char *
switch (option) {
case RES_INIT: return "init";
case RES_DEBUG: return "debug";
case RES_AAONLY: return "aaonly(unimpl)";
case RES_USEVC: return "usevc";
case RES_PRIMARY: return "primry(unimpl)";
case RES_IGNTC: return "igntc";
case RES_RECURSE: return "recurs";
case RES_DEFNAMES: return "defnam";
case RES_STAYOPEN: return "styopn";
case RES_DNSRCH: return "dnsrch";
case RES_INSECURE1: return "insecure1";
case RES_INSECURE2: return "insecure2";
return (nbuf);
}
}
/*
* Return a mnemonic for a time to live.
*/
const char *
return (nbuf);
}
/*
* routines to convert between on-the-wire RR format and zone file format.
* by 60*60*1000 for that.
*/
1000000,10000000,100000000,1000000000};
static const char *
)
{
unsigned long val;
return (retbuf);
}
static u_int8_t
char **strptr
)
{
char *cp;
int exponent;
int mantissa;
cp++;
}
}
}
break;
if (mantissa > 9)
mantissa = 9;
return (retval);
}
static u_int32_t
char **latlonstrptr,
int *which
)
{
char *cp;
cp = *latlonstrptr;
cp++;
goto fndhemi;
cp++;
goto fndhemi;
cp++;
}
}
}
}
cp++;
cp++;
switch (*cp) {
case 'N': case 'n':
case 'E': case 'e':
+ secsfrac;
break;
case 'S': case 's':
case 'W': case 'w':
- secsfrac;
break;
default:
retval = 0; /* invalid value -- indicates error */
break;
}
switch (*cp) {
case 'N': case 'n':
case 'S': case 's':
break;
case 'E': case 'e':
case 'W': case 'w':
break;
default:
*which = 0; /* error */
break;
}
cp++; /* skip the hemisphere */
cp++;
cp++;
*latlonstrptr = cp;
return (retval);
}
/* converts a zone file representation in a string to an RDATA on-the-wire
* representation. */
int
const char *ascii,
)
{
case 3: /* 1 + 2, the only valid combination */
} else { /* some kind of brokenness */
return (0);
}
break;
default: /* we didn't get one of each */
return (0);
}
/* altitude */
if (*cp == '-') {
altsign = -1;
cp++;
}
if (*cp == '+')
cp++;
cp++;
}
}
}
cp++;
cp++;
goto defaults;
cp++;
cp++;
goto defaults;
cp++;
cp++;
goto defaults;
return (16); /* size of RR in octets */
}
/* takes an on-the-wire LOC RR and formats it in a human readable format. */
const char *
char *ascii
)
{
versionval = *cp++;
if (versionval) {
return (ascii);
}
altsign = -1;
} else {
altsign = 1;
}
if (latval < 0) {
northsouth = 'S';
} else
northsouth = 'N';
if (longval < 0) {
eastwest = 'W';
} else
eastwest = 'E';
"%d %.2d %.2d.%.3d %c %d %.2d %.2d.%.3d %c %d.%.2dm %sm %sm %sm",
return (ascii);
}
/* Return the number of DNS hierarchy levels in the name. */
int
/* XXX need to check for \. or use named's nlabels(). */
if (name[i] == '.')
count++;
}
/* don't count initial wildcard */
if (name[0] == '*')
if (count)
count--;
/* don't count the null label for root. */
/* if terminating '.' not found, must adjust */
/* count to include last label */
count++;
return (count);
}
/*
* Make dates expressed in seconds-since-Jan-1-1970 easy to read.
* SIG records are required to be printed like this, by the Secure DNS RFC.
*/
char *
return (output);
}