2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Initial "rdata" support. RFC 1035 RR types minus WKS

totext/fromtext should all work
	towire/fromwire mostly work
	tostruct/fromstruct return DNS_R_NOTIMPLEMENTED
	compare untested
This commit is contained in:
Mark Andrews
1999-01-19 02:20:26 +00:00
parent bc6f28fa15
commit 5d51e67c3b
41 changed files with 5534 additions and 8 deletions

View File

@@ -21,7 +21,8 @@ TARGETS = name_test \
lex_test \
task_test \
timer_test \
wire_test
wire_test \
rdata_test
@BIND9_MAKE_RULES@
@@ -49,5 +50,8 @@ task_test: task_test.o ../../lib/isc/libisc.a ../../lib/dns/libdns.a
timer_test: timer_test.o ../../lib/isc/libisc.a ../../lib/dns/libdns.a
${CC} -o $@ timer_test.o ${LIBS}
rdata_test: rdata_test.o ../../lib/isc/libisc.a ../../lib/dns/libdns.a
${CC} -o $@ rdata_test.o ${LIBS}
clean distclean::
rm -f ${TARGETS}

182
bin/tests/rdata_test.c Normal file
View File

@@ -0,0 +1,182 @@
/*
* Copyright (C) 1998 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.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/lex.h>
#include <dns/rdata.h>
#include <dns/compress.h>
isc_mem_t *mctx;
isc_lex_t *lex;
isc_lexspecials_t specials;
int
main(int argc, char *argv[]) {
isc_token_t token;
isc_result_t result;
int quiet = 0;
int c;
int stats = 0;
unsigned int options = 0;
unsigned int parens = 0;
int type;
char outbuf[1024];
char inbuf[1024];
char wirebuf[1024];
isc_buffer_t dbuf;
isc_buffer_t tbuf;
isc_buffer_t wbuf;
dns_rdata_t rdata;
int need_eol = 0;
int wire = 0;
dns_compress_t cctx;
dns_decompress_t dctx;
while ((c = getopt(argc, argv, "qsw")) != -1) {
switch (c) {
case 'q':
quiet = 1;
break;
case 's':
stats = 1;
break;
case 'w':
wire = 1;
break;
}
}
memset(&cctx, '0', sizeof cctx);
memset(&dctx, '0', sizeof dctx);
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_lex_create(mctx, 256, &lex) == ISC_R_SUCCESS);
/* Set up to lex DNS master file. */
specials['('] = 1;
specials[')'] = 1;
specials['"'] = 1;
isc_lex_setspecials(lex, specials);
options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF |
ISC_LEXOPT_INITIALWS | ISC_LEXOPT_QSTRING;
isc_lex_setcomments(lex, ISC_LEXCOMMENT_DNSMASTERFILE);
RUNTIME_CHECK(isc_lex_openstream(lex, stdin) == ISC_R_SUCCESS);
while ((result = isc_lex_gettoken(lex, options | ISC_LEXOPT_NUMBER,
&token)) == ISC_R_SUCCESS) {
/* fprintf(stdout, "token.type = %d\n", token.type); */
if (token.type == isc_tokentype_special) {
if (token.value.as_char == '(') {
parens++;
options &= ~ISC_LEXOPT_EOL;
options &= ~ISC_LEXOPT_INITIALWS;
} else if (token.value.as_char == ')') {
if (parens == 0) {
printf("mismatched parens\n");
exit(1);
}
parens--;
if (parens == 0) {
options |= ISC_LEXOPT_EOL;
options |= ISC_LEXOPT_INITIALWS;
}
}
continue;
}
if (need_eol) {
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
need_eol = 0;
continue;
}
if (token.type != isc_tokentype_number)
continue;
dns_rdata_init(&rdata);
type = token.value.as_ulong;
fprintf(stdout, "type = %d\n", type);
fflush(stdout);
isc_buffer_init(&dbuf, inbuf, sizeof(inbuf),
ISC_BUFFERTYPE_BINARY);
result = dns_rdata_fromtext(&rdata, 1, type, lex,
NULL, ISC_FALSE, &dbuf);
if (result != DNS_R_SUCCESS) {
fprintf(stdout,
"dns_rdata_fromtext != DNS_R_SUCCESS\n");
fflush(stdout);
need_eol = 1;
continue;
}
/* Convert to wire and back? */
if (wire) {
isc_buffer_init(&wbuf, wirebuf, sizeof(wirebuf),
ISC_BUFFERTYPE_BINARY);
if (dns_rdata_towire(&rdata, &cctx, &wbuf)
!= DNS_R_SUCCESS) {
fprintf(stdout,
"dns_rdata_towire != DNS_R_SUCCESS\n");
fflush(stdout);
continue;
}
dns_rdata_init(&rdata);
isc_buffer_init(&dbuf, inbuf, sizeof(inbuf),
ISC_BUFFERTYPE_BINARY);
if (dns_rdata_fromwire(&rdata, 1, type, &wbuf, &dctx,
ISC_FALSE, &dbuf) != DNS_R_SUCCESS) {
fprintf(stdout,
"dns_rdata_fromwire != DNS_R_SUCCESS\n");
fflush(stdout);
continue;
}
}
isc_buffer_init(&tbuf, outbuf, sizeof(outbuf),
ISC_BUFFERTYPE_TEXT);
if (dns_rdata_totext(&rdata, &tbuf) != DNS_R_SUCCESS)
fprintf(stdout, "dns_rdata_totext != DNS_R_SUCCESS\n");
else
fprintf(stdout, "\"%.*s\"\n",
(int)tbuf.used, (char*)tbuf.base);
fflush(stdout);
}
if (result != ISC_R_EOF)
printf("Result: %s\n", isc_result_totext(result));
isc_lex_close(lex);
isc_lex_destroy(&lex);
if (!quiet && stats)
isc_mem_stats(mctx, stdout);
isc_mem_destroy(&mctx);
return (0);
}

View File

@@ -12,7 +12,7 @@ CINCLUDES = -I${srcdir}/../isc/unix/include \
CDEFINES =
CWARNINGS =
OBJS = name.o rdatalist.o rdataset.o result.o version.o
OBJS = name.o rdatalist.o rdataset.o result.o version.o rdata.o
SUBDIRS = include
TARGETS = timestamp
@@ -39,3 +39,11 @@ install:: timestamp installdirs
clean distclean::
rm -f libdns.a timestamp
rdata.o: code.h
code.h: gen
./gen > code.h
gen: gen.c
${CC} ${ALL_CFLAGS} -o $@ $?

372
lib/dns/gen.c Normal file
View File

@@ -0,0 +1,372 @@
/*
* Copyright (C) 1998 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.
*/
#include <sys/types.h>
#include <ctype.h>
#include <dirent.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define FROMTEXTDECL "dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target"
#define FROMTEXTARGS "class, type, lexer, origin, downcase, target"
#define FROMTEXTCLASS "class"
#define FROMTEXTTYPE "type"
#define FROMTEXTDEF "DNS_R_DEFAULT"
#define TOTEXTDECL "dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target"
#define TOTEXTARGS "rdata, origin, target"
#define TOTEXTCLASS "rdata->class"
#define TOTEXTTYPE "rdata->type"
#define TOTEXTDEF "DNS_R_DEFAULT"
#define FROMWIREDECL "dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_t *source, dns_decompress_t *dctx, isc_boolean_t downcase, isc_buffer_t *target"
#define FROMWIREARGS "class, type, source, dctx, downcase, target"
#define FROMWIRECLASS "class"
#define FROMWIRETYPE "type"
#define FROMWIREDEF "DNS_R_DEFAULT"
#define TOWIREDECL "dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target"
#define TOWIREARGS "rdata, cctx, target"
#define TOWIRECLASS "rdata->class"
#define TOWIRETYPE "rdata->type"
#define TOWIREDEF "DNS_R_DEFAULT"
#define FROMSTRUCTDECL "dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target"
#define FROMSTRUCTARGS "class, type, source, target"
#define FROMSTRUCTCLASS "class"
#define FROMSTRUCTTYPE "type"
#define FROMSTRUCTDEF "DNS_R_DEFAULT"
#define TOSTRUCTDECL "dns_rdata_t *rdata, void *target"
#define TOSTRUCTARGS "rdata, target"
#define TOSTRUCTCLASS "rdata->class"
#define TOSTRUCTTYPE "rdata->type"
#define TOSTRUCTDEF "DNS_R_DEFAULT"
#define COMPAREDECL "dns_rdata_t *rdata1, dns_rdata_t *rdata2"
#define COMPAREARGS "rdata1, rdata2"
#define COMPARECLASS "rdata1->class"
#define COMPARETYPE "rdata1->type"
#define COMPAREDEF "-2"
char copyright[] =
"/*\n\
* Copyright (C) 1998%s Internet Software Consortium.\n\
*\n\
* Permission to use, copy, modify, and distribute this software for any\n\
* purpose with or without fee is hereby granted, provided that the above\n\
* copyright notice and this permission notice appear in all copies.\n\
*\n\
* THE SOFTWARE IS PROVIDED \"AS IS\" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS\n\
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES\n\
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE\n\
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL\n\
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR\n\
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS\n\
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\n\
* SOFTWARE.\n\
*/\n\
\n\
/* THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT */\n\
\n";
struct cc {
struct cc *next;
int type;
} *classes;
struct tt {
struct tt *next;
int class;
int type;
char classname[11];
char typename[11];
char dirname[sizeof "rdata/0123456789_65535" ];
} *types;
char * upper(char *);
void doswitch(char *, char *, char *, char *, char *, char *);
void dodecl(char *, char *, char *);
void add(int, char *, int, char *, char *);
void sd(int, char *, char *);
char *
upper(char *s) {
static char buf[11];
char *b = buf;
char c;
while ((c = *s++)) {
*b++ = islower(c) ? toupper(c) : c;
}
*b = '\0';
return (buf);
}
void
doswitch(char *name, char *function, char *args,
char *tsw, char *csw, char *res)
{
struct tt *tt;
int first = 1;
int lasttype = 0;
int subswitch = 0;
for (tt = types; tt != NULL ; tt = tt->next) {
if (first) {
fprintf(stdout, "\n#define %s \\\n", name);
fprintf(stdout, "\tswitch (%s) { \\\n" /*}*/, tsw);
first = 0;
}
if (tt->type != lasttype && subswitch) {
fprintf(stdout, "\t\tdefault: result = %s; \\\n",
res);
fputs(/*{*/ "\t\t} \\\n", stdout);
subswitch = 0;
}
if (tt->class && tt->type != lasttype) {
fprintf(stdout, "\tcase %d: switch (%s) { \\\n" /*}*/,
tt->type, tsw);
subswitch = 1;
}
if (tt->class == 0)
fprintf(stdout,
"\tcase %d: result = %s_%s(%s); break;",
tt->type, function, tt->typename, args);
else
fprintf(stdout,
"\t\tcase %d: result = %s_%s_%s(%s); break;",
tt->class, function, tt->classname,
tt->typename, args);
fputs(" \\\n", stdout);
lasttype = tt->type;
}
if (subswitch) {
fprintf(stdout, "\t\tdefault: result = %s; \\\n", res);
fputs(/*{*/ "\t\t}\n", stdout);
}
if (first)
fprintf(stdout, "\n#define %s result = %s;\n", name, res);
else {
fprintf(stdout, "\tdefault: result = %s; \\\n", res);
fputs(/*{*/ "\t}\n", stdout);
}
}
void
dodecl(char *type, char *function, char *args) {
struct tt *tt;
fputs("\n", stdout);
for (tt = types; tt ; tt = tt->next)
if (tt->class)
fprintf(stdout,
"static %s %s_%s_%s(%s);\n",
type, function, tt->classname,
tt->typename, args);
else
fprintf(stdout,
"static %s %s_%s(%s);\n",
type, function, tt->typename, args);
}
void
add(int class, char *classname, int type, char *typename, char *dirname) {
struct tt *newtt = (struct tt *)malloc(sizeof *newtt);
struct tt *tt, *oldtt;
struct cc *newcc;
struct cc *cc, *oldcc;
if (newtt == NULL)
exit(1);
newtt->next = NULL;
newtt->class = class;
newtt->type = type;
strcpy(newtt->classname, classname);
strcpy(newtt->typename, typename);
strcpy(newtt->dirname, dirname);
tt = types;
oldtt = NULL;
while (tt && (tt->type < type)) {
oldtt = tt;
tt = tt->next;
}
while (tt && (tt->type == type) && (tt->class < class)) {
if (strcmp(tt->typename, typename) != 0)
exit(1);
oldtt = tt;
tt = tt->next;
}
if (tt && (tt->type == type) && (tt->class == class))
exit(1);
newtt->next = tt;
if (oldtt)
oldtt->next = newtt;
else
types = newtt;
/* do a class switch for this type */
if (class == 0)
return;
newcc = (struct cc *)malloc(sizeof *newcc);
newcc->type = type;
cc = classes;
oldcc = NULL;
while (cc && (cc->type < type)) {
oldcc = cc;
cc = cc->next;
}
if (cc && cc->type == type) {
free((char *)newcc);
return;
}
newcc->next = cc;
if (oldcc)
oldcc->next = newcc;
else
classes = newcc;
}
void
sd(int class, char *classname, char *dir) {
char buf[sizeof "0123456789_65535.h"];
DIR *d;
int type;
char typename[11];
struct dirent *dp;
if ((d = opendir(dir)) == NULL)
return;
while ((dp = readdir(d)) != NULL) {
if (sscanf(dp->d_name, "%10[0-9a-z]_%d.h",
typename, &type) != 2)
continue;
if ((type > 65535) || (type < 0))
continue;
sprintf(buf, "%s_%d.h", typename, type);
if (strcmp(buf, dp->d_name) != 0)
continue;
add(class, classname, type, typename, dir);
}
closedir(d);
}
int
main(int argc, char **argv) {
DIR *d;
char buf[sizeof "rdata/0123456789_65535" ];
int class;
char classname[11];
struct dirent *dp;
struct tt *tt;
struct tm *tm;
time_t now;
char year[11];
argc = argc;
argv = argv;
if ((d = opendir("rdata")) == NULL)
exit(1);
while ((dp = readdir(d)) != NULL) {
if (sscanf(dp->d_name, "%10[0-9a-z]_%d",
classname, &class) != 2)
continue;
if ((class > 65535) || (class < 0))
continue;
sprintf(buf, "rdata/%s_%d", classname, class);
if (strcmp(buf + 6, dp->d_name) != 0)
continue;
sd(class, classname, buf);
}
sd(0, "", "rdata/generic");
closedir(d);
if (time(&now) != -1) {
if ((tm = localtime(&now)) != NULL && tm->tm_year > 98)
sprintf(year, "-%d", tm->tm_year + 1900);
else
year[0] = 0;
} else
year[0] = 0;
fprintf(stdout, copyright, year);
dodecl("dns_result_t", "fromtext", FROMTEXTDECL);
dodecl("dns_result_t", "totext", TOTEXTDECL);
dodecl("dns_result_t", "fromwire", FROMWIREDECL);
dodecl("dns_result_t", "towire", TOWIREDECL);
dodecl("int", "compare", COMPAREDECL);
dodecl("dns_result_t", "fromstruct", FROMSTRUCTDECL);
dodecl("dns_result_t", "tostruct", TOSTRUCTDECL);
doswitch("FROMTEXTSWITCH", "fromtext", FROMTEXTARGS,
FROMTEXTTYPE, FROMTEXTCLASS, FROMTEXTDEF);
doswitch("TOTEXTSWITCH", "totext", TOTEXTARGS,
TOTEXTTYPE, TOTEXTCLASS, TOTEXTDEF);
doswitch("FROMWIRESWITCH", "fromwire", FROMWIREARGS,
FROMWIRETYPE, FROMWIRECLASS, FROMWIREDEF);
doswitch("TOWIRESWITCH", "towire", TOWIREARGS,
TOWIRETYPE, TOWIRECLASS, TOWIREDEF);
doswitch("COMPARESWITCH", "compare", COMPAREARGS,
COMPARETYPE, COMPARECLASS, COMPAREDEF);
doswitch("FROMSTRUCTSWITCH", "fromstruct", FROMSTRUCTARGS,
FROMSTRUCTTYPE, FROMSTRUCTCLASS, FROMSTRUCTDEF);
doswitch("TOSTRUCTSWITCH", "tostruct", TOSTRUCTARGS,
TOSTRUCTTYPE, TOSTRUCTCLASS, TOSTRUCTDEF);
fprintf(stdout, "\n#define TYPENAMES%s\n",
types != NULL ? " \\" : "");
for (tt = types; tt != NULL ; tt = tt->next)
if (tt->class == 0)
fprintf(stdout,
"\t{ %d, \"%s\" },%s\n",
tt->type, tt->typename,
tt->next != NULL ? " \\" : "");
fputs("\n", stdout);
for (tt = types; tt ; tt = tt->next)
fprintf(stdout, "#include \"%s/%s_%d.h\"\n",
tt->dirname, tt->typename, tt->type);
if (ferror(stdout) != 0)
exit(1);
exit(0);
}

View File

@@ -260,7 +260,7 @@ dns_result_t dns_rdata_fromtext(dns_rdata_t *rdata,
*
* Notes:
* Relative domain names in the rdata will have 'origin' appended to them.
* If 'origin' is NULL, then relative domain names will remain relative.
* A NULL origin implies "origin == dns_rootname".
*
* If 'downcase' is true, any uppercase letters in domain names in
* 'source' will be downcased when they are copied into 'target'.

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 1998 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.
*/
#define isc_region_consume(r,l) \
do { \
isc_region_t *__r = (r); \
unsigned int __l = (l); \
INSIST(__r->length >= __l); \
__r->base += __l; \
__r->length -= __l; \
} while (0)
#define isc_textregion_consume(r,l) \
do { \
isc_textregion_t *__r = (r); \
unsigned int __l = (l); \
INSIST(__r->length >= __l); \
__r->base += __l; \
__r->length -= __l; \
} while (0)

View File

@@ -37,8 +37,10 @@ typedef unsigned int dns_result_t;
#define DNS_R_TOOMANYHOPS 14
#define DNS_R_DISALLOWED 15
#define DNS_R_NOMORE 16
#define DNS_R_WIRE 17
#define DNS_R_DEFAULT 18
#define DNS_R_LASTENTRY 16 /* Last entry on list. */
#define DNS_R_LASTENTRY 18 /* Last entry on list. */
#define DNS_R_UNEXPECTED 0xFFFFFFFFL

445
lib/dns/rdata.c Normal file
View File

@@ -0,0 +1,445 @@
/*
* Copyright (C) 1998 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.
*/
#include <isc/buffer.h>
#include <isc/lex.h>
#include <dns/types.h>
#include <dns/result.h>
#include <dns/rdata.h>
#include <dns/region.h>
#include <stdio.h>
#include <isc/assertions.h>
static dns_result_t txt_totext(isc_region_t *source, isc_buffer_t *target);
static dns_result_t txt_fromtext(isc_textregion_t *source,
isc_buffer_t *target);
static dns_result_t txt_fromwire(isc_buffer_t *source,
isc_buffer_t *target);
static isc_boolean_t name_prefix(dns_name_t *name, dns_name_t *origin,
dns_name_t *target);
static unsigned int name_length(dns_name_t *name);
static dns_result_t str_totext(char *source, isc_buffer_t *target);
static isc_boolean_t buffer_empty(isc_buffer_t *source);
static void buffer_fromregion(isc_buffer_t *buffer,
isc_region_t *region,
unsigned int type);
static isc_result_t uint32_fromtext(unsigned long value,
isc_buffer_t *target);
static isc_result_t uint16_fromtext(unsigned long value,
isc_buffer_t *target);
static unsigned long uint32_fromregion(isc_region_t *region);
static unsigned short uint16_fromregion(isc_region_t *region);
#include "code.h"
/***
*** Initialization
***/
void
dns_rdata_init(dns_rdata_t *rdata) {
REQUIRE(rdata != NULL);
rdata->data = NULL;
rdata->length = 0;
rdata->class = 0;
rdata->type = 0;
ISC_LINK_INIT(rdata, link);
/* ISC_LIST_INIT(rdata->list); */
}
/***
*** Comparisons
***/
int
dns_rdata_compare(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
int result;
int l;
REQUIRE(rdata1 != NULL);
REQUIRE(rdata2 != NULL);
REQUIRE(rdata1->data != NULL);
REQUIRE(rdata2->data != NULL);
if (rdata1->class != rdata2->class)
return (rdata1->class < rdata2->class ? -1 : 1);
if (rdata1->type != rdata2->type)
return (rdata1->type < rdata2->type ? -1 : 1);
COMPARESWITCH
if (result == -2) {
l = (rdata1->length > rdata2->length) ?
rdata1->length : rdata2->length;
if ((result = memcmp(rdata1->data, rdata2->data, l)) == 0)
result = (result < 0) ? -1 : 1;
else
result = (rdata1->length < rdata2->length) ? -1 : 1;
}
return (result);
}
/***
*** Conversions
***/
void
dns_rdata_fromregion(dns_rdata_t *rdata,
dns_rdataclass_t class, dns_rdatatype_t type,
isc_region_t *r) {
rdata->data = r->base;
rdata->length = r->length;
rdata->class = class;
rdata->type = type;
}
void
dns_rdata_toregion(dns_rdata_t *rdata, isc_region_t *r) {
r->base = rdata->data;
r->length = rdata->length;
}
dns_result_t
dns_rdata_fromwire(dns_rdata_t *rdata,
dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source,
dns_decompress_t *dctx,
isc_boolean_t downcase,
isc_buffer_t *target) {
dns_result_t result;
isc_region_t region;
isc_buffer_t ss;
isc_buffer_t st;
ss = *source;
st = *target;
region.base = target->base + target->used;
FROMWIRESWITCH
if (result == DNS_R_DEFAULT)
result = DNS_R_NOTIMPLEMENTED;
/* We should have consumed all out buffer */
if (!buffer_empty(source))
result = DNS_R_WIRE;
if (rdata && result == DNS_R_SUCCESS) {
region.length = target->used - st.used;
dns_rdata_fromregion(rdata, class, type, &region);
}
if (result != DNS_R_SUCCESS) {
*source = ss;
*target = st;
}
return (result);
}
dns_result_t
dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
isc_buffer_t *target) {
dns_result_t result;
TOWIRESWITCH
if (result == DNS_R_DEFAULT) {
if (target->length < rdata->length)
return (DNS_R_NOSPACE);
memcpy(target->base, rdata->data, rdata->length);
target->length = rdata->length;
return (DNS_R_SUCCESS);
}
return (result);
}
dns_result_t
dns_rdata_fromtext(dns_rdata_t *rdata,
dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase,
isc_buffer_t *target) {
dns_result_t result;
isc_region_t region;
isc_buffer_t st;
st = *target;
region.base = target->base + target->used;
FROMTEXTSWITCH
if (result == DNS_R_DEFAULT)
result = DNS_R_NOTIMPLEMENTED;
if (rdata != NULL && result == DNS_R_SUCCESS) {
region.length = target->used - st.used;
dns_rdata_fromregion(rdata, class, type, &region);
}
if (result != DNS_R_SUCCESS) {
*target = st;
}
return (result);
}
dns_result_t
dns_rdata_totext(dns_rdata_t *rdata, isc_buffer_t *target) {
dns_result_t result;
dns_name_t *origin = NULL;
TOTEXTSWITCH
if (result == DNS_R_DEFAULT)
result = DNS_R_NOTIMPLEMENTED;
return (result);
}
dns_result_t
dns_rdata_fromstruct(dns_rdata_t *rdata,
dns_rdataclass_t class, dns_rdatatype_t type,
void *source,
isc_buffer_t *target) {
dns_result_t result;
isc_buffer_t st;
isc_region_t region;
region.base = target->base + target->used;
st = *target;
FROMSTRUCTSWITCH
if (result == DNS_R_DEFAULT)
result = DNS_R_NOTIMPLEMENTED;
if (rdata != NULL && result == DNS_R_SUCCESS) {
region.length = target->used - st.used;
dns_rdata_fromregion(rdata, class, type, &region);
}
if (result != DNS_R_SUCCESS)
*target = st;
return (result);
}
dns_result_t
dns_rdata_tostruct(dns_rdata_t *rdata, void *target) {
dns_result_t result;
TOSTRUCTSWITCH
if (result == DNS_R_DEFAULT)
result = DNS_R_NOTIMPLEMENTED;
return (result);
}
static unsigned int
name_length(dns_name_t *name) {
return (name->length);
}
static dns_result_t
txt_totext(isc_region_t *source, isc_buffer_t *target) {
unsigned int tl;
unsigned int n;
unsigned char *sp;
unsigned char *tp;
isc_region_t region;
isc_buffer_available(target, &region);
sp = source->base;
tp = region.base;
tl = region.length;
n = *sp++;
INSIST(n + 1 <= source->length);
if (tl < 1)
return (DNS_R_NOSPACE);
*tp++ = '"';
tl--;
while (n--) {
if (*sp < 0x20 || *sp > 0x7f) {
if (tl < 4)
return (DNS_R_NOSPACE);
sprintf(tp, "\\%03u", *sp++);
tp += 4;
tl -= 4;
continue;
}
if (*sp == 0x22 || *sp == 0x3b || *sp == 0x5c) {
if (tl < 2)
return (DNS_R_NOSPACE);
*tp++ = '\\';
tl--;
}
if (tl < 1)
return (DNS_R_NOSPACE);
*tp++ = *sp++;
tl--;
}
if (tl < 1)
return (DNS_R_NOSPACE);
*tp++ = '"';
tl--;
isc_buffer_add(target, tp - region.base);
isc_region_consume(source, *source->base + 1);
return (DNS_R_SUCCESS);
}
static dns_result_t
txt_fromtext(isc_textregion_t *source, isc_buffer_t *target) {
isc_region_t tregion;
isc_buffer_available(target, &tregion);
if (tregion.length < source->length + 1)
return (DNS_R_NOSPACE);
if (source->length > 255)
return (DNS_R_UNKNOWN);
*tregion.base = source->length;
memcpy(tregion.base + 1, source->base, source->length);
isc_buffer_add(target, source->length + 1);
return (DNS_R_SUCCESS);
}
static dns_result_t
txt_fromwire(isc_buffer_t *source, isc_buffer_t *target) {
unsigned int n;
isc_region_t sregion;
isc_region_t tregion;
isc_buffer_remaining(source, &sregion);
n = *sregion.base + 1;
if (n > sregion.length)
return (DNS_R_UNKNOWN);
isc_buffer_available(target, &tregion);
if (n < tregion.length)
return (DNS_R_NOSPACE);
memcpy(tregion.base, sregion.base, n);
isc_buffer_forward(source, n);
isc_buffer_add(target, n);
return (DNS_R_SUCCESS);
}
static isc_boolean_t
name_prefix(dns_name_t *name, dns_name_t *origin, dns_name_t *target) {
int l1, l2;
if (origin == NULL)
goto return_false;
if (dns_name_compare(origin, dns_rootname) == 0)
goto return_false;
if (!dns_name_issubdomain(name, origin))
goto return_false;
l1 = dns_name_countlabels(name);
l2 = dns_name_countlabels(origin);
if (l1 == l2)
goto return_false;
dns_name_getlabelsequence(name, 0, l1 - l2, target);
return (ISC_TRUE);
return_false:
*target = *name;
return (ISC_FALSE);
}
static dns_result_t
str_totext(char *source, isc_buffer_t *target) {
unsigned int l;
isc_region_t region;
isc_buffer_available(target, &region);
l = strlen(source);
if (l > region.length)
return (DNS_R_NOSPACE);
memcpy(region.base, source, l);
isc_buffer_add(target, l);
return (DNS_R_SUCCESS);
}
static isc_boolean_t
buffer_empty(isc_buffer_t *source) {
return((source->current == source->used) ? ISC_TRUE : ISC_FALSE);
}
static void
buffer_fromregion(isc_buffer_t *buffer, isc_region_t *region,
unsigned int type) {
isc_buffer_init(buffer, region->base, region->length, type);
isc_buffer_add(buffer, region->length);
}
static isc_result_t
uint32_fromtext(unsigned long value, isc_buffer_t *target) {
isc_region_t region;
isc_buffer_available(target, &region);
if (region.length < 4)
return (DNS_R_NOSPACE);
region.base[0] = (value >> 24) & 0xff;
region.base[1] = (value >> 16) & 0xff;
region.base[2] = (value >> 8) & 0xff;
region.base[3] = value & 0xff;
isc_buffer_add(target, 4);
return (DNS_R_SUCCESS);
}
static isc_result_t
uint16_fromtext(unsigned long value, isc_buffer_t *target) {
isc_region_t region;
isc_buffer_available(target, &region);
if (region.length < 2)
return (DNS_R_NOSPACE);
region.base[0] = (value >> 8) & 0xff;
region.base[1] = value & 0xff;
isc_buffer_add(target, 2);
return (DNS_R_SUCCESS);
}
static unsigned long
uint32_fromregion(isc_region_t *region) {
unsigned long value;
INSIST(region->length >= 4);
value = region->base[0] << 24;
value |= region->base[1] << 16;
value |= region->base[2] << 8;
value |= region->base[3];
return(value);
}
static unsigned short
uint16_fromregion(isc_region_t *region) {
INSIST(region->length >= 2);
return ((region->base[0] << 8) | region->base[1]);
}

View File

@@ -0,0 +1,129 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_5_CNAME_H
#define RDATA_TYPE_5_CNAME_H
static dns_result_t
fromtext_cname(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
INSIST(type == 5);
class = class; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_cname(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 5);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_cname(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 5);
class = class; /*unused*/
dns_name_init(&name, NULL);
return(dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_cname(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 5);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_cname(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_cname(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_cname(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,129 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_5_CNAME_H
#define RDATA_TYPE_5_CNAME_H
static dns_result_t
fromtext_cname(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
INSIST(type == 5);
class = class; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_cname(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 5);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_cname(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 5);
class = class; /*unused*/
dns_name_init(&name, NULL);
return(dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_cname(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 5);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_cname(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_cname(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_cname(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,132 @@
/*
* Copyright (C) 1998 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.
*/
static dns_result_t
fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_result_t result;
class = class; /*unused*/
origin = origin; /*unused*/
downcase = downcase; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
result = txt_fromtext(&token.value.as_textregion, target);
if (result != DNS_R_SUCCESS)
return (result);
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
return (txt_fromtext(&token.value.as_textregion, target));
}
static dns_result_t
totext_hinfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_result_t result;
origin = origin; /*unused*/
dns_rdata_toregion(rdata, &region);
result = txt_totext(&region, target);
if (result != DNS_R_SUCCESS)
return (result);
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
result = txt_totext(&region, target);
return (DNS_R_SUCCESS);
}
static dns_result_t
fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_result_t result;
dctx = dctx; /* unused */
class = class; /* unused */
downcase = downcase; /* unused */
INSIST(type == 13);
result = txt_fromwire(source, target);
if (result != DNS_R_SUCCESS)
return (result);
return (txt_fromwire(source, target));
}
static dns_result_t
towire_hinfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
cctx = cctx;
if (target->length < rdata->length)
return (DNS_R_NOSPACE);
memcpy(target->base, rdata->data, rdata->length);
return (DNS_R_SUCCESS);
}
static int
compare_hinfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
int l;
int result;
l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length;
result = memcmp(rdata1->data, rdata2->data, l);
if (result != 0)
result = (result < 0) ? -1 : 1;
else if (rdata1->length != rdata2->length)
result = (rdata1->length < rdata2->length) ? -1 : 1;
return (result);
}
static dns_result_t
fromstruct_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_hinfo(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}

View File

@@ -0,0 +1,132 @@
/*
* Copyright (C) 1998 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.
*/
static dns_result_t
fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_result_t result;
class = class; /*unused*/
origin = origin; /*unused*/
downcase = downcase; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
result = txt_fromtext(&token.value.as_textregion, target);
if (result != DNS_R_SUCCESS)
return (result);
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
return (txt_fromtext(&token.value.as_textregion, target));
}
static dns_result_t
totext_hinfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_result_t result;
origin = origin; /*unused*/
dns_rdata_toregion(rdata, &region);
result = txt_totext(&region, target);
if (result != DNS_R_SUCCESS)
return (result);
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
result = txt_totext(&region, target);
return (DNS_R_SUCCESS);
}
static dns_result_t
fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_result_t result;
dctx = dctx; /* unused */
class = class; /* unused */
downcase = downcase; /* unused */
INSIST(type == 13);
result = txt_fromwire(source, target);
if (result != DNS_R_SUCCESS)
return (result);
return (txt_fromwire(source, target));
}
static dns_result_t
towire_hinfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
cctx = cctx;
if (target->length < rdata->length)
return (DNS_R_NOSPACE);
memcpy(target->base, rdata->data, rdata->length);
return (DNS_R_SUCCESS);
}
static int
compare_hinfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
int l;
int result;
l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length;
result = memcmp(rdata1->data, rdata2->data, l);
if (result != 0)
result = (result < 0) ? -1 : 1;
else if (rdata1->length != rdata2->length)
result = (rdata1->length < rdata2->length) ? -1 : 1;
return (result);
}
static dns_result_t
fromstruct_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_hinfo(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}

View File

@@ -0,0 +1,130 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_7_MB_H
#define RDATA_TYPE_7_MB_H
static dns_result_t
fromtext_mb(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
isc_result_t result;
dns_name_t name;
isc_buffer_t buffer;
INSIST(type == 7);
class = class; /*unused*/
result = isc_lex_gettoken(lexer, 0, &token);
if (result != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_mb(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 7);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_mb(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 7);
class = class;
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_mb(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 7);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_mb(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_mb(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_mb(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,130 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_7_MB_H
#define RDATA_TYPE_7_MB_H
static dns_result_t
fromtext_mb(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
isc_result_t result;
dns_name_t name;
isc_buffer_t buffer;
INSIST(type == 7);
class = class; /*unused*/
result = isc_lex_gettoken(lexer, 0, &token);
if (result != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_mb(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 7);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_mb(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 7);
class = class;
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_mb(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 7);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_mb(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_mb(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_mb(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,127 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_3_MD_H
#define RDATA_TYPE_3_MD_H
static dns_result_t
fromtext_md(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
isc_result_t result;
dns_name_t name;
isc_buffer_t buffer;
class = class; /*unused*/
result = isc_lex_gettoken(lexer, 0, &token);
if (result != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_md(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 3);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return(dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_md(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 3);
class = class;
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_md(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 3);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_md(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_md(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_md(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,127 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_3_MD_H
#define RDATA_TYPE_3_MD_H
static dns_result_t
fromtext_md(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
isc_result_t result;
dns_name_t name;
isc_buffer_t buffer;
class = class; /*unused*/
result = isc_lex_gettoken(lexer, 0, &token);
if (result != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_md(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 3);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return(dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_md(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 3);
class = class;
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_md(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 3);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_md(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_md(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_md(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,127 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_4_MF_H
#define RDATA_TYPE_4_MF_H
static dns_result_t
fromtext_mf(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
isc_result_t result;
dns_name_t name;
isc_buffer_t buffer;
class = class; /*unused*/
result = isc_lex_gettoken(lexer, 0, &token);
if (result != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_mf(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 4);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_mf(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 4);
class = class;
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_mf(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 4);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_mf(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_mf(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_mf(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,127 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_4_MF_H
#define RDATA_TYPE_4_MF_H
static dns_result_t
fromtext_mf(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
isc_result_t result;
dns_name_t name;
isc_buffer_t buffer;
class = class; /*unused*/
result = isc_lex_gettoken(lexer, 0, &token);
if (result != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_mf(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 4);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_mf(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 4);
class = class;
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_mf(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 4);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_mf(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_mf(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_mf(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,129 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_8_MG_H
#define RDATA_TYPE_8_MG_H
static dns_result_t
fromtext_mg(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
isc_result_t result;
dns_name_t name;
isc_buffer_t buffer;
class = class; /*unused*/
result = isc_lex_gettoken(lexer, 0, &token);
if (result != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_mg(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 8);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_mg(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 8);
class = class;
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_mg(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 8);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_mg(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_mg(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_mg(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,129 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_8_MG_H
#define RDATA_TYPE_8_MG_H
static dns_result_t
fromtext_mg(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
isc_result_t result;
dns_name_t name;
isc_buffer_t buffer;
class = class; /*unused*/
result = isc_lex_gettoken(lexer, 0, &token);
if (result != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_mg(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 8);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_mg(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 8);
class = class;
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_mg(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 8);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_mg(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_mg(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_mg(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,204 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_14_MINFO_H
#define RDATA_TYPE_14_MINFO_H
static dns_result_t
fromtext_minfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_result_t result;
dns_name_t name;
isc_buffer_t buffer;
class = class; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
result = dns_name_fromtext(&name, &buffer, origin, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_minfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t rmail;
dns_name_t email;
dns_name_t prefix;
dns_result_t result;
isc_boolean_t sub;
INSIST(rdata->type == 14);
dns_name_init(&rmail, NULL);
dns_name_init(&email, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&rmail, &region);
isc_region_consume(&region, rmail.length);
dns_name_fromregion(&email, &region);
isc_region_consume(&region, email.length);
sub = name_prefix(&rmail, origin, &prefix);
result = dns_name_totext(&prefix, sub, target);
if (result != DNS_R_SUCCESS)
return (result);
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
sub = name_prefix(&email, origin, &prefix);
result = dns_name_totext(&prefix, sub, target);
if (result != DNS_R_SUCCESS)
return (result);
return (DNS_R_SUCCESS);
}
static dns_result_t
fromwire_minfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t rmail;
dns_name_t email;
dns_result_t result;
INSIST(type == 14);
class = class; /*unused*/
dns_name_init(&rmail, NULL);
dns_name_init(&email, NULL);
result = dns_name_fromwire(&rmail, source, dctx, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
return (dns_name_fromwire(&email, source, dctx, downcase, target));
}
static dns_result_t
towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t region;
dns_name_t rmail;
dns_name_t email;
dns_result_t result;
INSIST(rdata->type == 14);
dns_name_init(&rmail, NULL);
dns_name_init(&email, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&rmail, &region);
isc_region_consume(&region, rmail.length);
result = dns_name_towire(&rmail, cctx, target);
if (result != DNS_R_SUCCESS)
return (result);
dns_name_fromregion(&rmail, &region);
isc_region_consume(&region, rmail.length);
result = dns_name_towire(&rmail, cctx, target);
return (DNS_R_SUCCESS);
}
static int
compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
isc_region_t region1;
isc_region_t region2;
dns_name_t name1;
dns_name_t name2;
int result;
INSIST(rdata1->type == 14);
INSIST(rdata2->type == 14);
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region1);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
result = dns_name_compare(&name1, &name2);
if (result != 0)
return (result);
isc_region_consume(&region1, name1.length);
isc_region_consume(&region2, name2.length);
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
result = dns_name_compare(&name1, &name2);
return (result);
}
static dns_result_t
fromstruct_minfo(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_minfo(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,204 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_14_MINFO_H
#define RDATA_TYPE_14_MINFO_H
static dns_result_t
fromtext_minfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_result_t result;
dns_name_t name;
isc_buffer_t buffer;
class = class; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
result = dns_name_fromtext(&name, &buffer, origin, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_minfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t rmail;
dns_name_t email;
dns_name_t prefix;
dns_result_t result;
isc_boolean_t sub;
INSIST(rdata->type == 14);
dns_name_init(&rmail, NULL);
dns_name_init(&email, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&rmail, &region);
isc_region_consume(&region, rmail.length);
dns_name_fromregion(&email, &region);
isc_region_consume(&region, email.length);
sub = name_prefix(&rmail, origin, &prefix);
result = dns_name_totext(&prefix, sub, target);
if (result != DNS_R_SUCCESS)
return (result);
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
sub = name_prefix(&email, origin, &prefix);
result = dns_name_totext(&prefix, sub, target);
if (result != DNS_R_SUCCESS)
return (result);
return (DNS_R_SUCCESS);
}
static dns_result_t
fromwire_minfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t rmail;
dns_name_t email;
dns_result_t result;
INSIST(type == 14);
class = class; /*unused*/
dns_name_init(&rmail, NULL);
dns_name_init(&email, NULL);
result = dns_name_fromwire(&rmail, source, dctx, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
return (dns_name_fromwire(&email, source, dctx, downcase, target));
}
static dns_result_t
towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t region;
dns_name_t rmail;
dns_name_t email;
dns_result_t result;
INSIST(rdata->type == 14);
dns_name_init(&rmail, NULL);
dns_name_init(&email, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&rmail, &region);
isc_region_consume(&region, rmail.length);
result = dns_name_towire(&rmail, cctx, target);
if (result != DNS_R_SUCCESS)
return (result);
dns_name_fromregion(&rmail, &region);
isc_region_consume(&region, rmail.length);
result = dns_name_towire(&rmail, cctx, target);
return (DNS_R_SUCCESS);
}
static int
compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
isc_region_t region1;
isc_region_t region2;
dns_name_t name1;
dns_name_t name2;
int result;
INSIST(rdata1->type == 14);
INSIST(rdata2->type == 14);
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region1);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
result = dns_name_compare(&name1, &name2);
if (result != 0)
return (result);
isc_region_consume(&region1, name1.length);
isc_region_consume(&region2, name2.length);
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
result = dns_name_compare(&name1, &name2);
return (result);
}
static dns_result_t
fromstruct_minfo(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_minfo(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,127 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_9_MR_H
#define RDATA_TYPE_9_MR_H
static dns_result_t
fromtext_mr(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
class = class; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_mr(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 9);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_mr(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 9);
class = class;
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_mr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 9);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_mr(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_mr(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_mr(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,127 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_9_MR_H
#define RDATA_TYPE_9_MR_H
static dns_result_t
fromtext_mr(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
class = class; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_mr(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 9);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_mr(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 9);
class = class;
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_mr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 9);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_mr(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_mr(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_mr(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,178 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_15_MX_H
#define RDATA_TYPE_15_MX_H
static dns_result_t
fromtext_mx(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
dns_result_t result;
class = class; /*unused*/
if (isc_lex_gettoken(lexer, ISC_LEXOPT_NUMBER, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_number)
return (DNS_R_UNKNOWN);
result = uint16_fromtext(token.value.as_ulong, target);
if (result != DNS_R_SUCCESS)
return (result);
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_mx(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
dns_result_t result;
char buf[sizeof "64000"];
unsigned short num;
INSIST(rdata->type == 15);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
num = uint16_fromregion(&region);
isc_region_consume(&region, 2);
sprintf(buf, "%u", num);
result = str_totext(buf, target);
if (result != DNS_R_SUCCESS)
return (result);
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return(dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_mx(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
isc_region_t sregion;
isc_region_t tregion;
INSIST(type == 15);
class = class; /* unused */
dns_name_init(&name, NULL);
isc_buffer_remaining(source, &sregion);
isc_buffer_available(target, &tregion);
if (tregion.length < 2)
return (DNS_R_NOSPACE);
if (sregion.length < 2)
return (DNS_R_WIRE);
memcpy(tregion.base, sregion.base, 2);
isc_buffer_forward(source, 2);
isc_buffer_add(target, 2);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
dns_result_t result;
isc_region_t tr;
INSIST(rdata->type == 15);
isc_buffer_remaining(target, &tr);
dns_rdata_toregion(rdata, &region);
if (tr.length < 2)
return (DNS_R_NOSPACE);
memcpy(tr.base, region.base, 2);
isc_region_consume(&region, 2);
isc_buffer_forward(target, 2);
dns_name_init(&name, NULL);
dns_name_fromregion(&name, &region);
result = dns_name_towire(&name, cctx, target);
return (result);
}
static int
compare_mx(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
int result;
result = memcmp(rdata1->data, rdata2->data, 2);
if (result != 0)
return (result < 0 ? -1 : 1);
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
isc_region_consume(&region1, 2);
isc_region_consume(&region2, 2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_mx(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_mx(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,178 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_15_MX_H
#define RDATA_TYPE_15_MX_H
static dns_result_t
fromtext_mx(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
dns_result_t result;
class = class; /*unused*/
if (isc_lex_gettoken(lexer, ISC_LEXOPT_NUMBER, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_number)
return (DNS_R_UNKNOWN);
result = uint16_fromtext(token.value.as_ulong, target);
if (result != DNS_R_SUCCESS)
return (result);
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_mx(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
dns_result_t result;
char buf[sizeof "64000"];
unsigned short num;
INSIST(rdata->type == 15);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
num = uint16_fromregion(&region);
isc_region_consume(&region, 2);
sprintf(buf, "%u", num);
result = str_totext(buf, target);
if (result != DNS_R_SUCCESS)
return (result);
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return(dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_mx(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
isc_region_t sregion;
isc_region_t tregion;
INSIST(type == 15);
class = class; /* unused */
dns_name_init(&name, NULL);
isc_buffer_remaining(source, &sregion);
isc_buffer_available(target, &tregion);
if (tregion.length < 2)
return (DNS_R_NOSPACE);
if (sregion.length < 2)
return (DNS_R_WIRE);
memcpy(tregion.base, sregion.base, 2);
isc_buffer_forward(source, 2);
isc_buffer_add(target, 2);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
dns_result_t result;
isc_region_t tr;
INSIST(rdata->type == 15);
isc_buffer_remaining(target, &tr);
dns_rdata_toregion(rdata, &region);
if (tr.length < 2)
return (DNS_R_NOSPACE);
memcpy(tr.base, region.base, 2);
isc_region_consume(&region, 2);
isc_buffer_forward(target, 2);
dns_name_init(&name, NULL);
dns_name_fromregion(&name, &region);
result = dns_name_towire(&name, cctx, target);
return (result);
}
static int
compare_mx(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
int result;
result = memcmp(rdata1->data, rdata2->data, 2);
if (result != 0)
return (result < 0 ? -1 : 1);
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
isc_region_consume(&region1, 2);
isc_region_consume(&region2, 2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_mx(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_mx(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,127 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_2_NS_H
#define RDATA_TYPE_2_NS_H
static dns_result_t
fromtext_ns(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
class = class; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_ns(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 2);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_ns(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 2);
class = class;
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_ns(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 2);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_ns(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_ns(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_ns(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,127 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_2_NS_H
#define RDATA_TYPE_2_NS_H
static dns_result_t
fromtext_ns(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
class = class; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_ns(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 2);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_ns(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 2);
class = class;
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_ns(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 2);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_ns(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_ns(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_ns(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,94 @@
/*
* Copyright (C) 1998 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.
*/
static dns_result_t
fromtext_null(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
class = class; /*unused*/
type = type; /*unused*/
lexer = lexer; /*unused*/
origin = origin; /*unused*/
downcase = downcase; /*unused*/
target = target; /*unused*/
return (DNS_R_SUCCESS);
}
static dns_result_t
totext_null(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
INSIST(rdata->length == 0);
origin = origin; /*unused*/
target = target; /*unused*/
return (DNS_R_SUCCESS);
}
static dns_result_t
fromwire_null(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
INSIST(type == 10);
class = class; /*unused*/
dctx = dctx; /*unused*/
downcase = downcase; /*unused*/
target = target; /*unused*/
source = source; /*unused*/
return (DNS_R_SUCCESS);
}
static dns_result_t
towire_null(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
INSIST(rdata->type == 10);
cctx = cctx; /*unused*/
target = target; /*unused*/
return (DNS_R_SUCCESS);
}
static int
compare_null(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
INSIST(rdata1->type == 10);
INSIST(rdata2->type == 10);
return (0);
}
static dns_result_t
fromstruct_null(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_null(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright (C) 1998 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.
*/
static dns_result_t
fromtext_null(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
class = class; /*unused*/
type = type; /*unused*/
lexer = lexer; /*unused*/
origin = origin; /*unused*/
downcase = downcase; /*unused*/
target = target; /*unused*/
return (DNS_R_SUCCESS);
}
static dns_result_t
totext_null(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
INSIST(rdata->length == 0);
origin = origin; /*unused*/
target = target; /*unused*/
return (DNS_R_SUCCESS);
}
static dns_result_t
fromwire_null(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
INSIST(type == 10);
class = class; /*unused*/
dctx = dctx; /*unused*/
downcase = downcase; /*unused*/
target = target; /*unused*/
source = source; /*unused*/
return (DNS_R_SUCCESS);
}
static dns_result_t
towire_null(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
INSIST(rdata->type == 10);
cctx = cctx; /*unused*/
target = target; /*unused*/
return (DNS_R_SUCCESS);
}
static int
compare_null(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
INSIST(rdata1->type == 10);
INSIST(rdata2->type == 10);
return (0);
}
static dns_result_t
fromstruct_null(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_null(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) 1998 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.
*/
static dns_result_t
fromtext_#(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
totext_#(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
fromwire_#(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
towire_#(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
return (DNS_R_NOTIMPLEMENTED);
}
static int
compare_#(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
return (0);
}
static dns_result_t
fromstruct_#(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_#(dns_rdata_t *rdata, void *target) {
return (DNS_R_NOTIMPLEMENTED);
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) 1998 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.
*/
static dns_result_t
fromtext_#(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
totext_#(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
fromwire_#(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
towire_#(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
return (DNS_R_NOTIMPLEMENTED);
}
static int
compare_#(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
return (0);
}
static dns_result_t
fromstruct_#(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_#(dns_rdata_t *rdata, void *target) {
return (DNS_R_NOTIMPLEMENTED);
}

View File

@@ -0,0 +1,129 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_12_PTR_H
#define RDATA_TYPE_12_PTR_H
static dns_result_t
fromtext_ptr(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
INSIST(type == 12);
class = class; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_ptr(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 12);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_ptr(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 12);
class = class; /* unused */
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_ptr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 12);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_ptr(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_ptr(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_ptr(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,129 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_12_PTR_H
#define RDATA_TYPE_12_PTR_H
static dns_result_t
fromtext_ptr(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
INSIST(type == 12);
class = class; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}
static dns_result_t
totext_ptr(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
isc_boolean_t sub;
INSIST(rdata->type == 12);
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
}
static dns_result_t
fromwire_ptr(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t name;
INSIST(type == 12);
class = class; /* unused */
dns_name_init(&name, NULL);
return (dns_name_fromwire(&name, source, dctx, downcase, target));
}
static dns_result_t
towire_ptr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name;
isc_region_t region;
INSIST(rdata->type == 12);
dns_name_init(&name, NULL);
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
return (dns_name_towire(&name, cctx, target));
}
static int
compare_ptr(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_t name1;
dns_name_t name2;
isc_region_t region1;
isc_region_t region2;
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
}
static dns_result_t
fromstruct_ptr(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_ptr(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,268 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_6_SOA_H
#define RDATA_TYPE_6_SOA_H
static dns_result_t
fromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
dns_result_t result;
int i;
class = class; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
result = dns_name_fromtext(&name, &buffer, origin, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
result = dns_name_fromtext(&name, &buffer, origin, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
for (i = 0; i < 5; i++) {
if (isc_lex_gettoken(lexer, ISC_LEXOPT_NUMBER, &token)
!= ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_number)
return (DNS_R_UNKNOWN);
result = uint32_fromtext(token.value.as_ulong, target);
if (result != DNS_R_SUCCESS)
return (result);
}
return (DNS_R_SUCCESS);
}
static dns_result_t
totext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t dregion;
dns_name_t mname;
dns_name_t rname;
dns_name_t prefix;
dns_result_t result;
isc_boolean_t sub;
int i;
INSIST(rdata->type == 6);
dns_name_init(&mname, NULL);
dns_name_init(&rname, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &dregion);
dns_name_fromregion(&mname, &dregion);
isc_region_consume(&dregion, name_length(&mname));
dns_name_fromregion(&rname, &dregion);
isc_region_consume(&dregion, name_length(&rname));
sub = name_prefix(&mname, origin, &prefix);
result = dns_name_totext(&prefix, sub, target);
if (result != DNS_R_SUCCESS)
return (result);
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
sub = name_prefix(&rname, origin, &prefix);
result = dns_name_totext(&prefix, sub, target);
if (result != DNS_R_SUCCESS)
return (result);
for (i = 0; i < 5 ; i++) {
char buf[sizeof "2147483647"];
unsigned long num;
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
num = uint32_fromregion(&dregion);
isc_region_consume(&dregion, 4);
sprintf(buf, "%lu", num);
result = str_totext(buf, target);
if (result != DNS_R_SUCCESS)
return (result);
}
return (DNS_R_SUCCESS);
}
static dns_result_t
fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t mname;
dns_name_t rname;
dns_result_t result;
isc_region_t sregion;
isc_region_t tregion;
INSIST(type == 6);
class = class; /*unused*/
dns_name_init(&mname, NULL);
dns_name_init(&rname, NULL);
result = dns_name_fromwire(&mname, source, dctx, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
result = dns_name_fromwire(&rname, source, dctx, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_remaining(source, &sregion);
isc_buffer_available(target, &tregion);
if (sregion.length != 20)
return (DNS_R_WIRE);
if (tregion.length < 20)
return (DNS_R_NOSPACE);
memcpy(tregion.base, sregion.base, 20);
isc_buffer_forward(source, 20);
isc_buffer_add(target, 20);
return (DNS_R_SUCCESS);
}
static dns_result_t
towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t sregion;
isc_region_t tregion;
dns_name_t mname;
dns_name_t rname;
dns_result_t result;
INSIST(rdata->type == 6);
dns_name_init(&mname, NULL);
dns_name_init(&rname, NULL);
dns_rdata_toregion(rdata, &sregion);
dns_name_fromregion(&mname, &sregion);
isc_region_consume(&sregion, name_length(&mname));
result = dns_name_towire(&mname, cctx, target);
if (result != DNS_R_SUCCESS)
return (result);
dns_name_fromregion(&rname, &sregion);
isc_region_consume(&sregion, name_length(&rname));
result = dns_name_towire(&rname, cctx, target);
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_remaining(target, &tregion);
if (tregion.length < 20)
return (DNS_R_NOSPACE);
memcpy(tregion.base, sregion.base, 20);
isc_buffer_add(target, 20);
return (DNS_R_SUCCESS);
}
static int
compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
isc_region_t region1;
isc_region_t region2;
dns_name_t name1;
dns_name_t name2;
int result;
INSIST(rdata1->type == 6);
INSIST(rdata2->type == 6);
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region1);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
result = dns_name_compare(&name1, &name2);
if (result != 0)
return (result);
isc_region_consume(&region1, name1.length);
isc_region_consume(&region2, name2.length);
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
result = dns_name_compare(&name1, &name2);
if (result != 0)
return (result);
isc_region_consume(&region1, name1.length);
isc_region_consume(&region2, name2.length);
result = memcmp(region1.base, region2.base, 12);
if (result != 0)
return ((result < 0) ? -1 : 1);
return (0);
}
static dns_result_t
fromstruct_soa(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_soa(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,268 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_TYPE_6_SOA_H
#define RDATA_TYPE_6_SOA_H
static dns_result_t
fromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_name_t name;
isc_buffer_t buffer;
dns_result_t result;
int i;
class = class; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
result = dns_name_fromtext(&name, &buffer, origin, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region,
ISC_BUFFERTYPE_TEXT);
origin = (origin != NULL) ? origin : dns_rootname;
result = dns_name_fromtext(&name, &buffer, origin, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
for (i = 0; i < 5; i++) {
if (isc_lex_gettoken(lexer, ISC_LEXOPT_NUMBER, &token)
!= ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_number)
return (DNS_R_UNKNOWN);
result = uint32_fromtext(token.value.as_ulong, target);
if (result != DNS_R_SUCCESS)
return (result);
}
return (DNS_R_SUCCESS);
}
static dns_result_t
totext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t dregion;
dns_name_t mname;
dns_name_t rname;
dns_name_t prefix;
dns_result_t result;
isc_boolean_t sub;
int i;
INSIST(rdata->type == 6);
dns_name_init(&mname, NULL);
dns_name_init(&rname, NULL);
dns_name_init(&prefix, NULL);
dns_rdata_toregion(rdata, &dregion);
dns_name_fromregion(&mname, &dregion);
isc_region_consume(&dregion, name_length(&mname));
dns_name_fromregion(&rname, &dregion);
isc_region_consume(&dregion, name_length(&rname));
sub = name_prefix(&mname, origin, &prefix);
result = dns_name_totext(&prefix, sub, target);
if (result != DNS_R_SUCCESS)
return (result);
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
sub = name_prefix(&rname, origin, &prefix);
result = dns_name_totext(&prefix, sub, target);
if (result != DNS_R_SUCCESS)
return (result);
for (i = 0; i < 5 ; i++) {
char buf[sizeof "2147483647"];
unsigned long num;
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
num = uint32_fromregion(&dregion);
isc_region_consume(&dregion, 4);
sprintf(buf, "%lu", num);
result = str_totext(buf, target);
if (result != DNS_R_SUCCESS)
return (result);
}
return (DNS_R_SUCCESS);
}
static dns_result_t
fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t mname;
dns_name_t rname;
dns_result_t result;
isc_region_t sregion;
isc_region_t tregion;
INSIST(type == 6);
class = class; /*unused*/
dns_name_init(&mname, NULL);
dns_name_init(&rname, NULL);
result = dns_name_fromwire(&mname, source, dctx, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
result = dns_name_fromwire(&rname, source, dctx, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_remaining(source, &sregion);
isc_buffer_available(target, &tregion);
if (sregion.length != 20)
return (DNS_R_WIRE);
if (tregion.length < 20)
return (DNS_R_NOSPACE);
memcpy(tregion.base, sregion.base, 20);
isc_buffer_forward(source, 20);
isc_buffer_add(target, 20);
return (DNS_R_SUCCESS);
}
static dns_result_t
towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t sregion;
isc_region_t tregion;
dns_name_t mname;
dns_name_t rname;
dns_result_t result;
INSIST(rdata->type == 6);
dns_name_init(&mname, NULL);
dns_name_init(&rname, NULL);
dns_rdata_toregion(rdata, &sregion);
dns_name_fromregion(&mname, &sregion);
isc_region_consume(&sregion, name_length(&mname));
result = dns_name_towire(&mname, cctx, target);
if (result != DNS_R_SUCCESS)
return (result);
dns_name_fromregion(&rname, &sregion);
isc_region_consume(&sregion, name_length(&rname));
result = dns_name_towire(&rname, cctx, target);
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_remaining(target, &tregion);
if (tregion.length < 20)
return (DNS_R_NOSPACE);
memcpy(tregion.base, sregion.base, 20);
isc_buffer_add(target, 20);
return (DNS_R_SUCCESS);
}
static int
compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
isc_region_t region1;
isc_region_t region2;
dns_name_t name1;
dns_name_t name2;
int result;
INSIST(rdata1->type == 6);
INSIST(rdata2->type == 6);
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region1);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
result = dns_name_compare(&name1, &name2);
if (result != 0)
return (result);
isc_region_consume(&region1, name1.length);
isc_region_consume(&region2, name2.length);
dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL);
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
result = dns_name_compare(&name1, &name2);
if (result != 0)
return (result);
isc_region_consume(&region1, name1.length);
isc_region_consume(&region2, name2.length);
result = memcmp(region1.base, region2.base, 12);
if (result != 0)
return ((result < 0) ? -1 : 1);
return (0);
}
static dns_result_t
fromstruct_soa(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_soa(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -0,0 +1,134 @@
/*
* Copyright (C) 1998 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.
*/
static dns_result_t
fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_result_t result;
class = class; /*unused*/
origin = origin; /*unused*/
downcase = downcase; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
while (token.type == isc_tokentype_string) {
result = txt_fromtext(&token.value.as_textregion, target);
if (result != DNS_R_SUCCESS)
return (result);
if (isc_lex_gettoken(lexer, ISC_LEXOPT_EOL | ISC_LEXOPT_EOF,
&token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
}
/* Let upper layer handle eol/eof. */
isc_lex_ungettoken(lexer, &token);
return (DNS_R_SUCCESS);
}
static dns_result_t
totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_result_t result;
origin = origin; /*unused*/
dns_rdata_toregion(rdata, &region);
while (region.length) {
result = txt_totext(&region, target);
if (result != DNS_R_SUCCESS)
return (result);
if (region.length) {
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
}
}
return (DNS_R_SUCCESS);
}
static dns_result_t
fromwire_txt(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_result_t result;
dctx = dctx;
class = class;
downcase = downcase;
INSIST(type == 16);
while (!buffer_empty(source)) {
result = txt_fromwire(source, target);
if (result != DNS_R_SUCCESS)
return (result);
}
return (DNS_R_SUCCESS);
}
static dns_result_t
towire_txt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
cctx = cctx;
if (target->length < rdata->length)
return (DNS_R_NOSPACE);
memcpy(target->base, rdata->data, rdata->length);
/*XXX*/
return (DNS_R_SUCCESS);
}
static int
compare_txt(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
int l;
int result;
l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length;
result = memcmp(rdata1->data, rdata2->data, l);
if (result != 0)
result = (result < 0) ? -1 : 1;
else if (rdata1->length != rdata2->length)
result = (rdata1->length < rdata2->length) ? -1 : 1;
return (result);
}
static dns_result_t
fromstruct_txt(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_txt(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}

View File

@@ -0,0 +1,134 @@
/*
* Copyright (C) 1998 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.
*/
static dns_result_t
fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
dns_result_t result;
class = class; /*unused*/
origin = origin; /*unused*/
downcase = downcase; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
while (token.type == isc_tokentype_string) {
result = txt_fromtext(&token.value.as_textregion, target);
if (result != DNS_R_SUCCESS)
return (result);
if (isc_lex_gettoken(lexer, ISC_LEXOPT_EOL | ISC_LEXOPT_EOF,
&token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
}
/* Let upper layer handle eol/eof. */
isc_lex_ungettoken(lexer, &token);
return (DNS_R_SUCCESS);
}
static dns_result_t
totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
dns_result_t result;
origin = origin; /*unused*/
dns_rdata_toregion(rdata, &region);
while (region.length) {
result = txt_totext(&region, target);
if (result != DNS_R_SUCCESS)
return (result);
if (region.length) {
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
}
}
return (DNS_R_SUCCESS);
}
static dns_result_t
fromwire_txt(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
dns_result_t result;
dctx = dctx;
class = class;
downcase = downcase;
INSIST(type == 16);
while (!buffer_empty(source)) {
result = txt_fromwire(source, target);
if (result != DNS_R_SUCCESS)
return (result);
}
return (DNS_R_SUCCESS);
}
static dns_result_t
towire_txt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
cctx = cctx;
if (target->length < rdata->length)
return (DNS_R_NOSPACE);
memcpy(target->base, rdata->data, rdata->length);
/*XXX*/
return (DNS_R_SUCCESS);
}
static int
compare_txt(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
int l;
int result;
l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length;
result = memcmp(rdata1->data, rdata2->data, l);
if (result != 0)
result = (result < 0) ? -1 : 1;
else if (rdata1->length != rdata2->length)
result = (rdata1->length < rdata2->length) ? -1 : 1;
return (result);
}
static dns_result_t
fromstruct_txt(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_txt(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}

143
lib/dns/rdata/in_1/a_1.c Normal file
View File

@@ -0,0 +1,143 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_IN_1_A_1_H
#define RDATA_IN_1_A_1_H
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <string.h>
static dns_result_t
fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
struct in_addr addr;
isc_region_t region;
INSIST(type == 1);
class = class; /*unused*/
origin = origin; /*unused*/
downcase = downcase; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
if (inet_aton(token.value.as_pointer , &addr) != 1)
return (DNS_R_UNKNOWN);
isc_buffer_available(target, &region);
if (region.length < 4)
return (DNS_R_NOSPACE);
memcpy(region.base, &addr, 4);
isc_buffer_add(target, 4);
return (DNS_R_SUCCESS);
}
static dns_result_t
totext_in_a(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
INSIST(rdata->type == 1);
INSIST(rdata->class == 1);
INSIST(rdata->length == 4);
origin = origin; /* unused */
isc_buffer_available(target, &region);
if (inet_ntop(AF_INET, rdata->data,
region.base, region.length) == NULL)
return (DNS_R_NOSPACE);
isc_buffer_add(target, strlen(region.base));
return (DNS_R_SUCCESS);
}
static dns_result_t
fromwire_in_a(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_region_t sregion;
isc_region_t tregion;
INSIST(class == 1);
INSIST(type == 1);
dctx = dctx; /* unused */
downcase = downcase; /* unused */
isc_buffer_remaining(source, &sregion);
isc_buffer_available(target, &tregion);
if (sregion.length != 4)
return (DNS_R_WIRE);
if (tregion.length < 4)
return (DNS_R_NOSPACE);
memcpy(tregion.base, sregion.base, 4);
isc_buffer_forward(source, 4);
isc_buffer_add(target, 4);
return (DNS_R_SUCCESS);
}
static dns_result_t
towire_in_a(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t region;
cctx = cctx;
isc_buffer_available(target, &region);
if (region.length < rdata->length)
return (DNS_R_NOSPACE);
memcpy(region.base, rdata->data, rdata->length);
isc_buffer_add(target, 4);
return (DNS_R_SUCCESS);
}
static int
compare_in_a(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
int result;
result = memcmp(rdata1->data, rdata2->data, 4);
if (result != 0)
result = (result < 0) ? -1 : 1;
return (result);
}
static dns_result_t
fromstruct_in_a(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_in_a(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

143
lib/dns/rdata/in_1/a_1.h Normal file
View File

@@ -0,0 +1,143 @@
/*
* Copyright (C) 1998 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.
*/
#ifndef RDATA_IN_1_A_1_H
#define RDATA_IN_1_A_1_H
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <string.h>
static dns_result_t
fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token;
struct in_addr addr;
isc_region_t region;
INSIST(type == 1);
class = class; /*unused*/
origin = origin; /*unused*/
downcase = downcase; /*unused*/
if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
if (token.type != isc_tokentype_string)
return (DNS_R_UNKNOWN);
if (inet_aton(token.value.as_pointer , &addr) != 1)
return (DNS_R_UNKNOWN);
isc_buffer_available(target, &region);
if (region.length < 4)
return (DNS_R_NOSPACE);
memcpy(region.base, &addr, 4);
isc_buffer_add(target, 4);
return (DNS_R_SUCCESS);
}
static dns_result_t
totext_in_a(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region;
INSIST(rdata->type == 1);
INSIST(rdata->class == 1);
INSIST(rdata->length == 4);
origin = origin; /* unused */
isc_buffer_available(target, &region);
if (inet_ntop(AF_INET, rdata->data,
region.base, region.length) == NULL)
return (DNS_R_NOSPACE);
isc_buffer_add(target, strlen(region.base));
return (DNS_R_SUCCESS);
}
static dns_result_t
fromwire_in_a(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) {
isc_region_t sregion;
isc_region_t tregion;
INSIST(class == 1);
INSIST(type == 1);
dctx = dctx; /* unused */
downcase = downcase; /* unused */
isc_buffer_remaining(source, &sregion);
isc_buffer_available(target, &tregion);
if (sregion.length != 4)
return (DNS_R_WIRE);
if (tregion.length < 4)
return (DNS_R_NOSPACE);
memcpy(tregion.base, sregion.base, 4);
isc_buffer_forward(source, 4);
isc_buffer_add(target, 4);
return (DNS_R_SUCCESS);
}
static dns_result_t
towire_in_a(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t region;
cctx = cctx;
isc_buffer_available(target, &region);
if (region.length < rdata->length)
return (DNS_R_NOSPACE);
memcpy(region.base, rdata->data, rdata->length);
isc_buffer_add(target, 4);
return (DNS_R_SUCCESS);
}
static int
compare_in_a(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
int result;
result = memcmp(rdata1->data, rdata2->data, 4);
if (result != 0)
result = (result < 0) ? -1 : 1;
return (result);
}
static dns_result_t
fromstruct_in_a(dns_rdataclass_t class, dns_rdatatype_t type, void *source,
isc_buffer_t *target) {
class = class;
type = type;
source = source;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
static dns_result_t
tostruct_in_a(dns_rdata_t *rdata, void *target) {
rdata = rdata;
target = target;
return (DNS_R_NOTIMPLEMENTED);
}
#endif

View File

@@ -233,12 +233,9 @@ dns_rdataset_totext(dns_rdataset_t *rdataset,
}
dns_rdataset_current(rdataset, &rdata);
/* XXX */
#if 0
result = dns_rdata_totext(&rdata, NULL, target);
result = dns_rdata_totext(&rdata, target);
if (result != DNS_R_SUCCESS)
return (result);
#endif
isc_buffer_available(target, &r);
if (r.length < 1)
return (DNS_R_NOSPACE);