summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-server.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-24 16:48:13 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-25 21:58:37 +0100
commit636e813dc98ea40c58c6c85bc5e7e3c9f0904ea2 (patch)
tree4ea8f8a918f6efc364944503c25e909c86b8a791 /src/resolve/resolved-dns-server.c
parente3528a5c46c815974d4d17ea9964278f7ee9caae (diff)
resolved: unify code for parsing dns server information
Let's use the same parser when parsing dns server information from /etc/resolv.conf and our native configuration file. Also, move all code that manages lists of dns servers to a single place. resolved-dns-server.c
Diffstat (limited to 'src/resolve/resolved-dns-server.c')
-rw-r--r--src/resolve/resolved-dns-server.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c
index e803f635ab..3d6a6c92b3 100644
--- a/src/resolve/resolved-dns-server.c
+++ b/src/resolve/resolved-dns-server.c
@@ -161,3 +161,45 @@ const struct hash_ops dns_server_hash_ops = {
.hash = dns_server_hash_func,
.compare = dns_server_compare_func
};
+
+void manager_flush_dns_servers(Manager *m, DnsServerType type) {
+ DnsServer **first, *s;
+
+ assert(m);
+
+ first = type == DNS_SERVER_FALLBACK ? &m->fallback_dns_servers : &m->dns_servers;
+
+ while (*first) {
+ s = *first;
+
+ LIST_REMOVE(servers, *first, s);
+ dns_server_unref(s);
+ }
+}
+
+void manager_flush_marked_dns_servers(Manager *m, DnsServerType type) {
+ DnsServer **first, *s, *next;
+
+ assert(m);
+
+ first = type == DNS_SERVER_FALLBACK ? &m->fallback_dns_servers : &m->dns_servers;
+
+ LIST_FOREACH_SAFE(servers, s, next, *first) {
+ if (!s->marked)
+ continue;
+
+ LIST_REMOVE(servers, *first, s);
+ dns_server_unref(s);
+ }
+}
+
+void manager_mark_dns_servers(Manager *m, DnsServerType type) {
+ DnsServer *first, *s;
+
+ assert(m);
+
+ first = type == DNS_SERVER_FALLBACK ? m->fallback_dns_servers : m->dns_servers;
+
+ LIST_FOREACH(servers, s, first)
+ s->marked = true;
+}