]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-manager.h
resolved: synthesize RRs for data from /etc/hosts
[thirdparty/systemd.git] / src / resolve / resolved-manager.h
CommitLineData
091a364c
TG
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
74b2466e
LP
3#pragma once
4
091a364c
TG
5/***
6 This file is part of systemd.
7
4e945a6f 8 Copyright 2014 Tom Gundersen <teg@jklm.no>
091a364c
TG
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
091a364c 24#include "sd-event.h"
1c4baffc 25#include "sd-netlink.h"
71d35b6b
TA
26#include "sd-network.h"
27
74b2466e 28#include "hashmap.h"
71d35b6b 29#include "list.h"
9176a57c 30#include "ordered-set.h"
af49ca27 31#include "resolve-util.h"
091a364c 32
091a364c 33typedef struct Manager Manager;
19b50b5b
LP
34
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;
1716f6dc
LP
51
52 /* Network */
74b2466e
LP
53 Hashmap *links;
54
1c4baffc 55 sd_netlink *rtnl;
74b2466e
LP
56 sd_event_source *rtnl_event_source;
57
091a364c 58 sd_network_monitor *network_monitor;
74b2466e
LP
59 sd_event_source *network_event_source;
60
1716f6dc 61 /* DNS query management */
ec2c5e43 62 Hashmap *dns_transactions;
1716f6dc
LP
63 LIST_HEAD(DnsQuery, dns_queries);
64 unsigned n_dns_queries;
65
623a4c97
LP
66 LIST_HEAD(DnsStream, dns_streams);
67 unsigned n_dns_streams;
68
1716f6dc 69 /* Unicast dns */
74b2466e 70 LIST_HEAD(DnsServer, dns_servers);
4e945a6f 71 LIST_HEAD(DnsServer, fallback_dns_servers);
eed857b7 72 unsigned n_dns_servers; /* counts both main and fallback */
74b2466e
LP
73 DnsServer *current_dns_server;
74
a51c1048 75 LIST_HEAD(DnsSearchDomain, search_domains);
eed857b7 76 unsigned n_search_domains;
a51c1048 77
00fa60ae 78 bool need_builtin_fallbacks:1;
a51c1048 79
00fa60ae 80 bool read_resolv_conf:1;
5cb36f41
LP
81 usec_t resolv_conf_mtime;
82
0d2cd476
LP
83 DnsTrustAnchor trust_anchor;
84
74b2466e
LP
85 LIST_HEAD(DnsScope, dns_scopes);
86 DnsScope *unicast_scope;
87
1716f6dc
LP
88 /* LLMNR */
89 int llmnr_ipv4_udp_fd;
90 int llmnr_ipv6_udp_fd;
623a4c97
LP
91 int llmnr_ipv4_tcp_fd;
92 int llmnr_ipv6_tcp_fd;
1716f6dc
LP
93
94 sd_event_source *llmnr_ipv4_udp_event_source;
95 sd_event_source *llmnr_ipv6_udp_event_source;
623a4c97
LP
96 sd_event_source *llmnr_ipv4_tcp_event_source;
97 sd_event_source *llmnr_ipv6_tcp_event_source;
1716f6dc 98
bc7702b0
DM
99 /* mDNS */
100 int mdns_ipv4_fd;
101 int mdns_ipv6_fd;
102
103 sd_event_source *mdns_ipv4_event_source;
104 sd_event_source *mdns_ipv6_event_source;
105
74b2466e
LP
106 /* dbus */
107 sd_bus *bus;
108 sd_event_source *bus_retry_event_source;
623a4c97
LP
109
110 /* The hostname we publish on LLMNR and mDNS */
78c6a153
LP
111 char *llmnr_hostname;
112 char *mdns_hostname;
113 DnsResourceKey *llmnr_host_ipv4_key;
114 DnsResourceKey *llmnr_host_ipv6_key;
eb60f9cd
LP
115
116 /* Watch the system hostname */
117 int hostname_fd;
118 sd_event_source *hostname_event_source;
902bb5d8
LP
119
120 /* Watch for system suspends */
121 sd_bus_slot *prepare_for_sleep_slot;
4d506d6b
LP
122
123 sd_event_source *sigusr1_event_source;
a150ff5e
LP
124
125 unsigned n_transactions_total;
59c5b597 126 unsigned n_dnssec_verdict[_DNSSEC_VERDICT_MAX];
dd0bc0f1
LP
127
128 /* Data from /etc/hosts */
129 Set* etc_hosts_by_address;
130 Hashmap* etc_hosts_by_name;
131 usec_t etc_hosts_last, etc_hosts_mtime;
091a364c
TG
132};
133
134/* Manager */
135
136int manager_new(Manager **ret);
74b2466e
LP
137Manager* manager_free(Manager *m);
138
edc501d4 139int manager_start(Manager *m);
74b2466e 140
e1c95994 141uint32_t manager_find_mtu(Manager *m);
091a364c 142
72290734 143int manager_write(Manager *m, int fd, DnsPacket *p);
623a4c97 144int manager_send(Manager *m, int fd, int ifindex, int family, const union in_addr_union *addr, uint16_t port, DnsPacket *p);
1716f6dc 145int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret);
74b2466e 146
623a4c97 147int manager_find_ifindex(Manager *m, int family, const union in_addr_union *in_addr);
4e945a6f 148LinkAddress* manager_find_link_address(Manager *m, int family, const union in_addr_union *in_addr);
ec2c5e43 149
eb60f9cd 150void manager_refresh_rrs(Manager *m);
ec2c5e43 151int manager_next_hostname(Manager *m);
74b2466e 152
a4076574
LP
153bool manager_our_packet(Manager *m, DnsPacket *p);
154DnsScope* manager_find_scope(Manager *m, DnsPacket *p);
091a364c 155
902bb5d8
LP
156void manager_verify_all(Manager *m);
157
091a364c 158DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
091a364c 159
623a4c97 160#define EXTRA_CMSG_SPACE 1024
4e945a6f 161
78c6a153
LP
162int manager_is_own_hostname(Manager *m, const char *name);
163
9176a57c
LP
164int manager_compile_dns_servers(Manager *m, OrderedSet **servers);
165int manager_compile_search_domains(Manager *m, OrderedSet **domains);
c69fa7e3
LP
166
167DnssecMode manager_get_dnssec_mode(Manager *m);
168bool manager_dnssec_supported(Manager *m);
59c5b597
LP
169
170void manager_dnssec_verdict(Manager *m, DnssecVerdict verdict, const DnsResourceKey *key);