]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/resolved-link.h
resolved: make sure DNS configuration pushed in by the user stays around on restarts
[thirdparty/systemd.git] / src / resolve / resolved-link.h
1 #pragma once
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2014 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <net/if.h>
23
24 #include "in-addr-util.h"
25 #include "ratelimit.h"
26 #include "resolve-util.h"
27
28 typedef struct Link Link;
29 typedef struct LinkAddress LinkAddress;
30
31 #include "resolved-dns-rr.h"
32 #include "resolved-dns-search-domain.h"
33 #include "resolved-dns-server.h"
34 #include "resolved-manager.h"
35
36 #define LINK_SEARCH_DOMAINS_MAX 32
37 #define LINK_DNS_SERVERS_MAX 32
38
39 struct LinkAddress {
40 Link *link;
41
42 int family;
43 union in_addr_union in_addr;
44
45 unsigned char flags, scope;
46
47 DnsResourceRecord *llmnr_address_rr;
48 DnsResourceRecord *llmnr_ptr_rr;
49
50 LIST_FIELDS(LinkAddress, addresses);
51 };
52
53 struct Link {
54 Manager *manager;
55
56 int ifindex;
57 unsigned flags;
58
59 LIST_HEAD(LinkAddress, addresses);
60
61 LIST_HEAD(DnsServer, dns_servers);
62 DnsServer *current_dns_server;
63 unsigned n_dns_servers;
64
65 LIST_HEAD(DnsSearchDomain, search_domains);
66 unsigned n_search_domains;
67
68 ResolveSupport llmnr_support;
69 ResolveSupport mdns_support;
70 DnssecMode dnssec_mode;
71 Set *dnssec_negative_trust_anchors;
72
73 DnsScope *unicast_scope;
74 DnsScope *llmnr_ipv4_scope;
75 DnsScope *llmnr_ipv6_scope;
76 DnsScope *mdns_ipv4_scope;
77 DnsScope *mdns_ipv6_scope;
78
79 bool is_managed;
80
81 char name[IF_NAMESIZE];
82 uint32_t mtu;
83 uint8_t operstate;
84
85 bool loaded;
86 char *state_file;
87 };
88
89 int link_new(Manager *m, Link **ret, int ifindex);
90 Link *link_free(Link *l);
91 int link_process_rtnl(Link *l, sd_netlink_message *m);
92 int link_update(Link *l);
93 bool link_relevant(Link *l, int family, bool local_multicast);
94 LinkAddress* link_find_address(Link *l, int family, const union in_addr_union *in_addr);
95 void link_add_rrs(Link *l, bool force_remove);
96
97 void link_flush_settings(Link *l);
98 void link_set_dnssec_mode(Link *l, DnssecMode mode);
99 void link_allocate_scopes(Link *l);
100
101 DnsServer* link_set_dns_server(Link *l, DnsServer *s);
102 DnsServer* link_get_dns_server(Link *l);
103 void link_next_dns_server(Link *l);
104
105 DnssecMode link_get_dnssec_mode(Link *l);
106 bool link_dnssec_supported(Link *l);
107
108 int link_save_user(Link *l);
109 int link_load_user(Link *l);
110 void link_remove_user(Link *l);
111
112 int link_address_new(Link *l, LinkAddress **ret, int family, const union in_addr_union *in_addr);
113 LinkAddress *link_address_free(LinkAddress *a);
114 int link_address_update_rtnl(LinkAddress *a, sd_netlink_message *m);
115 bool link_address_relevant(LinkAddress *l, bool local_multicast);
116 void link_address_add_rrs(LinkAddress *a, bool force_remove);
117
118 DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);