static inline int compare_l32(ARGS_COMPARE) { isc_region_t region1; isc_region_t region2; REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); REQUIRE(rdata1->type == 105); REQUIRE(rdata1->length == 6); REQUIRE(rdata2->length == 6); dns_rdata_toregion(rdata1, ®ion1); dns_rdata_toregion(rdata2, ®ion2); return (isc_region_compare(®ion1, ®ion2)); }
static inline int compare_openpgpkey(ARGS_COMPARE) { isc_region_t r1; isc_region_t r2; REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); REQUIRE(rdata1->type == dns_rdatatype_openpgpkey); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); return (isc_region_compare(&r1, &r2)); }
static inline int compare_caa(ARGS_COMPARE) { isc_region_t r1, r2; REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); REQUIRE(rdata1->type == 257); REQUIRE(rdata1->length >= 3U); REQUIRE(rdata2->length >= 3U); REQUIRE(rdata1->data != NULL); REQUIRE(rdata2->data != NULL); dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); return (isc_region_compare(&r1, &r2)); }
static inline int compare_in_a(ARGS_COMPARE) { isc_region_t r1; isc_region_t r2; REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); REQUIRE(rdata1->type == 1); REQUIRE(rdata1->rdclass == 1); REQUIRE(rdata1->length == 4); REQUIRE(rdata2->length == 4); dns_rdata_toregion(rdata1, &r1); dns_rdata_toregion(rdata2, &r2); return (isc_region_compare(&r1, &r2)); }
static inline int compare_soa(ARGS_COMPARE) { isc_region_t region1; isc_region_t region2; dns_name_t name1; dns_name_t name2; int order; REQUIRE(rdata1->type == rdata2->type); REQUIRE(rdata1->rdclass == rdata2->rdclass); REQUIRE(rdata1->type == 6); REQUIRE(rdata1->length != 0); REQUIRE(rdata2->length != 0); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); dns_rdata_toregion(rdata1, ®ion1); dns_rdata_toregion(rdata2, ®ion2); dns_name_fromregion(&name1, ®ion1); dns_name_fromregion(&name2, ®ion2); order = dns_name_rdatacompare(&name1, &name2); if (order != 0) return (order); isc_region_consume(®ion1, name_length(&name1)); isc_region_consume(®ion2, name_length(&name2)); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); dns_name_fromregion(&name1, ®ion1); dns_name_fromregion(&name2, ®ion2); order = dns_name_rdatacompare(&name1, &name2); if (order != 0) return (order); isc_region_consume(®ion1, name_length(&name1)); isc_region_consume(®ion2, name_length(&name2)); return (isc_region_compare(®ion1, ®ion2)); }
/* * Compares only the public portion of two keys, by converting them * both to wire format and comparing the results. */ static isc_boolean_t pub_compare(const dst_key_t *key1, const dst_key_t *key2) { isc_result_t result; unsigned char buf1[DST_KEY_MAXSIZE], buf2[DST_KEY_MAXSIZE]; isc_buffer_t b1, b2; isc_region_t r1, r2; isc_buffer_init(&b1, buf1, sizeof(buf1)); result = dst_key_todns(key1, &b1); if (result != ISC_R_SUCCESS) return (ISC_FALSE); /* Zero out flags. */ buf1[0] = buf1[1] = 0; if ((key1->key_flags & DNS_KEYFLAG_EXTENDED) != 0) isc_buffer_subtract(&b1, 2); isc_buffer_init(&b2, buf2, sizeof(buf2)); result = dst_key_todns(key2, &b2); if (result != ISC_R_SUCCESS) return (ISC_FALSE); /* Zero out flags. */ buf2[0] = buf2[1] = 0; if ((key2->key_flags & DNS_KEYFLAG_EXTENDED) != 0) isc_buffer_subtract(&b2, 2); isc_buffer_usedregion(&b1, &r1); /* Remove extended flags. */ if ((key1->key_flags & DNS_KEYFLAG_EXTENDED) != 0) { memmove(&buf1[4], &buf1[6], r1.length - 6); r1.length -= 2; } isc_buffer_usedregion(&b2, &r2); /* Remove extended flags. */ if ((key2->key_flags & DNS_KEYFLAG_EXTENDED) != 0) { memmove(&buf2[4], &buf2[6], r2.length - 6); r2.length -= 2; } return (ISC_TF(isc_region_compare(&r1, &r2) == 0)); }