4 This file is part of systemd.
6 Copyright 2014 Tom Gundersen <teg@jklm.no>
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.
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.
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/>.
23 #include "sd-netlink.h"
24 #include "sd-network.h"
28 #include "ordered-set.h"
29 #include "resolve-util.h"
31 typedef struct Manager Manager
;
33 #include "resolved-dns-query.h"
34 #include "resolved-dns-search-domain.h"
35 #include "resolved-dns-server.h"
36 #include "resolved-dns-stream.h"
37 #include "resolved-dns-trust-anchor.h"
38 #include "resolved-link.h"
40 #define MANAGER_SEARCH_DOMAINS_MAX 32
41 #define MANAGER_DNS_SERVERS_MAX 32
46 ResolveSupport llmnr_support
;
47 ResolveSupport mdns_support
;
48 DnssecMode dnssec_mode
;
54 sd_event_source
*rtnl_event_source
;
56 sd_network_monitor
*network_monitor
;
57 sd_event_source
*network_event_source
;
59 /* DNS query management */
60 Hashmap
*dns_transactions
;
61 LIST_HEAD(DnsQuery
, dns_queries
);
62 unsigned n_dns_queries
;
64 LIST_HEAD(DnsStream
, dns_streams
);
65 unsigned n_dns_streams
;
68 LIST_HEAD(DnsServer
, dns_servers
);
69 LIST_HEAD(DnsServer
, fallback_dns_servers
);
70 unsigned n_dns_servers
; /* counts both main and fallback */
71 DnsServer
*current_dns_server
;
73 LIST_HEAD(DnsSearchDomain
, search_domains
);
74 unsigned n_search_domains
;
75 bool permit_domain_search
;
77 bool need_builtin_fallbacks
:1;
79 bool read_resolv_conf
:1;
80 usec_t resolv_conf_mtime
;
82 DnsTrustAnchor trust_anchor
;
84 LIST_HEAD(DnsScope
, dns_scopes
);
85 DnsScope
*unicast_scope
;
88 int llmnr_ipv4_udp_fd
;
89 int llmnr_ipv6_udp_fd
;
90 int llmnr_ipv4_tcp_fd
;
91 int llmnr_ipv6_tcp_fd
;
93 sd_event_source
*llmnr_ipv4_udp_event_source
;
94 sd_event_source
*llmnr_ipv6_udp_event_source
;
95 sd_event_source
*llmnr_ipv4_tcp_event_source
;
96 sd_event_source
*llmnr_ipv6_tcp_event_source
;
102 sd_event_source
*mdns_ipv4_event_source
;
103 sd_event_source
*mdns_ipv6_event_source
;
107 sd_event_source
*bus_retry_event_source
;
109 /* The hostname we publish on LLMNR and mDNS */
110 char *llmnr_hostname
;
112 DnsResourceKey
*llmnr_host_ipv4_key
;
113 DnsResourceKey
*llmnr_host_ipv6_key
;
115 /* Watch the system hostname */
117 sd_event_source
*hostname_event_source
;
119 /* Watch for system suspends */
120 sd_bus_slot
*prepare_for_sleep_slot
;
122 sd_event_source
*sigusr1_event_source
;
123 sd_event_source
*sigusr2_event_source
;
125 unsigned n_transactions_total
;
126 unsigned n_dnssec_verdict
[_DNSSEC_VERDICT_MAX
];
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
;
136 int manager_new(Manager
**ret
);
137 Manager
* manager_free(Manager
*m
);
139 int manager_start(Manager
*m
);
141 uint32_t manager_find_mtu(Manager
*m
);
143 int manager_write(Manager
*m
, int fd
, DnsPacket
*p
);
144 int manager_send(Manager
*m
, int fd
, int ifindex
, int family
, const union in_addr_union
*addr
, uint16_t port
, DnsPacket
*p
);
145 int manager_recv(Manager
*m
, int fd
, DnsProtocol protocol
, DnsPacket
**ret
);
147 int manager_find_ifindex(Manager
*m
, int family
, const union in_addr_union
*in_addr
);
148 LinkAddress
* manager_find_link_address(Manager
*m
, int family
, const union in_addr_union
*in_addr
);
150 void manager_refresh_rrs(Manager
*m
);
151 int manager_next_hostname(Manager
*m
);
153 bool manager_our_packet(Manager
*m
, DnsPacket
*p
);
154 DnsScope
* manager_find_scope(Manager
*m
, DnsPacket
*p
);
156 void manager_verify_all(Manager
*m
);
158 DEFINE_TRIVIAL_CLEANUP_FUNC(Manager
*, manager_free
);
160 #define EXTRA_CMSG_SPACE 1024
162 int manager_is_own_hostname(Manager
*m
, const char *name
);
164 int manager_compile_dns_servers(Manager
*m
, OrderedSet
**servers
);
165 int manager_compile_search_domains(Manager
*m
, OrderedSet
**domains
, int filter_route
);
167 DnssecMode
manager_get_dnssec_mode(Manager
*m
);
168 bool manager_dnssec_supported(Manager
*m
);
170 void manager_dnssec_verdict(Manager
*m
, DnssecVerdict verdict
, const DnsResourceKey
*key
);
172 bool manager_routable(Manager
*m
, int family
);
174 void manager_flush_caches(Manager
*m
);
176 void manager_cleanup_saved_user(Manager
*m
);