rdata.c revision 431a83fb29482c5170b3e4026e59bb14849a6707
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Copyright (C) 1998-2003 Internet Software Consortium.
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson * Permission to use, copy, modify, and/or distribute this software for any
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson * purpose with or without fee is hereby granted, provided that the above
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * copyright notice and this permission notice appear in all copies.
15a44745412679c30a6d022733925af70a38b715David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
15a44745412679c30a6d022733925af70a38b715David Lawrence * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15a44745412679c30a6d022733925af70a38b715David Lawrence * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15a44745412679c30a6d022733925af70a38b715David Lawrence * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15a44745412679c30a6d022733925af70a38b715David Lawrence * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15a44745412679c30a6d022733925af70a38b715David Lawrence * PERFORMANCE OF THIS SOFTWARE.
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson#define DNS_AS_STR(t) ((t).value.as_textregion.base)
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrence#define ARGS_FROMTEXT int rdclass, dns_rdatatype_t type, \
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson unsigned int options, isc_buffer_t *target, \
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrence#define ARGS_TOTEXT dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, \
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson#define ARGS_FROMWIRE int rdclass, dns_rdatatype_t type, \
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson isc_buffer_t *source, dns_decompress_t *dctx, \
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson unsigned int options, isc_buffer_t *target
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson#define ARGS_TOWIRE dns_rdata_t *rdata, dns_compress_t *cctx, \
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrence#define ARGS_COMPARE const dns_rdata_t *rdata1, const dns_rdata_t *rdata2
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson#define ARGS_FROMSTRUCT int rdclass, dns_rdatatype_t type, \
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson#define ARGS_TOSTRUCT dns_rdata_t *rdata, void *target, isc_mem_t *mctx
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson#define ARGS_ADDLDATA dns_rdata_t *rdata, dns_additionaldatafunc_t add, \
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson#define ARGS_DIGEST dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson#define ARGS_CHECKOWNER dns_name_t *name, dns_rdataclass_t rdclass, \
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson dns_rdatatype_t type, isc_boolean_t wildcard
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson#define ARGS_CHECKNAMES dns_rdata_t *rdata, dns_name_t *owner, dns_name_t *bad
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson * Context structure for the totext_ functions.
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson * Contains formatting options for rdata-to-text
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafsson dns_name_t *origin; /*%< Current origin, or NULL. */
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafsson unsigned int flags; /*%< DNS_STYLEFLAG_* */
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafsson unsigned int width; /*%< Width of rdata column. */
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafsson const char *linebreak; /*%< Line break string. */
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafssontxt_totext(isc_region_t *source, isc_buffer_t *target);
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafssontxt_fromtext(isc_textregion_t *source, isc_buffer_t *target);
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafssontxt_fromwire(isc_buffer_t *source, isc_buffer_t *target);
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrencemultitxt_totext(isc_region_t *source, isc_buffer_t *target);
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafssonmultitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target);
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafssonmultitxt_fromwire(isc_buffer_t *source, isc_buffer_t *target);
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafssonname_prefix(dns_name_t *name, dns_name_t *origin, dns_name_t *target);
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafssonstatic unsigned int
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafssonstr_totext(const char *source, isc_buffer_t *target);
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafssoninet_totext(int af, isc_region_t *src, isc_buffer_t *target);
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafssonbuffer_fromregion(isc_buffer_t *buffer, isc_region_t *region);
9cd6d409b78a6f833b681c13a68fbdc7c024fe66David Lawrenceuint32_tobuffer(isc_uint32_t, isc_buffer_t *target);
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafssonuint16_tobuffer(isc_uint32_t, isc_buffer_t *target);
8eaa51a6991ea6bc6c9db0b907beacde8dd1fed2Andreas Gustafssonuint8_tobuffer(isc_uint32_t, isc_buffer_t *target);
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssonname_tobuffer(dns_name_t *name, isc_buffer_t *target);
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssonuint8_consume_fromregion(isc_region_t *region);
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssonmem_tobuffer(isc_buffer_t *target, void *base, unsigned int length);
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssonbtoa_totext(unsigned char *inbuf, int inbuflen, isc_buffer_t *target);
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssonatob_tobuffer(isc_lex_t *lexer, isc_buffer_t *target);
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssondefault_fromtext_callback(dns_rdatacallbacks_t *callbacks, const char *, ...)
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssonfromtext_error(void (*callback)(dns_rdatacallbacks_t *, const char *, ...),
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson dns_rdatacallbacks_t *callbacks, const char *name,
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson unsigned long line, isc_token_t *token, isc_result_t result);
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssonfromtext_warneof(isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks);
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssonrdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssonwarn_badname(dns_name_t *name, isc_lex_t *lexer,
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssonwarn_badmx(isc_token_t *token, isc_lex_t *lexer,
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssonuint16_consume_fromregion(isc_region_t *region);
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafssonunknown_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson/*% INT16 Size */
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson/*% IPv6 Address Size */
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson * convert presentation level address to network order binary form.
5d82424f5d3c77c092c111b935041fd3dc4b3e98Andreas Gustafsson * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
7e361074bc8a2df7a0891a7040eea02ca3a5e286Andreas Gustafsson * (1) does not touch `dst' unless it's returning 1.
7e361074bc8a2df7a0891a7040eea02ca3a5e286Andreas Gustafssonstatic inline int
7e361074bc8a2df7a0891a7040eea02ca3a5e286Andreas Gustafssonlocator_pton(const char *src, unsigned char *dst) {
7e361074bc8a2df7a0891a7040eea02ca3a5e286Andreas Gustafsson static const char xdigits_l[] = "0123456789abcdef",
d80da258e377f02f0dcd703b89a1044cc58e949fMichael Graff const char *pch;
if (seen_xdigits) {
int result;
return (result);
static inline isc_result_t
return (ISC_R_SUCCESS);
void *new;
return (source);
return (new);
#include "code.h"
int result = 0;
if (use_default) {
return (result);
int result = 0;
if (use_default) {
return (result);
unsigned int length;
if (type == 0)
return (DNS_R_FORMERR);
if (use_default) {
return (result);
return (ISC_R_SUCCESS);
if (use_default) {
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
return (result);
static isc_result_t
return (DNS_R_METATYPE);
ISC_FALSE));
return (ISC_R_RANGE);
return (result);
goto failure;
goto failure;
isc_region_t r;
goto failure;
return (ISC_R_SUCCESS);
return (result);
char *name;
unsigned long line;
unsigned int length;
return (result);
if (!unknown)
return (result);
static isc_result_t
return (result);
return (result);
return (result);
target);
return (result);
static isc_result_t
return (ISC_R_SUCCESS);
if (use_default)
return (result);
unsigned int length;
if (use_default)
(void)NULL;
return (result);
if (use_default)
(void)NULL;
return (result);
void *arg)
if (use_default)
return (result);
isc_region_t r;
if (use_default) {
return (result);
return (result);
return (result);
return (DNS_RDATATYPEATTR_UNKNOWN);
unsigned int hash;
return (DNS_R_UNKNOWN);
char *endp;
unsigned int val;
return (ISC_R_SUCCESS);
return (DNS_R_UNKNOWN);
if (size == 0U)
static isc_result_t
unsigned int tl;
unsigned char *sp;
char *tp;
n = *sp++;
return (ISC_R_NOSPACE);
tl--;
return (ISC_R_NOSPACE);
sp++;
return (ISC_R_NOSPACE);
tl--;
return (ISC_R_NOSPACE);
tl--;
return (ISC_R_NOSPACE);
tl--;
return (ISC_R_SUCCESS);
static isc_result_t
unsigned int n, nrem;
return (ISC_R_NOSPACE);
nrem--;
return (DNS_R_SYNTAX);
return (DNS_R_SYNTAX);
return (DNS_R_SYNTAX);
return (DNS_R_SYNTAX);
return (DNS_R_SYNTAX);
if (nrem == 0)
nrem--;
if (escape)
return (DNS_R_SYNTAX);
return (ISC_R_SUCCESS);
static isc_result_t
return(ISC_R_UNEXPECTEDEND);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static isc_result_t
unsigned int tl;
unsigned int n0, n;
unsigned char *sp;
char *tp;
return (ISC_R_NOSPACE);
tl--;
return (ISC_R_NOSPACE);
sp++;
return (ISC_R_NOSPACE);
tl--;
return (ISC_R_NOSPACE);
tl--;
return (ISC_R_NOSPACE);
tl--;
return (ISC_R_SUCCESS);
static isc_result_t
unsigned int n, nrem;
unsigned char *t0, *t;
return (ISC_R_NOSPACE);
t = t0;
nrem--;
return (DNS_R_SYNTAX);
return (DNS_R_SYNTAX);
return (DNS_R_SYNTAX);
return (DNS_R_SYNTAX);
return (DNS_R_SYNTAX);
nrem--;
if (nrem == 0)
if (escape)
return (DNS_R_SYNTAX);
return (ISC_R_SUCCESS);
static isc_result_t
return(ISC_R_UNEXPECTEDEND);
return (DNS_R_SYNTAX);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static isc_boolean_t
goto return_false;
goto return_false;
goto return_false;
goto return_false;
goto return_false;
return (ISC_TRUE);
return (ISC_FALSE);
static isc_result_t
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_NOSPACE);
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static isc_boolean_t
static isc_result_t
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_RANGE);
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static isc_result_t
return (ISC_R_RANGE);
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static isc_result_t
isc_region_t r;
static isc_uint32_t
return(value);
static isc_uint16_t
static isc_uint16_t
static isc_uint8_t
static isc_uint8_t
static isc_result_t
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
c = (unsigned char)value;
if (!isascii(c))
if (isupper(c))
c = tolower(c);
return (int)(s - hexdigits);
return (int)(s - decdigits);
struct state {
static isc_result_t
if (bcount != 0)
return(DNS_R_SYNTAX);
if (bcount == 0) {
++bcount;
++bcount;
word = 0;
bcount = 0;
return(DNS_R_SYNTAX);
return(ISC_R_SUCCESS);
static isc_result_t
Ceor ^= c;
Csum += c;
Crot += c;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static isc_result_t
ISC_FALSE));
ISC_FALSE));
ISC_FALSE));
return (DNS_R_SYNTAX);
ISC_FALSE));
return (DNS_R_SYNTAX);
ISC_FALSE));
return (DNS_R_SYNTAX);
return(DNS_R_BADCKSUM);
return (ISC_R_SUCCESS);
static isc_result_t
Ceor ^= c;
Csum += c;
Crot += c;
word |= c;
if (word == 0) {
return (ISC_R_NOSPACE);
register int tmp = 0;
if (tmpword < 0) {
if (tmpword < 0) {
return (ISC_R_NOSPACE);
+ tmp];
bcount = 0;
return (ISC_R_SUCCESS);
static isc_result_t
int inc;
while (bcount != 0)
const char *file;
unsigned long line;
const char *file;
unsigned long line;
case isc_tokentype_eol:
case isc_tokentype_eof:
case isc_tokentype_number:
case isc_tokentype_string:
case isc_tokentype_qstring:
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_FALSE);
switch (section) {
case DNS_SECTION_PREREQUISITE:
case dns_rdataclass_none:
case dns_rdatatype_any:
case dns_rdataclass_any:
case dns_rdatatype_any:
case DNS_SECTION_UPDATE:
case dns_rdataclass_none:
case dns_rdataclass_any:
case dns_rdatatype_any: