/*
* Copyright (c) 1996, 1998 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.
*/
/*
* 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 Intel Corporation and
* its contributors.
*
* 4. Neither the name of Intel Corporation or its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY 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 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.
*
*/
#ifndef lint
#endif
/* Import. */
#include <assert.h>
#include <errno.h>
#include <resolv.h>
#include <string.h>
#include <ctype.h>
/* Forward. */
/* Macros. */
#define T(x) \
do { \
if ((ssize_t)(x) < 0) \
return (-1); \
} while (0)
/* Public. */
/*
* int
* ns_sprintrr(handle, rr, name_ctx, origin, buf, buflen)
* Convert an RR to presentation format.
* return:
* Number of characters written to buf, or -1 (check errno).
*/
int
{
int n;
return (n);
}
/*
* int
* ns_sprintrrf(msg, msglen, name, class, type, ttl, rdata, rdlen,
* name_ctx, origin, buf, buflen)
* Convert the fields of an RR into presentation format.
* return:
* Number of characters written to buf, or -1 (check errno).
*/
int
{
int spaced = 0;
const char *comment;
int x;
static char t[255*3];
/*
* Owner.
*/
} else {
if (len == 0) {
} else {
/* Origin not used and no trailing dot? */
len++;
}
}
}
/*
* TTL, Class, Type.
*/
/*
* RData.
*/
switch (type) {
case ns_t_a:
if (rdlen != NS_INADDRSZ)
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:
break;
case ns_t_hinfo:
case ns_t_isdn:
/* First word. */
if (len == 0)
goto formerr;
/* Second word. */
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: {
u_int t;
if (rdlen < NS_INT16SZ)
goto formerr;
/* Priority. */
rdata += NS_INT16SZ;
/* Target. */
break;
}
case ns_t_px: {
u_int t;
if (rdlen < NS_INT16SZ)
goto formerr;
/* Priority. */
rdata += NS_INT16SZ;
/* Name1. */
/* Name2. */
break;
}
case ns_t_x25:
if (len == 0)
goto formerr;
break;
case ns_t_txt:
if (len == 0)
goto formerr;
}
break;
case ns_t_nsap: {
break;
}
case ns_t_aaaa:
if (rdlen != NS_IN6ADDRSZ)
goto formerr;
break;
case ns_t_loc: {
/* XXX protocol format checking? */
break;
}
case ns_t_naptr: {
goto formerr;
/* Order, Precedence. */
/* Flags. */
if (len == 0)
goto formerr;
/* Service. */
if (len == 0)
goto formerr;
/* Regexp. */
return (-1);
if (len == 0)
goto formerr;
/* Server. */
break;
}
case ns_t_srv: {
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: {
const char *leader;
int n;
goto formerr;
/* Key flags, Protocol, Algorithm. */
/* Public key data. */
base64_key, sizeof base64_key);
goto formerr;
if (len > 15) {
leader = "\n\t\t";
spaced = 0;
} else
leader = " ";
for (n = 0; n < (int)len; n += 48) {
}
if (len > 15)
break;
}
case ns_t_sig: {
const char *leader;
u_long t;
int n;
if (rdlen < 22)
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 = " ";
goto formerr;
for (n = 0; n < (int)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;
}
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. */
/* No trailing dot. */
goto enospc; /* No room for ".\0". */
}
if (newlen == 0) {
/* Use "@" instead of name. */
goto enospc; /* No room for "@\0". */
}
*pp += n;
**buf = '\0';
return ((int)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);
}