remove dns_name_towire2()

we don't need two versions of dns_name_towire(), we can just add NULL
to the calls that don't need to specify a compression offset.
This commit is contained in:
Evan Hunt
2023-08-15 17:55:13 -07:00
parent a290ed5bd0
commit 62d70966f2
39 changed files with 57 additions and 70 deletions

View File

@@ -78,7 +78,7 @@ main(void) {
for (unsigned int i = 0; i < count; i++) {
dns_name_t *name = dns_fixedname_name(&fixedname[i]);
result = dns_name_towire(name, &cctx, &buf);
result = dns_name_towire(name, &cctx, &buf, NULL);
if (result == ISC_R_NOSPACE) {
dns_compress_invalidate(&cctx);
dns_compress_init(&cctx, mctx, 0);

View File

@@ -173,7 +173,7 @@ ISC_RUN_TEST_IMPL(dns_dt_send) {
isc_buffer_init(&zb, zone, sizeof(zone));
dns_compress_init(&cctx, mctx, 0);
dns_compress_setpermitted(&cctx, false);
result = dns_name_towire(zname, &cctx, &zb);
result = dns_name_towire(zname, &cctx, &zb, NULL);
assert_int_equal(result, ISC_R_SUCCESS);
dns_compress_invalidate(&cctx);
isc_buffer_usedregion(&zb, &zr);

View File

@@ -144,33 +144,29 @@ compress_test(const dns_name_t *name1, const dns_name_t *name2,
if (rdata) {
/* RDATA compression */
assert_int_equal(dns_name_towire(name1, cctx, &source),
assert_int_equal(dns_name_towire(name1, cctx, &source, NULL),
ISC_R_SUCCESS);
assert_int_equal(dns_name_towire(name2, cctx, &source),
assert_int_equal(dns_name_towire(name2, cctx, &source, NULL),
ISC_R_SUCCESS);
assert_int_equal(dns_name_towire(name2, cctx, &source),
assert_int_equal(dns_name_towire(name2, cctx, &source, NULL),
ISC_R_SUCCESS);
assert_int_equal(dns_name_towire(name3, cctx, &source),
assert_int_equal(dns_name_towire(name3, cctx, &source, NULL),
ISC_R_SUCCESS);
} else {
/* Owner name compression */
uint16_t offset = 0xffff;
assert_int_equal(
dns_name_towire2(name1, cctx, &source, &offset),
ISC_R_SUCCESS);
assert_int_equal(dns_name_towire(name1, cctx, &source, &offset),
ISC_R_SUCCESS);
offset = 0xffff;
assert_int_equal(
dns_name_towire2(name2, cctx, &source, &offset),
ISC_R_SUCCESS);
assert_int_equal(
dns_name_towire2(name2, cctx, &source, &offset),
ISC_R_SUCCESS);
assert_int_equal(dns_name_towire(name2, cctx, &source, &offset),
ISC_R_SUCCESS);
assert_int_equal(dns_name_towire(name2, cctx, &source, &offset),
ISC_R_SUCCESS);
offset = 0xffff;
assert_int_equal(
dns_name_towire2(name3, cctx, &source, &offset),
ISC_R_SUCCESS);
assert_int_equal(dns_name_towire(name3, cctx, &source, &offset),
ISC_R_SUCCESS);
}
assert_int_equal(source.used, compressed_length);
assert_true(memcmp(source.base, compressed, source.used) == 0);
@@ -434,7 +430,7 @@ ISC_RUN_TEST_IMPL(collision) {
}
dns_compress_rollback(&cctx, coff);
result = dns_name_towire(&name, &cctx, &message);
result = dns_name_towire(&name, &cctx, &message, NULL);
assert_int_equal(result, ISC_R_SUCCESS);
/* we must be able to find the name we just added */