t_names.c revision ecb6c5782ea248307e86c4bceac6c371d27576a6
/*
* Copyright (C) 1998, 1999, 2000 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 <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dns/compress.h>
#define MAXTOKS 16
#define BUFLEN 256
#define BIGBUFLEN 4096
void t_dns_label_countbits(void);
void t_dns_label_getbit(void);
void t_dns_name_init(void);
void t_dns_name_invalidate(void);
void t_dns_name_setbuffer(void);
void t_dns_name_hasbuffer(void);
void t_dns_name_isabsolute(void);
void t_dns_name_hash(void);
void t_dns_name_fullcompare(void);
void t_dns_name_compare(void);
void t_dns_name_rdatacompare(void);
void t_dns_name_issubdomain(void);
void t_dns_name_countlabels(void);
void t_dns_name_getlabel(void);
void t_dns_name_getlabelsequence(void);
void t_dns_name_fromregion(void);
void t_dns_name_toregion(void);
void t_dns_name_fromwire(void);
void t_dns_name_towire(void);
void t_dns_name_fromtext(void);
void t_dns_name_totext(void);
void t_dns_name_concatenate(void);
void t_dns_name_towire_1(void);
void t_dns_name_towire_2(void);
char *a1 = "dns_label_countbits returns the number of "
"bits in a bitstring label";
/*
* get a hex formatted dns message from a data
* file into an isc_buffer_t
* caller supplies data storage and the isc_buffer
* we read the file, convert, setup the buffer
* and return the data length
*/
#ifdef NEED_PBUF
static char *
ctoh(unsigned char c) {
int val;
static char buf[3];
val = c & 0x0f;
return(buf);
}
static void
unsigned char *p;
len = 0;
++p;
++len;
if ((len % 40) == 0)
printf("\n");
}
}
#endif /* NEED_PBUF */
/*
* compare data at buf with data in hex representation at exp_data,
* of length exp_data_len, for equality.
* return 0 if equal, else non-zero
*/
static int
int result;
unsigned char *p;
unsigned char *v;
char *q;
unsigned char *data;
if (buflen == exp_data_len) {
t_info("malloc failed unexpectedly\n");
return(-1);
}
/* first convert exp_data from hex format */
p = data;
q = exp_data;
cnt = 0;
while (cnt < exp_data_len) {
if (('0' <= *q) && (*q <= '9'))
*p = *q - '0';
else if (('a' <= *q) && (*q <= 'z'))
*p = *q - 'a' + 10;
else if (('A' <= *q) && (*q <= 'Z'))
*p = *q - 'A' + 10;
++q;
*p <<= 4;
if (('0' <= *q) && (*q <= '9'))
*p |= ((*q - '0') & 0x0f);
else if (('a' <= *q) && (*q <= 'z'))
*p |= ((*q - 'a' + 10) & 0x0f);
else if (('A' <= *q) && (*q <= 'Z'))
*p |= ((*q - 'A' + 10) & 0x0f);
++p;
++q;
++cnt;
}
/* now compare data */
p = buf;
v = data;
if (*p != *v)
break;
++p;
++v;
}
if (cnt == exp_data_len)
result = 0;
else {
t_info("bad data at position %d, got 0x%.2x, expected 0x%.2x\n",
cnt, *p, *q);
}
}
else {
t_info("data length error, expected %d, got %d\n",
}
return(result);
}
/*
* get a hex formatted dns message from a data
* file into an isc_buffer_t
* caller supplies data storage and the isc_buffer
* we read the file, convert, setup the buffer
* and return the data length
*/
static int
{
int c;
int len;
int cnt;
unsigned int val;
unsigned char *p;
return(0);
}
p = buf;
cnt = 0;
len = 0;
val = 0;
if ( (c == ' ') || (c == '\t') ||
(c == '\r') || (c == '\n'))
continue;
if (c == '#') {
;
continue;
}
if (('0' <= c) && (c <= '9'))
val = c - '0';
else if (('a' <= c) && (c <= 'z'))
else if (('A' <= c) && (c <= 'Z'))
else {
t_info("Bad format in datafile\n");
return(0);
}
if ((len % 2) == 0) {
*p = (val << 4);
}
else {
*p += val;
++p;
++cnt;
/* buffer too small */
t_info("Buffer overflow error\n");
return(0);
}
}
++len;
}
if (len % 2) {
return(0);
}
*p = '\0';
return(cnt);
}
static int
int cnt;
char *p;
cnt = 0;
*toks++ = p;
++cnt;
}
}
return(cnt);
}
/*
* convert a name from hex representation to text form
* format of hex notation is:
* %xXXXXXXXX
*/
#ifdef NEED_HNAME_TO_TNAME
static int
int i;
int c;
unsigned int val;
char *p;
char *q;
p = src;
/* no conversion needed */
return(1);
return(0);
}
i = 0;
p += 2;
q = target;
while (*p) {
c = *p;
if (('0' < c) && (c <= '9'))
val = c - '0';
else if (('a' <= c) && (c <= 'z'))
else if (('A' <= c) && (c <= 'Z'))
else {
return(1);
}
if (i % 2) {
*q |= val;
++q;
}
else
*q = (val << 4);
++i;
++p;
}
if (i % 2) {
return(1);
}
else {
*q = '\0';
return(0);
}
}
#endif /* NEED_HNAME_TO_TNAME */
/*
* initialize a dns_name_t from a text name, hiding all
* buffer and other object initialization from the caller
*
*/
static isc_result_t
{
int len;
unsigned char *junk;
}
else {
}
return(result);
}
static int
int bits;
int rval;
rval = T_UNRESOLVED;
if (result == DNS_R_SUCCESS) {
if (bits == expected_bits)
else {
}
}
else {
t_info("dname_from_tname %s failed, result = %s\n",
rval = T_UNRESOLVED;
}
return(rval);
}
void
char *p;
int line;
int cnt;
int result;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
/* testname, labelpos, bitpos, expected val */
if (cnt == 3) {
}
else {
t_info("bad datafile format at line %d\n",
line);
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_label_countbits_data\n");
}
}
char *a2 = "dns_label_getbit returns the n'th most significant "
"bit of a bitstring label";
static int
int expected_bitval) {
int bitval;
int rval;
rval = T_UNRESOLVED;
t_info("testing name %s, label %d, bit %d\n",
if (result == DNS_R_SUCCESS) {
if (bitval == expected_bitval)
else {
}
}
else {
t_info("dname_from_tname %s failed, result = %s\n",
rval = T_UNRESOLVED;
}
return(rval);
}
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 4) {
/* label, bitpos, expected value */
}
else {
t_info("bad datafile format at line %d\n",
line);
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_label_getbit_data\n");
}
}
char *a3 = "dns_name_init initializes 'name' to the empty name";
void
t_dns_name_init() {
int rval;
int result;
unsigned char offsets[1];
rval = 0;
/* magic is hidden in name.c ...
if (name.magic != NAME_MAGIC) {
t_info("name.magic is not set to NAME_MAGIC\n");
++rval;
}
*/
t_info("name.ndata is not NULL\n");
++rval;
}
t_info("name.length is not 0\n");
++rval;
}
t_info("name.labels is not 0\n");
++rval;
}
if (name.attributes != 0) {
t_info("name.attributes is not 0\n");
++rval;
}
t_info("name.offsets is incorrect\n");
++rval;
}
t_info("name.buffer is not NULL\n");
++rval;
}
if (rval == 0)
else
}
char *a4 = "dns_name_invalidate invalidates 'name'";
void
int rval;
int result;
unsigned char offsets[1];
rval = 0;
/* magic is hidden in name.c ...
if (name.magic != 0) {
t_info("name.magic is not set to NAME_MAGIC\n");
++rval;
}
*/
t_info("name.ndata is not NULL\n");
++rval;
}
t_info("name.length is not 0\n");
++rval;
}
t_info("name.labels is not 0\n");
++rval;
}
if (name.attributes != 0) {
t_info("name.attributes is not 0\n");
++rval;
}
t_info("name.offsets is not NULL\n");
++rval;
}
t_info("name.buffer is not NULL\n");
++rval;
}
if (rval == 0)
else
}
char *a5 = "dns_name_setbuffer dedicates a binary buffer for use "
"with 'name'";
void
int result;
else
}
char *a6 = "dns_name_hasbuffer returns ISC_TRUE if 'name' has a "
"dedicated buffer, otherwise it returns ISC_FALSE";
void
int result;
int rval;
rval = 0;
++rval;
++rval;
if (rval == 0)
else
}
char *a7 = "dns_name_isabsolute returns ISC_TRUE if 'name' ends "
"in the root label";
static int
int len;
int rval;
rval = T_UNRESOLVED;
if (result == DNS_R_SUCCESS) {
else
}
else {
t_info("dns_name_fromtext %s failed, result = %s\n",
}
return(rval);
}
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 2) {
/* label, bitpos, expected value */
Tokens[0],
}
else {
t_info("bad datafile format at line %d\n",
line);
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_isabsolute_data\n");
}
}
char *a8 = "dns_name_hash(name, case_sensitive) returns "
"a hash of 'name' which is case_sensitive if case_sensitive "
"is true";
/* a9 merged with a8 */
static int
int rval;
int failures;
unsigned int hash1;
unsigned int hash2;
rval = T_UNRESOLVED;
failures = 0;
if (result == DNS_R_SUCCESS) {
if (result == DNS_R_SUCCESS) {
++failures;
t_info("hash mismatch when ISC_TRUE\n");
}
if (match != cish_match) {
++failures;
t_info("hash mismatch when ISC_FALSE\n");
}
if (failures == 0)
else
}
else {
t_info("dns_fromtext %s failed, result = %s\n",
}
}
else {
t_info("dns_fromtext %s failed, result = %s\n",
}
return(rval);
}
void
t_dns_name_hash() {
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 4) {
/*
* name1, name2, exp match value if
* case_sensitive true,
* exp match value of case_sensitive false
*/
Tokens[0],
Tokens[1],
}
else {
t_info("bad datafile format at line %d\n",
line);
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_hash_data\n");
}
}
char *a10 = "dns_name_fullcompare(name1, name2, orderp, nlabelsp, nbitsp) "
"returns the DNSSEC ordering relationship between name1 and "
"name2, sets orderp to -1 if name1 < name2, to 0 if "
"name1 == name2, or to 1 if name1 > name2, sets nlabelsp "
"to the number of labels name1 and name2 have in common, "
"and sets nbitsp to the number of bits name1 and name2 "
"have in common";
/* a11 thru a22 merged into a10 */
static char *
char *p;
if (reln == dns_namereln_contains)
p = "contains";
else if (reln == dns_namereln_subdomain)
p = "subdomain";
else if (reln == dns_namereln_equal)
p = "equal";
else if (reln == dns_namereln_none)
p = "none";
else if (reln == dns_namereln_commonancestor)
p = "commonancestor";
else
p = "unknown";
return(p);
}
static int
int result;
int nfails;
int order;
unsigned int nlabels;
unsigned int nbits;
nfails = 0;
if (dns_result == DNS_R_SUCCESS) {
if (dns_result == DNS_R_SUCCESS) {
if (dns_reln != exp_dns_reln) {
++nfails;
t_info("expected relationship of %s, got %s\n",
}
++nfails;
t_info("expected ordering %d, got %d\n",
}
++nfails;
t_info("expecting %d labels, got %d\n",
}
++nfails;
t_info("expecting %d bits, got %d\n",
}
if (nfails == 0)
else
}
else {
t_info("dname_from_tname failed, result == %s\n",
}
}
else {
t_info("dname_from_tname failed, result == %s\n",
}
return(result);
}
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 6) {
/*
* name1, name2, exp_reln, exp_order,
* exp_nlabels, exp_nbits
*/
else {
continue;
}
Tokens[0],
Tokens[1],
reln,
}
else {
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_fullcompare_data\n");
}
}
char *a23 = "dns_name_compare(name1, name2) returns information about "
"the relative ordering under the DNSSEC ordering relationship "
"of name1 and name2";
/* a24 thru a29 merged into a23 */
static int
int result;
int order;
t_info("testing %s %s %s\n",
name2);
if (dns_result == DNS_R_SUCCESS) {
if (dns_result == DNS_R_SUCCESS) {
t_info("expected order of %d, got %d\n",
}
else
}
else {
t_info("dname_from_tname failed, result == %s\n",
}
}
else {
t_info("dname_from_tname failed, result == %s\n",
}
return(result);
}
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 3) {
/*
* name1, name2, order
*/
Tokens[0],
Tokens[1],
}
else {
t_info("bad datafile format at line %d\n",
line);
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_compare_data\n");
}
}
char *a30 = "dns_name_rdatacompare(name1, name2) returns information about "
"the relative ordering of name1 and name2 as if they are part "
"of rdata in DNSSEC canonical form";
/* a31, a32 merged into a30 */
static int
int result;
int order;
t_info("testing %s %s %s\n",
name2);
if (dns_result == DNS_R_SUCCESS) {
if (dns_result == DNS_R_SUCCESS) {
t_info("expected order of %d, got %d\n",
}
else
}
else {
t_info("dname_from_tname failed, result == %s\n",
}
}
else {
t_info("dname_from_tname failed, result == %s\n",
}
return(result);
}
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 3) {
/*
* name1, name2, order
*/
Tokens[0],
Tokens[1],
}
else {
t_info("bad datafile format at line %d\n",
line);
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_rdatacompare_data\n");
}
}
char *a33 = "when name1 is a subdomain of name2, "
"dns_name_issubdomain(name1, name2) returns true, "
"otherwise it returns false.";
/* a34 merged into a33 */
static int
int result;
t_info("testing %s %s a subdomain of %s\n",
name2);
if (dns_result == DNS_R_SUCCESS) {
if (dns_result == DNS_R_SUCCESS) {
t_info("expected return value of %s, got %s\n",
}
else
}
else {
t_info("dname_from_tname failed, result == %s\n",
}
}
else {
t_info("dname_from_tname failed, result == %s\n",
}
return(result);
}
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 3) {
/*
* name1, name2, issubdomain_p
*/
Tokens[0],
Tokens[1],
}
else {
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_issubdomain_data\n");
}
}
char *a35 = "dns_name_countlabels(name) returns the number "
"of labels in name";
static int
int result;
unsigned int nlabels;
if (dns_result == DNS_R_SUCCESS) {
if (nlabels != exp_nlabels) {
}
else
}
else {
t_info("dname_from_tname failed, result == %s\n",
}
return(result);
}
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 2) {
/*
* name, nlabels
*/
Tokens[0],
}
else {
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_countlabels_data\n");
}
}
char *a36 = "when n is less than the number of labels in name, "
"dns_name_getlabel(name, n, labelp) initializes labelp "
"to point to the nth label in name";
/*
* The strategy here is two take two dns names with a shared label in
* different positions, get the two labels and compare them for equality.
* If they don't match, dns_name_getlabel failed.
*/
static int
char *test_name2, int label2_pos) {
int result;
int nfails;
unsigned int cnt;
unsigned char *p;
unsigned char *q;
nfails = 0;
if (dns_result == DNS_R_SUCCESS) {
if (dns_result == DNS_R_SUCCESS) {
t_info("label lengths differ\n");
++nfails;
}
p = dns_label1.base;
q = dns_label2.base;
if (*p++ != *q++) {
t_info("labels differ at position %d",
cnt);
++nfails;
}
}
if (nfails == 0)
else
}
else {
t_info("dname_from_tname failed, result == %s",
}
}
else {
t_info("dname_from_tname failed, result == %s",
}
return(result);
}
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 4) {
/*
* name1, name2, nlabels
*/
Tokens[0],
Tokens[2],
}
else {
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_getlabel_data\n");
}
}
char *a37 = "when source contains at least first + n labels, "
"dns_name_getlabelsequence(source, first, n, target) "
"initializes target to point to the n label sequence of "
"labels in source starting with first";
/*
* we adopt a similiar strategy to that used by the dns_name_getlabel test
*/
static int
int result;
int nfails;
unsigned int cnt;
unsigned char *p;
unsigned char *q;
nfails = 0;
if (dns_result == DNS_R_SUCCESS) {
if (dns_result == DNS_R_SUCCESS) {
range, &dns_targetname1);
range, &dns_targetname2);
/* now convert both targets to text for comparison */
if (*p != *q) {
++nfails;
t_info("names differ at %d\n",
cnt);
break;
}
++p; ++q;
}
}
else {
++nfails;
t_info("lengths differ\n");
}
if (nfails == 0)
else
}
else {
t_info("dname_from_tname failed, result == %s",
}
}
else {
t_info("dname_from_tname failed, result == %s",
}
return(result);
}
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 5) {
/*
* name1, name2, nlabels
*/
Tokens[0],
Tokens[2],
}
else {
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_getlabelsequence_data\n");
}
}
char *a38 = "dns_name_fromregion(name, region) converts a DNS name "
"from a region representation to a name representation";
static int
test_dns_name_fromregion(char *test_name) {
int result;
int order;
unsigned int nlabels;
unsigned int nbits;
if (dns_result == DNS_R_SUCCESS) {
if ( dns_namereln == dns_namereln_equal)
else
}
else {
t_info("dname_from_tname failed, result == %s\n",
}
return(result);
}
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 1) {
/*
* test_name
*/
}
else {
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_fromregion_data\n");
}
}
char *a39 = "dns_name_toregion(name, region) converts a DNS name "
"from a region representation to a name representation";
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 1) {
/*
* test_name
*/
}
else {
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_toregion_data\n");
}
}
char *a40 = "dns_name_fromtext(name, source, origin, downcase, target) "
"converts the textual representation of a DNS name at source "
"into uncompressed wire form at target, appending origin to "
"the converted name if origin is non-NULL and converting "
"upper case to lower case during conversion "
"if downcase is true.";
static int
int result;
int order;
unsigned int nlabels;
unsigned int nbits;
if (dns_result != DNS_R_SUCCESS) {
t_info("dns_name_fromtext(dns_name3) failed, result == %s\n",
return(T_FAIL);
}
if (dns_result != DNS_R_SUCCESS) {
t_info("dns_name_fromtext(dns_name1) failed, result == %s\n",
return(T_FAIL);
}
if (dns_result != DNS_R_SUCCESS) {
t_info("dns_name_fromtext(dns_name2) failed, result == %s\n",
return(T_FAIL);
}
if (dns_namereln == dns_namereln_equal)
else {
t_info("dns_name_fullcompare returned %s\n",
}
return(result);
}
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 4) {
/*
* test_name1, test_name2, test_origin
* downcase
*/
}
else {
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_fromtext\n");
}
}
char *a41 = "dns_name_totext(name, omit_final_dot, target) converts "
"the DNS name 'name' in wire format to textual format "
"at target, and adds a final '.' to the name if "
"omit_final_dot is false";
static int
int result;
int len;
int order;
unsigned int nlabels;
unsigned int nbits;
/* out of the data file to dns_name1 */
&buf2);
if (dns_result != DNS_R_SUCCESS) {
t_info("dns_name_fromtext failed, result == %s\n",
return(T_UNRESOLVED);
}
/* from dns_name1 into a text buffer */
if (dns_result != DNS_R_SUCCESS) {
t_info("dns_name_totext failed, result == %s\n",
return(T_FAIL);
}
/* from the text buffer into dns_name2 */
if (dns_result != DNS_R_SUCCESS) {
t_info("dns_name_fromtext failed, result == %s\n",
return(T_UNRESOLVED);
}
if (dns_namereln == dns_namereln_equal)
else {
t_info("dns_name_fullcompare returned %s\n",
}
return(result);
}
void
int line;
int cnt;
int result;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 2) {
/*
* test_name, omit_final
*/
}
else {
}
(void) free(p);
}
}
else {
t_info("Missing datafile dns_name_totext\n");
}
}
char *a42 = "dns_name_fromwire(name, source, dctx, downcase, target) "
"converts the possibly compressed DNS name 'name' in wire "
"format to canonicalized form at target, performing upper to "
"lower case conversion if downcase is true, and returns "
"DNS_R_SUCCESS";
char *a43 = "when a label length is invalid, dns_name_fromwire() "
"returns DNS_R_NOSPACE";
char *a44 = "when a label type is invalid, dns_name_fromwire() "
"returns DNS_R_BADLABELTYPE";
char *a45 = "when a name length is invalid, dns_name_fromwire() "
"returns DNS_R_NOSPACE";
char *a46 = "when a compression type is invalid, dns_name_fromwire() "
"returns DNS_R_DISALLOWED";
char *a47 = "when a bad compression pointer is encountered, "
"dns_name_fromwire() returns DNS_R_BADPOINTER";
char *a48 = "when input ends unexpected, dns_name_fromwire() "
"returns DNS_R_UNEXPECTEDEND";
char *a49 = "when there are too many compression pointers, "
"dns_name_fromwire() returns DNS_R_TOOMANYHOPS";
char *a50 = "when there is not enough space in target, "
"dns_name_fromwire(name, source, dcts, downcase, target) "
"returns DNS_R_NOSPACE";
static int
test_dns_name_fromwire( char *datafile_name,
int testname_offset,
int downcase,
int dc_method,
char *exp_name,
int result;
int order;
unsigned int nlabels;
unsigned int nbits;
int len;
if (dns_result == DNS_R_SUCCESS) {
&order,
&nlabels,
&nbits);
if (dns_namereln != dns_namereln_equal) {
t_info("dns_name_fullcompare returned %s\n",
}
else {
}
}
else {
t_info("dns_name_fromtext %s failed, result = %s\n",
}
}
else if (dns_result == exp_result) {
}
else {
t_info("dns_name_fromwire returned %s\n",
}
return(result);
}
static void
int line;
int cnt;
int result;
int dc_method;
char *p;
char *tok;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 6) {
/*
* datafile_name, testname_offset,
* downcase, dc_method,
* exp_name, exp_result
*/
Tokens[0],
Tokens[4],
buflen);
}
else {
}
(void) free(p);
}
}
else {
}
}
void
/*
* XXXRTH these tests appear to be broken, so I have
* disabled them.
*/
#if 0
#endif
}
char *a51 = "dns_name_towire(name, cctx, target) converts the DNS name "
"'name' into wire format, compresses it as specified "
"by the compression context cctx, stores the result in "
"target and returns DNS_SUCCESS";
char *a52 = "when not enough space exists in target, "
"dns_name_towire(name, cctx, target) returns DNS_R_NOSPACE";
static int
test_dns_name_towire( char *testname,
int dc_method,
char *exp_data,
int exp_data_len,
int result;
int val;
int len;
if (isc_result != ISC_R_SUCCESS) {
t_info("isc_mem_create failed\n");
return(result);
}
if (dns_result == DNS_R_SUCCESS) {
if (dns_result == exp_result) {
if (exp_result == DNS_R_SUCCESS) {
/* compare results with expected data */
if (val == 0)
else
}
else
}
else {
t_info("dns_name_towire unexpectedly returned %s\n",
}
}
else {
t_info("dns_name_fromtext %s failed, result = %s\n",
}
return(result);
}
static void
int line;
int cnt;
int result;
int dc_method;
char *p;
line = 0;
++line;
/* skip comment lines */
if ((isspace((int)*p)) || (*p == '#'))
continue;
if (cnt == 5) {
/*
* testname, dc_method,
* exp_data, exp_data_len,
* exp_result
*/
Tokens[0],
Tokens[2],
buflen);
}
else {
}
(void) free(p);
}
}
else {
}
}
void
}
void
}
void
}
char *a53 = "dns_name_concatenate(prefix, suffix, name, target) "
"concatenates prefix and suffix, stores the result "
"in target, canonicalizes any bitstring labels "
"and returns DNS_R_SUCCESS";
void
}
testspec_t T_testlist[] = {
{ t_dns_label_countbits, "dns_label_countbits" },
{ t_dns_label_getbit, "dns_label_getbit" },
{ t_dns_name_init, "dns_name_init" },
{ t_dns_name_invalidate, "dns_name_invalidate" },
{ t_dns_name_setbuffer, "dns_name_setbuffer" },
{ t_dns_name_hasbuffer, "dns_name_hasbuffer" },
{ t_dns_name_isabsolute, "dns_name_isabsolute" },
{ t_dns_name_hash, "dns_name_hash" },
{ t_dns_name_fullcompare, "dns_name_fullcompare" },
{ t_dns_name_compare, "dns_name_compare" },
{ t_dns_name_rdatacompare, "dns_name_rdatacompare" },
{ t_dns_name_issubdomain, "dns_name_issubdomain" },
{ t_dns_name_countlabels, "dns_name_countlabels" },
{ t_dns_name_getlabel, "dns_name_getlabel" },
{ t_dns_name_getlabelsequence, "dns_name_getlabelsequence" },
{ t_dns_name_fromregion, "dns_name_fromregion" },
{ t_dns_name_toregion, "dns_name_toregion" },
{ t_dns_name_fromwire, "dns_name_fromwire" },
{ t_dns_name_towire, "dns_name_towire" },
{ t_dns_name_fromtext, "dns_name_fromtext" },
{ t_dns_name_totext, "dns_name_totext" },
{ t_dns_name_concatenate, "dns_name_concatenate" },
};