]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dns-configuration: dispatch all protocol modes to DNSConfiguration
authorNick Rosbrook <enr0n@ubuntu.com>
Fri, 30 Jan 2026 19:34:15 +0000 (14:34 -0500)
committerNick Rosbrook <enr0n@ubuntu.com>
Tue, 3 Feb 2026 20:07:41 +0000 (15:07 -0500)
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.

src/shared/dns-configuration.c
src/shared/dns-configuration.h

index 9efd2d8f7b4a19c85ab4873ca814e5169a7ff81b..03c4f3e2f13fba08b79ac888f17f5f194d673b92 100644 (file)
@@ -158,6 +158,10 @@ DNSConfiguration* dns_configuration_free(DNSConfiguration *c) {
         set_free(c->dns_servers);
         set_free(c->search_domains);
         free(c->ifname);
+        free(c->dnssec_mode_str);
+        free(c->dns_over_tls_mode_str);
+        free(c->llmnr_mode_str);
+        free(c->mdns_mode_str);
 
         return mfree(c);
 }
@@ -172,21 +176,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             },
+                { "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             },
 
                 /* The remaining fields are currently unused by wait-online. */
                 { "delegate",             _SD_JSON_VARIANT_TYPE_INVALID, NULL,                         0,                                              0             },
                 { "fallbackServers",      _SD_JSON_VARIANT_TYPE_INVALID, NULL,                         0,                                              0             },
                 { "negativeTrustAnchors", _SD_JSON_VARIANT_TYPE_INVALID, NULL,                         0,                                              0             },
-                { "dnssec",               _SD_JSON_VARIANT_TYPE_INVALID, NULL,                         0,                                              0             },
-                { "dnsOverTLS",           _SD_JSON_VARIANT_TYPE_INVALID, NULL,                         0,                                              0             },
-                { "llmnr",                _SD_JSON_VARIANT_TYPE_INVALID, NULL,                         0,                                              0             },
-                { "mDNS",                 _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             },
                 {},
index e865defaab6da83f5c4d62bfb2594b506669a027..9e2addd0a07b78fa4f56ffae8089b909fd6b86e1 100644 (file)
@@ -33,6 +33,10 @@ typedef struct DNSConfiguration {
         DNSServer *current_dns_server;
         Set *dns_servers;
         Set *search_domains;
+        char *dnssec_mode_str;
+        char *dns_over_tls_mode_str;
+        char *llmnr_mode_str;
+        char *mdns_mode_str;
 } DNSConfiguration;
 
 DNSConfiguration* dns_configuration_free(DNSConfiguration *c);