Commit 7c0539be authored by Mark Andrews's avatar Mark Andrews
Browse files

Created dns_name_rdatacompare() to do DNSSEC rdata comparisions

	as opposed to DNSSEC owner name comparisions of names.  Changed
	all rdata types that were using dns_name_compare() to use
	dns_name_rdatacompare().
parent 73131dbe
......@@ -286,6 +286,26 @@ dns_name_compare(dns_name_t *name1, dns_name_t *name2);
* 1 'name1' is greater than 'name2'
*/
int
dns_name_rdatacompare(dns_name_t *name1, dns_name_t *name2);
/*
* Compare two names as if they are part of rdata.
*
* Requires:
* 'name1' is a valid absolute name
*
* dns_name_countlabels(name1) > 0
*
* 'name2' is a valid absolute name
*
* dns_name_countlabels(name2) > 0
*
* Returns:
* -1 'name1' is less than 'name2'
* 0 'name1' is equal to 'name2'
* 1 'name1' is greater than 'name2'
*/
isc_boolean_t
dns_name_issubdomain(dns_name_t *name1, dns_name_t *name2);
/*
......
......@@ -456,6 +456,78 @@ dns_name_compare(dns_name_t *name1, dns_name_t *name2) {
return (ldiff);
}
int
dns_name_rdatacompare(dns_name_t *name1, dns_name_t *name2) {
unsigned int l1, l2, l, count1, count2, count;
unsigned char c1, c2;
unsigned char *label1, *label2;
/*
* Compare two absolute names as rdata.
*/
REQUIRE(VALID_NAME(name1));
REQUIRE(name1->labels > 0);
REQUIRE((name1->attributes & DNS_NAMEATTR_ABSOLUTE) != 0);
REQUIRE(VALID_NAME(name2));
REQUIRE(name2->labels > 0);
REQUIRE((name2->attributes & DNS_NAMEATTR_ABSOLUTE) != 0);
l1 = name1->labels;
l2 = name2->labels;
l = (l1 < l2) ? l1 : l2;
label1 = name1->ndata;
label2 = name2->ndata;
while (l > 0) {
l--;
count1 = *label1++;
count2 = *label2++;
if (count1 <= 63 && count2 <= 63) {
if (count1 != count2)
return ((count1 < count2) ? -1 : 1);
count = count1;
while (count > 0) {
count--;
c1 = maptolower[*label1++];
c2 = maptolower[*label2++];
if (c1 < c2)
return (-1);
else if (c1 > c2)
return (1);
}
} else if (count1 == DNS_LABELTYPE_BITSTRING && count2 <= 63) {
return (1);
} else if (count2 == DNS_LABELTYPE_BITSTRING && count1 <= 63) {
return (-1);
} else {
INSIST(count1 == DNS_LABELTYPE_BITSTRING &&
count2 == DNS_LABELTYPE_BITSTRING);
count2 = *label2++;
count1 = *label1++;
if (count1 != count2)
return ((count1 < count2) ? -1 : 1);
if (count1 == 0)
count1 = 256;
if (count2 == 0)
count2 = 256;
/* number of bytes */
count = (count1 + 7) / 8;
while (count > 0) {
c1 = *label1++;
c2 = *label2++;
if (c1 != c2)
return ((c1 < c2) ? -1 : 1);
}
}
}
INSIST(l1 == l2);
return (0);
}
isc_boolean_t
dns_name_issubdomain(dns_name_t *name1, dns_name_t *name2) {
unsigned int l1, l2, count1, count2;
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tsig_250.c,v 1.3 1999/02/05 05:15:15 marka Exp $ */
/* $Id: tsig_250.c,v 1.4 1999/02/15 05:44:15 marka Exp $ */
/* draft-ietf-dnsind-tsig-07.txt */
......@@ -263,7 +263,7 @@ compare_any_tsig(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_init(&name2, NULL);
dns_name_fromregion(&name1, &r1);
dns_name_fromregion(&name2, &r2);
result = dns_name_compare(&name1, &name2);
result = dns_name_rdatacompare(&name1, &name2);
if (result != 0)
return (result);
isc_region_consume(&r1, name_length(&name1));
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: tsig_250.h,v 1.3 1999/02/05 05:15:15 marka Exp $ */
/* $Id: tsig_250.h,v 1.4 1999/02/15 05:44:15 marka Exp $ */
/* draft-ietf-dnsind-tsig-07.txt */
......@@ -263,7 +263,7 @@ compare_any_tsig(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_init(&name2, NULL);
dns_name_fromregion(&name1, &r1);
dns_name_fromregion(&name2, &r2);
result = dns_name_compare(&name1, &name2);
result = dns_name_rdatacompare(&name1, &name2);
if (result != 0)
return (result);
isc_region_consume(&r1, name_length(&name1));
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: afsdb_18.c,v 1.1 1999/01/22 05:02:44 marka Exp $ */
/* $Id: afsdb_18.c,v 1.2 1999/02/15 05:44:15 marka Exp $ */
/* RFC 1183 */
......@@ -148,7 +148,7 @@ compare_afsdb(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: afsdb_18.h,v 1.1 1999/01/22 05:02:44 marka Exp $ */
/* $Id: afsdb_18.h,v 1.2 1999/02/15 05:44:15 marka Exp $ */
/* RFC 1183 */
......@@ -148,7 +148,7 @@ compare_afsdb(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: cname_5.c,v 1.6 1999/01/22 05:02:44 marka Exp $ */
/* $Id: cname_5.c,v 1.7 1999/02/15 05:44:16 marka Exp $ */
#ifndef RDATA_GENERIC_CNAME_5_H
#define RDATA_GENERIC_CNAME_5_H
......@@ -107,7 +107,7 @@ compare_cname(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: cname_5.h,v 1.6 1999/01/22 05:02:44 marka Exp $ */
/* $Id: cname_5.h,v 1.7 1999/02/15 05:44:16 marka Exp $ */
#ifndef RDATA_GENERIC_CNAME_5_H
#define RDATA_GENERIC_CNAME_5_H
......@@ -107,7 +107,7 @@ compare_cname(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: dname_39.c,v 1.1 1999/02/02 05:03:10 marka Exp $ */
/* $Id: dname_39.c,v 1.2 1999/02/15 05:44:16 marka Exp $ */
/* draft-ietf-dnsind-dname-02.txt */
......@@ -111,7 +111,7 @@ compare_dname(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: dname_39.h,v 1.1 1999/02/02 05:03:10 marka Exp $ */
/* $Id: dname_39.h,v 1.2 1999/02/15 05:44:16 marka Exp $ */
/* draft-ietf-dnsind-dname-02.txt */
......@@ -111,7 +111,7 @@ compare_dname(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mb_7.c,v 1.6 1999/01/22 05:02:45 marka Exp $ */
/* $Id: mb_7.c,v 1.7 1999/02/15 05:44:16 marka Exp $ */
#ifndef RDATA_GENERIC_MB_7_H
#define RDATA_GENERIC_MB_7_H
......@@ -109,7 +109,7 @@ compare_mb(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mb_7.h,v 1.6 1999/01/22 05:02:45 marka Exp $ */
/* $Id: mb_7.h,v 1.7 1999/02/15 05:44:16 marka Exp $ */
#ifndef RDATA_GENERIC_MB_7_H
#define RDATA_GENERIC_MB_7_H
......@@ -109,7 +109,7 @@ compare_mb(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: md_3.c,v 1.6 1999/01/22 05:02:45 marka Exp $ */
/* $Id: md_3.c,v 1.7 1999/02/15 05:44:16 marka Exp $ */
#ifndef RDATA_GENERIC_MD_3_H
#define RDATA_GENERIC_MD_3_H
......@@ -107,7 +107,7 @@ compare_md(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: md_3.h,v 1.6 1999/01/22 05:02:45 marka Exp $ */
/* $Id: md_3.h,v 1.7 1999/02/15 05:44:16 marka Exp $ */
#ifndef RDATA_GENERIC_MD_3_H
#define RDATA_GENERIC_MD_3_H
......@@ -107,7 +107,7 @@ compare_md(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mf_4.c,v 1.6 1999/01/22 05:02:45 marka Exp $ */
/* $Id: mf_4.c,v 1.7 1999/02/15 05:44:17 marka Exp $ */
#ifndef RDATA_GENERIC_MF_4_H
#define RDATA_GENERIC_MF_4_H
......@@ -107,7 +107,7 @@ compare_mf(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mf_4.h,v 1.6 1999/01/22 05:02:45 marka Exp $ */
/* $Id: mf_4.h,v 1.7 1999/02/15 05:44:17 marka Exp $ */
#ifndef RDATA_GENERIC_MF_4_H
#define RDATA_GENERIC_MF_4_H
......@@ -107,7 +107,7 @@ compare_mf(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mg_8.c,v 1.6 1999/01/22 05:02:45 marka Exp $ */
/* $Id: mg_8.c,v 1.7 1999/02/15 05:44:17 marka Exp $ */
#ifndef RDATA_GENERIC_MG_8_H
#define RDATA_GENERIC_MG_8_H
......@@ -109,7 +109,7 @@ compare_mg(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: mg_8.h,v 1.6 1999/01/22 05:02:45 marka Exp $ */
/* $Id: mg_8.h,v 1.7 1999/02/15 05:44:17 marka Exp $ */
#ifndef RDATA_GENERIC_MG_8_H
#define RDATA_GENERIC_MG_8_H
......@@ -109,7 +109,7 @@ compare_mg(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
return (dns_name_compare(&name1, &name2));
return (dns_name_rdatacompare(&name1, &name2));
}
static dns_result_t
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: minfo_14.c,v 1.7 1999/01/27 13:38:20 marka Exp $ */
/* $Id: minfo_14.c,v 1.8 1999/02/15 05:44:17 marka Exp $ */
#ifndef RDATA_GENERIC_MINFO_14_H
#define RDATA_GENERIC_MINFO_14_H
......@@ -141,7 +141,7 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
result = dns_name_compare(&name1, &name2);
result = dns_name_rdatacompare(&name1, &name2);
if (result != 0)
return (result);
......@@ -154,7 +154,7 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
result = dns_name_compare(&name1, &name2);
result = dns_name_rdatacompare(&name1, &name2);
return (result);
}
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: minfo_14.h,v 1.7 1999/01/27 13:38:20 marka Exp $ */
/* $Id: minfo_14.h,v 1.8 1999/02/15 05:44:17 marka Exp $ */
#ifndef RDATA_GENERIC_MINFO_14_H
#define RDATA_GENERIC_MINFO_14_H
......@@ -141,7 +141,7 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
result = dns_name_compare(&name1, &name2);
result = dns_name_rdatacompare(&name1, &name2);
if (result != 0)
return (result);
......@@ -154,7 +154,7 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
dns_name_fromregion(&name1, &region1);
dns_name_fromregion(&name2, &region2);
result = dns_name_compare(&name1, &name2);
result = dns_name_rdatacompare(&name1, &name2);
return (result);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment