DnsServer *dns_servers,
DnsSearchDomain *search_domains,
Set *negative_trust_anchors,
+ Set *dns_scopes,
sd_json_variant **configuration) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *dns_servers_json = NULL,
*search_domains_json = NULL,
- *current_dns_server_json = NULL;
+ *current_dns_server_json = NULL,
+ *scopes_json = NULL;
+ DnsScope *scope;
int r;
assert(configuration);
return r;
}
+ SET_FOREACH(scope, dns_scopes) {
+ _cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
+
+ r = dns_scope_dump_cache_to_json(scope, &v);
+ if (r < 0)
+ return r;
+
+ /* The cache is not relevant to the configuration of the scope. */
+ r = sd_json_variant_filter(&v, STRV_MAKE("cache"));
+ if (r < 0)
+ return r;
+
+ r = sd_json_variant_append_array(&scopes_json, v);
+ if (r < 0)
+ return r;
+ }
+
LIST_FOREACH(servers, s, dns_servers) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
JSON_BUILD_PAIR_VARIANT_NON_NULL("searchDomains", search_domains_json),
SD_JSON_BUILD_PAIR_CONDITION(!set_isempty(negative_trust_anchors),
"negativeTrustAnchors",
- JSON_BUILD_STRING_SET(negative_trust_anchors)));
+ JSON_BUILD_STRING_SET(negative_trust_anchors)),
+ JSON_BUILD_PAIR_VARIANT_NON_NULL("scopes", scopes_json));
}
static int global_dns_configuration_json_append(Manager *m, sd_json_variant **configuration) {
+ _cleanup_set_free_ Set *scopes = NULL;
+ int r;
+
assert(m);
assert(configuration);
+ r = set_ensure_put(&scopes, NULL, m->unicast_scope);
+ if (r < 0)
+ return r;
+
return dns_configuration_json_append(
/* ifname = */ NULL,
/* ifindex = */ 0,
m->dns_servers,
m->search_domains,
m->trust_anchor.negative_by_name,
+ scopes,
configuration);
}
static int link_dns_configuration_json_append(Link *l, sd_json_variant **configuration) {
+ _cleanup_set_free_ Set *scopes = NULL;
+ int r;
+
assert(l);
assert(configuration);
+ if (l->unicast_scope) {
+ r = set_ensure_put(&scopes, NULL, l->unicast_scope);
+ if (r < 0)
+ return r;
+ }
+
+ if (l->llmnr_ipv4_scope) {
+ r = set_ensure_put(&scopes, NULL, l->llmnr_ipv4_scope);
+ if (r < 0)
+ return r;
+ }
+
+ if (l->llmnr_ipv6_scope) {
+ r = set_ensure_put(&scopes, NULL, l->llmnr_ipv6_scope);
+ if (r < 0)
+ return r;
+ }
+
+ if (l->mdns_ipv4_scope) {
+ r = set_ensure_put(&scopes, NULL, l->mdns_ipv4_scope);
+ if (r < 0)
+ return r;
+ }
+
+ if (l->mdns_ipv6_scope) {
+ r = set_ensure_put(&scopes, NULL, l->mdns_ipv6_scope);
+ if (r < 0)
+ return r;
+ }
+
return dns_configuration_json_append(
l->ifname,
l->ifindex,
l->dns_servers,
l->search_domains,
l->dnssec_negative_trust_anchors,
+ scopes,
configuration);
}
static int delegate_dns_configuration_json_append(DnsDelegate *d, sd_json_variant **configuration) {
+ _cleanup_set_free_ Set *scopes = NULL;
+ int r;
+
assert(d);
assert(configuration);
+ r = set_ensure_put(&scopes, NULL, d->scope);
+ if (r < 0)
+ return r;
+
return dns_configuration_json_append(
/* ifname = */ NULL,
/* ifindex = */ 0,
d->dns_servers,
d->search_domains,
/* negative_trust_anchors = */ NULL,
+ scopes,
configuration);
}
SD_VARLINK_FIELD_COMMENT("Interface index for which this search domain is configured."),
SD_VARLINK_DEFINE_FIELD(ifindex, SD_VARLINK_INT, SD_VARLINK_NULLABLE));
+static SD_VARLINK_DEFINE_STRUCT_TYPE(
+ DNSScope,
+ SD_VARLINK_FIELD_COMMENT("Protocol associated with this scope."),
+ SD_VARLINK_DEFINE_FIELD(protocol, SD_VARLINK_STRING, 0),
+ SD_VARLINK_FIELD_COMMENT("Address family associated with this scope."),
+ SD_VARLINK_DEFINE_FIELD(family, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
+ SD_VARLINK_FIELD_COMMENT("Interface index associated with this scope."),
+ SD_VARLINK_DEFINE_FIELD(ifindex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
+ SD_VARLINK_FIELD_COMMENT("Interface name associated with this scope."),
+ SD_VARLINK_DEFINE_FIELD(ifname, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
+ SD_VARLINK_FIELD_COMMENT("DNSSEC mode associated with this scope."),
+ SD_VARLINK_DEFINE_FIELD(dnssec, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
+ SD_VARLINK_FIELD_COMMENT("DNSOverTLS mode associated with this scope."),
+ SD_VARLINK_DEFINE_FIELD(dnsOverTLS, SD_VARLINK_STRING, SD_VARLINK_NULLABLE));
+
static SD_VARLINK_DEFINE_STRUCT_TYPE(
DNSConfiguration,
SD_VARLINK_FIELD_COMMENT("Interface name, if any, associated with this configuration. Empty for global configuration."),
SD_VARLINK_FIELD_COMMENT("Array of configured search domains."),
SD_VARLINK_DEFINE_FIELD_BY_TYPE(searchDomains, SearchDomain, SD_VARLINK_ARRAY|SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Array of configured DNSSEC negative trust anchors."),
- SD_VARLINK_DEFINE_FIELD(negativeTrustAnchors, SD_VARLINK_STRING, SD_VARLINK_ARRAY|SD_VARLINK_NULLABLE));
+ SD_VARLINK_DEFINE_FIELD(negativeTrustAnchors, SD_VARLINK_STRING, SD_VARLINK_ARRAY|SD_VARLINK_NULLABLE),
+ SD_VARLINK_FIELD_COMMENT("Array of current DNS scopes."),
+ SD_VARLINK_DEFINE_FIELD_BY_TYPE(scopes, DNSScope, SD_VARLINK_ARRAY|SD_VARLINK_NULLABLE));
static SD_VARLINK_DEFINE_METHOD_FULL(
SubscribeDNSConfiguration,
&vl_type_SearchDomain,
SD_VARLINK_SYMBOL_COMMENT("Encapsulates a global or per-link DNS configuration, including configured DNS servers, search domains, and more."),
&vl_type_DNSConfiguration,
+ SD_VARLINK_SYMBOL_COMMENT("Encapsulates a DNS scope specification."),
+ &vl_type_DNSScope,
SD_VARLINK_SYMBOL_COMMENT("Sends the complete global and per-link DNS configurations when any changes are made to them. The current configurations are given immediately when this method is invoked."),
&vl_method_SubscribeDNSConfiguration);