diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-06-18 17:08:49 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-06-19 22:50:02 +0200 |
commit | be5bee2a132d2d3b45d79bb3f27b05bbc767cd0a (patch) | |
tree | 7bf23c1e6ecb5289bbbb44e6e7492f764a4340bb /src/resolve | |
parent | sd-json: add sd_json_build() wrapper macro that implies SD_JSON_BUILD_OBJECT() (diff) | |
download | systemd-be5bee2a132d2d3b45d79bb3f27b05bbc767cd0a.tar.xz systemd-be5bee2a132d2d3b45d79bb3f27b05bbc767cd0a.zip |
tree-wide: port over to new builder apis
Diffstat (limited to 'src/resolve')
-rw-r--r-- | src/resolve/resolved-dns-cache.c | 37 | ||||
-rw-r--r-- | src/resolve/resolved-dns-rr.c | 264 | ||||
-rw-r--r-- | src/resolve/resolved-dns-scope.c | 14 | ||||
-rw-r--r-- | src/resolve/resolved-dns-server.c | 36 | ||||
-rw-r--r-- | src/resolve/resolved-manager.c | 97 | ||||
-rw-r--r-- | src/resolve/resolved-varlink.c | 138 |
6 files changed, 290 insertions, 296 deletions
diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c index afda571ed5..f80f9dff8a 100644 --- a/src/resolve/resolved-dns-cache.c +++ b/src/resolve/resolved-dns-cache.c @@ -1456,11 +1456,10 @@ int dns_cache_dump_to_json(DnsCache *cache, sd_json_variant **ret) { if (r < 0) return r; - r = sd_json_variant_append_arrayb( + r = sd_json_variant_append_arraybo( &l, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_VARIANT("rr", rj), - SD_JSON_BUILD_PAIR_BASE64("raw", j->rr->wire_format, j->rr->wire_format_size))); + SD_JSON_BUILD_PAIR_VARIANT("rr", rj), + SD_JSON_BUILD_PAIR_BASE64("raw", j->rr->wire_format, j->rr->wire_format_size)); if (r < 0) return r; } @@ -1471,23 +1470,23 @@ int dns_cache_dump_to_json(DnsCache *cache, sd_json_variant **ret) { return r; } - r = sd_json_build(&d, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_VARIANT("key", k), - SD_JSON_BUILD_PAIR_VARIANT("rrs", l), - SD_JSON_BUILD_PAIR_UNSIGNED("until", i->until))); + r = sd_json_buildo( + &d, + SD_JSON_BUILD_PAIR_VARIANT("key", k), + SD_JSON_BUILD_PAIR_VARIANT("rrs", l), + SD_JSON_BUILD_PAIR_UNSIGNED("until", i->until)); } else if (i->type == DNS_CACHE_NODATA) { - r = sd_json_build(&d, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_VARIANT("key", k), - SD_JSON_BUILD_PAIR_EMPTY_ARRAY("rrs"), - SD_JSON_BUILD_PAIR_UNSIGNED("until", i->until))); + r = sd_json_buildo( + &d, + SD_JSON_BUILD_PAIR_VARIANT("key", k), + SD_JSON_BUILD_PAIR_EMPTY_ARRAY("rrs"), + SD_JSON_BUILD_PAIR_UNSIGNED("until", i->until)); } else - r = sd_json_build(&d, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_VARIANT("key", k), - SD_JSON_BUILD_PAIR_STRING("type", dns_cache_item_type_to_string(i)), - SD_JSON_BUILD_PAIR_UNSIGNED("until", i->until))); + r = sd_json_buildo( + &d, + SD_JSON_BUILD_PAIR_VARIANT("key", k), + SD_JSON_BUILD_PAIR_STRING("type", dns_cache_item_type_to_string(i)), + SD_JSON_BUILD_PAIR_UNSIGNED("until", i->until)); if (r < 0) return r; diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c index 33ee644efd..e9d667f7d5 100644 --- a/src/resolve/resolved-dns-rr.c +++ b/src/resolve/resolved-dns-rr.c @@ -2135,11 +2135,11 @@ int dns_resource_key_to_json(DnsResourceKey *key, sd_json_variant **ret) { assert(key); assert(ret); - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("class", SD_JSON_BUILD_INTEGER(key->class)), - SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_INTEGER(key->type)), - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(dns_resource_key_name(key))))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("class", SD_JSON_BUILD_INTEGER(key->class)), + SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_INTEGER(key->type)), + SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(dns_resource_key_name(key)))); } int dns_resource_key_from_json(sd_json_variant *v, DnsResourceKey **ret) { @@ -2263,29 +2263,29 @@ int dns_resource_record_to_json(DnsResourceRecord *rr, sd_json_variant **ret) { switch (rr->unparsable ? _DNS_TYPE_INVALID : rr->key->type) { case DNS_TYPE_SRV: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->srv.priority)), - SD_JSON_BUILD_PAIR("weight", SD_JSON_BUILD_UNSIGNED(rr->srv.weight)), - SD_JSON_BUILD_PAIR("port", SD_JSON_BUILD_UNSIGNED(rr->srv.port)), - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(rr->srv.name)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->srv.priority)), + SD_JSON_BUILD_PAIR("weight", SD_JSON_BUILD_UNSIGNED(rr->srv.weight)), + SD_JSON_BUILD_PAIR("port", SD_JSON_BUILD_UNSIGNED(rr->srv.port)), + SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(rr->srv.name))); case DNS_TYPE_PTR: case DNS_TYPE_NS: case DNS_TYPE_CNAME: case DNS_TYPE_DNAME: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(rr->ptr.name)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(rr->ptr.name))); case DNS_TYPE_HINFO: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("cpu", SD_JSON_BUILD_STRING(rr->hinfo.cpu)), - SD_JSON_BUILD_PAIR("os", SD_JSON_BUILD_STRING(rr->hinfo.os)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("cpu", SD_JSON_BUILD_STRING(rr->hinfo.cpu)), + SD_JSON_BUILD_PAIR("os", SD_JSON_BUILD_STRING(rr->hinfo.os))); case DNS_TYPE_SPF: case DNS_TYPE_TXT: { @@ -2295,93 +2295,93 @@ int dns_resource_record_to_json(DnsResourceRecord *rr, sd_json_variant **ret) { if (r < 0) return r; - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("items", SD_JSON_BUILD_VARIANT(l)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("items", SD_JSON_BUILD_VARIANT(l))); } case DNS_TYPE_A: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("address", JSON_BUILD_IN4_ADDR(&rr->a.in_addr)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("address", JSON_BUILD_IN4_ADDR(&rr->a.in_addr))); case DNS_TYPE_AAAA: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("address", JSON_BUILD_IN6_ADDR(&rr->aaaa.in6_addr)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("address", JSON_BUILD_IN6_ADDR(&rr->aaaa.in6_addr))); case DNS_TYPE_SOA: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("mname", SD_JSON_BUILD_STRING(rr->soa.mname)), - SD_JSON_BUILD_PAIR("rname", SD_JSON_BUILD_STRING(rr->soa.rname)), - SD_JSON_BUILD_PAIR("serial", SD_JSON_BUILD_UNSIGNED(rr->soa.serial)), - SD_JSON_BUILD_PAIR("refresh", SD_JSON_BUILD_UNSIGNED(rr->soa.refresh)), - SD_JSON_BUILD_PAIR("expire", SD_JSON_BUILD_UNSIGNED(rr->soa.retry)), - SD_JSON_BUILD_PAIR("minimum", SD_JSON_BUILD_UNSIGNED(rr->soa.minimum)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("mname", SD_JSON_BUILD_STRING(rr->soa.mname)), + SD_JSON_BUILD_PAIR("rname", SD_JSON_BUILD_STRING(rr->soa.rname)), + SD_JSON_BUILD_PAIR("serial", SD_JSON_BUILD_UNSIGNED(rr->soa.serial)), + SD_JSON_BUILD_PAIR("refresh", SD_JSON_BUILD_UNSIGNED(rr->soa.refresh)), + SD_JSON_BUILD_PAIR("expire", SD_JSON_BUILD_UNSIGNED(rr->soa.retry)), + SD_JSON_BUILD_PAIR("minimum", SD_JSON_BUILD_UNSIGNED(rr->soa.minimum))); case DNS_TYPE_MX: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->mx.priority)), - SD_JSON_BUILD_PAIR("exchange", SD_JSON_BUILD_STRING(rr->mx.exchange)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->mx.priority)), + SD_JSON_BUILD_PAIR("exchange", SD_JSON_BUILD_STRING(rr->mx.exchange))); case DNS_TYPE_LOC: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("version", SD_JSON_BUILD_UNSIGNED(rr->loc.version)), - SD_JSON_BUILD_PAIR("size", SD_JSON_BUILD_UNSIGNED(rr->loc.size)), - SD_JSON_BUILD_PAIR("horiz_pre", SD_JSON_BUILD_UNSIGNED(rr->loc.horiz_pre)), - SD_JSON_BUILD_PAIR("vert_pre", SD_JSON_BUILD_UNSIGNED(rr->loc.vert_pre)), - SD_JSON_BUILD_PAIR("latitude", SD_JSON_BUILD_UNSIGNED(rr->loc.latitude)), - SD_JSON_BUILD_PAIR("longitude", SD_JSON_BUILD_UNSIGNED(rr->loc.longitude)), - SD_JSON_BUILD_PAIR("altitude", SD_JSON_BUILD_UNSIGNED(rr->loc.altitude)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("version", SD_JSON_BUILD_UNSIGNED(rr->loc.version)), + SD_JSON_BUILD_PAIR("size", SD_JSON_BUILD_UNSIGNED(rr->loc.size)), + SD_JSON_BUILD_PAIR("horiz_pre", SD_JSON_BUILD_UNSIGNED(rr->loc.horiz_pre)), + SD_JSON_BUILD_PAIR("vert_pre", SD_JSON_BUILD_UNSIGNED(rr->loc.vert_pre)), + SD_JSON_BUILD_PAIR("latitude", SD_JSON_BUILD_UNSIGNED(rr->loc.latitude)), + SD_JSON_BUILD_PAIR("longitude", SD_JSON_BUILD_UNSIGNED(rr->loc.longitude)), + SD_JSON_BUILD_PAIR("altitude", SD_JSON_BUILD_UNSIGNED(rr->loc.altitude))); case DNS_TYPE_DS: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("keyTag", SD_JSON_BUILD_UNSIGNED(rr->ds.key_tag)), - SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->ds.algorithm)), - SD_JSON_BUILD_PAIR("digestType", SD_JSON_BUILD_UNSIGNED(rr->ds.digest_type)), - SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(rr->ds.digest, rr->ds.digest_size)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("keyTag", SD_JSON_BUILD_UNSIGNED(rr->ds.key_tag)), + SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->ds.algorithm)), + SD_JSON_BUILD_PAIR("digestType", SD_JSON_BUILD_UNSIGNED(rr->ds.digest_type)), + SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(rr->ds.digest, rr->ds.digest_size))); case DNS_TYPE_SSHFP: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->sshfp.algorithm)), - SD_JSON_BUILD_PAIR("fptype", SD_JSON_BUILD_UNSIGNED(rr->sshfp.fptype)), - SD_JSON_BUILD_PAIR("fingerprint", SD_JSON_BUILD_HEX(rr->sshfp.fingerprint, rr->sshfp.fingerprint_size)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->sshfp.algorithm)), + SD_JSON_BUILD_PAIR("fptype", SD_JSON_BUILD_UNSIGNED(rr->sshfp.fptype)), + SD_JSON_BUILD_PAIR("fingerprint", SD_JSON_BUILD_HEX(rr->sshfp.fingerprint, rr->sshfp.fingerprint_size))); case DNS_TYPE_DNSKEY: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(rr->dnskey.flags)), - SD_JSON_BUILD_PAIR("protocol", SD_JSON_BUILD_UNSIGNED(rr->dnskey.protocol)), - SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->dnskey.algorithm)), - SD_JSON_BUILD_PAIR("dnskey", SD_JSON_BUILD_BASE64(rr->dnskey.key, rr->dnskey.key_size)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(rr->dnskey.flags)), + SD_JSON_BUILD_PAIR("protocol", SD_JSON_BUILD_UNSIGNED(rr->dnskey.protocol)), + SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->dnskey.algorithm)), + SD_JSON_BUILD_PAIR("dnskey", SD_JSON_BUILD_BASE64(rr->dnskey.key, rr->dnskey.key_size))); case DNS_TYPE_RRSIG: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("signer", SD_JSON_BUILD_STRING(rr->rrsig.signer)), - SD_JSON_BUILD_PAIR("typeCovered", SD_JSON_BUILD_UNSIGNED(rr->rrsig.type_covered)), - SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->rrsig.algorithm)), - SD_JSON_BUILD_PAIR("labels", SD_JSON_BUILD_UNSIGNED(rr->rrsig.labels)), - SD_JSON_BUILD_PAIR("originalTtl", SD_JSON_BUILD_UNSIGNED(rr->rrsig.original_ttl)), - SD_JSON_BUILD_PAIR("expiration", SD_JSON_BUILD_UNSIGNED(rr->rrsig.expiration)), - SD_JSON_BUILD_PAIR("inception", SD_JSON_BUILD_UNSIGNED(rr->rrsig.inception)), - SD_JSON_BUILD_PAIR("keyTag", SD_JSON_BUILD_UNSIGNED(rr->rrsig.key_tag)), - SD_JSON_BUILD_PAIR("signature", SD_JSON_BUILD_BASE64(rr->rrsig.signature, rr->rrsig.signature_size)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("signer", SD_JSON_BUILD_STRING(rr->rrsig.signer)), + SD_JSON_BUILD_PAIR("typeCovered", SD_JSON_BUILD_UNSIGNED(rr->rrsig.type_covered)), + SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->rrsig.algorithm)), + SD_JSON_BUILD_PAIR("labels", SD_JSON_BUILD_UNSIGNED(rr->rrsig.labels)), + SD_JSON_BUILD_PAIR("originalTtl", SD_JSON_BUILD_UNSIGNED(rr->rrsig.original_ttl)), + SD_JSON_BUILD_PAIR("expiration", SD_JSON_BUILD_UNSIGNED(rr->rrsig.expiration)), + SD_JSON_BUILD_PAIR("inception", SD_JSON_BUILD_UNSIGNED(rr->rrsig.inception)), + SD_JSON_BUILD_PAIR("keyTag", SD_JSON_BUILD_UNSIGNED(rr->rrsig.key_tag)), + SD_JSON_BUILD_PAIR("signature", SD_JSON_BUILD_BASE64(rr->rrsig.signature, rr->rrsig.signature_size))); case DNS_TYPE_NSEC: { _cleanup_(sd_json_variant_unrefp) sd_json_variant *bm = NULL; @@ -2390,11 +2390,11 @@ int dns_resource_record_to_json(DnsResourceRecord *rr, sd_json_variant **ret) { if (r < 0) return r; - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("nextDomain", SD_JSON_BUILD_STRING(rr->nsec.next_domain_name)), - SD_JSON_BUILD_PAIR("types", SD_JSON_BUILD_VARIANT(bm)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("nextDomain", SD_JSON_BUILD_STRING(rr->nsec.next_domain_name)), + SD_JSON_BUILD_PAIR("types", SD_JSON_BUILD_VARIANT(bm))); } case DNS_TYPE_NSEC3: { @@ -2404,25 +2404,25 @@ int dns_resource_record_to_json(DnsResourceRecord *rr, sd_json_variant **ret) { if (r < 0) return r; - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->nsec3.algorithm)), - SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(rr->nsec3.flags)), - SD_JSON_BUILD_PAIR("iterations", SD_JSON_BUILD_UNSIGNED(rr->nsec3.iterations)), - SD_JSON_BUILD_PAIR("salt", SD_JSON_BUILD_HEX(rr->nsec3.salt, rr->nsec3.salt_size)), - SD_JSON_BUILD_PAIR("hash", SD_JSON_BUILD_BASE32HEX(rr->nsec3.next_hashed_name, rr->nsec3.next_hashed_name_size)), - SD_JSON_BUILD_PAIR("types", SD_JSON_BUILD_VARIANT(bm)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->nsec3.algorithm)), + SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(rr->nsec3.flags)), + SD_JSON_BUILD_PAIR("iterations", SD_JSON_BUILD_UNSIGNED(rr->nsec3.iterations)), + SD_JSON_BUILD_PAIR("salt", SD_JSON_BUILD_HEX(rr->nsec3.salt, rr->nsec3.salt_size)), + SD_JSON_BUILD_PAIR("hash", SD_JSON_BUILD_BASE32HEX(rr->nsec3.next_hashed_name, rr->nsec3.next_hashed_name_size)), + SD_JSON_BUILD_PAIR("types", SD_JSON_BUILD_VARIANT(bm))); } case DNS_TYPE_TLSA: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("certUsage", SD_JSON_BUILD_UNSIGNED(rr->tlsa.cert_usage)), - SD_JSON_BUILD_PAIR("selector", SD_JSON_BUILD_UNSIGNED(rr->tlsa.selector)), - SD_JSON_BUILD_PAIR("matchingType", SD_JSON_BUILD_UNSIGNED(rr->tlsa.matching_type)), - SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_HEX(rr->tlsa.data, rr->tlsa.data_size)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("certUsage", SD_JSON_BUILD_UNSIGNED(rr->tlsa.cert_usage)), + SD_JSON_BUILD_PAIR("selector", SD_JSON_BUILD_UNSIGNED(rr->tlsa.selector)), + SD_JSON_BUILD_PAIR("matchingType", SD_JSON_BUILD_UNSIGNED(rr->tlsa.matching_type)), + SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_HEX(rr->tlsa.data, rr->tlsa.data_size))); case DNS_TYPE_SVCB: case DNS_TYPE_HTTPS: { @@ -2431,33 +2431,33 @@ int dns_resource_record_to_json(DnsResourceRecord *rr, sd_json_variant **ret) { if (r < 0) return r; - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->svcb.priority)), - SD_JSON_BUILD_PAIR("target", SD_JSON_BUILD_STRING(rr->svcb.target_name)), - SD_JSON_BUILD_PAIR("params", SD_JSON_BUILD_VARIANT(p)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->svcb.priority)), + SD_JSON_BUILD_PAIR("target", SD_JSON_BUILD_STRING(rr->svcb.target_name)), + SD_JSON_BUILD_PAIR("params", SD_JSON_BUILD_VARIANT(p))); } case DNS_TYPE_CAA: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(rr->caa.flags)), - SD_JSON_BUILD_PAIR("tag", SD_JSON_BUILD_STRING(rr->caa.tag)), - SD_JSON_BUILD_PAIR("value", SD_JSON_BUILD_OCTESCAPE(rr->caa.value, rr->caa.value_size)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(rr->caa.flags)), + SD_JSON_BUILD_PAIR("tag", SD_JSON_BUILD_STRING(rr->caa.tag)), + SD_JSON_BUILD_PAIR("value", SD_JSON_BUILD_OCTESCAPE(rr->caa.value, rr->caa.value_size))); case DNS_TYPE_NAPTR: - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), - SD_JSON_BUILD_PAIR("order", SD_JSON_BUILD_UNSIGNED(rr->naptr.order)), - SD_JSON_BUILD_PAIR("preference", SD_JSON_BUILD_UNSIGNED(rr->naptr.preference)), - /* NB: we name this flags field here naptrFlags, because there's already another "flags" field (for example in CAA) which has a different type */ - SD_JSON_BUILD_PAIR("naptrFlags", SD_JSON_BUILD_STRING(rr->naptr.flags)), - SD_JSON_BUILD_PAIR("services", SD_JSON_BUILD_STRING(rr->naptr.services)), - SD_JSON_BUILD_PAIR("regexp", SD_JSON_BUILD_STRING(rr->naptr.regexp)), - SD_JSON_BUILD_PAIR("replacement", SD_JSON_BUILD_STRING(rr->naptr.replacement)))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)), + SD_JSON_BUILD_PAIR("order", SD_JSON_BUILD_UNSIGNED(rr->naptr.order)), + SD_JSON_BUILD_PAIR("preference", SD_JSON_BUILD_UNSIGNED(rr->naptr.preference)), + /* NB: we name this flags field here naptrFlags, because there's already another "flags" field (for example in CAA) which has a different type */ + SD_JSON_BUILD_PAIR("naptrFlags", SD_JSON_BUILD_STRING(rr->naptr.flags)), + SD_JSON_BUILD_PAIR("services", SD_JSON_BUILD_STRING(rr->naptr.services)), + SD_JSON_BUILD_PAIR("regexp", SD_JSON_BUILD_STRING(rr->naptr.regexp)), + SD_JSON_BUILD_PAIR("replacement", SD_JSON_BUILD_STRING(rr->naptr.replacement))); default: /* Can't provide broken-down format */ diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c index a2756c1162..21b9844e04 100644 --- a/src/resolve/resolved-dns-scope.c +++ b/src/resolve/resolved-dns-scope.c @@ -1726,13 +1726,13 @@ int dns_scope_dump_cache_to_json(DnsScope *scope, sd_json_variant **ret) { if (r < 0) return r; - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_STRING("protocol", dns_protocol_to_string(scope->protocol)), - SD_JSON_BUILD_PAIR_CONDITION(scope->family != AF_UNSPEC, "family", SD_JSON_BUILD_INTEGER(scope->family)), - SD_JSON_BUILD_PAIR_CONDITION(!!scope->link, "ifindex", SD_JSON_BUILD_INTEGER(scope->link ? scope->link->ifindex : 0)), - SD_JSON_BUILD_PAIR_CONDITION(!!scope->link, "ifname", SD_JSON_BUILD_STRING(scope->link ? scope->link->ifname : NULL)), - SD_JSON_BUILD_PAIR_VARIANT("cache", cache))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR_STRING("protocol", dns_protocol_to_string(scope->protocol)), + SD_JSON_BUILD_PAIR_CONDITION(scope->family != AF_UNSPEC, "family", SD_JSON_BUILD_INTEGER(scope->family)), + SD_JSON_BUILD_PAIR_CONDITION(!!scope->link, "ifindex", SD_JSON_BUILD_INTEGER(scope->link ? scope->link->ifindex : 0)), + SD_JSON_BUILD_PAIR_CONDITION(!!scope->link, "ifname", SD_JSON_BUILD_STRING(scope->link ? scope->link->ifname : NULL)), + SD_JSON_BUILD_PAIR_VARIANT("cache", cache)); } int dns_type_suitable_for_protocol(uint16_t type, DnsProtocol protocol) { diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c index 8abba8b064..70894977eb 100644 --- a/src/resolve/resolved-dns-server.c +++ b/src/resolve/resolved-dns-server.c @@ -1111,22 +1111,22 @@ int dns_server_dump_state_to_json(DnsServer *server, sd_json_variant **ret) { assert(server); assert(ret); - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_STRING("Server", strna(dns_server_string_full(server))), - SD_JSON_BUILD_PAIR_STRING("Type", strna(dns_server_type_to_string(server->type))), - SD_JSON_BUILD_PAIR_CONDITION(server->type == DNS_SERVER_LINK, "Interface", SD_JSON_BUILD_STRING(server->link ? server->link->ifname : NULL)), - SD_JSON_BUILD_PAIR_CONDITION(server->type == DNS_SERVER_LINK, "InterfaceIndex", SD_JSON_BUILD_UNSIGNED(server->link ? server->link->ifindex : 0)), - SD_JSON_BUILD_PAIR_STRING("VerifiedFeatureLevel", strna(dns_server_feature_level_to_string(server->verified_feature_level))), - SD_JSON_BUILD_PAIR_STRING("PossibleFeatureLevel", strna(dns_server_feature_level_to_string(server->possible_feature_level))), - SD_JSON_BUILD_PAIR_STRING("DNSSECMode", strna(dnssec_mode_to_string(dns_server_get_dnssec_mode(server)))), - SD_JSON_BUILD_PAIR_BOOLEAN("DNSSECSupported", dns_server_dnssec_supported(server)), - SD_JSON_BUILD_PAIR_UNSIGNED("ReceivedUDPFragmentMax", server->received_udp_fragment_max), - SD_JSON_BUILD_PAIR_UNSIGNED("FailedUDPAttempts", server->n_failed_udp), - SD_JSON_BUILD_PAIR_UNSIGNED("FailedTCPAttempts", server->n_failed_tcp), - SD_JSON_BUILD_PAIR_BOOLEAN("PacketTruncated", server->packet_truncated), - SD_JSON_BUILD_PAIR_BOOLEAN("PacketBadOpt", server->packet_bad_opt), - SD_JSON_BUILD_PAIR_BOOLEAN("PacketRRSIGMissing", server->packet_rrsig_missing), - SD_JSON_BUILD_PAIR_BOOLEAN("PacketInvalid", server->packet_invalid), - SD_JSON_BUILD_PAIR_BOOLEAN("PacketDoOff", server->packet_do_off))); + return sd_json_buildo( + ret, + SD_JSON_BUILD_PAIR_STRING("Server", strna(dns_server_string_full(server))), + SD_JSON_BUILD_PAIR_STRING("Type", strna(dns_server_type_to_string(server->type))), + SD_JSON_BUILD_PAIR_CONDITION(server->type == DNS_SERVER_LINK, "Interface", SD_JSON_BUILD_STRING(server->link ? server->link->ifname : NULL)), + SD_JSON_BUILD_PAIR_CONDITION(server->type == DNS_SERVER_LINK, "InterfaceIndex", SD_JSON_BUILD_UNSIGNED(server->link ? server->link->ifindex : 0)), + SD_JSON_BUILD_PAIR_STRING("VerifiedFeatureLevel", strna(dns_server_feature_level_to_string(server->verified_feature_level))), + SD_JSON_BUILD_PAIR_STRING("PossibleFeatureLevel", strna(dns_server_feature_level_to_string(server->possible_feature_level))), + SD_JSON_BUILD_PAIR_STRING("DNSSECMode", strna(dnssec_mode_to_string(dns_server_get_dnssec_mode(server)))), + SD_JSON_BUILD_PAIR_BOOLEAN("DNSSECSupported", dns_server_dnssec_supported(server)), + SD_JSON_BUILD_PAIR_UNSIGNED("ReceivedUDPFragmentMax", server->received_udp_fragment_max), + SD_JSON_BUILD_PAIR_UNSIGNED("FailedUDPAttempts", server->n_failed_udp), + SD_JSON_BUILD_PAIR_UNSIGNED("FailedTCPAttempts", server->n_failed_tcp), + SD_JSON_BUILD_PAIR_BOOLEAN("PacketTruncated", server->packet_truncated), + SD_JSON_BUILD_PAIR_BOOLEAN("PacketBadOpt", server->packet_bad_opt), + SD_JSON_BUILD_PAIR_BOOLEAN("PacketRRSIGMissing", server->packet_rrsig_missing), + SD_JSON_BUILD_PAIR_BOOLEAN("PacketInvalid", server->packet_invalid), + SD_JSON_BUILD_PAIR_BOOLEAN("PacketDoOff", server->packet_do_off)); } diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index 5959546dbb..2eee418adf 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -1211,40 +1211,40 @@ int manager_monitor_send(Manager *m, DnsQuery *q) { if (r < 0) return log_error_errno(r, "Failed to generate RR wire format: %m"); - r = sd_json_variant_append_arrayb( + r = sd_json_variant_append_arraybo( &janswer, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_CONDITION(!!v, "rr", SD_JSON_BUILD_VARIANT(v)), - SD_JSON_BUILD_PAIR("raw", SD_JSON_BUILD_BASE64(rri->rr->wire_format, rri->rr->wire_format_size)), - SD_JSON_BUILD_PAIR_CONDITION(rri->ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(rri->ifindex)))); + SD_JSON_BUILD_PAIR_CONDITION(!!v, "rr", SD_JSON_BUILD_VARIANT(v)), + SD_JSON_BUILD_PAIR("raw", SD_JSON_BUILD_BASE64(rri->rr->wire_format, rri->rr->wire_format_size)), + SD_JSON_BUILD_PAIR_CONDITION(rri->ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(rri->ifindex))); if (r < 0) return log_debug_errno(r, "Failed to append notification entry to array: %m"); } SET_FOREACH(connection, m->varlink_subscription) { - r = varlink_notifyb(connection, - SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("state", SD_JSON_BUILD_STRING(dns_transaction_state_to_string(q->state))), - SD_JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_DNSSEC_FAILED, - "result", SD_JSON_BUILD_STRING(dnssec_result_to_string(q->answer_dnssec_result))), - SD_JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_RCODE_FAILURE, - "rcode", SD_JSON_BUILD_INTEGER(q->answer_rcode)), - SD_JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_ERRNO, - "errno", SD_JSON_BUILD_INTEGER(q->answer_errno)), - SD_JSON_BUILD_PAIR_CONDITION(IN_SET(q->state, - DNS_TRANSACTION_DNSSEC_FAILED, - DNS_TRANSACTION_RCODE_FAILURE) && - q->answer_ede_rcode >= 0, - "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)), - SD_JSON_BUILD_PAIR_CONDITION(IN_SET(q->state, - DNS_TRANSACTION_DNSSEC_FAILED, - DNS_TRANSACTION_RCODE_FAILURE) && - q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg), - "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg)), - SD_JSON_BUILD_PAIR("question", SD_JSON_BUILD_VARIANT(jquestion)), - SD_JSON_BUILD_PAIR_CONDITION(!!jcollected_questions, - "collectedQuestions", SD_JSON_BUILD_VARIANT(jcollected_questions)), - SD_JSON_BUILD_PAIR_CONDITION(!!janswer, - "answer", SD_JSON_BUILD_VARIANT(janswer)))); + r = varlink_notifybo( + connection, + SD_JSON_BUILD_PAIR("state", SD_JSON_BUILD_STRING(dns_transaction_state_to_string(q->state))), + SD_JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_DNSSEC_FAILED, + "result", SD_JSON_BUILD_STRING(dnssec_result_to_string(q->answer_dnssec_result))), + SD_JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_RCODE_FAILURE, + "rcode", SD_JSON_BUILD_INTEGER(q->answer_rcode)), + SD_JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_ERRNO, + "errno", SD_JSON_BUILD_INTEGER(q->answer_errno)), + SD_JSON_BUILD_PAIR_CONDITION(IN_SET(q->state, + DNS_TRANSACTION_DNSSEC_FAILED, + DNS_TRANSACTION_RCODE_FAILURE) && + q->answer_ede_rcode >= 0, + "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)), + SD_JSON_BUILD_PAIR_CONDITION(IN_SET(q->state, + DNS_TRANSACTION_DNSSEC_FAILED, + DNS_TRANSACTION_RCODE_FAILURE) && + q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg), + "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg)), + SD_JSON_BUILD_PAIR("question", SD_JSON_BUILD_VARIANT(jquestion)), + SD_JSON_BUILD_PAIR_CONDITION(!!jcollected_questions, + "collectedQuestions", SD_JSON_BUILD_VARIANT(jcollected_questions)), + SD_JSON_BUILD_PAIR_CONDITION(!!janswer, + "answer", SD_JSON_BUILD_VARIANT(janswer))); if (r < 0) log_debug_errno(r, "Failed to send monitor event, ignoring: %m"); } @@ -1891,27 +1891,26 @@ int dns_manager_dump_statistics_json(Manager *m, sd_json_variant **ret) { miss += s->cache.n_miss; } - return sd_json_build(ret, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("transactions", SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_UNSIGNED("currentTransactions", hashmap_size(m->dns_transactions)), - SD_JSON_BUILD_PAIR_UNSIGNED("totalTransactions", m->n_transactions_total), - SD_JSON_BUILD_PAIR_UNSIGNED("totalTimeouts", m->n_timeouts_total), - SD_JSON_BUILD_PAIR_UNSIGNED("totalTimeoutsServedStale", m->n_timeouts_served_stale_total), - SD_JSON_BUILD_PAIR_UNSIGNED("totalFailedResponses", m->n_failure_responses_total), - SD_JSON_BUILD_PAIR_UNSIGNED("totalFailedResponsesServedStale", m->n_failure_responses_served_stale_total) - )), - SD_JSON_BUILD_PAIR("cache", SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_UNSIGNED("size", size), - SD_JSON_BUILD_PAIR_UNSIGNED("hits", hit), - SD_JSON_BUILD_PAIR_UNSIGNED("misses", miss) - )), - SD_JSON_BUILD_PAIR("dnssec", SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_UNSIGNED("secure", m->n_dnssec_verdict[DNSSEC_SECURE]), - SD_JSON_BUILD_PAIR_UNSIGNED("insecure", m->n_dnssec_verdict[DNSSEC_INSECURE]), - SD_JSON_BUILD_PAIR_UNSIGNED("bogus", m->n_dnssec_verdict[DNSSEC_BOGUS]), - SD_JSON_BUILD_PAIR_UNSIGNED("indeterminate", m->n_dnssec_verdict[DNSSEC_INDETERMINATE]) - )))); + return sd_json_buildo(ret, + SD_JSON_BUILD_PAIR("transactions", SD_JSON_BUILD_OBJECT( + SD_JSON_BUILD_PAIR_UNSIGNED("currentTransactions", hashmap_size(m->dns_transactions)), + SD_JSON_BUILD_PAIR_UNSIGNED("totalTransactions", m->n_transactions_total), + SD_JSON_BUILD_PAIR_UNSIGNED("totalTimeouts", m->n_timeouts_total), + SD_JSON_BUILD_PAIR_UNSIGNED("totalTimeoutsServedStale", m->n_timeouts_served_stale_total), + SD_JSON_BUILD_PAIR_UNSIGNED("totalFailedResponses", m->n_failure_responses_total), + SD_JSON_BUILD_PAIR_UNSIGNED("totalFailedResponsesServedStale", m->n_failure_responses_served_stale_total) + )), + SD_JSON_BUILD_PAIR("cache", SD_JSON_BUILD_OBJECT( + SD_JSON_BUILD_PAIR_UNSIGNED("size", size), + SD_JSON_BUILD_PAIR_UNSIGNED("hits", hit), + SD_JSON_BUILD_PAIR_UNSIGNED("misses", miss) + )), + SD_JSON_BUILD_PAIR("dnssec", SD_JSON_BUILD_OBJECT( + SD_JSON_BUILD_PAIR_UNSIGNED("secure", m->n_dnssec_verdict[DNSSEC_SECURE]), + SD_JSON_BUILD_PAIR_UNSIGNED("insecure", m->n_dnssec_verdict[DNSSEC_INSECURE]), + SD_JSON_BUILD_PAIR_UNSIGNED("bogus", m->n_dnssec_verdict[DNSSEC_BOGUS]), + SD_JSON_BUILD_PAIR_UNSIGNED("indeterminate", m->n_dnssec_verdict[DNSSEC_INDETERMINATE]) + ))); } void dns_manager_reset_statistics(Manager *m) { diff --git a/src/resolve/resolved-varlink.c b/src/resolve/resolved-varlink.c index d0da67c78b..3d109026d2 100644 --- a/src/resolve/resolved-varlink.c +++ b/src/resolve/resolved-varlink.c @@ -60,12 +60,12 @@ static int reply_query_state(DnsQuery *q) { return varlink_error(q->varlink_request, "io.systemd.Resolve.QueryAborted", NULL); case DNS_TRANSACTION_DNSSEC_FAILED: - return varlink_errorb(q->varlink_request, "io.systemd.Resolve.DNSSECValidationFailed", - SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("result", SD_JSON_BUILD_STRING(dnssec_result_to_string(q->answer_dnssec_result))), - SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0, - "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)), - SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg), - "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg)))); + return varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSSECValidationFailed", + SD_JSON_BUILD_PAIR("result", SD_JSON_BUILD_STRING(dnssec_result_to_string(q->answer_dnssec_result))), + SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0, + "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)), + SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg), + "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg))); case DNS_TRANSACTION_NO_TRUST_ANCHOR: return varlink_error(q->varlink_request, "io.systemd.Resolve.NoTrustAnchor", NULL); @@ -85,16 +85,16 @@ static int reply_query_state(DnsQuery *q) { case DNS_TRANSACTION_NOT_FOUND: /* We return this as NXDOMAIN. This is only generated when a host doesn't implement LLMNR/TCP, and we * thus quickly know that we cannot resolve an in-addr.arpa or ip6.arpa address. */ - return varlink_errorb(q->varlink_request, "io.systemd.Resolve.DNSError", - SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(DNS_RCODE_NXDOMAIN)))); + return varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError", + SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(DNS_RCODE_NXDOMAIN))); case DNS_TRANSACTION_RCODE_FAILURE: - return varlink_errorb(q->varlink_request, "io.systemd.Resolve.DNSError", - SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(q->answer_rcode)), - SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0, - "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)), - SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg), - "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg)))); + return varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError", + SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(q->answer_rcode)), + SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0, + "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)), + SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg), + "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg))); case DNS_TRANSACTION_NULL: case DNS_TRANSACTION_PENDING: @@ -211,11 +211,11 @@ static int find_addr_records( return -EAFNOSUPPORT; } - r = sd_json_build(&entry, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)), - SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(family)), - SD_JSON_BUILD_PAIR("address", SD_JSON_BUILD_BYTE_ARRAY(p, FAMILY_ADDRESS_SIZE(family))))); + r = sd_json_buildo( + &entry, + SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)), + SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(family)), + SD_JSON_BUILD_PAIR("address", SD_JSON_BUILD_BYTE_ARRAY(p, FAMILY_ADDRESS_SIZE(family)))); if (r < 0) return r; @@ -274,11 +274,11 @@ static void vl_method_resolve_hostname_complete(DnsQuery *query) { if (r < 0) goto finish; - r = varlink_replyb(q->varlink_request, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("addresses", SD_JSON_BUILD_VARIANT(array)), - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(normalized)), - SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q))))); + r = varlink_replybo( + q->varlink_request, + SD_JSON_BUILD_PAIR("addresses", SD_JSON_BUILD_VARIANT(array)), + SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(normalized)), + SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q)))); finish: if (r < 0) { log_full_errno(ERRNO_IS_DISCONNECT(r) ? LOG_DEBUG : LOG_ERR, r, "Failed to send hostname reply: %m"); @@ -311,18 +311,17 @@ static int parse_as_address(Varlink *link, LookupParameters *p) { if (r < 0) return r; - return varlink_replyb( + return varlink_replybo( link, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("addresses", - SD_JSON_BUILD_ARRAY( - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)), - SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(ff)), - SD_JSON_BUILD_PAIR("address", SD_JSON_BUILD_BYTE_ARRAY(&parsed, FAMILY_ADDRESS_SIZE(ff)))))), - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(canonical)), - SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(SD_RESOLVED_FLAGS_MAKE(dns_synthesize_protocol(p->flags), ff, true, true)| - SD_RESOLVED_SYNTHETIC)))); + SD_JSON_BUILD_PAIR("addresses", + SD_JSON_BUILD_ARRAY( + SD_JSON_BUILD_OBJECT( + SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)), + SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(ff)), + SD_JSON_BUILD_PAIR("address", SD_JSON_BUILD_BYTE_ARRAY(&parsed, FAMILY_ADDRESS_SIZE(ff)))))), + SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(canonical)), + SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(SD_RESOLVED_FLAGS_MAKE(dns_synthesize_protocol(p->flags), ff, true, true)| + SD_RESOLVED_SYNTHETIC))); } static int vl_method_resolve_hostname(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) { @@ -476,11 +475,10 @@ static void vl_method_resolve_address_complete(DnsQuery *query) { if (r < 0) goto finish; - r = sd_json_variant_append_arrayb( + r = sd_json_variant_append_arraybo( &array, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)), - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(normalized)))); + SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)), + SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(normalized))); if (r < 0) goto finish; } @@ -490,10 +488,10 @@ static void vl_method_resolve_address_complete(DnsQuery *query) { goto finish; } - r = varlink_replyb(q->varlink_request, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("names", SD_JSON_BUILD_VARIANT(array)), - SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q))))); + r = varlink_replybo( + q->varlink_request, + SD_JSON_BUILD_PAIR("names", SD_JSON_BUILD_VARIANT(array)), + SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q)))); finish: if (r < 0) { log_full_errno(ERRNO_IS_DISCONNECT(r) ? LOG_DEBUG : LOG_ERR, r, "Failed to send address reply: %m"); @@ -655,12 +653,12 @@ static int append_srv( if (r < 0) return r; - r = sd_json_build(&v, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->srv.priority)), - SD_JSON_BUILD_PAIR("weight", SD_JSON_BUILD_UNSIGNED(rr->srv.weight)), - SD_JSON_BUILD_PAIR("port", SD_JSON_BUILD_UNSIGNED(rr->srv.port)), - SD_JSON_BUILD_PAIR("hostname", SD_JSON_BUILD_STRING(normalized)))); + r = sd_json_buildo( + &v, + SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->srv.priority)), + SD_JSON_BUILD_PAIR("weight", SD_JSON_BUILD_UNSIGNED(rr->srv.weight)), + SD_JSON_BUILD_PAIR("port", SD_JSON_BUILD_UNSIGNED(rr->srv.port)), + SD_JSON_BUILD_PAIR("hostname", SD_JSON_BUILD_STRING(normalized))); if (r < 0) return r; @@ -830,14 +828,15 @@ static void resolve_service_all_complete(DnsQuery *query) { if (r < 0) goto finish; - r = varlink_replyb(query->varlink_request, SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("services", SD_JSON_BUILD_VARIANT(srv)), - SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_object(txt), "txt", SD_JSON_BUILD_VARIANT(txt)), - SD_JSON_BUILD_PAIR("canonical", SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)), - SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(type)), - SD_JSON_BUILD_PAIR("domain", SD_JSON_BUILD_STRING(domain)))), - SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(dns_query_reply_flags_make(query))))); + r = varlink_replybo( + query->varlink_request, + SD_JSON_BUILD_PAIR("services", SD_JSON_BUILD_VARIANT(srv)), + SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_object(txt), "txt", SD_JSON_BUILD_VARIANT(txt)), + SD_JSON_BUILD_PAIR("canonical", SD_JSON_BUILD_OBJECT( + SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)), + SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(type)), + SD_JSON_BUILD_PAIR("domain", SD_JSON_BUILD_STRING(domain)))), + SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(dns_query_reply_flags_make(query)))); finish: if (r < 0) { @@ -1125,11 +1124,11 @@ static void vl_method_resolve_record_complete(DnsQuery *query) { if (r < 0) goto finish; - r = sd_json_variant_append_arrayb( + r = sd_json_variant_append_arraybo( &array, - SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)), - SD_JSON_BUILD_PAIR_CONDITION(!!v, "rr", SD_JSON_BUILD_VARIANT(v)), - SD_JSON_BUILD_PAIR("raw", SD_JSON_BUILD_BASE64(rr->wire_format, rr->wire_format_size)))); + SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)), + SD_JSON_BUILD_PAIR_CONDITION(!!v, "rr", SD_JSON_BUILD_VARIANT(v)), + SD_JSON_BUILD_PAIR("raw", SD_JSON_BUILD_BASE64(rr->wire_format, rr->wire_format_size))); if (r < 0) goto finish; @@ -1141,10 +1140,10 @@ static void vl_method_resolve_record_complete(DnsQuery *query) { goto finish; } - r = varlink_replyb(q->varlink_request, - SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("rrs", SD_JSON_BUILD_VARIANT(array)), - SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q))))); + r = varlink_replybo( + q->varlink_request, + SD_JSON_BUILD_PAIR("rrs", SD_JSON_BUILD_VARIANT(array)), + SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q)))); finish: if (r < 0) { log_full_errno(ERRNO_IS_DISCONNECT(r) ? LOG_DEBUG : LOG_ERR, r, "Failed to send record reply: %m"); @@ -1246,8 +1245,7 @@ static int vl_method_subscribe_query_results(Varlink *link, sd_json_variant *par /* Send a ready message to the connecting client, to indicate that we are now listinening, and all * queries issued after the point the client sees this will also be reported to the client. */ - r = varlink_notifyb(link, - SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("ready", SD_JSON_BUILD_BOOLEAN(true)))); + r = varlink_notifybo(link, SD_JSON_BUILD_PAIR("ready", SD_JSON_BUILD_BOOLEAN(true))); if (r < 0) return log_error_errno(r, "Failed to report monitor to be established: %m"); @@ -1291,8 +1289,7 @@ static int vl_method_dump_cache(Varlink *link, sd_json_variant *parameters, Varl return r; } - return varlink_replyb(link, SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list)))); + return varlink_replybo(link, SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list))); } static int dns_server_dump_state_to_json_list(DnsServer *server, sd_json_variant **list) { @@ -1347,8 +1344,7 @@ static int vl_method_dump_server_state(Varlink *link, sd_json_variant *parameter return r; } - return varlink_replyb(link, SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list)))); + return varlink_replybo(link, SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list))); } static int vl_method_dump_statistics(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) { |