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