]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-manager.h
Merge pull request #7388 from keszybz/doc-tweak
[thirdparty/systemd.git] / src / resolve / resolved-manager.h
CommitLineData
74b2466e
LP
1#pragma once
2
091a364c
TG
3/***
4 This file is part of systemd.
5
4e945a6f 6 Copyright 2014 Tom Gundersen <teg@jklm.no>
091a364c
TG
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
091a364c 22#include "sd-event.h"
1c4baffc 23#include "sd-netlink.h"
71d35b6b
TA
24#include "sd-network.h"
25
74b2466e 26#include "hashmap.h"
71d35b6b 27#include "list.h"
9176a57c 28#include "ordered-set.h"
af49ca27 29#include "resolve-util.h"
091a364c 30
091a364c 31typedef struct Manager Manager;
19b50b5b 32
1ae43295 33#include "resolved-conf.h"
19b50b5b 34#include "resolved-dns-query.h"
a51c1048
LP
35#include "resolved-dns-search-domain.h"
36#include "resolved-dns-server.h"
19b50b5b 37#include "resolved-dns-stream.h"
0d2cd476 38#include "resolved-dns-trust-anchor.h"
19b50b5b 39#include "resolved-link.h"
4e945a6f 40
eed857b7
LP
41#define MANAGER_SEARCH_DOMAINS_MAX 32
42#define MANAGER_DNS_SERVERS_MAX 32
43
091a364c
TG
44struct Manager {
45 sd_event *event;
46
af49ca27
LP
47 ResolveSupport llmnr_support;
48 ResolveSupport mdns_support;
ad6c0475 49 DnssecMode dnssec_mode;
ceeddf79 50 bool enable_cache;
1ae43295 51 DnsStubListenerMode dns_stub_listener_mode;
1716f6dc
LP
52
53 /* Network */
74b2466e
LP
54 Hashmap *links;
55
1c4baffc 56 sd_netlink *rtnl;
74b2466e
LP
57 sd_event_source *rtnl_event_source;
58
091a364c 59 sd_network_monitor *network_monitor;
74b2466e
LP
60 sd_event_source *network_event_source;
61
1716f6dc 62 /* DNS query management */
ec2c5e43 63 Hashmap *dns_transactions;
1716f6dc
LP
64 LIST_HEAD(DnsQuery, dns_queries);
65 unsigned n_dns_queries;
66
623a4c97
LP
67 LIST_HEAD(DnsStream, dns_streams);
68 unsigned n_dns_streams;
69
1716f6dc 70 /* Unicast dns */
74b2466e 71 LIST_HEAD(DnsServer, dns_servers);
4e945a6f 72 LIST_HEAD(DnsServer, fallback_dns_servers);
eed857b7 73 unsigned n_dns_servers; /* counts both main and fallback */
74b2466e
LP
74 DnsServer *current_dns_server;
75
a51c1048 76 LIST_HEAD(DnsSearchDomain, search_domains);
eed857b7 77 unsigned n_search_domains;
a51c1048 78
00fa60ae 79 bool need_builtin_fallbacks:1;
a51c1048 80
00fa60ae 81 bool read_resolv_conf:1;
5cb36f41
LP
82 usec_t resolv_conf_mtime;
83
0d2cd476
LP
84 DnsTrustAnchor trust_anchor;
85
74b2466e
LP
86 LIST_HEAD(DnsScope, dns_scopes);
87 DnsScope *unicast_scope;
88
1716f6dc
LP
89 /* LLMNR */
90 int llmnr_ipv4_udp_fd;
91 int llmnr_ipv6_udp_fd;
623a4c97
LP
92 int llmnr_ipv4_tcp_fd;
93 int llmnr_ipv6_tcp_fd;
1716f6dc
LP
94
95 sd_event_source *llmnr_ipv4_udp_event_source;
96 sd_event_source *llmnr_ipv6_udp_event_source;
623a4c97
LP
97 sd_event_source *llmnr_ipv4_tcp_event_source;
98 sd_event_source *llmnr_ipv6_tcp_event_source;
1716f6dc 99
bc7702b0
DM
100 /* mDNS */
101 int mdns_ipv4_fd;
102 int mdns_ipv6_fd;
103
104 sd_event_source *mdns_ipv4_event_source;
105 sd_event_source *mdns_ipv6_event_source;
106
74b2466e
LP
107 /* dbus */
108 sd_bus *bus;
109 sd_event_source *bus_retry_event_source;
623a4c97
LP
110
111 /* The hostname we publish on LLMNR and mDNS */
e96de0ce 112 char *full_hostname;
78c6a153
LP
113 char *llmnr_hostname;
114 char *mdns_hostname;
115 DnsResourceKey *llmnr_host_ipv4_key;
116 DnsResourceKey *llmnr_host_ipv6_key;
400cb36e
DR
117 DnsResourceKey *mdns_host_ipv4_key;
118 DnsResourceKey *mdns_host_ipv6_key;
eb60f9cd
LP
119
120 /* Watch the system hostname */
121 int hostname_fd;
122 sd_event_source *hostname_event_source;
902bb5d8
LP
123
124 /* Watch for system suspends */
125 sd_bus_slot *prepare_for_sleep_slot;
4d506d6b
LP
126
127 sd_event_source *sigusr1_event_source;
bc81447e 128 sd_event_source *sigusr2_event_source;
d55b0463 129 sd_event_source *sigrtmin1_event_source;
a150ff5e
LP
130
131 unsigned n_transactions_total;
59c5b597 132 unsigned n_dnssec_verdict[_DNSSEC_VERDICT_MAX];
dd0bc0f1
LP
133
134 /* Data from /etc/hosts */
135 Set* etc_hosts_by_address;
136 Hashmap* etc_hosts_by_name;
137 usec_t etc_hosts_last, etc_hosts_mtime;
b30bf55d
LP
138
139 /* Local DNS stub on 127.0.0.53:53 */
140 int dns_stub_udp_fd;
141 int dns_stub_tcp_fd;
142
143 sd_event_source *dns_stub_udp_event_source;
144 sd_event_source *dns_stub_tcp_event_source;
091a364c
TG
145};
146
147/* Manager */
148
149int manager_new(Manager **ret);
74b2466e
LP
150Manager* manager_free(Manager *m);
151
edc501d4 152int manager_start(Manager *m);
74b2466e 153
e1c95994 154uint32_t manager_find_mtu(Manager *m);
091a364c 155
72290734 156int manager_write(Manager *m, int fd, DnsPacket *p);
b30bf55d 157int manager_send(Manager *m, int fd, int ifindex, int family, const union in_addr_union *destination, uint16_t port, const union in_addr_union *source, DnsPacket *p);
1716f6dc 158int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret);
74b2466e 159
623a4c97 160int manager_find_ifindex(Manager *m, int family, const union in_addr_union *in_addr);
4e945a6f 161LinkAddress* manager_find_link_address(Manager *m, int family, const union in_addr_union *in_addr);
ec2c5e43 162
eb60f9cd 163void manager_refresh_rrs(Manager *m);
ec2c5e43 164int manager_next_hostname(Manager *m);
74b2466e 165
a4076574
LP
166bool manager_our_packet(Manager *m, DnsPacket *p);
167DnsScope* manager_find_scope(Manager *m, DnsPacket *p);
091a364c 168
902bb5d8
LP
169void manager_verify_all(Manager *m);
170
091a364c 171DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
091a364c 172
623a4c97 173#define EXTRA_CMSG_SPACE 1024
4e945a6f 174
78c6a153
LP
175int manager_is_own_hostname(Manager *m, const char *name);
176
9176a57c 177int manager_compile_dns_servers(Manager *m, OrderedSet **servers);
6f7da49d 178int manager_compile_search_domains(Manager *m, OrderedSet **domains, int filter_route);
c69fa7e3
LP
179
180DnssecMode manager_get_dnssec_mode(Manager *m);
181bool manager_dnssec_supported(Manager *m);
59c5b597
LP
182
183void manager_dnssec_verdict(Manager *m, DnssecVerdict verdict, const DnsResourceKey *key);
011696f7
LP
184
185bool manager_routable(Manager *m, int family);
ba35662f
LP
186
187void manager_flush_caches(Manager *m);
59c0fd0e 188void manager_reset_server_features(Manager *m);
943ef07c
LP
189
190void manager_cleanup_saved_user(Manager *m);