1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2014 Tom Gundersen <teg@jklm.no>
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.
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.
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/>.
25 #include "sd-netlink.h"
26 #include "sd-network.h"
30 #include "ordered-set.h"
32 typedef struct Manager Manager
;
33 typedef enum Support Support
;
43 #include "resolved-dns-query.h"
44 #include "resolved-dns-search-domain.h"
45 #include "resolved-dns-server.h"
46 #include "resolved-dns-stream.h"
47 #include "resolved-dns-trust-anchor.h"
48 #include "resolved-link.h"
50 #define MANAGER_SEARCH_DOMAINS_MAX 32
51 #define MANAGER_DNS_SERVERS_MAX 32
56 Support llmnr_support
;
63 sd_event_source
*rtnl_event_source
;
65 sd_network_monitor
*network_monitor
;
66 sd_event_source
*network_event_source
;
68 /* DNS query management */
69 Hashmap
*dns_transactions
;
70 LIST_HEAD(DnsQuery
, dns_queries
);
71 unsigned n_dns_queries
;
73 LIST_HEAD(DnsStream
, dns_streams
);
74 unsigned n_dns_streams
;
77 LIST_HEAD(DnsServer
, dns_servers
);
78 LIST_HEAD(DnsServer
, fallback_dns_servers
);
79 unsigned n_dns_servers
; /* counts both main and fallback */
80 DnsServer
*current_dns_server
;
82 LIST_HEAD(DnsSearchDomain
, search_domains
);
83 unsigned n_search_domains
;
85 bool need_builtin_fallbacks
:1;
87 bool read_resolv_conf
:1;
88 usec_t resolv_conf_mtime
;
90 DnsTrustAnchor trust_anchor
;
92 LIST_HEAD(DnsScope
, dns_scopes
);
93 DnsScope
*unicast_scope
;
96 int llmnr_ipv4_udp_fd
;
97 int llmnr_ipv6_udp_fd
;
98 int llmnr_ipv4_tcp_fd
;
99 int llmnr_ipv6_tcp_fd
;
101 sd_event_source
*llmnr_ipv4_udp_event_source
;
102 sd_event_source
*llmnr_ipv6_udp_event_source
;
103 sd_event_source
*llmnr_ipv4_tcp_event_source
;
104 sd_event_source
*llmnr_ipv6_tcp_event_source
;
110 sd_event_source
*mdns_ipv4_event_source
;
111 sd_event_source
*mdns_ipv6_event_source
;
115 sd_event_source
*bus_retry_event_source
;
117 /* The hostname we publish on LLMNR and mDNS */
118 char *llmnr_hostname
;
120 DnsResourceKey
*llmnr_host_ipv4_key
;
121 DnsResourceKey
*llmnr_host_ipv6_key
;
123 /* Watch the system hostname */
125 sd_event_source
*hostname_event_source
;
127 /* Watch for system suspends */
128 sd_bus_slot
*prepare_for_sleep_slot
;
130 sd_event_source
*sigusr1_event_source
;
132 unsigned n_transactions_total
;
133 unsigned n_dnssec_secure
, n_dnssec_insecure
, n_dnssec_bogus
, n_dnssec_indeterminate
;
138 int manager_new(Manager
**ret
);
139 Manager
* manager_free(Manager
*m
);
141 int manager_start(Manager
*m
);
143 uint32_t manager_find_mtu(Manager
*m
);
145 int manager_write(Manager
*m
, int fd
, DnsPacket
*p
);
146 int manager_send(Manager
*m
, int fd
, int ifindex
, int family
, const union in_addr_union
*addr
, uint16_t port
, DnsPacket
*p
);
147 int manager_recv(Manager
*m
, int fd
, DnsProtocol protocol
, DnsPacket
**ret
);
149 int manager_find_ifindex(Manager
*m
, int family
, const union in_addr_union
*in_addr
);
150 LinkAddress
* manager_find_link_address(Manager
*m
, int family
, const union in_addr_union
*in_addr
);
152 void manager_refresh_rrs(Manager
*m
);
153 int manager_next_hostname(Manager
*m
);
155 bool manager_our_packet(Manager
*m
, DnsPacket
*p
);
156 DnsScope
* manager_find_scope(Manager
*m
, DnsPacket
*p
);
158 void manager_verify_all(Manager
*m
);
160 DEFINE_TRIVIAL_CLEANUP_FUNC(Manager
*, manager_free
);
162 #define EXTRA_CMSG_SPACE 1024
164 int manager_is_own_hostname(Manager
*m
, const char *name
);
166 int manager_compile_dns_servers(Manager
*m
, OrderedSet
**servers
);
167 int manager_compile_search_domains(Manager
*m
, OrderedSet
**domains
);
169 const char* support_to_string(Support p
) _const_
;
170 int support_from_string(const char *s
) _pure_
;