dns-configuration: dispatch negative trust anchors to DNSConfiguration

This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
This commit is contained in:
Nick Rosbrook
2026-02-03 15:07:41 -05:00
parent d3b60567d7
commit 4a8f4efd44
2 changed files with 17 additions and 12 deletions
+16 -12
View File
@@ -11,6 +11,7 @@
#include "json-util.h"
#include "set.h"
#include "string-util.h"
#include "strv.h"
DNSServer* dns_server_free(DNSServer *s) {
if (!s)
@@ -163,6 +164,7 @@ DNSConfiguration* dns_configuration_free(DNSConfiguration *c) {
free(c->dns_over_tls_mode_str);
free(c->llmnr_mode_str);
free(c->mdns_mode_str);
strv_free(c->negative_trust_anchors);
return mfree(c);
}
@@ -177,21 +179,21 @@ DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
static int dispatch_dns_configuration(const char *name, sd_json_variant *variant, sd_json_dispatch_flags_t flags, void *userdata) {
static const sd_json_dispatch_field dns_configuration_dispatch_table[] = {
{ "ifname", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(DNSConfiguration, ifname), 0 },
{ "ifindex", SD_JSON_VARIANT_UNSIGNED, json_dispatch_ifindex, offsetof(DNSConfiguration, ifindex), SD_JSON_RELAX },
{ "defaultRoute", SD_JSON_VARIANT_BOOLEAN, sd_json_dispatch_stdbool, offsetof(DNSConfiguration, default_route), 0 },
{ "currentServer", SD_JSON_VARIANT_OBJECT, dispatch_dns_server, offsetof(DNSConfiguration, current_dns_server), 0 },
{ "servers", SD_JSON_VARIANT_ARRAY, dispatch_dns_server_array, offsetof(DNSConfiguration, dns_servers), 0 },
{ "searchDomains", SD_JSON_VARIANT_ARRAY, dispatch_search_domain_array, offsetof(DNSConfiguration, search_domains), 0 },
{ "dnssec", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(DNSConfiguration, dnssec_mode_str), 0 },
{ "dnsOverTLS", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(DNSConfiguration, dns_over_tls_mode_str), 0 },
{ "llmnr", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(DNSConfiguration, llmnr_mode_str), 0 },
{ "mDNS", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(DNSConfiguration, mdns_mode_str), 0 },
{ "fallbackServers", SD_JSON_VARIANT_ARRAY, dispatch_dns_server_array, offsetof(DNSConfiguration, fallback_dns_servers), 0 },
{ "ifname", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(DNSConfiguration, ifname), 0 },
{ "ifindex", SD_JSON_VARIANT_UNSIGNED, json_dispatch_ifindex, offsetof(DNSConfiguration, ifindex), SD_JSON_RELAX },
{ "defaultRoute", SD_JSON_VARIANT_BOOLEAN, sd_json_dispatch_stdbool, offsetof(DNSConfiguration, default_route), 0 },
{ "currentServer", SD_JSON_VARIANT_OBJECT, dispatch_dns_server, offsetof(DNSConfiguration, current_dns_server), 0 },
{ "servers", SD_JSON_VARIANT_ARRAY, dispatch_dns_server_array, offsetof(DNSConfiguration, dns_servers), 0 },
{ "searchDomains", SD_JSON_VARIANT_ARRAY, dispatch_search_domain_array, offsetof(DNSConfiguration, search_domains), 0 },
{ "dnssec", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(DNSConfiguration, dnssec_mode_str), 0 },
{ "dnsOverTLS", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(DNSConfiguration, dns_over_tls_mode_str), 0 },
{ "llmnr", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(DNSConfiguration, llmnr_mode_str), 0 },
{ "mDNS", SD_JSON_VARIANT_STRING, sd_json_dispatch_string, offsetof(DNSConfiguration, mdns_mode_str), 0 },
{ "fallbackServers", SD_JSON_VARIANT_ARRAY, dispatch_dns_server_array, offsetof(DNSConfiguration, fallback_dns_servers), 0 },
{ "negativeTrustAnchors", SD_JSON_VARIANT_ARRAY, sd_json_dispatch_strv, offsetof(DNSConfiguration, negative_trust_anchors), 0 },
/* The remaining fields are currently unused by wait-online. */
{ "delegate", _SD_JSON_VARIANT_TYPE_INVALID, NULL, 0, 0 },
{ "negativeTrustAnchors", _SD_JSON_VARIANT_TYPE_INVALID, NULL, 0, 0 },
{ "resolvConfMode", _SD_JSON_VARIANT_TYPE_INVALID, NULL, 0, 0 },
{ "scopes", _SD_JSON_VARIANT_TYPE_INVALID, NULL, 0, 0 },
{},
@@ -209,6 +211,8 @@ static int dispatch_dns_configuration(const char *name, sd_json_variant *variant
if (r < 0)
return r;
strv_sort(c->negative_trust_anchors);
*ret = TAKE_PTR(c);
return 0;
+1
View File
@@ -38,6 +38,7 @@ typedef struct DNSConfiguration {
char *dns_over_tls_mode_str;
char *llmnr_mode_str;
char *mdns_mode_str;
char **negative_trust_anchors;
} DNSConfiguration;
DNSConfiguration* dns_configuration_free(DNSConfiguration *c);