]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
remove the 'name_coff' parameter in dns_name_towire()
authorEvan Hunt <each@isc.org>
Sat, 22 Feb 2025 02:14:55 +0000 (18:14 -0800)
committerEvan Hunt <each@isc.org>
Tue, 25 Feb 2025 20:53:25 +0000 (12:53 -0800)
this parameter was added as a (minor) optimization for
cases where dns_name_towire() is run repeatedly with the
same compression context, as when rendering all of the rdatas
in an rdataset. it is currently only used in one place.

we now simplify the interface by removing the extra parameter.
the compression offset value is now part of the compression
context, and can be activated when needed by calling
dns_compress_setmultiuse(). multiuse mode is automatically
deactivated by any subsequent call to dns_compress_permitted().

41 files changed:
lib/dns/compress.c
lib/dns/include/dns/compress.h
lib/dns/include/dns/name.h
lib/dns/name.c
lib/dns/ncache.c
lib/dns/rdata/any_255/tsig_250.c
lib/dns/rdata/ch_3/a_1.c
lib/dns/rdata/generic/afsdb_18.c
lib/dns/rdata/generic/cname_5.c
lib/dns/rdata/generic/dname_39.c
lib/dns/rdata/generic/mb_7.c
lib/dns/rdata/generic/md_3.c
lib/dns/rdata/generic/mf_4.c
lib/dns/rdata/generic/mg_8.c
lib/dns/rdata/generic/minfo_14.c
lib/dns/rdata/generic/mr_9.c
lib/dns/rdata/generic/mx_15.c
lib/dns/rdata/generic/naptr_35.c
lib/dns/rdata/generic/ns_2.c
lib/dns/rdata/generic/nsec_47.c
lib/dns/rdata/generic/nxt_30.c
lib/dns/rdata/generic/ptr_12.c
lib/dns/rdata/generic/rp_17.c
lib/dns/rdata/generic/rrsig_46.c
lib/dns/rdata/generic/rt_21.c
lib/dns/rdata/generic/sig_24.c
lib/dns/rdata/generic/soa_6.c
lib/dns/rdata/generic/talink_58.c
lib/dns/rdata/generic/tkey_249.c
lib/dns/rdata/in_1/a6_38.c
lib/dns/rdata/in_1/kx_36.c
lib/dns/rdata/in_1/nsap-ptr_23.c
lib/dns/rdata/in_1/px_26.c
lib/dns/rdata/in_1/srv_33.c
lib/dns/rdata/in_1/svcb_64.c
lib/dns/rdataset.c
lib/dns/resolver.c
lib/ns/client.c
tests/bench/compress.c
tests/dns/dnstap_test.c
tests/dns/name_test.c

index 9490d2a7f763b09608da2f5efe2ed4a65b77b6d9..9fc067a46959c7a8f98fd40698d6f0a481933b3a 100644 (file)
@@ -57,6 +57,7 @@ dns_compress_init(dns_compress_t *cctx, isc_mem_t *mctx,
                .mctx = mctx,
                .mask = mask,
                .set = set,
+               .coff = 0xffff,
        };
 }
 
@@ -69,6 +70,23 @@ dns_compress_invalidate(dns_compress_t *cctx) {
        *cctx = (dns_compress_t){ 0 };
 }
 
+void
+dns_compress_setmultiuse(dns_compress_t *cctx, bool multi) {
+       REQUIRE(CCTX_VALID(cctx));
+       if (multi) {
+               cctx->flags |= DNS_COMPRESS_MULTIUSE;
+       } else {
+               cctx->flags &= ~DNS_COMPRESS_MULTIUSE;
+       }
+       cctx->coff = 0xffff;
+}
+
+bool
+dns_compress_getmultiuse(dns_compress_t *cctx) {
+       REQUIRE(CCTX_VALID(cctx));
+       return (cctx->flags & DNS_COMPRESS_MULTIUSE) != 0;
+}
+
 void
 dns_compress_setpermitted(dns_compress_t *cctx, bool permitted) {
        REQUIRE(CCTX_VALID(cctx));
@@ -77,6 +95,7 @@ dns_compress_setpermitted(dns_compress_t *cctx, bool permitted) {
        } else {
                cctx->flags &= ~DNS_COMPRESS_PERMITTED;
        }
+       dns_compress_setmultiuse(cctx, false);
 }
 
 bool
index 1e3fb84527b6f2ca3b0ade4421954439f114979d..9ca1b98327fb76cde2dbb0852d473f8dd883dc52 100644 (file)
@@ -75,6 +75,7 @@ enum dns_compress_flags {
        DNS_COMPRESS_LARGE = 0x00000004U,
        /* can toggle while rendering a message */
        DNS_COMPRESS_PERMITTED = 0x00000008U,
+       DNS_COMPRESS_MULTIUSE = 0x00000010U,
 };
 
 /*
@@ -91,6 +92,7 @@ struct dns_compress {
        dns_compress_flags_t flags;
        uint16_t             mask;
        uint16_t             count;
+       uint16_t             coff;
        isc_mem_t           *mctx;
        dns_compress_slot_t *set;
        dns_compress_slot_t  smallset[1 << DNS_COMPRESS_SMALLBITS];
@@ -140,11 +142,36 @@ dns_compress_invalidate(dns_compress_t *cctx);
  */
 
 void
+dns_compress_setmultiuse(dns_compress_t *cctx, bool multi);
+/*%<
+ *     Indicates this compression context is to be used for
+ *     multiple calls to dns_name_towire(), for example when
+ *     rendering the rdata in an rdataset. This causes the
+ *     compression offset to be reusable across calls.
+ *
+ *     Requires:
+ *\li          'cctx' is not NULL.
+ */
+
+bool
+dns_compress_getmultiuse(dns_compress_t *cctx);
+
+/*%<
+ *     Find out whether multiuse is enabled.
+ *
+ *     Requires:
+ *\li          'cctx' to be initialized.
+ *
+ *     Returns:
+ *\li          allowed compression bitmap.
+ */
+void
 dns_compress_setpermitted(dns_compress_t *cctx, bool permitted);
 
 /*%<
  *     Sets whether compression is allowed, according to RFC 3597.
- *     This can vary depending on the rdata type.
+ *     This can vary depending on the rdata type. This will also
+ *     reset multiuse to false.
  *
  *     Requires:
  *\li          'cctx' to be initialized.
index 24340b2e4b6e80715f49e4e995b2b5ff71c1211c..2760e5bf8958e5b8a2e95ec75847bac611a1e244 100644 (file)
@@ -768,7 +768,7 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, dns_decompress_t dctx,
 
 isc_result_t
 dns_name_towire(const dns_name_t *name, dns_compress_t *cctx,
-               isc_buffer_t *target, uint16_t *comp_offsetp);
+               isc_buffer_t *target);
 /*%<
  * Convert 'name' into wire format, compressing it as specified by the
  * compression context 'cctx', and storing the result in 'target'.
index 12201c05d8d988f73e6b7975517d832a3305b4cb..138848937dbeecea8c92e0af02731854c137e0cd 100644 (file)
@@ -1436,8 +1436,8 @@ root_label:;
 
 isc_result_t
 dns_name_towire(const dns_name_t *name, dns_compress_t *cctx,
-               isc_buffer_t *target, uint16_t *name_coff) {
-       bool compress;
+               isc_buffer_t *target) {
+       bool compress, multi;
        unsigned int here;
        unsigned int prefix_length;
        unsigned int suffix_coff;
@@ -1453,16 +1453,17 @@ dns_name_towire(const dns_name_t *name, dns_compress_t *cctx,
 
        compress = !name->attributes.nocompress &&
                   dns_compress_getpermitted(cctx);
+       multi = compress && dns_compress_getmultiuse(cctx);
 
        /*
         * Write a compression pointer directly if the caller passed us
         * a pointer to this name's offset that we saved previously.
         */
-       if (compress && name_coff != NULL && *name_coff < 0x4000) {
+       if (multi && cctx->coff < 0x4000) {
                if (isc_buffer_availablelength(target) < 2) {
                        return ISC_R_NOSPACE;
                }
-               isc_buffer_putuint16(target, *name_coff | 0xc000);
+               isc_buffer_putuint16(target, cctx->coff | 0xc000);
                return ISC_R_SUCCESS;
        }
 
@@ -1483,8 +1484,8 @@ dns_name_towire(const dns_name_t *name, dns_compress_t *cctx,
         * it isn't too short for compression to help (i.e. it's the root)
         */
        here = isc_buffer_usedlength(target);
-       if (name_coff != NULL && here < 0x4000 && prefix_length > 1) {
-               *name_coff = (uint16_t)here;
+       if (multi && here < 0x4000 && prefix_length > 1) {
+               cctx->coff = (uint16_t)here;
        }
 
        if (prefix_length > 0) {
@@ -1496,8 +1497,8 @@ dns_name_towire(const dns_name_t *name, dns_compress_t *cctx,
        }
 
        if (suffix_coff > 0) {
-               if (name_coff != NULL && prefix_length == 0) {
-                       *name_coff = suffix_coff;
+               if (multi && prefix_length == 0) {
+                       cctx->coff = suffix_coff;
                }
                if (isc_buffer_availablelength(target) < 2) {
                        return ISC_R_NOSPACE;
index edf8bbe816d9ba0e748a06b7c4786cfa9ff3c42c..bd9c43288b52219f0a1d2b010d47886c788769fc 100644 (file)
@@ -360,7 +360,7 @@ dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx,
                         * Write the name.
                         */
                        dns_compress_setpermitted(cctx, true);
-                       result = dns_name_towire(&name, cctx, target, NULL);
+                       result = dns_name_towire(&name, cctx, target);
                        if (result != ISC_R_SUCCESS) {
                                goto rollback;
                        }
index f568665981fadae00b855047c7511db2092b60de..e356840d933d73f0edaee4b42ef9aa32c4bee6e1 100644 (file)
@@ -335,7 +335,7 @@ towire_any_tsig(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &sr);
        dns_name_init(&name);
        dns_name_fromregion(&name, &sr);
-       RETERR(dns_name_towire(&name, cctx, target, NULL));
+       RETERR(dns_name_towire(&name, cctx, target));
        isc_region_consume(&sr, name_length(&name));
        return mem_tobuffer(target, sr.base, sr.length);
 }
index af7ee1e8e185219e6ec97386a17592bb1b78f587..99c9334c406c75484eeb33233f41a441d1d3917b 100644 (file)
@@ -146,7 +146,7 @@ towire_ch_a(ARGS_TOWIRE) {
 
        dns_name_fromregion(&name, &sregion);
        isc_region_consume(&sregion, name_length(&name));
-       RETERR(dns_name_towire(&name, cctx, target, NULL));
+       RETERR(dns_name_towire(&name, cctx, target));
 
        isc_buffer_availableregion(target, &tregion);
        if (tregion.length < 2) {
index 9a8ed8ff44c1f52d603923235694d2b9e2e622d0..25bd2e0b69fea201ddee816049b989ee31d3b5d4 100644 (file)
@@ -141,7 +141,7 @@ towire_afsdb(ARGS_TOWIRE) {
        dns_name_init(&name);
        dns_name_fromregion(&name, &sr);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index a66c719b3326b6effd49aded1237a36ddbbbf234..a946097be6912249d777104a888e439397abb8f3 100644 (file)
@@ -91,7 +91,7 @@ towire_cname(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &region);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index 7fa31a471d4b952e6dd58af82ad91e3bcaae582b..ce87676a1e8e77c1470a45fee5d2a653dbc6eb52 100644 (file)
@@ -91,7 +91,7 @@ towire_dname(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &region);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index 767d5b5c510b5df64720bc8fbd9170a5404fb710..ab6ab42b0cdab130fade91db43f1e64d6ae28b1e 100644 (file)
@@ -90,7 +90,7 @@ towire_mb(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &region);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index 70d6006e65b2c562167eae318cb895d4bc7053e2..702b60c1852f045229bffdf8f3275abda873531c 100644 (file)
@@ -90,7 +90,7 @@ towire_md(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &region);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index ad14f8fa40dc934eb0c9a4d4da36b293ac9d5216..0142c124785d7221eccf0e6d61f8ffcacf0b3a28 100644 (file)
@@ -90,7 +90,7 @@ towire_mf(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &region);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index f426c299a597cfc681c71515f7ca71c7fae4ef90..0c8fae21c942b200f0cc8903eb2d293e4c06edbc 100644 (file)
@@ -90,7 +90,7 @@ towire_mg(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &region);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index aef31a4dc32352f9e50bac97c8d24ca98c5a7a22..7ea92d7c99121370a7f9490209b21ebe967a34f5 100644 (file)
@@ -129,12 +129,12 @@ towire_minfo(ARGS_TOWIRE) {
        dns_name_fromregion(&rmail, &region);
        isc_region_consume(&region, name_length(&rmail));
 
-       RETERR(dns_name_towire(&rmail, cctx, target, NULL));
+       RETERR(dns_name_towire(&rmail, cctx, target));
 
        dns_name_fromregion(&rmail, &region);
        isc_region_consume(&region, rmail.length);
 
-       return dns_name_towire(&rmail, cctx, target, NULL);
+       return dns_name_towire(&rmail, cctx, target);
 }
 
 static int
index a63b37a947e1cb05245b64c4fc9588f670df4607..4e62678852ffbf665c1f35a81cd78564d217cbc8 100644 (file)
@@ -90,7 +90,7 @@ towire_mr(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &region);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index 50464d71b65db3f859eb033385c663e8286fef1f..20510dda98113cf9296f7aae93588525381c03fb 100644 (file)
@@ -165,7 +165,7 @@ towire_mx(ARGS_TOWIRE) {
        dns_name_init(&name);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index d66b6934a752f1134bad1d5952f9e767b954e5b6..3715bbcbe3d75c1d786748c21b8b639168eda3da 100644 (file)
@@ -388,7 +388,7 @@ towire_naptr(ARGS_TOWIRE) {
         */
        dns_name_init(&name);
        dns_name_fromregion(&name, &sr);
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index 73e9b7c6e6b70f66f11b5bb96c9ed0f083712134..b6b38f438850262837522f3e13e7321a9a02b944 100644 (file)
@@ -101,7 +101,7 @@ towire_ns(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &region);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index 59db69d25689e81ad88abed7d260ed1c0cf59780..28fea07c8225d25fc18d09459b9be9e4540e5a2c 100644 (file)
@@ -110,7 +110,7 @@ towire_nsec(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &sr);
        dns_name_fromregion(&name, &sr);
        isc_region_consume(&sr, name_length(&name));
-       RETERR(dns_name_towire(&name, cctx, target, NULL));
+       RETERR(dns_name_towire(&name, cctx, target));
 
        return mem_tobuffer(target, sr.base, sr.length);
 }
index 1a828933b26f50b3d9d5fe7bc5513755b546015c..a552276292cff9acb4cab4efc25be744eb3a43b3 100644 (file)
@@ -173,7 +173,7 @@ towire_nxt(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &sr);
        dns_name_fromregion(&name, &sr);
        isc_region_consume(&sr, name_length(&name));
-       RETERR(dns_name_towire(&name, cctx, target, NULL));
+       RETERR(dns_name_towire(&name, cctx, target));
 
        return mem_tobuffer(target, sr.base, sr.length);
 }
index b24178c9677185165c73b152bb7b57d5fa87f9d1..24d975a0b96eb5e4bba6b8115cbd760589ca18fd 100644 (file)
@@ -103,7 +103,7 @@ towire_ptr(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &region);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index f652aa2c2c16a0b288be8be8f03e089aae0a6b9d..33c8192fac2c2df383bf006e1d0642f5b2d84e14 100644 (file)
@@ -130,12 +130,12 @@ towire_rp(ARGS_TOWIRE) {
        dns_name_fromregion(&rmail, &region);
        isc_region_consume(&region, rmail.length);
 
-       RETERR(dns_name_towire(&rmail, cctx, target, NULL));
+       RETERR(dns_name_towire(&rmail, cctx, target));
 
        dns_name_fromregion(&rmail, &region);
        isc_region_consume(&region, rmail.length);
 
-       return dns_name_towire(&rmail, cctx, target, NULL);
+       return dns_name_towire(&rmail, cctx, target);
 }
 
 static int
index 7cad4b65aecb29719b96ebb1ab5ab6b50f0eec63..bcfac4a6669f476c429828738aee05b0a35e578a 100644 (file)
@@ -377,7 +377,7 @@ towire_rrsig(ARGS_TOWIRE) {
        dns_name_init(&name);
        dns_name_fromregion(&name, &sr);
        isc_region_consume(&sr, name_length(&name));
-       RETERR(dns_name_towire(&name, cctx, target, NULL));
+       RETERR(dns_name_towire(&name, cctx, target));
 
        /*
         * Signature.
index 7402a14acd138c0da090a0534b2e7cd51ba0ee97..41c0df41f30834f46a2ae7b1d6b05f1da45641e4 100644 (file)
@@ -138,7 +138,7 @@ towire_rt(ARGS_TOWIRE) {
        dns_name_init(&name);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index beeb366571b9506362f5e898f7e3f2e31fcecb87..c5d3ed3ef7bb50dcb8070fee6ac8ac72fb87eccb 100644 (file)
@@ -341,7 +341,7 @@ towire_sig(ARGS_TOWIRE) {
        dns_name_init(&name);
        dns_name_fromregion(&name, &sr);
        isc_region_consume(&sr, name_length(&name));
-       RETERR(dns_name_towire(&name, cctx, target, NULL));
+       RETERR(dns_name_towire(&name, cctx, target));
 
        /*
         * Signature.
index 14575c3002d195310cb6bda829f65f767d0d59fe..782da3c1a84ac6c06e2d70979a50b821e1c2c732 100644 (file)
@@ -213,11 +213,11 @@ towire_soa(ARGS_TOWIRE) {
 
        dns_name_fromregion(&mname, &sregion);
        isc_region_consume(&sregion, name_length(&mname));
-       RETERR(dns_name_towire(&mname, cctx, target, NULL));
+       RETERR(dns_name_towire(&mname, cctx, target));
 
        dns_name_fromregion(&rname, &sregion);
        isc_region_consume(&sregion, name_length(&rname));
-       RETERR(dns_name_towire(&rname, cctx, target, NULL));
+       RETERR(dns_name_towire(&rname, cctx, target));
 
        isc_buffer_availableregion(target, &tregion);
        if (tregion.length < 20) {
index 68328dc65a279deb92871292f988319a986b507e..148a11569c2e3ab8570a7014fe4b7191acde0e92 100644 (file)
@@ -117,11 +117,11 @@ towire_talink(ARGS_TOWIRE) {
 
        dns_name_fromregion(&prev, &sregion);
        isc_region_consume(&sregion, name_length(&prev));
-       RETERR(dns_name_towire(&prev, cctx, target, NULL));
+       RETERR(dns_name_towire(&prev, cctx, target));
 
        dns_name_fromregion(&next, &sregion);
        isc_region_consume(&sregion, name_length(&next));
-       return dns_name_towire(&next, cctx, target, NULL);
+       return dns_name_towire(&next, cctx, target);
 }
 
 static int
index e700ab4987b3ba5af9192d6aecdaaa0b95228e24..dbea25a1da18dfa1f24bc573f3ac24477d476bbd 100644 (file)
@@ -320,7 +320,7 @@ towire_tkey(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &sr);
        dns_name_init(&name);
        dns_name_fromregion(&name, &sr);
-       RETERR(dns_name_towire(&name, cctx, target, NULL));
+       RETERR(dns_name_towire(&name, cctx, target));
        isc_region_consume(&sr, name_length(&name));
 
        return mem_tobuffer(target, sr.base, sr.length);
index da76a50f5d06c1e19b0281aa0fc063bd5b9c3f41..b70a65343f3a0312bb6c8ec6c1b50efce331ee05 100644 (file)
@@ -226,7 +226,7 @@ towire_in_a6(ARGS_TOWIRE) {
 
        dns_name_init(&name);
        dns_name_fromregion(&name, &sr);
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index 8bc548913f8bb69548ea71b4aa0d11c9131eab09..aebc7292a5683350ba8ad14cb099675b626d9d53 100644 (file)
@@ -120,7 +120,7 @@ towire_in_kx(ARGS_TOWIRE) {
        dns_name_init(&name);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index 1afb6a5ef06db45fc2995d6f009a812de7f429a6..55167cebeec5310bc31a502745f29541b11e961d 100644 (file)
@@ -95,7 +95,7 @@ towire_in_nsap_ptr(ARGS_TOWIRE) {
        dns_rdata_toregion(rdata, &region);
        dns_name_fromregion(&name, &region);
 
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index 07b555750dc8c8b435ec4693254e556ca7a1013a..1301767596996148786b1d0f8367e9113f31ee8a 100644 (file)
@@ -168,7 +168,7 @@ towire_in_px(ARGS_TOWIRE) {
         */
        dns_name_init(&name);
        dns_name_fromregion(&name, &region);
-       RETERR(dns_name_towire(&name, cctx, target, NULL));
+       RETERR(dns_name_towire(&name, cctx, target));
        isc_region_consume(&region, name_length(&name));
 
        /*
@@ -176,7 +176,7 @@ towire_in_px(ARGS_TOWIRE) {
         */
        dns_name_init(&name);
        dns_name_fromregion(&name, &region);
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index d8693a511372d95db2c316b72cebe0faa55b5bb2..d488b94193a1f4f427d232b2ec14bab64cdd3274 100644 (file)
@@ -191,7 +191,7 @@ towire_in_srv(ARGS_TOWIRE) {
         */
        dns_name_init(&name);
        dns_name_fromregion(&name, &sr);
-       return dns_name_towire(&name, cctx, target, NULL);
+       return dns_name_towire(&name, cctx, target);
 }
 
 static int
index ce7a297ec08995a521689282559b2c109ae6114e..b2f239ef99c7bc7263ca0f6cd495f5f2b4dc04d2 100644 (file)
@@ -940,7 +940,7 @@ generic_towire_in_svcb(ARGS_TOWIRE) {
         */
        dns_name_init(&name);
        dns_name_fromregion(&name, &region);
-       RETERR(dns_name_towire(&name, cctx, target, NULL));
+       RETERR(dns_name_towire(&name, cctx, target));
        isc_region_consume(&region, name_length(&name));
 
        /*
index d0962fe95e6b8876a2e9d2f3792ee8c0931c5751..28659b4867082207cddcb7808718bc5e4ca18b78 100644 (file)
@@ -247,7 +247,6 @@ towire(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
        struct towire_sort *out = out_fixed;
        dns_fixedname_t fixed;
        dns_name_t *name = NULL;
-       uint16_t offset;
 
        /*
         * Convert 'rdataset' to wire format, compressing names as specified
@@ -357,7 +356,7 @@ towire(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
        name = dns_fixedname_initname(&fixed);
        dns_name_copy(owner_name, name);
        dns_rdataset_getownercase(rdataset, name);
-       offset = 0xffff;
+       dns_compress_setmultiuse(cctx, true);
 
        name->attributes.nocompress |= owner_name->attributes.nocompress;
 
@@ -368,15 +367,14 @@ towire(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
 
                rrbuffer = *target;
                dns_compress_setpermitted(cctx, true);
-               result = dns_name_towire(name, cctx, target, &offset);
+               result = dns_name_towire(name, cctx, target);
                if (result != ISC_R_SUCCESS) {
                        goto rollback;
                }
                headlen = sizeof(dns_rdataclass_t) + sizeof(dns_rdatatype_t);
                if (!question) {
                        headlen += sizeof(dns_ttl_t) + 2;
-               } /* XXX 2 for rdata len
-                  */
+               } /* XXX 2 for rdata len */
                isc_buffer_availableregion(target, &r);
                if (r.length < headlen) {
                        result = ISC_R_NOSPACE;
index 962b79109b38046a460d11eae16452374d45d30a..e2601548fed57b394927bf96f133b8f6e291b25c 100644 (file)
@@ -2703,7 +2703,7 @@ resquery_send(resquery_t *query) {
        memset(&zr, 0, sizeof(zr));
        isc_buffer_init(&zb, zone, sizeof(zone));
        dns_compress_setpermitted(&cctx, false);
-       result = dns_name_towire(fctx->domain, &cctx, &zb, NULL);
+       result = dns_name_towire(fctx->domain, &cctx, &zb);
        if (result == ISC_R_SUCCESS) {
                isc_buffer_usedregion(&zb, &zr);
        }
@@ -9730,7 +9730,7 @@ rctx_logpacket(respctx_t *rctx) {
        dns_compress_init(&cctx, fctx->mctx, 0);
        dns_compress_setpermitted(&cctx, false);
        isc_buffer_init(&zb, zone, sizeof(zone));
-       result = dns_name_towire(fctx->domain, &cctx, &zb, NULL);
+       result = dns_name_towire(fctx->domain, &cctx, &zb);
        if (result == ISC_R_SUCCESS) {
                isc_buffer_usedregion(&zb, &zr);
        }
index 6a3d40f446efc871af97c0b6e80c5ebf4dba775d..222a4f4f500c3833067ee56386064f3ea2f621ae 100644 (file)
@@ -699,7 +699,7 @@ renderend:
 
                isc_buffer_init(&b, zone, sizeof(zone));
                dns_compress_setpermitted(&cctx, false);
-               eresult = dns_name_towire(zo, &cctx, &b, NULL);
+               eresult = dns_name_towire(zo, &cctx, &b);
                if (eresult == ISC_R_SUCCESS) {
                        isc_buffer_usedregion(&b, &zr);
                }
index 0660785ddc5e6236772573c2ae3a70cae5775614..31e73f5be100a97353d7b10011f7ca3c8762028a 100644 (file)
@@ -80,7 +80,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, NULL);
+                       result = dns_name_towire(name, &cctx, &buf);
                        if (result == ISC_R_NOSPACE) {
                                dns_compress_invalidate(&cctx);
                                dns_compress_init(&cctx, mctx, 0);
index a7156b7ba94ecc1e66df4deaaaecae1c77528fd0..a7b1aaf5b0810056614c39d814ee606a177411c6 100644 (file)
@@ -187,7 +187,7 @@ ISC_LOOP_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, NULL);
+       result = dns_name_towire(zname, &cctx, &zb);
        assert_int_equal(result, ISC_R_SUCCESS);
        dns_compress_invalidate(&cctx);
        isc_buffer_usedregion(&zb, &zr);
index 47369761a4fa59e76a035cd55e9a5c01e82a58e7..a786299a0297c3c3993fb5d1cc52de7491ffb394 100644 (file)
@@ -148,28 +148,28 @@ 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, NULL),
+               assert_int_equal(dns_name_towire(name1, cctx, &source),
                                 ISC_R_SUCCESS);
-               assert_int_equal(dns_name_towire(name2, cctx, &source, NULL),
+               assert_int_equal(dns_name_towire(name2, cctx, &source),
                                 ISC_R_SUCCESS);
-               assert_int_equal(dns_name_towire(name2, cctx, &source, NULL),
+               assert_int_equal(dns_name_towire(name2, cctx, &source),
                                 ISC_R_SUCCESS);
-               assert_int_equal(dns_name_towire(name3, cctx, &source, NULL),
+               assert_int_equal(dns_name_towire(name3, cctx, &source),
                                 ISC_R_SUCCESS);
        } else {
                /* Owner name compression */
-               uint16_t offset = 0xffff;
-               assert_int_equal(dns_name_towire(name1, cctx, &source, &offset),
+               dns_compress_setmultiuse(cctx, true);
+               assert_int_equal(dns_name_towire(name1, cctx, &source),
                                 ISC_R_SUCCESS);
 
-               offset = 0xffff;
-               assert_int_equal(dns_name_towire(name2, cctx, &source, &offset),
+               dns_compress_setmultiuse(cctx, true);
+               assert_int_equal(dns_name_towire(name2, cctx, &source),
                                 ISC_R_SUCCESS);
-               assert_int_equal(dns_name_towire(name2, cctx, &source, &offset),
+               assert_int_equal(dns_name_towire(name2, cctx, &source),
                                 ISC_R_SUCCESS);
 
-               offset = 0xffff;
-               assert_int_equal(dns_name_towire(name3, cctx, &source, &offset),
+               dns_compress_setmultiuse(cctx, true);
+               assert_int_equal(dns_name_towire(name3, cctx, &source),
                                 ISC_R_SUCCESS);
        }
        assert_int_equal(source.used, compressed_length);
@@ -433,7 +433,8 @@ ISC_RUN_TEST_IMPL(collision) {
                }
                dns_compress_rollback(&cctx, coff);
 
-               result = dns_name_towire(&name, &cctx, &message, NULL);
+               dns_compress_setmultiuse(&cctx, true);
+               result = dns_name_towire(&name, &cctx, &message);
                assert_int_equal(result, ISC_R_SUCCESS);
 
                /* we must be able to find the name we just added */