1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "list.h"
5 #include "macro.h"
6
7 typedef struct DnsSearchDomain DnsSearchDomain;
8 typedef struct Link Link;
9 typedef struct Manager Manager;
10
11 typedef enum DnsSearchDomainType {
12 DNS_SEARCH_DOMAIN_SYSTEM,
13 DNS_SEARCH_DOMAIN_LINK,
14 } DnsSearchDomainType;
15
16 struct DnsSearchDomain {
17 Manager *manager;
18
19 unsigned n_ref;
20
21 DnsSearchDomainType type;
22 Link *link;
23
24 char *name;
25
26 bool marked:1;
27 bool route_only:1;
28
29 bool linked:1;
30 LIST_FIELDS(DnsSearchDomain, domains);
31 };
32
33 int dns_search_domain_new(
34 Manager *m,
35 DnsSearchDomain **ret,
36 DnsSearchDomainType type,
37 Link *link,
38 const char *name);
39
40 DnsSearchDomain* dns_search_domain_ref(DnsSearchDomain *d);
41 DnsSearchDomain* dns_search_domain_unref(DnsSearchDomain *d);
42
43 void dns_search_domain_unlink(DnsSearchDomain *d);
44 void dns_search_domain_move_back_and_unmark(DnsSearchDomain *d);
45
46 void dns_search_domain_unlink_all(DnsSearchDomain *first);
47 bool dns_search_domain_unlink_marked(DnsSearchDomain *first);
48 void dns_search_domain_mark_all(DnsSearchDomain *first);
49
50 int dns_search_domain_find(DnsSearchDomain *first, const char *name, DnsSearchDomain **ret);
51
DNS_SEARCH_DOMAIN_NAME(DnsSearchDomain * d)52 static inline const char* DNS_SEARCH_DOMAIN_NAME(DnsSearchDomain *d) {
53 return d ? d->name : NULL;
54 }
55
56 DEFINE_TRIVIAL_CLEANUP_FUNC(DnsSearchDomain*, dns_search_domain_unref);
57