Deleted Added
sdiff udiff text old ( 156956 ) new ( 170244 )
full compact
1/*
2 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (c) 1996-1999 by Internet Software Consortium.
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
15 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef lint
19static const char rcsid[] = "$Id: ns_print.c,v 1.6.18.4 2005/04/27 05:01:09 sra Exp $";
20#endif
21#include <sys/cdefs.h>
22__FBSDID("$FreeBSD: head/lib/libc/nameser/ns_print.c 170244 2007-06-03 17:20:27Z ume $");
23
24/* Import. */
25
26#include "port_before.h"
27
28#include <sys/types.h>
29#include <sys/socket.h>
30

--- 40 unchanged lines hidden (view full) ---

71#define T(x) \
72 do { \
73 if ((x) < 0) \
74 return (-1); \
75 } while (0)
76
77/* Public. */
78
79/*%
80 * Convert an RR to presentation format.
81 *
82 * return:
83 *\li Number of characters written to buf, or -1 (check errno).
84 */
85int
86ns_sprintrr(const ns_msg *handle, const ns_rr *rr,
87 const char *name_ctx, const char *origin,
88 char *buf, size_t buflen)
89{
90 int n;
91
92 n = ns_sprintrrf(ns_msg_base(*handle), ns_msg_size(*handle),
93 ns_rr_name(*rr), ns_rr_class(*rr), ns_rr_type(*rr),
94 ns_rr_ttl(*rr), ns_rr_rdata(*rr), ns_rr_rdlen(*rr),
95 name_ctx, origin, buf, buflen);
96 return (n);
97}
98
99/*%
100 * Convert the fields of an RR into presentation format.
101 *
102 * return:
103 *\li Number of characters written to buf, or -1 (check errno).
104 */
105int
106ns_sprintrrf(const u_char *msg, size_t msglen,
107 const char *name, ns_class class, ns_type type,
108 u_long ttl, const u_char *rdata, size_t rdlen,
109 const char *name_ctx, const char *origin,
110 char *buf, size_t buflen)
111{

--- 536 unchanged lines hidden (view full) ---

648 }
649
650 case ns_t_tsig: {
651 /* BEW - need to complete this */
652 int n;
653
654 T(len = addname(msg, msglen, &rdata, origin, &buf, &buflen));
655 T(addstr(" ", 1, &buf, &buflen));
656 rdata += 8; /*%< time */
657 n = ns_get16(rdata); rdata += INT16SZ;
658 rdata += n; /*%< sig */
659 n = ns_get16(rdata); rdata += INT16SZ; /*%< original id */
660 sprintf(buf, "%d", ns_get16(rdata));
661 rdata += INT16SZ;
662 addlen(strlen(buf), &buf, &buflen);
663 break;
664 }
665
666 case ns_t_a6: {
667 struct in6_addr a;

--- 70 unchanged lines hidden (view full) ---

738 rdata += n;
739 }
740 return (buf - obuf);
741 }
742}
743
744/* Private. */
745
746/*%
747 * size_t
748 * prune_origin(name, origin)
749 * Find out if the name is at or under the current origin.
750 * return:
751 * Number of characters in name before start of origin,
752 * or length of name if origin does not match.
753 * notes:
754 * This function should share code with samedomain().

--- 16 unchanged lines hidden (view full) ---

771 break;
772 }
773 name++;
774 }
775 }
776 return (name - oname);
777}
778
779/*%
780 * int
781 * charstr(rdata, edata, buf, buflen)
782 * Format a <character-string> into the presentation buffer.
783 * return:
784 * Number of rdata octets consumed
785 * 0 for protocol format error
786 * -1 for output buffer error
787 * side effects:

--- 39 unchanged lines hidden (view full) ---

827 char **buf, size_t *buflen)
828{
829 size_t newlen, save_buflen = *buflen;
830 char *save_buf = *buf;
831 int n;
832
833 n = dn_expand(msg, msg + msglen, *pp, *buf, *buflen);
834 if (n < 0)
835 goto enospc; /*%< Guess. */
836 newlen = prune_origin(*buf, origin);
837 if (**buf == '\0') {
838 goto root;
839 } else if (newlen == 0U) {
840 /* Use "@" instead of name. */
841 if (newlen + 2 > *buflen)
842 goto enospc; /* No room for "@\0". */
843 (*buf)[newlen++] = '@';

--- 55 unchanged lines hidden (view full) ---

899 *buflen = save_buflen;
900 *buf = save_buf;
901 return (-1);
902 }
903 spaced = 0;
904 }
905 return (spaced);
906}
907
908/*! \file */