simplify dns_name_fromtext() interface
previously, dns_name_fromtext() took both a target name and an optional target buffer parameter, which could override the name's dedicated buffer. this interface is unnecessarily complex. we now have two functions, dns_name_fromtext() to convert text into a dns_name that has a dedicated buffer, and dns_name_wirefromtext() to convert text into uncompressed DNS wire format and append it to a target buffer. in cases where it really is necessary to have both, we can use dns_name_fromtext() to load the dns_name, then dns_name_towire() to append the wire format to the target buffer.
This commit is contained in:
@@ -62,7 +62,7 @@ main(void) {
|
||||
errx(1, "too many names");
|
||||
}
|
||||
dns_name_t *name = dns_fixedname_initname(&fixedname[count++]);
|
||||
result = dns_name_fromtext(name, &buf, dns_rootname, 0, NULL);
|
||||
result = dns_name_fromtext(name, &buf, dns_rootname, 0);
|
||||
CHECKRESULT(result, line);
|
||||
}
|
||||
|
||||
|
||||
@@ -471,8 +471,7 @@ main(int argc, char *argv[]) {
|
||||
isc_buffer_t buffer;
|
||||
isc_buffer_init(&buffer, domain, len);
|
||||
isc_buffer_add(&buffer, len);
|
||||
result = dns_name_fromtext(name, &buffer, dns_rootname, 0,
|
||||
NULL);
|
||||
result = dns_name_fromtext(name, &buffer, dns_rootname, 0);
|
||||
FILE_CHECK(result == ISC_R_SUCCESS, isc_result_totext(result));
|
||||
|
||||
wirebytes += name->length;
|
||||
|
||||
@@ -203,8 +203,7 @@ main(int argc, char *argv[]) {
|
||||
|
||||
isc_buffer_init(&buffer, domain, len);
|
||||
isc_buffer_add(&buffer, len);
|
||||
result = dns_name_fromtext(name, &buffer, dns_rootname, 0,
|
||||
NULL);
|
||||
result = dns_name_fromtext(name, &buffer, dns_rootname, 0);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
smallname_from_name(name, &pval, &ival);
|
||||
result = dns_qp_insert(qp, pval, ival);
|
||||
|
||||
@@ -162,8 +162,7 @@ load_qp(dns_qp_t *qp, const char *filename) {
|
||||
|
||||
isc_buffer_init(&buffer, domain, len);
|
||||
isc_buffer_add(&buffer, len);
|
||||
result = dns_name_fromtext(name, &buffer, dns_rootname, 0,
|
||||
NULL);
|
||||
result = dns_name_fromtext(name, &buffer, dns_rootname, 0);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
smallname_from_name(name, &pval, &ival);
|
||||
result = dns_qp_insert(qp, pval, ival);
|
||||
|
||||
@@ -42,7 +42,7 @@ make_name(const char *src, dns_name_t *name) {
|
||||
isc_buffer_t b;
|
||||
isc_buffer_constinit(&b, src, strlen(src));
|
||||
isc_buffer_add(&b, strlen(src));
|
||||
return dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
|
||||
return dns_name_fromtext(name, &b, dns_rootname, 0);
|
||||
}
|
||||
|
||||
/* create: make sure we can create a dbiterator */
|
||||
|
||||
@@ -219,7 +219,7 @@ setup_test(void **state) {
|
||||
isc_buffer_constinit(&namesrc, tls_name_str, strlen(tls_name_str));
|
||||
isc_buffer_add(&namesrc, strlen(tls_name_str));
|
||||
if (dns_name_fromtext(tls_name, &namesrc, dns_rootname,
|
||||
DNS_NAME_DOWNCASE, NULL) != ISC_R_SUCCESS)
|
||||
DNS_NAME_DOWNCASE) != ISC_R_SUCCESS)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ ISC_LOOP_TEST_IMPL(dns_dt_send) {
|
||||
zname = dns_fixedname_initname(&zfname);
|
||||
isc_buffer_constinit(&zb, "example.com.", 12);
|
||||
isc_buffer_add(&zb, 12);
|
||||
result = dns_name_fromtext(zname, &zb, NULL, 0, NULL);
|
||||
result = dns_name_fromtext(zname, &zb, NULL, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
memset(&zr, 0, sizeof(zr));
|
||||
|
||||
@@ -163,7 +163,7 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
|
||||
name = dns_fixedname_initname(&fname);
|
||||
isc_buffer_constinit(&b, keyname, strlen(keyname));
|
||||
isc_buffer_add(&b, strlen(keyname));
|
||||
result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
|
||||
result = dns_name_fromtext(name, &b, dns_rootname, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = dst_key_fromfile(name, id, alg, type,
|
||||
TESTS_DIR "/testdata/dst", mctx, &key);
|
||||
@@ -298,7 +298,7 @@ check_cmp(const char *key1_name, dns_keytag_t key1_id, const char *key2_name,
|
||||
name1 = dns_fixedname_initname(&fname1);
|
||||
isc_buffer_constinit(&b1, key1_name, strlen(key1_name));
|
||||
isc_buffer_add(&b1, strlen(key1_name));
|
||||
result = dns_name_fromtext(name1, &b1, dns_rootname, 0, NULL);
|
||||
result = dns_name_fromtext(name1, &b1, dns_rootname, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = dst_key_fromfile(name1, key1_id, alg, type,
|
||||
TESTS_DIR "/comparekeys", mctx, &key1);
|
||||
@@ -310,7 +310,7 @@ check_cmp(const char *key1_name, dns_keytag_t key1_id, const char *key2_name,
|
||||
name2 = dns_fixedname_initname(&fname2);
|
||||
isc_buffer_constinit(&b2, key2_name, strlen(key2_name));
|
||||
isc_buffer_add(&b2, strlen(key2_name));
|
||||
result = dns_name_fromtext(name2, &b2, dns_rootname, 0, NULL);
|
||||
result = dns_name_fromtext(name2, &b2, dns_rootname, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = dst_key_fromfile(name2, key2_id, alg, type,
|
||||
TESTS_DIR "/comparekeys", mctx, &key2);
|
||||
@@ -445,7 +445,7 @@ ISC_RUN_TEST_IMPL(ecdsa_determinism_test) {
|
||||
name = dns_fixedname_initname(&fname);
|
||||
isc_buffer_constinit(&keybuf, "example.", strlen("example."));
|
||||
isc_buffer_add(&keybuf, strlen("example."));
|
||||
result = dns_name_fromtext(name, &keybuf, dns_rootname, 0, NULL);
|
||||
result = dns_name_fromtext(name, &keybuf, dns_rootname, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = dst_key_fromfile(name, 19786, DST_ALG_ECDSA256,
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE,
|
||||
|
||||
@@ -97,9 +97,8 @@ str2name(const char *namestr) {
|
||||
name = dns_fixedname_initname(&fname);
|
||||
isc_buffer_init(&namebuf, UNCONST(namestr), strlen(namestr));
|
||||
isc_buffer_add(&namebuf, strlen(namestr));
|
||||
assert_int_equal(
|
||||
dns_name_fromtext(name, &namebuf, dns_rootname, 0, NULL),
|
||||
ISC_R_SUCCESS);
|
||||
assert_int_equal(dns_name_fromtext(name, &namebuf, dns_rootname, 0),
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ setup_master(void (*warn)(struct dns_rdatacallbacks *, const char *, ...),
|
||||
isc_buffer_setactive(&source, len);
|
||||
dns_master_initrawheader(&header);
|
||||
|
||||
result = dns_name_fromtext(dns_origin, &source, dns_rootname, 0, NULL);
|
||||
result = dns_name_fromtext(dns_origin, &source, dns_rootname, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -640,7 +640,7 @@ ISC_RUN_TEST_IMPL(isabsolute) {
|
||||
dns_name_init(&name);
|
||||
isc_buffer_init(&nb, data, BUFSIZ);
|
||||
dns_name_setbuffer(&name, &nb);
|
||||
result = dns_name_fromtext(&name, &b, NULL, 0, NULL);
|
||||
result = dns_name_fromtext(&name, &b, NULL, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
assert_int_equal(dns_name_isabsolute(&name),
|
||||
|
||||
@@ -134,12 +134,12 @@ ownercase_test_one(const char *str1, const char *str2) {
|
||||
|
||||
isc_buffer_constinit(&b, str1, strlen(str1));
|
||||
isc_buffer_add(&b, strlen(str1));
|
||||
result = dns_name_fromtext(name1, &b, dns_rootname, 0, NULL);
|
||||
result = dns_name_fromtext(name1, &b, dns_rootname, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
isc_buffer_constinit(&b, str2, strlen(str2));
|
||||
isc_buffer_add(&b, strlen(str2));
|
||||
result = dns_name_fromtext(name2, &b, dns_rootname, 0, NULL);
|
||||
result = dns_name_fromtext(name2, &b, dns_rootname, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
/* Store the case from name1 */
|
||||
@@ -206,12 +206,12 @@ ISC_RUN_TEST_IMPL(setownercase) {
|
||||
|
||||
isc_buffer_constinit(&b, str1, strlen(str1));
|
||||
isc_buffer_add(&b, strlen(str1));
|
||||
result = dns_name_fromtext(name1, &b, dns_rootname, 0, NULL);
|
||||
result = dns_name_fromtext(name1, &b, dns_rootname, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
isc_buffer_constinit(&b, str1, strlen(str1));
|
||||
isc_buffer_add(&b, strlen(str1));
|
||||
result = dns_name_fromtext(name2, &b, dns_rootname, 0, NULL);
|
||||
result = dns_name_fromtext(name2, &b, dns_rootname, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
assert_false(CASESET(&header));
|
||||
|
||||
@@ -133,7 +133,7 @@ ISC_RUN_TEST_IMPL(isc_rsa_verify) {
|
||||
name = dns_fixedname_initname(&fname);
|
||||
isc_buffer_constinit(&buf, "rsa.", 4);
|
||||
isc_buffer_add(&buf, 4);
|
||||
ret = dns_name_fromtext(name, &buf, NULL, 0, NULL);
|
||||
ret = dns_name_fromtext(name, &buf, NULL, 0);
|
||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||
|
||||
ret = dst_key_fromfile(name, 29238, DST_ALG_RSASHA256, DST_TYPE_PUBLIC,
|
||||
|
||||
@@ -448,7 +448,7 @@ ISC_RUN_TEST_IMPL(skr_read) {
|
||||
dname = dns_fixedname_initname(&dfname);
|
||||
isc_buffer_init(&b, name, strlen(name));
|
||||
isc_buffer_add(&b, strlen(name));
|
||||
result = dns_name_fromtext(dname, &b, dns_rootname, 0, NULL);
|
||||
result = dns_name_fromtext(dname, &b, dns_rootname, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
/* Get the KSK */
|
||||
|
||||
@@ -419,7 +419,7 @@ dns_test_namefromstring(const char *namestr, dns_fixedname_t *fname) {
|
||||
isc_buffer_allocate(mctx, &b, length);
|
||||
|
||||
isc_buffer_putmem(b, (const unsigned char *)namestr, length);
|
||||
result = dns_name_fromtext(name, b, NULL, 0, NULL);
|
||||
result = dns_name_fromtext(name, b, NULL, 0);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
||||
isc_buffer_free(&b);
|
||||
|
||||
Reference in New Issue
Block a user