/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-1999 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 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.
*/
#ifndef lint
#endif
/* Import. */
#include "port_before.h"
#include <isc/assertions.h>
#include <errno.h>
#include <resolv.h>
#include <string.h>
#include <ctype.h>
#include "port_after.h"
#ifdef SPRINTF_CHAR
#else
#endif
/* Forward. */
/* Macros. */
#define T(x) \
do { \
if ((x) < 0) \
return (-1); \
} while (0)
static const char base32hex[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUV=0123456789abcdefghijklmnopqrstuv";
/* Public. */
/*%
* Convert an RR to presentation format.
*
* return:
*\li Number of characters written to buf, or -1 (check errno).
*/
int
{
int n;
return (n);
}
/*%
* Convert the fields of an RR into presentation format.
*
* return:
*\li Number of characters written to buf, or -1 (check errno).
*/
int
{
int spaced = 0;
const char *comment;
int len, x;
/*
* Owner.
*/
} else {
if (*name == '\0') {
goto root;
} else if (len == 0) {
} else {
/* Origin not used or not root, and no trailing dot? */
root:
len++;
}
}
}
/*
* TTL, Class, Type.
*/
/*
* RData.
*/
switch (type) {
case ns_t_a:
goto formerr;
break;
case ns_t_cname:
case ns_t_mb:
case ns_t_mg:
case ns_t_mr:
case ns_t_ns:
case ns_t_ptr:
case ns_t_dname:
break;
case ns_t_hinfo:
case ns_t_isdn:
/* First word. */
if (len == 0)
goto formerr;
/* Second word, optional in ISDN records. */
break;
if (len == 0)
goto formerr;
break;
case ns_t_soa: {
u_long t;
/* Server name. */
/* Administrator name. */
spaced = 0;
goto formerr;
/* Serial number. */
spaced = 0;
/* Refresh interval. */
spaced = 0;
/* Retry interval. */
spaced = 0;
/* Expiry. */
spaced = 0;
/* Minimum TTL. */
break;
}
case ns_t_mx:
case ns_t_afsdb:
case ns_t_rt:
case ns_t_kx: {
u_int t;
goto formerr;
/* Priority. */
rdata += NS_INT16SZ;
/* Target. */
break;
}
case ns_t_px: {
u_int t;
goto formerr;
/* Priority. */
rdata += NS_INT16SZ;
/* Name1. */
/* Name2. */
break;
}
case ns_t_x25:
if (len == 0)
goto formerr;
break;
case ns_t_txt:
case ns_t_spf:
if (len == 0)
goto formerr;
}
break;
case ns_t_nsap: {
char t[2+255*3];
break;
}
case ns_t_aaaa:
goto formerr;
break;
case ns_t_loc: {
char t[255];
/* XXX protocol format checking? */
break;
}
case ns_t_naptr: {
char t[50];
goto formerr;
/* Order, Precedence. */
/* Flags. */
if (len == 0)
goto formerr;
/* Service. */
if (len == 0)
goto formerr;
/* Regexp. */
if (len < 0)
return (-1);
if (len == 0)
goto formerr;
/* Server. */
break;
}
case ns_t_srv: {
char t[50];
goto formerr;
/* Priority, Weight, Port. */
/* Server. */
break;
}
case ns_t_minfo:
case ns_t_rp:
/* Name1. */
/* Name2. */
break;
case ns_t_wks: {
int n, lcnt;
goto formerr;
/* Address. */
rdata += NS_INADDRSZ;
/* Protocol. */
/* Bit map. */
n = 0;
lcnt = 0;
do {
if (c & 0200) {
if (lcnt == 0) {
lcnt = 10;
spaced = 0;
}
lcnt--;
}
c <<= 1;
} while (++n & 07);
}
break;
}
case ns_t_key:
case ns_t_dnskey: {
const char *leader;
int n;
goto formerr;
/* Key flags, Protocol, Algorithm. */
/* Public key data. */
base64_key, sizeof base64_key);
if (len < 0)
goto formerr;
if (len > 15) {
leader = "\n\t\t";
spaced = 0;
} else
leader = " ";
for (n = 0; n < len; n += 48) {
}
if (len > 15)
break;
}
case ns_t_sig:
case ns_t_rrsig: {
const char *leader;
u_long t;
int n;
if (rdlen < 22U)
goto formerr;
/* Type covered, Algorithm, Label count, Original TTL. */
goto formerr;
/* Signature expiry. */
/* Time signed. */
/* Signature Footprint. */
/* Signer's name. */
/* Signature. */
base64_key, sizeof base64_key);
if (len > 15) {
leader = "\n\t\t";
spaced = 0;
} else
leader = " ";
if (len < 0)
goto formerr;
for (n = 0; n < len; n += 48) {
}
if (len > 15)
break;
}
case ns_t_nxt: {
int n, c;
/* Next domain name. */
/* Type bit map. */
for (c = 0; c < n*8; c++)
if (NS_NXT_BIT_ISSET(c, rdata)) {
}
break;
}
case ns_t_cert: {
int n;
unsigned int siz;
const char *leader;
}
else {
if (len < 0)
goto formerr;
else if (len > 15) {
leader = "\n\t\t";
spaced = 0;
}
else
leader = " ";
for (n = 0; n < len; n += 48) {
}
if (len > 15)
}
break;
}
case ns_t_tkey: {
/* KJD - need to complete this */
u_long t;
/* Algorithm name. */
/* Inception. */
/* Experation. */
/* Mode , Error, Key Size. */
/* Priority, Weight, Port. */
/* XXX need to dump key, print otherdata length & other data */
break;
}
case ns_t_tsig: {
/* BEW - need to complete this */
int n;
rdata += n; /*%< sig */
break;
}
case ns_t_a6: {
struct in6_addr a;
/* prefix length */
rdata++;
/* address suffix: provided only when prefix len != 128 */
if (pbit < 128) {
memset(&a, 0, sizeof(a));
}
/* prefix name: provided only when prefix len > 0 */
if (pbit == 0)
break;
break;
}
case ns_t_opt: {
break;
}
case ns_t_ds:
case ns_t_dlv:
case ns_t_sshfp: {
u_int t;
rdata += NS_INT16SZ;
} else
rdata++;
rdata++;
rdata++;
}
break;
}
case ns_t_nsec3:
case ns_t_nsec3param: {
u_int t, w, l, j, k, c;
rdata++;
rdata++;
rdata += NS_INT16SZ;
t = *rdata++;
if (t == 0) {
} else {
while (t-- > 0) {
rdata++;
}
}
if (type == ns_t_nsec3param)
break;
t = *rdata++;
while (t > 0) {
switch (t) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
default:
break;
}
if (t >= 5) {
rdata += 5;
t -= 5;
} else {
rdata += t;
t -= t;
}
}
w = *rdata++;
l = *rdata++;
for (j = 0; j < l; j++) {
if (rdata[j] == 0)
continue;
for (k = 0; k < 8; k++) {
if ((rdata[j] & (0x80 >> k)) == 0)
continue;
c = w * 256 + j * 8 + k;
}
}
rdata += l;
}
break;
}
case ns_t_nsec: {
u_int w, l, j, k, c;
w = *rdata++;
l = *rdata++;
for (j = 0; j < l; j++) {
if (rdata[j] == 0)
continue;
for (k = 0; k < 8; k++) {
if ((rdata[j] & (0x80 >> k)) == 0)
continue;
c = w * 256 + j * 8 + k;
}
}
rdata += l;
}
break;
}
case ns_t_dhcid: {
int n;
unsigned int siz;
const char *leader;
} else {
if (len < 0)
goto formerr;
else if (len > 15) {
leader = "\n\t\t";
spaced = 0;
}
else
leader = " ";
for (n = 0; n < len; n += 48) {
}
if (len > 15)
}
}
case ns_t_ipseckey: {
int n;
unsigned int siz;
const char *leader;
if (rdlen < 2)
goto formerr;
switch (rdata[1]) {
case 0:
case 3:
if (rdlen < 3)
goto formerr;
break;
case 1:
if (rdlen < 7)
goto formerr;
break;
case 2:
if (rdlen < 19)
goto formerr;
break;
default:
comment = "unknown IPSECKEY gateway type";
goto hexify;
}
rdata++;
rdata++;
rdata++;
switch (rdata[-2]) {
case 0:
break;
case 1:
rdata += 4;
break;
case 2:
rdata += 16;
break;
case 3:
break;
}
break;
} else {
if (len < 0)
goto formerr;
else if (len > 15) {
leader = "\n\t\t";
spaced = 0;
}
else
leader = " ";
for (n = 0; n < len; n += 48) {
}
if (len > 15)
}
}
case ns_t_hip: {
unsigned int siz;
rdata += NS_INT16SZ;
} else {
for (i = 0; i < hip_len; i++) {
rdata++;
}
if (len < 0)
goto formerr;
}
}
break;
}
default:
comment = "unknown RR type";
goto hexify;
}
comment = "RR format error";
hexify: {
int n, m;
char *p;
p = tmp;
p += SPRINTF((p, "\n\t"));
spaced = 0;
for (m = 0; m < n; m++)
if (n < 16) {
}
p = tmp;
p += SPRINTF((p, "; "));
for (m = 0; m < n; m++)
? rdata[m]
: '.';
rdata += n;
}
}
}
/* Private. */
/*%
* size_t
* prune_origin(name, origin)
* Find out if the name is at or under the current origin.
* return:
* Number of characters in name before start of origin,
* or length of name if origin does not match.
* notes:
* This function should share code with samedomain().
*/
static size_t
while (*name != '\0') {
while (*name != '\0') {
if (*name == '\\') {
name++;
/* XXX need to handle \nnn form. */
if (*name == '\0')
break;
} else if (*name == '.') {
name++;
break;
}
name++;
}
}
}
/*%
* int
* charstr(rdata, edata, buf, buflen)
* Format a <character-string> into the presentation buffer.
* return:
* Number of rdata octets consumed
* 0 for protocol format error
* -1 for output buffer error
* side effects:
* buffer is advanced on success.
*/
static int
goto enospc;
int n = *rdata;
rdata++;
while (n-- > 0) {
goto enospc;
goto enospc;
rdata++;
}
}
}
goto enospc;
*buflen = save_buflen;
return (-1);
}
static int
{
int n;
if (n < 0)
goto enospc; /*%< Guess. */
if (**buf == '\0') {
goto root;
} else if (newlen == 0U) {
/* Use "@" instead of name. */
goto enospc; /* No room for "@\0". */
} else {
/* No trailing dot. */
root:
goto enospc; /* No room for ".\0". */
}
}
*pp += n;
**buf = '\0';
return (newlen);
*buflen = save_buflen;
return (-1);
}
static void
}
static int
return (-1);
}
**buf = '\0';
return (0);
}
static int
int t;
spaced = 1;
} else {
*buflen = save_buflen;
return (-1);
}
spaced = 0;
}
return (spaced);
}
/*! \file */