summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-server.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/resolve/resolved-dns-server.c')
-rw-r--r--src/resolve/resolved-dns-server.c82
1 files changed, 36 insertions, 46 deletions
diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c
index 81301ab800..93b954139b 100644
--- a/src/resolve/resolved-dns-server.c
+++ b/src/resolve/resolved-dns-server.c
@@ -240,74 +240,64 @@ const struct hash_ops dns_server_hash_ops = {
.compare = dns_server_compare_func
};
-DnsServer *manager_get_first_dns_server(Manager *m, DnsServerType t) {
- assert(m);
-
- switch (t) {
+void dns_server_unlink_all(DnsServer *first) {
+ DnsServer *next;
- case DNS_SERVER_SYSTEM:
- return m->dns_servers;
+ if (!first)
+ return;
- case DNS_SERVER_FALLBACK:
- return m->fallback_dns_servers;
+ next = first->servers_next;
+ dns_server_unlink(first);
- default:
- return NULL;
- }
+ dns_server_unlink_all(next);
}
-void manager_flush_dns_servers(Manager *m, DnsServerType type) {
- assert(m);
+void dns_server_unlink_marked(DnsServer *first) {
+ DnsServer *next;
- for (;;) {
- DnsServer *first;
+ if (!first)
+ return;
- first = manager_get_first_dns_server(m, type);
- if (!first)
- break;
+ next = first->servers_next;
+ if (first->marked)
dns_server_unlink(first);
- }
-}
-
-void manager_flush_marked_dns_servers(Manager *m, DnsServerType type) {
- DnsServer *first, *s, *next;
- assert(m);
-
- first = manager_get_first_dns_server(m, type);
+ dns_server_unlink_marked(next);
+}
- LIST_FOREACH_SAFE(servers, s, next, first) {
- if (!s->marked)
- continue;
+void dns_server_mark_all(DnsServer *first) {
+ if (!first)
+ return;
- dns_server_unlink(s);
- }
+ first->marked = true;
+ dns_server_mark_all(first->servers_next);
}
-void manager_mark_dns_servers(Manager *m, DnsServerType type) {
- DnsServer *first, *s;
+DnsServer *dns_server_find(DnsServer *first, int family, const union in_addr_union *in_addr) {
+ DnsServer *s;
- assert(m);
-
- first = manager_get_first_dns_server(m, type);
LIST_FOREACH(servers, s, first)
- s->marked = true;
-}
+ if (s->family == family && in_addr_equal(family, &s->address, in_addr) > 0)
+ return s;
-DnsServer* manager_find_dns_server(Manager *m, DnsServerType type, int family, const union in_addr_union *in_addr) {
- DnsServer *first, *s;
+ return NULL;
+}
+DnsServer *manager_get_first_dns_server(Manager *m, DnsServerType t) {
assert(m);
- assert(in_addr);
- first = manager_get_first_dns_server(m, type);
+ switch (t) {
- LIST_FOREACH(servers, s, first)
- if (s->family == family && in_addr_equal(family, &s->address, in_addr) > 0)
- return s;
+ case DNS_SERVER_SYSTEM:
+ return m->dns_servers;
- return NULL;
+ case DNS_SERVER_FALLBACK:
+ return m->fallback_dns_servers;
+
+ default:
+ return NULL;
+ }
}
DnsServer *manager_set_dns_server(Manager *m, DnsServer *s) {