2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-03 16:15:27 +00:00

dns_rdata_compare checked for RFC 1035 types

converted frometext* to use gettoken()
	converted:
		result = foo();
		if (result != DNS_R_SUCCESS)
			return (result);
	to
		RETERR(foo());
This commit is contained in:
Mark Andrews
1999-01-22 00:36:59 +00:00
parent 530570705a
commit deaaf94332
32 changed files with 264 additions and 805 deletions

View File

@@ -45,6 +45,7 @@ main(int argc, char *argv[]) {
unsigned int options = 0; unsigned int options = 0;
unsigned int parens = 0; unsigned int parens = 0;
dns_rdatatype_t type; dns_rdatatype_t type;
dns_rdatatype_t lasttype = 0;
char outbuf[16*1024]; char outbuf[16*1024];
char inbuf[16*1024]; char inbuf[16*1024];
char wirebuf[16*1024]; char wirebuf[16*1024];
@@ -52,6 +53,7 @@ main(int argc, char *argv[]) {
isc_buffer_t tbuf; isc_buffer_t tbuf;
isc_buffer_t wbuf; isc_buffer_t wbuf;
dns_rdata_t rdata; dns_rdata_t rdata;
dns_rdata_t last;
int need_eol = 0; int need_eol = 0;
int wire = 0; int wire = 0;
dns_compress_t cctx; dns_compress_t cctx;
@@ -61,6 +63,8 @@ main(int argc, char *argv[]) {
int len; int len;
int zero = 0; int zero = 0;
int debug = 0; int debug = 0;
isc_region_t region;
int first = 1;
while ((c = getopt(argc, argv, "dqswtaz")) != -1) { while ((c = getopt(argc, argv, "dqswtaz")) != -1) {
switch (c) { switch (c) {
@@ -107,6 +111,7 @@ main(int argc, char *argv[]) {
RUNTIME_CHECK(isc_lex_openstream(lex, stdin) == ISC_R_SUCCESS); RUNTIME_CHECK(isc_lex_openstream(lex, stdin) == ISC_R_SUCCESS);
dns_rdata_init(&last);
while ((result = isc_lex_gettoken(lex, options | ISC_LEXOPT_NUMBER, while ((result = isc_lex_gettoken(lex, options | ISC_LEXOPT_NUMBER,
&token)) == ISC_R_SUCCESS) { &token)) == ISC_R_SUCCESS) {
if (debug) fprintf(stdout, "token.type = %d\n", token.type); if (debug) fprintf(stdout, "token.type = %d\n", token.type);
@@ -219,6 +224,24 @@ main(int argc, char *argv[]) {
fprintf(stdout, "\"%.*s\"\n", fprintf(stdout, "\"%.*s\"\n",
(int)tbuf.used, (char*)tbuf.base); (int)tbuf.used, (char*)tbuf.base);
fflush(stdout); fflush(stdout);
if (lasttype == type) {
fprintf(stdout, "dns_rdata_compare = %d\n",
dns_rdata_compare(&rdata, &last));
}
if (!first) {
free(last.data);
}
dns_rdata_init(&last);
region.base = malloc(region.length = rdata.length);
if (region.base) {
memcpy(region.base, rdata.data, rdata.length);
dns_rdata_fromregion(&last, 1, type, &region);
lasttype = type;
first = 0;
} else
first = 1;
} }
if (result != ISC_R_EOF) if (result != ISC_R_EOF)
printf("Result: %s\n", isc_result_totext(result)); printf("Result: %s\n", isc_result_totext(result));

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: rdata.c,v 1.8 1999/01/21 06:02:13 marka Exp $ */ /* $Id: rdata.c,v 1.9 1999/01/22 00:36:54 marka Exp $ */
#include <isc/buffer.h> #include <isc/buffer.h>
#include <isc/lex.h> #include <isc/lex.h>
@@ -28,6 +28,12 @@
#include <stdio.h> #include <stdio.h>
#include <isc/assertions.h> #include <isc/assertions.h>
#define RETERR(x) { \
dns_result_t __r = (x); \
if (__r != DNS_R_SUCCESS) \
return (__r); \
}
static dns_result_t txt_totext(isc_region_t *source, isc_buffer_t *target); static dns_result_t txt_totext(isc_region_t *source, isc_buffer_t *target);
static dns_result_t txt_fromtext(isc_textregion_t *source, static dns_result_t txt_fromtext(isc_textregion_t *source,
isc_buffer_t *target); isc_buffer_t *target);

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: cname_5.c,v 1.4 1999/01/20 05:20:19 marka Exp $ */ /* $Id: cname_5.c,v 1.5 1999/01/22 00:36:55 marka Exp $ */
#ifndef RDATA_GENERIC_CNAME_5_H #ifndef RDATA_GENERIC_CNAME_5_H
#define RDATA_GENERIC_CNAME_5_H #define RDATA_GENERIC_CNAME_5_H
@@ -27,21 +27,11 @@ fromtext_cname(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 5); REQUIRE(type == 5);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: cname_5.h,v 1.4 1999/01/20 05:20:19 marka Exp $ */ /* $Id: cname_5.h,v 1.5 1999/01/22 00:36:55 marka Exp $ */
#ifndef RDATA_GENERIC_CNAME_5_H #ifndef RDATA_GENERIC_CNAME_5_H
#define RDATA_GENERIC_CNAME_5_H #define RDATA_GENERIC_CNAME_5_H
@@ -27,21 +27,11 @@ fromtext_cname(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 5); REQUIRE(type == 5);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: hinfo_13.c,v 1.5 1999/01/20 05:20:20 marka Exp $ */ /* $Id: hinfo_13.c,v 1.6 1999/01/22 00:36:55 marka Exp $ */
#ifndef RDATA_GENERIC_HINFO_13_H #ifndef RDATA_GENERIC_HINFO_13_H
#define RDATA_GENERIC_HINFO_13_H #define RDATA_GENERIC_HINFO_13_H
@@ -25,8 +25,7 @@ fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin, isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token; isc_token_t token;
dns_result_t result; int i;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 13); REQUIRE(type == 13);
@@ -34,60 +33,32 @@ fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
origin = origin; /*unused*/ origin = origin; /*unused*/
downcase = downcase; /*unused*/ downcase = downcase; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) for (i = 0; i < 2 ; i++) {
return (DNS_R_UNEXPECTED); RETERR(gettoken(lexer, &token, isc_tokentype_string,
if (token.type != isc_tokentype_string) { ISC_FALSE));
isc_lex_ungettoken(lexer, &token); RETERR(txt_fromtext(&token.value.as_textregion, target));
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
} }
return (DNS_R_SUCCESS);
result = txt_fromtext(&token.value.as_textregion, target);
if (result != DNS_R_SUCCESS)
return (result);
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS)
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
return (txt_fromtext(&token.value.as_textregion, target));
} }
static dns_result_t static dns_result_t
totext_hinfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { totext_hinfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region; isc_region_t region;
dns_result_t result;
REQUIRE(rdata->type == 13); REQUIRE(rdata->type == 13);
origin = origin; /*unused*/ origin = origin; /*unused*/
dns_rdata_toregion(rdata, &region); dns_rdata_toregion(rdata, &region);
RETERR(txt_totext(&region, target));
result = txt_totext(&region, target); RETERR(str_totext(" ", target));
if (result != DNS_R_SUCCESS) return (txt_totext(&region, target));
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 static dns_result_t
fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx, isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
dns_result_t result;
REQUIRE(type == 13); REQUIRE(type == 13);
@@ -95,10 +66,7 @@ fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
class = class; /* unused */ class = class; /* unused */
downcase = downcase; /* unused */ downcase = downcase; /* unused */
result = txt_fromwire(source, target); RETERR(txt_fromwire(source, target));
if (result != DNS_R_SUCCESS)
return (result);
return (txt_fromwire(source, target)); return (txt_fromwire(source, target));
} }

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: hinfo_13.h,v 1.5 1999/01/20 05:20:20 marka Exp $ */ /* $Id: hinfo_13.h,v 1.6 1999/01/22 00:36:55 marka Exp $ */
#ifndef RDATA_GENERIC_HINFO_13_H #ifndef RDATA_GENERIC_HINFO_13_H
#define RDATA_GENERIC_HINFO_13_H #define RDATA_GENERIC_HINFO_13_H
@@ -25,8 +25,7 @@ fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin, isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token; isc_token_t token;
dns_result_t result; int i;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 13); REQUIRE(type == 13);
@@ -34,60 +33,32 @@ fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
origin = origin; /*unused*/ origin = origin; /*unused*/
downcase = downcase; /*unused*/ downcase = downcase; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) for (i = 0; i < 2 ; i++) {
return (DNS_R_UNEXPECTED); RETERR(gettoken(lexer, &token, isc_tokentype_string,
if (token.type != isc_tokentype_string) { ISC_FALSE));
isc_lex_ungettoken(lexer, &token); RETERR(txt_fromtext(&token.value.as_textregion, target));
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
} }
return (DNS_R_SUCCESS);
result = txt_fromtext(&token.value.as_textregion, target);
if (result != DNS_R_SUCCESS)
return (result);
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS)
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
return (txt_fromtext(&token.value.as_textregion, target));
} }
static dns_result_t static dns_result_t
totext_hinfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { totext_hinfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region; isc_region_t region;
dns_result_t result;
REQUIRE(rdata->type == 13); REQUIRE(rdata->type == 13);
origin = origin; /*unused*/ origin = origin; /*unused*/
dns_rdata_toregion(rdata, &region); dns_rdata_toregion(rdata, &region);
RETERR(txt_totext(&region, target));
result = txt_totext(&region, target); RETERR(str_totext(" ", target));
if (result != DNS_R_SUCCESS) return (txt_totext(&region, target));
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 static dns_result_t
fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_t *source, dns_decompress_t *dctx, isc_buffer_t *source, dns_decompress_t *dctx,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
dns_result_t result;
REQUIRE(type == 13); REQUIRE(type == 13);
@@ -95,10 +66,7 @@ fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type,
class = class; /* unused */ class = class; /* unused */
downcase = downcase; /* unused */ downcase = downcase; /* unused */
result = txt_fromwire(source, target); RETERR(txt_fromwire(source, target));
if (result != DNS_R_SUCCESS)
return (result);
return (txt_fromwire(source, target)); return (txt_fromwire(source, target));
} }

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: mb_7.c,v 1.4 1999/01/20 05:20:20 marka Exp $ */ /* $Id: mb_7.c,v 1.5 1999/01/22 00:36:55 marka Exp $ */
#ifndef RDATA_GENERIC_MB_7_H #ifndef RDATA_GENERIC_MB_7_H
#define RDATA_GENERIC_MB_7_H #define RDATA_GENERIC_MB_7_H
@@ -27,21 +27,12 @@ fromtext_mb(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 7); REQUIRE(type == 7);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: mb_7.h,v 1.4 1999/01/20 05:20:20 marka Exp $ */ /* $Id: mb_7.h,v 1.5 1999/01/22 00:36:55 marka Exp $ */
#ifndef RDATA_GENERIC_MB_7_H #ifndef RDATA_GENERIC_MB_7_H
#define RDATA_GENERIC_MB_7_H #define RDATA_GENERIC_MB_7_H
@@ -27,21 +27,12 @@ fromtext_mb(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 7); REQUIRE(type == 7);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: md_3.c,v 1.4 1999/01/20 05:20:20 marka Exp $ */ /* $Id: md_3.c,v 1.5 1999/01/22 00:36:55 marka Exp $ */
#ifndef RDATA_GENERIC_MD_3_H #ifndef RDATA_GENERIC_MD_3_H
#define RDATA_GENERIC_MD_3_H #define RDATA_GENERIC_MD_3_H
@@ -25,25 +25,14 @@ fromtext_md(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin, isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token; isc_token_t token;
isc_result_t result;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 3); REQUIRE(type == 3);
class = class; /*unused*/ class = class; /*unused*/
result = isc_lex_gettoken(lexer, options, &token); RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
if (result != ISC_R_SUCCESS)
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: md_3.h,v 1.4 1999/01/20 05:20:20 marka Exp $ */ /* $Id: md_3.h,v 1.5 1999/01/22 00:36:55 marka Exp $ */
#ifndef RDATA_GENERIC_MD_3_H #ifndef RDATA_GENERIC_MD_3_H
#define RDATA_GENERIC_MD_3_H #define RDATA_GENERIC_MD_3_H
@@ -25,25 +25,14 @@ fromtext_md(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin, isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token; isc_token_t token;
isc_result_t result;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 3); REQUIRE(type == 3);
class = class; /*unused*/ class = class; /*unused*/
result = isc_lex_gettoken(lexer, options, &token); RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
if (result != ISC_R_SUCCESS)
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: mf_4.c,v 1.4 1999/01/20 05:20:20 marka Exp $ */ /* $Id: mf_4.c,v 1.5 1999/01/22 00:36:56 marka Exp $ */
#ifndef RDATA_GENERIC_MF_4_H #ifndef RDATA_GENERIC_MF_4_H
#define RDATA_GENERIC_MF_4_H #define RDATA_GENERIC_MF_4_H
@@ -27,21 +27,12 @@ fromtext_mf(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 4); REQUIRE(type == 4);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: mf_4.h,v 1.4 1999/01/20 05:20:20 marka Exp $ */ /* $Id: mf_4.h,v 1.5 1999/01/22 00:36:56 marka Exp $ */
#ifndef RDATA_GENERIC_MF_4_H #ifndef RDATA_GENERIC_MF_4_H
#define RDATA_GENERIC_MF_4_H #define RDATA_GENERIC_MF_4_H
@@ -27,21 +27,12 @@ fromtext_mf(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 4); REQUIRE(type == 4);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: mg_8.c,v 1.4 1999/01/20 05:20:21 marka Exp $ */ /* $Id: mg_8.c,v 1.5 1999/01/22 00:36:56 marka Exp $ */
#ifndef RDATA_GENERIC_MG_8_H #ifndef RDATA_GENERIC_MG_8_H
#define RDATA_GENERIC_MG_8_H #define RDATA_GENERIC_MG_8_H
@@ -27,21 +27,12 @@ fromtext_mg(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 8); REQUIRE(type == 8);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: mg_8.h,v 1.4 1999/01/20 05:20:21 marka Exp $ */ /* $Id: mg_8.h,v 1.5 1999/01/22 00:36:56 marka Exp $ */
#ifndef RDATA_GENERIC_MG_8_H #ifndef RDATA_GENERIC_MG_8_H
#define RDATA_GENERIC_MG_8_H #define RDATA_GENERIC_MG_8_H
@@ -27,21 +27,12 @@ fromtext_mg(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 8); REQUIRE(type == 8);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: minfo_14.c,v 1.4 1999/01/20 05:20:21 marka Exp $ */ /* $Id: minfo_14.c,v 1.5 1999/01/22 00:36:56 marka Exp $ */
#ifndef RDATA_GENERIC_MINFO_14_H #ifndef RDATA_GENERIC_MINFO_14_H
#define RDATA_GENERIC_MINFO_14_H #define RDATA_GENERIC_MINFO_14_H
@@ -25,48 +25,25 @@ fromtext_minfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin, isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token; isc_token_t token;
dns_result_t result;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; int i;
REQUIRE(type == 14); REQUIRE(type == 14);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) for (i = 0; i < 2 ; i++) {
return (DNS_R_UNEXPECTED); RETERR(gettoken(lexer, &token, isc_tokentype_string,
if (token.type != isc_tokentype_string) { ISC_FALSE));
isc_lex_ungettoken(lexer, &token); dns_name_init(&name, NULL);
if (token.type == isc_tokentype_eol || buffer_fromregion(&buffer, &token.value.as_region,
token.type == isc_tokentype_eof) ISC_BUFFERTYPE_TEXT);
return(DNS_R_UNEXPECTEDEND); origin = (origin != NULL) ? origin : dns_rootname;
return (DNS_R_UNEXPECTED); RETERR(dns_name_fromtext(&name, &buffer, origin,
downcase, target));
} }
return (DNS_R_SUCCESS);
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, options, &token) != ISC_R_SUCCESS) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
if (token.type != isc_tokentype_string)
return (DNS_R_UNEXPECTED);
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 static dns_result_t
@@ -75,7 +52,6 @@ totext_minfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
dns_name_t rmail; dns_name_t rmail;
dns_name_t email; dns_name_t email;
dns_name_t prefix; dns_name_t prefix;
dns_result_t result;
isc_boolean_t sub; isc_boolean_t sub;
REQUIRE(rdata->type == 14); REQUIRE(rdata->type == 14);
@@ -94,20 +70,12 @@ totext_minfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
sub = name_prefix(&rmail, origin, &prefix); sub = name_prefix(&rmail, origin, &prefix);
result = dns_name_totext(&prefix, sub, target); RETERR(dns_name_totext(&prefix, sub, target));
if (result != DNS_R_SUCCESS)
return (result);
result = str_totext(" ", target); RETERR(str_totext(" ", target));
if (result != DNS_R_SUCCESS)
return (result);
sub = name_prefix(&email, origin, &prefix); sub = name_prefix(&email, origin, &prefix);
result = dns_name_totext(&prefix, sub, target); return (dns_name_totext(&prefix, sub, target));
if (result != DNS_R_SUCCESS)
return (result);
return (DNS_R_SUCCESS);
} }
static dns_result_t static dns_result_t
@@ -116,7 +84,6 @@ fromwire_minfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t rmail; dns_name_t rmail;
dns_name_t email; dns_name_t email;
dns_result_t result;
REQUIRE(type == 14); REQUIRE(type == 14);
@@ -125,10 +92,7 @@ fromwire_minfo(dns_rdataclass_t class, dns_rdatatype_t type,
dns_name_init(&rmail, NULL); dns_name_init(&rmail, NULL);
dns_name_init(&email, NULL); dns_name_init(&email, NULL);
result = dns_name_fromwire(&rmail, source, dctx, downcase, target); RETERR(dns_name_fromwire(&rmail, source, dctx, downcase, target));
if (result != DNS_R_SUCCESS)
return (result);
return (dns_name_fromwire(&email, source, dctx, downcase, target)); return (dns_name_fromwire(&email, source, dctx, downcase, target));
} }
@@ -137,7 +101,6 @@ towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t region; isc_region_t region;
dns_name_t rmail; dns_name_t rmail;
dns_name_t email; dns_name_t email;
dns_result_t result;
REQUIRE(rdata->type == 14); REQUIRE(rdata->type == 14);
@@ -149,16 +112,12 @@ towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_fromregion(&rmail, &region); dns_name_fromregion(&rmail, &region);
isc_region_consume(&region, rmail.length); isc_region_consume(&region, rmail.length);
result = dns_name_towire(&rmail, cctx, target); RETERR(dns_name_towire(&rmail, cctx, target));
if (result != DNS_R_SUCCESS)
return (result);
dns_name_fromregion(&rmail, &region); dns_name_fromregion(&rmail, &region);
isc_region_consume(&region, rmail.length); isc_region_consume(&region, rmail.length);
result = dns_name_towire(&rmail, cctx, target); return (dns_name_towire(&rmail, cctx, target));
return (DNS_R_SUCCESS);
} }
static int static int
@@ -177,7 +136,7 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_init(&name2, NULL); dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1); dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region1); dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1); dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2); dns_name_fromregion(&name2, &region2);
@@ -186,8 +145,8 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
if (result != 0) if (result != 0)
return (result); return (result);
isc_region_consume(&region1, name1.length); isc_region_consume(&region1, name_length(&name1));
isc_region_consume(&region2, name2.length); isc_region_consume(&region2, name_length(&name2));
dns_name_init(&name1, NULL); dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL); dns_name_init(&name2, NULL);

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: minfo_14.h,v 1.4 1999/01/20 05:20:21 marka Exp $ */ /* $Id: minfo_14.h,v 1.5 1999/01/22 00:36:56 marka Exp $ */
#ifndef RDATA_GENERIC_MINFO_14_H #ifndef RDATA_GENERIC_MINFO_14_H
#define RDATA_GENERIC_MINFO_14_H #define RDATA_GENERIC_MINFO_14_H
@@ -25,48 +25,25 @@ fromtext_minfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin, isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token; isc_token_t token;
dns_result_t result;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; int i;
REQUIRE(type == 14); REQUIRE(type == 14);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) for (i = 0; i < 2 ; i++) {
return (DNS_R_UNEXPECTED); RETERR(gettoken(lexer, &token, isc_tokentype_string,
if (token.type != isc_tokentype_string) { ISC_FALSE));
isc_lex_ungettoken(lexer, &token); dns_name_init(&name, NULL);
if (token.type == isc_tokentype_eol || buffer_fromregion(&buffer, &token.value.as_region,
token.type == isc_tokentype_eof) ISC_BUFFERTYPE_TEXT);
return(DNS_R_UNEXPECTEDEND); origin = (origin != NULL) ? origin : dns_rootname;
return (DNS_R_UNEXPECTED); RETERR(dns_name_fromtext(&name, &buffer, origin,
downcase, target));
} }
return (DNS_R_SUCCESS);
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, options, &token) != ISC_R_SUCCESS) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
if (token.type != isc_tokentype_string)
return (DNS_R_UNEXPECTED);
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 static dns_result_t
@@ -75,7 +52,6 @@ totext_minfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
dns_name_t rmail; dns_name_t rmail;
dns_name_t email; dns_name_t email;
dns_name_t prefix; dns_name_t prefix;
dns_result_t result;
isc_boolean_t sub; isc_boolean_t sub;
REQUIRE(rdata->type == 14); REQUIRE(rdata->type == 14);
@@ -94,20 +70,12 @@ totext_minfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
sub = name_prefix(&rmail, origin, &prefix); sub = name_prefix(&rmail, origin, &prefix);
result = dns_name_totext(&prefix, sub, target); RETERR(dns_name_totext(&prefix, sub, target));
if (result != DNS_R_SUCCESS)
return (result);
result = str_totext(" ", target); RETERR(str_totext(" ", target));
if (result != DNS_R_SUCCESS)
return (result);
sub = name_prefix(&email, origin, &prefix); sub = name_prefix(&email, origin, &prefix);
result = dns_name_totext(&prefix, sub, target); return (dns_name_totext(&prefix, sub, target));
if (result != DNS_R_SUCCESS)
return (result);
return (DNS_R_SUCCESS);
} }
static dns_result_t static dns_result_t
@@ -116,7 +84,6 @@ fromwire_minfo(dns_rdataclass_t class, dns_rdatatype_t type,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t rmail; dns_name_t rmail;
dns_name_t email; dns_name_t email;
dns_result_t result;
REQUIRE(type == 14); REQUIRE(type == 14);
@@ -125,10 +92,7 @@ fromwire_minfo(dns_rdataclass_t class, dns_rdatatype_t type,
dns_name_init(&rmail, NULL); dns_name_init(&rmail, NULL);
dns_name_init(&email, NULL); dns_name_init(&email, NULL);
result = dns_name_fromwire(&rmail, source, dctx, downcase, target); RETERR(dns_name_fromwire(&rmail, source, dctx, downcase, target));
if (result != DNS_R_SUCCESS)
return (result);
return (dns_name_fromwire(&email, source, dctx, downcase, target)); return (dns_name_fromwire(&email, source, dctx, downcase, target));
} }
@@ -137,7 +101,6 @@ towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t region; isc_region_t region;
dns_name_t rmail; dns_name_t rmail;
dns_name_t email; dns_name_t email;
dns_result_t result;
REQUIRE(rdata->type == 14); REQUIRE(rdata->type == 14);
@@ -149,16 +112,12 @@ towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_fromregion(&rmail, &region); dns_name_fromregion(&rmail, &region);
isc_region_consume(&region, rmail.length); isc_region_consume(&region, rmail.length);
result = dns_name_towire(&rmail, cctx, target); RETERR(dns_name_towire(&rmail, cctx, target));
if (result != DNS_R_SUCCESS)
return (result);
dns_name_fromregion(&rmail, &region); dns_name_fromregion(&rmail, &region);
isc_region_consume(&region, rmail.length); isc_region_consume(&region, rmail.length);
result = dns_name_towire(&rmail, cctx, target); return (dns_name_towire(&rmail, cctx, target));
return (DNS_R_SUCCESS);
} }
static int static int
@@ -177,7 +136,7 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_init(&name2, NULL); dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1); dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region1); dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1); dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2); dns_name_fromregion(&name2, &region2);
@@ -186,8 +145,8 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
if (result != 0) if (result != 0)
return (result); return (result);
isc_region_consume(&region1, name1.length); isc_region_consume(&region1, name_length(&name1));
isc_region_consume(&region2, name2.length); isc_region_consume(&region2, name_length(&name2));
dns_name_init(&name1, NULL); dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL); dns_name_init(&name2, NULL);

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: mr_9.c,v 1.4 1999/01/20 05:20:21 marka Exp $ */ /* $Id: mr_9.c,v 1.5 1999/01/22 00:36:57 marka Exp $ */
#ifndef RDATA_GENERIC_MR_9_H #ifndef RDATA_GENERIC_MR_9_H
#define RDATA_GENERIC_MR_9_H #define RDATA_GENERIC_MR_9_H
@@ -27,21 +27,12 @@ fromtext_mr(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 9); REQUIRE(type == 9);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: mr_9.h,v 1.4 1999/01/20 05:20:21 marka Exp $ */ /* $Id: mr_9.h,v 1.5 1999/01/22 00:36:57 marka Exp $ */
#ifndef RDATA_GENERIC_MR_9_H #ifndef RDATA_GENERIC_MR_9_H
#define RDATA_GENERIC_MR_9_H #define RDATA_GENERIC_MR_9_H
@@ -27,21 +27,12 @@ fromtext_mr(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 9); REQUIRE(type == 9);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: mx_15.c,v 1.7 1999/01/21 06:02:14 marka Exp $ */ /* $Id: mx_15.c,v 1.8 1999/01/22 00:36:57 marka Exp $ */
#ifndef RDATA_GENERIC_MX_15_H #ifndef RDATA_GENERIC_MX_15_H
#define RDATA_GENERIC_MX_15_H #define RDATA_GENERIC_MX_15_H
@@ -27,38 +27,16 @@ fromtext_mx(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
dns_result_t result;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 15); REQUIRE(type == 15);
class = class; /*unused*/ class = class; /*unused*/
options |= ISC_LEXOPT_NUMBER; RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS)
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_number) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
result = uint16_tobuffer(token.value.as_ulong, target); RETERR(uint16_tobuffer(token.value.as_ulong, target));
if (result != DNS_R_SUCCESS)
return (result);
options &= ~ISC_LEXOPT_NUMBER; RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS)
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,
@@ -73,7 +51,6 @@ totext_mx(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
dns_name_t name; dns_name_t name;
dns_name_t prefix; dns_name_t prefix;
isc_boolean_t sub; isc_boolean_t sub;
dns_result_t result;
char buf[sizeof "64000"]; char buf[sizeof "64000"];
unsigned short num; unsigned short num;
@@ -86,14 +63,8 @@ totext_mx(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
num = uint16_fromregion(&region); num = uint16_fromregion(&region);
isc_region_consume(&region, 2); isc_region_consume(&region, 2);
sprintf(buf, "%u", num); sprintf(buf, "%u", num);
result = str_totext(buf, target); RETERR(str_totext(buf, target));
if (result != DNS_R_SUCCESS) RETERR(str_totext(" ", target));
return (result);
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
dns_name_fromregion(&name, &region); dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix); sub = name_prefix(&name, origin, &prefix);
return(dns_name_totext(&prefix, sub, target)); return(dns_name_totext(&prefix, sub, target));
@@ -128,7 +99,6 @@ static dns_result_t
towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name; dns_name_t name;
isc_region_t region; isc_region_t region;
dns_result_t result;
isc_region_t tr; isc_region_t tr;
REQUIRE(rdata->type == 15); REQUIRE(rdata->type == 15);
@@ -144,8 +114,7 @@ towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
dns_name_fromregion(&name, &region); dns_name_fromregion(&name, &region);
result = dns_name_towire(&name, cctx, target); return (dns_name_towire(&name, cctx, target));
return (result);
} }
static int static int

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: mx_15.h,v 1.7 1999/01/21 06:02:14 marka Exp $ */ /* $Id: mx_15.h,v 1.8 1999/01/22 00:36:57 marka Exp $ */
#ifndef RDATA_GENERIC_MX_15_H #ifndef RDATA_GENERIC_MX_15_H
#define RDATA_GENERIC_MX_15_H #define RDATA_GENERIC_MX_15_H
@@ -27,38 +27,16 @@ fromtext_mx(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
dns_result_t result;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 15); REQUIRE(type == 15);
class = class; /*unused*/ class = class; /*unused*/
options |= ISC_LEXOPT_NUMBER; RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS)
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_number) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
result = uint16_tobuffer(token.value.as_ulong, target); RETERR(uint16_tobuffer(token.value.as_ulong, target));
if (result != DNS_R_SUCCESS)
return (result);
options &= ~ISC_LEXOPT_NUMBER; RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS)
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,
@@ -73,7 +51,6 @@ totext_mx(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
dns_name_t name; dns_name_t name;
dns_name_t prefix; dns_name_t prefix;
isc_boolean_t sub; isc_boolean_t sub;
dns_result_t result;
char buf[sizeof "64000"]; char buf[sizeof "64000"];
unsigned short num; unsigned short num;
@@ -86,14 +63,8 @@ totext_mx(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
num = uint16_fromregion(&region); num = uint16_fromregion(&region);
isc_region_consume(&region, 2); isc_region_consume(&region, 2);
sprintf(buf, "%u", num); sprintf(buf, "%u", num);
result = str_totext(buf, target); RETERR(str_totext(buf, target));
if (result != DNS_R_SUCCESS) RETERR(str_totext(" ", target));
return (result);
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
dns_name_fromregion(&name, &region); dns_name_fromregion(&name, &region);
sub = name_prefix(&name, origin, &prefix); sub = name_prefix(&name, origin, &prefix);
return(dns_name_totext(&prefix, sub, target)); return(dns_name_totext(&prefix, sub, target));
@@ -128,7 +99,6 @@ static dns_result_t
towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_t name; dns_name_t name;
isc_region_t region; isc_region_t region;
dns_result_t result;
isc_region_t tr; isc_region_t tr;
REQUIRE(rdata->type == 15); REQUIRE(rdata->type == 15);
@@ -144,8 +114,7 @@ towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
dns_name_fromregion(&name, &region); dns_name_fromregion(&name, &region);
result = dns_name_towire(&name, cctx, target); return (dns_name_towire(&name, cctx, target));
return (result);
} }
static int static int

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: ns_2.c,v 1.4 1999/01/20 05:20:22 marka Exp $ */ /* $Id: ns_2.c,v 1.5 1999/01/22 00:36:57 marka Exp $ */
#ifndef RDATA_GENERIC_NS_2_H #ifndef RDATA_GENERIC_NS_2_H
#define RDATA_GENERIC_NS_2_H #define RDATA_GENERIC_NS_2_H
@@ -27,21 +27,12 @@ fromtext_ns(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 2); REQUIRE(type == 2);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token,isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: ns_2.h,v 1.4 1999/01/20 05:20:22 marka Exp $ */ /* $Id: ns_2.h,v 1.5 1999/01/22 00:36:57 marka Exp $ */
#ifndef RDATA_GENERIC_NS_2_H #ifndef RDATA_GENERIC_NS_2_H
#define RDATA_GENERIC_NS_2_H #define RDATA_GENERIC_NS_2_H
@@ -27,21 +27,12 @@ fromtext_ns(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 2); REQUIRE(type == 2);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token,isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: ptr_12.c,v 1.4 1999/01/20 05:20:23 marka Exp $ */ /* $Id: ptr_12.c,v 1.5 1999/01/22 00:36:58 marka Exp $ */
#ifndef RDATA_GENERIC_PTR_12_H #ifndef RDATA_GENERIC_PTR_12_H
#define RDATA_GENERIC_PTR_12_H #define RDATA_GENERIC_PTR_12_H
@@ -27,21 +27,12 @@ fromtext_ptr(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 12); REQUIRE(type == 12);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: ptr_12.h,v 1.4 1999/01/20 05:20:23 marka Exp $ */ /* $Id: ptr_12.h,v 1.5 1999/01/22 00:36:58 marka Exp $ */
#ifndef RDATA_GENERIC_PTR_12_H #ifndef RDATA_GENERIC_PTR_12_H
#define RDATA_GENERIC_PTR_12_H #define RDATA_GENERIC_PTR_12_H
@@ -27,21 +27,12 @@ fromtext_ptr(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 12); REQUIRE(type == 12);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
dns_name_init(&name, NULL); dns_name_init(&name, NULL);
buffer_fromregion(&buffer, &token.value.as_region, buffer_fromregion(&buffer, &token.value.as_region,

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: soa_6.c,v 1.7 1999/01/21 06:02:14 marka Exp $ */ /* $Id: soa_6.c,v 1.8 1999/01/22 00:36:58 marka Exp $ */
#ifndef RDATA_GENERIC_SOA_6_H #ifndef RDATA_GENERIC_SOA_6_H
#define RDATA_GENERIC_SOA_6_H #define RDATA_GENERIC_SOA_6_H
@@ -27,65 +27,28 @@ fromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
dns_result_t result;
int i; int i;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 6); REQUIRE(type == 6);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) for (i = 0 ; i < 2 ; i++) {
return (DNS_R_UNEXPECTED); RETERR(gettoken(lexer, &token, isc_tokentype_string,
if (token.type != isc_tokentype_string) { ISC_FALSE));
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol || dns_name_init(&name, NULL);
token.type == isc_tokentype_eof) buffer_fromregion(&buffer, &token.value.as_region,
return(DNS_R_UNEXPECTEDEND); ISC_BUFFERTYPE_TEXT);
return (DNS_R_UNEXPECTED); origin = (origin != NULL) ? origin : dns_rootname;
RETERR(dns_name_fromtext(&name, &buffer, origin,
downcase, target));
} }
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, options, &token) != ISC_R_SUCCESS)
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
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);
options |= ISC_LEXOPT_NUMBER;
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_number,
return (DNS_R_UNEXPECTED); ISC_FALSE));
if (token.type != isc_tokentype_number) { RETERR(uint32_tobuffer(token.value.as_ulong, target));
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
result = uint32_tobuffer(token.value.as_ulong, target);
if (result != DNS_R_SUCCESS)
return (result);
} }
return (DNS_R_SUCCESS); return (DNS_R_SUCCESS);
} }
@@ -96,7 +59,6 @@ totext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
dns_name_t mname; dns_name_t mname;
dns_name_t rname; dns_name_t rname;
dns_name_t prefix; dns_name_t prefix;
dns_result_t result;
isc_boolean_t sub; isc_boolean_t sub;
int i; int i;
@@ -115,33 +77,23 @@ totext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_consume(&dregion, name_length(&rname)); isc_region_consume(&dregion, name_length(&rname));
sub = name_prefix(&mname, origin, &prefix); sub = name_prefix(&mname, origin, &prefix);
result = dns_name_totext(&prefix, sub, target); RETERR(dns_name_totext(&prefix, sub, target));
if (result != DNS_R_SUCCESS)
return (result);
result = str_totext(" ", target); RETERR(str_totext(" ", target));
if (result != DNS_R_SUCCESS)
return (result);
sub = name_prefix(&rname, origin, &prefix); sub = name_prefix(&rname, origin, &prefix);
result = dns_name_totext(&prefix, sub, target); RETERR(dns_name_totext(&prefix, sub, target));
if (result != DNS_R_SUCCESS)
return (result);
for (i = 0; i < 5 ; i++) { for (i = 0; i < 5 ; i++) {
char buf[sizeof "2147483647"]; char buf[sizeof "2147483647"];
unsigned long num; unsigned long num;
result = str_totext(" ", target); RETERR(str_totext(" ", target));
if (result != DNS_R_SUCCESS)
return (result);
num = uint32_fromregion(&dregion); num = uint32_fromregion(&dregion);
isc_region_consume(&dregion, 4); isc_region_consume(&dregion, 4);
sprintf(buf, "%lu", num); sprintf(buf, "%lu", num);
result = str_totext(buf, target); RETERR(str_totext(buf, target));
if (result != DNS_R_SUCCESS)
return (result);
} }
return (DNS_R_SUCCESS); return (DNS_R_SUCCESS);
} }
@@ -152,7 +104,6 @@ fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t mname; dns_name_t mname;
dns_name_t rname; dns_name_t rname;
dns_result_t result;
isc_region_t sregion; isc_region_t sregion;
isc_region_t tregion; isc_region_t tregion;
@@ -163,13 +114,8 @@ fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type,
dns_name_init(&mname, NULL); dns_name_init(&mname, NULL);
dns_name_init(&rname, NULL); dns_name_init(&rname, NULL);
result = dns_name_fromwire(&mname, source, dctx, downcase, target); RETERR(dns_name_fromwire(&mname, source, dctx, downcase, target));
if (result != DNS_R_SUCCESS) RETERR(dns_name_fromwire(&rname, source, dctx, downcase, target));
return (result);
result = dns_name_fromwire(&rname, source, dctx, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_active(source, &sregion); isc_buffer_active(source, &sregion);
isc_buffer_available(target, &tregion); isc_buffer_available(target, &tregion);
@@ -191,7 +137,6 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t tregion; isc_region_t tregion;
dns_name_t mname; dns_name_t mname;
dns_name_t rname; dns_name_t rname;
dns_result_t result;
REQUIRE(rdata->type == 6); REQUIRE(rdata->type == 6);
@@ -201,15 +146,11 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_rdata_toregion(rdata, &sregion); dns_rdata_toregion(rdata, &sregion);
dns_name_fromregion(&mname, &sregion); dns_name_fromregion(&mname, &sregion);
isc_region_consume(&sregion, name_length(&mname)); isc_region_consume(&sregion, name_length(&mname));
result = dns_name_towire(&mname, cctx, target); RETERR(dns_name_towire(&mname, cctx, target));
if (result != DNS_R_SUCCESS)
return (result);
dns_name_fromregion(&rname, &sregion); dns_name_fromregion(&rname, &sregion);
isc_region_consume(&sregion, name_length(&rname)); isc_region_consume(&sregion, name_length(&rname));
result = dns_name_towire(&rname, cctx, target); RETERR(dns_name_towire(&rname, cctx, target));
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_available(target, &tregion); isc_buffer_available(target, &tregion);
if (tregion.length < 20) if (tregion.length < 20)
@@ -236,7 +177,7 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_init(&name2, NULL); dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1); dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region1); dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1); dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2); dns_name_fromregion(&name2, &region2);
@@ -245,8 +186,8 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
if (result != 0) if (result != 0)
return (result); return (result);
isc_region_consume(&region1, name1.length); isc_region_consume(&region1, name_length(&name1));
isc_region_consume(&region2, name2.length); isc_region_consume(&region2, name_length(&name2));
dns_name_init(&name1, NULL); dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL); dns_name_init(&name2, NULL);
@@ -258,14 +199,10 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
if (result != 0) if (result != 0)
return (result); return (result);
isc_region_consume(&region1, name1.length); isc_region_consume(&region1, name_length(&name1));
isc_region_consume(&region2, name2.length); isc_region_consume(&region2, name_length(&name2));
result = memcmp(region1.base, region2.base, 12); return (compare_region(&region1, &region2));
if (result != 0)
return ((result < 0) ? -1 : 1);
return (0);
} }
static dns_result_t static dns_result_t

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: soa_6.h,v 1.7 1999/01/21 06:02:14 marka Exp $ */ /* $Id: soa_6.h,v 1.8 1999/01/22 00:36:58 marka Exp $ */
#ifndef RDATA_GENERIC_SOA_6_H #ifndef RDATA_GENERIC_SOA_6_H
#define RDATA_GENERIC_SOA_6_H #define RDATA_GENERIC_SOA_6_H
@@ -27,65 +27,28 @@ fromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
dns_name_t name; dns_name_t name;
isc_buffer_t buffer; isc_buffer_t buffer;
dns_result_t result;
int i; int i;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 6); REQUIRE(type == 6);
class = class; /*unused*/ class = class; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) for (i = 0 ; i < 2 ; i++) {
return (DNS_R_UNEXPECTED); RETERR(gettoken(lexer, &token, isc_tokentype_string,
if (token.type != isc_tokentype_string) { ISC_FALSE));
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol || dns_name_init(&name, NULL);
token.type == isc_tokentype_eof) buffer_fromregion(&buffer, &token.value.as_region,
return(DNS_R_UNEXPECTEDEND); ISC_BUFFERTYPE_TEXT);
return (DNS_R_UNEXPECTED); origin = (origin != NULL) ? origin : dns_rootname;
RETERR(dns_name_fromtext(&name, &buffer, origin,
downcase, target));
} }
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, options, &token) != ISC_R_SUCCESS)
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
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);
options |= ISC_LEXOPT_NUMBER;
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_number,
return (DNS_R_UNEXPECTED); ISC_FALSE));
if (token.type != isc_tokentype_number) { RETERR(uint32_tobuffer(token.value.as_ulong, target));
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
result = uint32_tobuffer(token.value.as_ulong, target);
if (result != DNS_R_SUCCESS)
return (result);
} }
return (DNS_R_SUCCESS); return (DNS_R_SUCCESS);
} }
@@ -96,7 +59,6 @@ totext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
dns_name_t mname; dns_name_t mname;
dns_name_t rname; dns_name_t rname;
dns_name_t prefix; dns_name_t prefix;
dns_result_t result;
isc_boolean_t sub; isc_boolean_t sub;
int i; int i;
@@ -115,33 +77,23 @@ totext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_consume(&dregion, name_length(&rname)); isc_region_consume(&dregion, name_length(&rname));
sub = name_prefix(&mname, origin, &prefix); sub = name_prefix(&mname, origin, &prefix);
result = dns_name_totext(&prefix, sub, target); RETERR(dns_name_totext(&prefix, sub, target));
if (result != DNS_R_SUCCESS)
return (result);
result = str_totext(" ", target); RETERR(str_totext(" ", target));
if (result != DNS_R_SUCCESS)
return (result);
sub = name_prefix(&rname, origin, &prefix); sub = name_prefix(&rname, origin, &prefix);
result = dns_name_totext(&prefix, sub, target); RETERR(dns_name_totext(&prefix, sub, target));
if (result != DNS_R_SUCCESS)
return (result);
for (i = 0; i < 5 ; i++) { for (i = 0; i < 5 ; i++) {
char buf[sizeof "2147483647"]; char buf[sizeof "2147483647"];
unsigned long num; unsigned long num;
result = str_totext(" ", target); RETERR(str_totext(" ", target));
if (result != DNS_R_SUCCESS)
return (result);
num = uint32_fromregion(&dregion); num = uint32_fromregion(&dregion);
isc_region_consume(&dregion, 4); isc_region_consume(&dregion, 4);
sprintf(buf, "%lu", num); sprintf(buf, "%lu", num);
result = str_totext(buf, target); RETERR(str_totext(buf, target));
if (result != DNS_R_SUCCESS)
return (result);
} }
return (DNS_R_SUCCESS); return (DNS_R_SUCCESS);
} }
@@ -152,7 +104,6 @@ fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
dns_name_t mname; dns_name_t mname;
dns_name_t rname; dns_name_t rname;
dns_result_t result;
isc_region_t sregion; isc_region_t sregion;
isc_region_t tregion; isc_region_t tregion;
@@ -163,13 +114,8 @@ fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type,
dns_name_init(&mname, NULL); dns_name_init(&mname, NULL);
dns_name_init(&rname, NULL); dns_name_init(&rname, NULL);
result = dns_name_fromwire(&mname, source, dctx, downcase, target); RETERR(dns_name_fromwire(&mname, source, dctx, downcase, target));
if (result != DNS_R_SUCCESS) RETERR(dns_name_fromwire(&rname, source, dctx, downcase, target));
return (result);
result = dns_name_fromwire(&rname, source, dctx, downcase, target);
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_active(source, &sregion); isc_buffer_active(source, &sregion);
isc_buffer_available(target, &tregion); isc_buffer_available(target, &tregion);
@@ -191,7 +137,6 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
isc_region_t tregion; isc_region_t tregion;
dns_name_t mname; dns_name_t mname;
dns_name_t rname; dns_name_t rname;
dns_result_t result;
REQUIRE(rdata->type == 6); REQUIRE(rdata->type == 6);
@@ -201,15 +146,11 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
dns_rdata_toregion(rdata, &sregion); dns_rdata_toregion(rdata, &sregion);
dns_name_fromregion(&mname, &sregion); dns_name_fromregion(&mname, &sregion);
isc_region_consume(&sregion, name_length(&mname)); isc_region_consume(&sregion, name_length(&mname));
result = dns_name_towire(&mname, cctx, target); RETERR(dns_name_towire(&mname, cctx, target));
if (result != DNS_R_SUCCESS)
return (result);
dns_name_fromregion(&rname, &sregion); dns_name_fromregion(&rname, &sregion);
isc_region_consume(&sregion, name_length(&rname)); isc_region_consume(&sregion, name_length(&rname));
result = dns_name_towire(&rname, cctx, target); RETERR(dns_name_towire(&rname, cctx, target));
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_available(target, &tregion); isc_buffer_available(target, &tregion);
if (tregion.length < 20) if (tregion.length < 20)
@@ -236,7 +177,7 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_init(&name2, NULL); dns_name_init(&name2, NULL);
dns_rdata_toregion(rdata1, &region1); dns_rdata_toregion(rdata1, &region1);
dns_rdata_toregion(rdata2, &region1); dns_rdata_toregion(rdata2, &region2);
dns_name_fromregion(&name1, &region1); dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2); dns_name_fromregion(&name2, &region2);
@@ -245,8 +186,8 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
if (result != 0) if (result != 0)
return (result); return (result);
isc_region_consume(&region1, name1.length); isc_region_consume(&region1, name_length(&name1));
isc_region_consume(&region2, name2.length); isc_region_consume(&region2, name_length(&name2));
dns_name_init(&name1, NULL); dns_name_init(&name1, NULL);
dns_name_init(&name2, NULL); dns_name_init(&name2, NULL);
@@ -258,14 +199,10 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
if (result != 0) if (result != 0)
return (result); return (result);
isc_region_consume(&region1, name1.length); isc_region_consume(&region1, name_length(&name1));
isc_region_consume(&region2, name2.length); isc_region_consume(&region2, name_length(&name2));
result = memcmp(region1.base, region2.base, 12); return (compare_region(&region1, &region2));
if (result != 0)
return ((result < 0) ? -1 : 1);
return (0);
} }
static dns_result_t static dns_result_t

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: txt_16.c,v 1.5 1999/01/20 05:20:24 marka Exp $ */ /* $Id: txt_16.c,v 1.6 1999/01/22 00:36:58 marka Exp $ */
#ifndef RDATA_GENERIC_TXT_16_H #ifndef RDATA_GENERIC_TXT_16_H
#define RDATA_GENERIC_TXT_16_H #define RDATA_GENERIC_TXT_16_H
@@ -25,8 +25,6 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin, isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token; isc_token_t token;
dns_result_t result;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 16); REQUIRE(type == 16);
@@ -34,14 +32,12 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type,
origin = origin; /*unused*/ origin = origin; /*unused*/
downcase = downcase; /*unused*/ downcase = downcase; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) while (1) {
return (DNS_R_UNEXPECTED); RETERR(gettoken(lexer, &token, isc_tokentype_string,
while (token.type == isc_tokentype_string) { ISC_TRUE));
result = txt_fromtext(&token.value.as_textregion, target); if (token.type != isc_tokentype_string)
if (result != DNS_R_SUCCESS) break;
return (result); RETERR(txt_fromtext(&token.value.as_textregion, target));
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
} }
/* Let upper layer handle eol/eof. */ /* Let upper layer handle eol/eof. */
isc_lex_ungettoken(lexer, &token); isc_lex_ungettoken(lexer, &token);
@@ -51,7 +47,6 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type,
static dns_result_t static dns_result_t
totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region; isc_region_t region;
dns_result_t result;
REQUIRE(rdata->type == 16); REQUIRE(rdata->type == 16);
@@ -60,14 +55,9 @@ totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
dns_rdata_toregion(rdata, &region); dns_rdata_toregion(rdata, &region);
while (region.length) { while (region.length) {
result = txt_totext(&region, target); RETERR(txt_totext(&region, target));
if (result != DNS_R_SUCCESS) if (region.length)
return (result); RETERR(str_totext(" ", target));
if (region.length) {
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
}
} }
return (DNS_R_SUCCESS); return (DNS_R_SUCCESS);
@@ -112,22 +102,16 @@ towire_txt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
static int static int
compare_txt(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { compare_txt(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
int l; isc_region_t r1;
int result; isc_region_t r2;
REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->type == rdata2->type);
REQUIRE(rdata1->class == rdata2->class); REQUIRE(rdata1->class == rdata2->class);
REQUIRE(rdata1->class == 16); REQUIRE(rdata1->type == 16);
l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length; dns_rdata_toregion(rdata1, &r1);
result = memcmp(rdata1->data, rdata2->data, l); dns_rdata_toregion(rdata2, &r2);
return (compare_region(&r1, &r2));
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 static dns_result_t

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: txt_16.h,v 1.5 1999/01/20 05:20:24 marka Exp $ */ /* $Id: txt_16.h,v 1.6 1999/01/22 00:36:58 marka Exp $ */
#ifndef RDATA_GENERIC_TXT_16_H #ifndef RDATA_GENERIC_TXT_16_H
#define RDATA_GENERIC_TXT_16_H #define RDATA_GENERIC_TXT_16_H
@@ -25,8 +25,6 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin, isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token; isc_token_t token;
dns_result_t result;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 16); REQUIRE(type == 16);
@@ -34,14 +32,12 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type,
origin = origin; /*unused*/ origin = origin; /*unused*/
downcase = downcase; /*unused*/ downcase = downcase; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) while (1) {
return (DNS_R_UNEXPECTED); RETERR(gettoken(lexer, &token, isc_tokentype_string,
while (token.type == isc_tokentype_string) { ISC_TRUE));
result = txt_fromtext(&token.value.as_textregion, target); if (token.type != isc_tokentype_string)
if (result != DNS_R_SUCCESS) break;
return (result); RETERR(txt_fromtext(&token.value.as_textregion, target));
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS)
return (DNS_R_UNKNOWN);
} }
/* Let upper layer handle eol/eof. */ /* Let upper layer handle eol/eof. */
isc_lex_ungettoken(lexer, &token); isc_lex_ungettoken(lexer, &token);
@@ -51,7 +47,6 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type,
static dns_result_t static dns_result_t
totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t region; isc_region_t region;
dns_result_t result;
REQUIRE(rdata->type == 16); REQUIRE(rdata->type == 16);
@@ -60,14 +55,9 @@ totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
dns_rdata_toregion(rdata, &region); dns_rdata_toregion(rdata, &region);
while (region.length) { while (region.length) {
result = txt_totext(&region, target); RETERR(txt_totext(&region, target));
if (result != DNS_R_SUCCESS) if (region.length)
return (result); RETERR(str_totext(" ", target));
if (region.length) {
result = str_totext(" ", target);
if (result != DNS_R_SUCCESS)
return (result);
}
} }
return (DNS_R_SUCCESS); return (DNS_R_SUCCESS);
@@ -112,22 +102,16 @@ towire_txt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
static int static int
compare_txt(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { compare_txt(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
int l; isc_region_t r1;
int result; isc_region_t r2;
REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->type == rdata2->type);
REQUIRE(rdata1->class == rdata2->class); REQUIRE(rdata1->class == rdata2->class);
REQUIRE(rdata1->class == 16); REQUIRE(rdata1->type == 16);
l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length; dns_rdata_toregion(rdata1, &r1);
result = memcmp(rdata1->data, rdata2->data, l); dns_rdata_toregion(rdata2, &r2);
return (compare_region(&r1, &r2));
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 static dns_result_t

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: a_1.c,v 1.5 1999/01/20 05:20:24 marka Exp $ */ /* $Id: a_1.c,v 1.6 1999/01/22 00:36:58 marka Exp $ */
#ifndef RDATA_IN_1_A_1_H #ifndef RDATA_IN_1_A_1_H
#define RDATA_IN_1_A_1_H #define RDATA_IN_1_A_1_H
@@ -33,7 +33,6 @@ fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
struct in_addr addr; struct in_addr addr;
isc_region_t region; isc_region_t region;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 1); REQUIRE(type == 1);
REQUIRE(class == 1); REQUIRE(class == 1);
@@ -41,15 +40,7 @@ fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type,
origin = origin; /*unused*/ origin = origin; /*unused*/
downcase = downcase; /*unused*/ downcase = downcase; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
if (inet_aton(token.value.as_pointer , &addr) != 1) if (inet_aton(token.value.as_pointer , &addr) != 1)
return (DNS_R_UNEXPECTED); return (DNS_R_UNEXPECTED);

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: a_1.h,v 1.5 1999/01/20 05:20:24 marka Exp $ */ /* $Id: a_1.h,v 1.6 1999/01/22 00:36:58 marka Exp $ */
#ifndef RDATA_IN_1_A_1_H #ifndef RDATA_IN_1_A_1_H
#define RDATA_IN_1_A_1_H #define RDATA_IN_1_A_1_H
@@ -33,7 +33,6 @@ fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type,
isc_token_t token; isc_token_t token;
struct in_addr addr; struct in_addr addr;
isc_region_t region; isc_region_t region;
unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF;
REQUIRE(type == 1); REQUIRE(type == 1);
REQUIRE(class == 1); REQUIRE(class == 1);
@@ -41,15 +40,7 @@ fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type,
origin = origin; /*unused*/ origin = origin; /*unused*/
downcase = downcase; /*unused*/ downcase = downcase; /*unused*/
if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
return (DNS_R_UNEXPECTED);
if (token.type != isc_tokentype_string) {
isc_lex_ungettoken(lexer, &token);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
return(DNS_R_UNEXPECTEDEND);
return (DNS_R_UNEXPECTED);
}
if (inet_aton(token.value.as_pointer , &addr) != 1) if (inet_aton(token.value.as_pointer , &addr) != 1)
return (DNS_R_UNEXPECTED); return (DNS_R_UNEXPECTED);

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: wks_11.c,v 1.1 1999/01/21 06:02:15 marka Exp $ */ /* $Id: wks_11.c,v 1.2 1999/01/22 00:36:59 marka Exp $ */
#ifndef RDATA_IN_1_WKS_11_H #ifndef RDATA_IN_1_WKS_11_H
#define RDATA_IN_1_WKS_11_H #define RDATA_IN_1_WKS_11_H
@@ -36,14 +36,13 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin, isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token; isc_token_t token;
dns_result_t result;
isc_region_t region; isc_region_t region;
struct in_addr addr; struct in_addr addr;
struct protoent *pe; struct protoent *pe;
struct servent *se; struct servent *se;
char *e; char *e;
long proto; long proto;
unsigned char bm[8*1024]; unsigned char bm[8*1024]; /* 64k bits */
long port; long port;
long maxport = -1; long maxport = -1;
char *ps = NULL; char *ps = NULL;
@@ -56,9 +55,7 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type,
downcase = downcase; /*unused*/ downcase = downcase; /*unused*/
/* IPv4 dotted quad */ /* IPv4 dotted quad */
result = gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE); RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_available(target, &region); isc_buffer_available(target, &region);
if (inet_aton(token.value.as_pointer , &addr) != 1) if (inet_aton(token.value.as_pointer , &addr) != 1)
@@ -69,9 +66,7 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_add(target, 4); isc_buffer_add(target, 4);
/* protocol */ /* protocol */
result = gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE); RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
if (result != DNS_R_SUCCESS)
return (result);
proto = strtol(token.value.as_pointer, &e, 10); proto = strtol(token.value.as_pointer, &e, 10);
if (*e == '\0') if (*e == '\0')
@@ -88,16 +83,13 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type,
else if (proto == IPPROTO_UDP) else if (proto == IPPROTO_UDP)
ps = "udp"; ps = "udp";
result = uint16_tobuffer(proto, target); RETERR(uint16_tobuffer(proto, target));
memset(bm, 0, sizeof bm); memset(bm, 0, sizeof bm);
while (1) { while (1) {
result = gettoken(lexer, &token, isc_tokentype_string, RETERR(gettoken(lexer, &token, isc_tokentype_string,
ISC_TRUE); ISC_TRUE));
if (result != DNS_R_SUCCESS) if (token.type != isc_tokentype_string)
return (result);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
break; break;
port = strtol(token.value.as_pointer, &e, 10); port = strtol(token.value.as_pointer, &e, 10);
if (*e == '\0') if (*e == '\0')
@@ -124,7 +116,6 @@ totext_in_wks(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t tr; isc_region_t tr;
unsigned short proto; unsigned short proto;
char buf[sizeof "65535"]; char buf[sizeof "65535"];
dns_result_t result;
unsigned int i, j; unsigned int i, j;
REQUIRE(rdata->type == 11); REQUIRE(rdata->type == 11);
@@ -140,30 +131,21 @@ totext_in_wks(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
proto = uint16_fromregion(&sr); proto = uint16_fromregion(&sr);
sprintf(buf, "%u", proto); sprintf(buf, "%u", proto);
result = str_totext(" ", target); RETERR(str_totext(" ", target));
if (result != DNS_R_SUCCESS) RETERR(str_totext(buf, target));
return (result);
result = str_totext(buf, target);
if (result != DNS_R_SUCCESS)
return (result);
isc_region_consume(&sr, 2); isc_region_consume(&sr, 2);
result = str_totext(" (", target); RETERR(str_totext(" (", target));
if (result != DNS_R_SUCCESS)
return (result);
for (i = 0 ; i < sr.length ; i++) { for (i = 0 ; i < sr.length ; i++) {
if (sr.base[i] != 0) if (sr.base[i] != 0)
for (j = 0; j < 8; j++) for (j = 0; j < 8; j++)
if ((sr.base[i] & (0x80>>j)) != 0) { if ((sr.base[i] & (0x80>>j)) != 0) {
sprintf(buf, "%u", i * 8 + j); sprintf(buf, "%u", i * 8 + j);
result = str_totext(" ", target); RETERR(str_totext(" ", target));
if (result != DNS_R_SUCCESS) RETERR(str_totext(buf, target));
return (result);
result = str_totext(buf, target);
if (result != DNS_R_SUCCESS)
return (result);
} }
} }
result = str_totext(" )", target); RETERR(str_totext(" )", target));
return (DNS_R_SUCCESS); return (DNS_R_SUCCESS);
} }

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: wks_11.h,v 1.1 1999/01/21 06:02:15 marka Exp $ */ /* $Id: wks_11.h,v 1.2 1999/01/22 00:36:59 marka Exp $ */
#ifndef RDATA_IN_1_WKS_11_H #ifndef RDATA_IN_1_WKS_11_H
#define RDATA_IN_1_WKS_11_H #define RDATA_IN_1_WKS_11_H
@@ -36,14 +36,13 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type,
isc_lex_t *lexer, dns_name_t *origin, isc_lex_t *lexer, dns_name_t *origin,
isc_boolean_t downcase, isc_buffer_t *target) { isc_boolean_t downcase, isc_buffer_t *target) {
isc_token_t token; isc_token_t token;
dns_result_t result;
isc_region_t region; isc_region_t region;
struct in_addr addr; struct in_addr addr;
struct protoent *pe; struct protoent *pe;
struct servent *se; struct servent *se;
char *e; char *e;
long proto; long proto;
unsigned char bm[8*1024]; unsigned char bm[8*1024]; /* 64k bits */
long port; long port;
long maxport = -1; long maxport = -1;
char *ps = NULL; char *ps = NULL;
@@ -56,9 +55,7 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type,
downcase = downcase; /*unused*/ downcase = downcase; /*unused*/
/* IPv4 dotted quad */ /* IPv4 dotted quad */
result = gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE); RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
if (result != DNS_R_SUCCESS)
return (result);
isc_buffer_available(target, &region); isc_buffer_available(target, &region);
if (inet_aton(token.value.as_pointer , &addr) != 1) if (inet_aton(token.value.as_pointer , &addr) != 1)
@@ -69,9 +66,7 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type,
isc_buffer_add(target, 4); isc_buffer_add(target, 4);
/* protocol */ /* protocol */
result = gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE); RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
if (result != DNS_R_SUCCESS)
return (result);
proto = strtol(token.value.as_pointer, &e, 10); proto = strtol(token.value.as_pointer, &e, 10);
if (*e == '\0') if (*e == '\0')
@@ -88,16 +83,13 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type,
else if (proto == IPPROTO_UDP) else if (proto == IPPROTO_UDP)
ps = "udp"; ps = "udp";
result = uint16_tobuffer(proto, target); RETERR(uint16_tobuffer(proto, target));
memset(bm, 0, sizeof bm); memset(bm, 0, sizeof bm);
while (1) { while (1) {
result = gettoken(lexer, &token, isc_tokentype_string, RETERR(gettoken(lexer, &token, isc_tokentype_string,
ISC_TRUE); ISC_TRUE));
if (result != DNS_R_SUCCESS) if (token.type != isc_tokentype_string)
return (result);
if (token.type == isc_tokentype_eol ||
token.type == isc_tokentype_eof)
break; break;
port = strtol(token.value.as_pointer, &e, 10); port = strtol(token.value.as_pointer, &e, 10);
if (*e == '\0') if (*e == '\0')
@@ -124,7 +116,6 @@ totext_in_wks(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
isc_region_t tr; isc_region_t tr;
unsigned short proto; unsigned short proto;
char buf[sizeof "65535"]; char buf[sizeof "65535"];
dns_result_t result;
unsigned int i, j; unsigned int i, j;
REQUIRE(rdata->type == 11); REQUIRE(rdata->type == 11);
@@ -140,30 +131,21 @@ totext_in_wks(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) {
proto = uint16_fromregion(&sr); proto = uint16_fromregion(&sr);
sprintf(buf, "%u", proto); sprintf(buf, "%u", proto);
result = str_totext(" ", target); RETERR(str_totext(" ", target));
if (result != DNS_R_SUCCESS) RETERR(str_totext(buf, target));
return (result);
result = str_totext(buf, target);
if (result != DNS_R_SUCCESS)
return (result);
isc_region_consume(&sr, 2); isc_region_consume(&sr, 2);
result = str_totext(" (", target); RETERR(str_totext(" (", target));
if (result != DNS_R_SUCCESS)
return (result);
for (i = 0 ; i < sr.length ; i++) { for (i = 0 ; i < sr.length ; i++) {
if (sr.base[i] != 0) if (sr.base[i] != 0)
for (j = 0; j < 8; j++) for (j = 0; j < 8; j++)
if ((sr.base[i] & (0x80>>j)) != 0) { if ((sr.base[i] & (0x80>>j)) != 0) {
sprintf(buf, "%u", i * 8 + j); sprintf(buf, "%u", i * 8 + j);
result = str_totext(" ", target); RETERR(str_totext(" ", target));
if (result != DNS_R_SUCCESS) RETERR(str_totext(buf, target));
return (result);
result = str_totext(buf, target);
if (result != DNS_R_SUCCESS)
return (result);
} }
} }
result = str_totext(" )", target); RETERR(str_totext(" )", target));
return (DNS_R_SUCCESS); return (DNS_R_SUCCESS);
} }