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