]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-manager.h
journal-cat: don't allocate memory for the syslog identifier
[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;
3df9bec5 77 bool permit_domain_search;
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 */
78c6a153
LP
112 char *llmnr_hostname;
113 char *mdns_hostname;
114 DnsResourceKey *llmnr_host_ipv4_key;
115 DnsResourceKey *llmnr_host_ipv6_key;
eb60f9cd
LP
116
117 /* Watch the system hostname */
118 int hostname_fd;
119 sd_event_source *hostname_event_source;
902bb5d8
LP
120
121 /* Watch for system suspends */
122 sd_bus_slot *prepare_for_sleep_slot;
4d506d6b
LP
123
124 sd_event_source *sigusr1_event_source;
a150ff5e
LP
125
126 unsigned n_transactions_total;
59c5b597 127 unsigned n_dnssec_verdict[_DNSSEC_VERDICT_MAX];
dd0bc0f1
LP
128
129 /* Data from /etc/hosts */
130 Set* etc_hosts_by_address;
131 Hashmap* etc_hosts_by_name;
132 usec_t etc_hosts_last, etc_hosts_mtime;
091a364c
TG
133};
134
135/* Manager */
136
137int manager_new(Manager **ret);
74b2466e
LP
138Manager* manager_free(Manager *m);
139
edc501d4 140int manager_start(Manager *m);
74b2466e 141
e1c95994 142uint32_t manager_find_mtu(Manager *m);
091a364c 143
72290734 144int manager_write(Manager *m, int fd, DnsPacket *p);
623a4c97 145int manager_send(Manager *m, int fd, int ifindex, int family, const union in_addr_union *addr, uint16_t port, DnsPacket *p);
1716f6dc 146int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret);
74b2466e 147
623a4c97 148int manager_find_ifindex(Manager *m, int family, const union in_addr_union *in_addr);
4e945a6f 149LinkAddress* manager_find_link_address(Manager *m, int family, const union in_addr_union *in_addr);
ec2c5e43 150
eb60f9cd 151void manager_refresh_rrs(Manager *m);
ec2c5e43 152int manager_next_hostname(Manager *m);
74b2466e 153
a4076574
LP
154bool manager_our_packet(Manager *m, DnsPacket *p);
155DnsScope* manager_find_scope(Manager *m, DnsPacket *p);
091a364c 156
902bb5d8
LP
157void manager_verify_all(Manager *m);
158
091a364c 159DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
091a364c 160
623a4c97 161#define EXTRA_CMSG_SPACE 1024
4e945a6f 162
78c6a153
LP
163int manager_is_own_hostname(Manager *m, const char *name);
164
9176a57c
LP
165int manager_compile_dns_servers(Manager *m, OrderedSet **servers);
166int manager_compile_search_domains(Manager *m, OrderedSet **domains);
c69fa7e3
LP
167
168DnssecMode manager_get_dnssec_mode(Manager *m);
169bool manager_dnssec_supported(Manager *m);
59c5b597
LP
170
171void manager_dnssec_verdict(Manager *m, DnssecVerdict verdict, const DnsResourceKey *key);