static int dns_configuration_json_append(
const char *ifname,
int ifindex,
+ const char *delegate,
int default_route,
DnsServer *current_dns_server,
DnsServer *dns_servers,
configuration,
JSON_BUILD_PAIR_STRING_NON_EMPTY("ifname", ifname),
SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_UNSIGNED(ifindex)),
- SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "defaultRoute", SD_JSON_BUILD_BOOLEAN(default_route > 0)),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("delegate", delegate),
+ JSON_BUILD_PAIR_CONDITION_BOOLEAN(ifindex > 0 || !!delegate,
+ "defaultRoute",
+ default_route > 0),
JSON_BUILD_PAIR_VARIANT_NON_NULL("currentServer", current_dns_server_json),
JSON_BUILD_PAIR_VARIANT_NON_NULL("servers", dns_servers_json),
JSON_BUILD_PAIR_VARIANT_NON_NULL("searchDomains", search_domains_json));
return dns_configuration_json_append(
/* ifname = */ NULL,
/* ifindex = */ 0,
+ /* delegate = */ NULL,
/* default_route = */ 0,
manager_get_dns_server(m),
m->dns_servers,
return dns_configuration_json_append(
l->ifname,
l->ifindex,
+ /* delegate = */ NULL,
link_get_default_route(l),
link_get_dns_server(l),
l->dns_servers,
configuration);
}
+static int delegate_dns_configuration_json_append(DnsDelegate *d, sd_json_variant **configuration) {
+ assert(d);
+ assert(configuration);
+
+ return dns_configuration_json_append(
+ /* ifname = */ NULL,
+ /* ifindex = */ 0,
+ d->id,
+ d->default_route,
+ dns_delegate_get_dns_server(d),
+ d->dns_servers,
+ d->search_domains,
+ configuration);
+}
+
int manager_dump_dns_configuration_json(Manager *m, sd_json_variant **ret) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *configuration = NULL;
Link *l;
+ DnsDelegate *d;
int r;
assert(m);
return r;
}
+ /* Append configuration for each delegate */
+ HASHMAP_FOREACH(d, m->delegates) {
+ r = delegate_dns_configuration_json_append(d, &configuration);
+ if (r < 0)
+ return r;
+ }
+
return sd_json_buildo(ret, SD_JSON_BUILD_PAIR_VARIANT("configuration", configuration));
}
SD_VARLINK_DEFINE_FIELD(ifname, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Interface index, if any, associated with this configuration. Empty for global configuration."),
SD_VARLINK_DEFINE_FIELD(ifindex, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
+ SD_VARLINK_FIELD_COMMENT("Delegate name, if any, associated with this configuration. Empty for global or link configurations."),
+ SD_VARLINK_DEFINE_FIELD(delegate, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("Indicates whether or not this link's DNS servers will be used for resolving domain names that do not match any link's configured domains."),
SD_VARLINK_DEFINE_FIELD(defaultRoute, SD_VARLINK_BOOL, SD_VARLINK_NULLABLE),
SD_VARLINK_FIELD_COMMENT("DNS server currently selected to use for lookups."),