]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-manager.h
Add SPDX license identifiers to source files under the LGPL
[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
105 sd_event_source *mdns_ipv4_event_source;
106 sd_event_source *mdns_ipv6_event_source;
107
74b2466e
LP
108 /* dbus */
109 sd_bus *bus;
110 sd_event_source *bus_retry_event_source;
623a4c97
LP
111
112 /* The hostname we publish on LLMNR and mDNS */
e96de0ce 113 char *full_hostname;
78c6a153
LP
114 char *llmnr_hostname;
115 char *mdns_hostname;
116 DnsResourceKey *llmnr_host_ipv4_key;
117 DnsResourceKey *llmnr_host_ipv6_key;
400cb36e
DR
118 DnsResourceKey *mdns_host_ipv4_key;
119 DnsResourceKey *mdns_host_ipv6_key;
eb60f9cd
LP
120
121 /* Watch the system hostname */
122 int hostname_fd;
123 sd_event_source *hostname_event_source;
902bb5d8
LP
124
125 /* Watch for system suspends */
126 sd_bus_slot *prepare_for_sleep_slot;
4d506d6b
LP
127
128 sd_event_source *sigusr1_event_source;
bc81447e 129 sd_event_source *sigusr2_event_source;
d55b0463 130 sd_event_source *sigrtmin1_event_source;
a150ff5e
LP
131
132 unsigned n_transactions_total;
59c5b597 133 unsigned n_dnssec_verdict[_DNSSEC_VERDICT_MAX];
dd0bc0f1
LP
134
135 /* Data from /etc/hosts */
136 Set* etc_hosts_by_address;
137 Hashmap* etc_hosts_by_name;
138 usec_t etc_hosts_last, etc_hosts_mtime;
b30bf55d
LP
139
140 /* Local DNS stub on 127.0.0.53:53 */
141 int dns_stub_udp_fd;
142 int dns_stub_tcp_fd;
143
144 sd_event_source *dns_stub_udp_event_source;
145 sd_event_source *dns_stub_tcp_event_source;
091a364c
TG
146};
147
148/* Manager */
149
150int manager_new(Manager **ret);
74b2466e
LP
151Manager* manager_free(Manager *m);
152
edc501d4 153int manager_start(Manager *m);
74b2466e 154
e1c95994 155uint32_t manager_find_mtu(Manager *m);
091a364c 156
72290734 157int manager_write(Manager *m, int fd, DnsPacket *p);
b30bf55d 158int 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 159int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret);
74b2466e 160
623a4c97 161int manager_find_ifindex(Manager *m, int family, const union in_addr_union *in_addr);
4e945a6f 162LinkAddress* manager_find_link_address(Manager *m, int family, const union in_addr_union *in_addr);
ec2c5e43 163
eb60f9cd 164void manager_refresh_rrs(Manager *m);
ec2c5e43 165int manager_next_hostname(Manager *m);
74b2466e 166
a4076574
LP
167bool manager_our_packet(Manager *m, DnsPacket *p);
168DnsScope* manager_find_scope(Manager *m, DnsPacket *p);
091a364c 169
902bb5d8
LP
170void manager_verify_all(Manager *m);
171
091a364c 172DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
091a364c 173
623a4c97 174#define EXTRA_CMSG_SPACE 1024
4e945a6f 175
78c6a153
LP
176int manager_is_own_hostname(Manager *m, const char *name);
177
9176a57c 178int manager_compile_dns_servers(Manager *m, OrderedSet **servers);
6f7da49d 179int manager_compile_search_domains(Manager *m, OrderedSet **domains, int filter_route);
c69fa7e3
LP
180
181DnssecMode manager_get_dnssec_mode(Manager *m);
182bool manager_dnssec_supported(Manager *m);
59c5b597
LP
183
184void manager_dnssec_verdict(Manager *m, DnssecVerdict verdict, const DnsResourceKey *key);
011696f7
LP
185
186bool manager_routable(Manager *m, int family);
ba35662f
LP
187
188void manager_flush_caches(Manager *m);
59c0fd0e 189void manager_reset_server_features(Manager *m);
943ef07c
LP
190
191void manager_cleanup_saved_user(Manager *m);