]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-manager.h
resolved: add a generic DnsSearchDomain concept
[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"
091a364c 30
091a364c 31typedef struct Manager Manager;
19b50b5b 32typedef enum Support Support;
091a364c 33
19b50b5b 34enum Support {
4e945a6f
LP
35 SUPPORT_NO,
36 SUPPORT_YES,
37 SUPPORT_RESOLVE,
38 _SUPPORT_MAX,
39 _SUPPORT_INVALID = -1
19b50b5b
LP
40};
41
42#include "resolved-dns-query.h"
a51c1048
LP
43#include "resolved-dns-search-domain.h"
44#include "resolved-dns-server.h"
19b50b5b
LP
45#include "resolved-dns-stream.h"
46#include "resolved-link.h"
4e945a6f 47
091a364c
TG
48struct Manager {
49 sd_event *event;
50
4e945a6f 51 Support llmnr_support;
1716f6dc
LP
52
53 /* Network */
74b2466e
LP
54 Hashmap *links;
55
1c4baffc 56 sd_netlink *rtnl;
74b2466e
LP
57 sd_event_source *rtnl_event_source;
58
091a364c 59 sd_network_monitor *network_monitor;
74b2466e
LP
60 sd_event_source *network_event_source;
61
1716f6dc 62 /* DNS query management */
ec2c5e43 63 Hashmap *dns_transactions;
1716f6dc
LP
64 LIST_HEAD(DnsQuery, dns_queries);
65 unsigned n_dns_queries;
66
623a4c97
LP
67 LIST_HEAD(DnsStream, dns_streams);
68 unsigned n_dns_streams;
69
1716f6dc 70 /* Unicast dns */
74b2466e 71 LIST_HEAD(DnsServer, dns_servers);
4e945a6f 72 LIST_HEAD(DnsServer, fallback_dns_servers);
74b2466e
LP
73 DnsServer *current_dns_server;
74
a51c1048
LP
75 LIST_HEAD(DnsSearchDomain, search_domains);
76
00fa60ae 77 bool need_builtin_fallbacks:1;
a51c1048 78
00fa60ae 79 bool read_resolv_conf:1;
5cb36f41
LP
80 usec_t resolv_conf_mtime;
81
74b2466e
LP
82 LIST_HEAD(DnsScope, dns_scopes);
83 DnsScope *unicast_scope;
84
1716f6dc
LP
85 /* LLMNR */
86 int llmnr_ipv4_udp_fd;
87 int llmnr_ipv6_udp_fd;
623a4c97
LP
88 int llmnr_ipv4_tcp_fd;
89 int llmnr_ipv6_tcp_fd;
1716f6dc
LP
90
91 sd_event_source *llmnr_ipv4_udp_event_source;
92 sd_event_source *llmnr_ipv6_udp_event_source;
623a4c97
LP
93 sd_event_source *llmnr_ipv4_tcp_event_source;
94 sd_event_source *llmnr_ipv6_tcp_event_source;
1716f6dc 95
74b2466e
LP
96 /* dbus */
97 sd_bus *bus;
98 sd_event_source *bus_retry_event_source;
623a4c97
LP
99
100 /* The hostname we publish on LLMNR and mDNS */
78c6a153
LP
101 char *llmnr_hostname;
102 char *mdns_hostname;
103 DnsResourceKey *llmnr_host_ipv4_key;
104 DnsResourceKey *llmnr_host_ipv6_key;
eb60f9cd
LP
105
106 /* Watch the system hostname */
107 int hostname_fd;
108 sd_event_source *hostname_event_source;
902bb5d8
LP
109
110 /* Watch for system suspends */
111 sd_bus_slot *prepare_for_sleep_slot;
4d506d6b
LP
112
113 sd_event_source *sigusr1_event_source;
091a364c
TG
114};
115
116/* Manager */
117
118int manager_new(Manager **ret);
74b2466e
LP
119Manager* manager_free(Manager *m);
120
edc501d4 121int manager_start(Manager *m);
74b2466e 122
e1c95994 123uint32_t manager_find_mtu(Manager *m);
091a364c 124
72290734 125int manager_write(Manager *m, int fd, DnsPacket *p);
623a4c97 126int manager_send(Manager *m, int fd, int ifindex, int family, const union in_addr_union *addr, uint16_t port, DnsPacket *p);
1716f6dc 127int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret);
74b2466e 128
623a4c97 129int manager_find_ifindex(Manager *m, int family, const union in_addr_union *in_addr);
4e945a6f 130LinkAddress* manager_find_link_address(Manager *m, int family, const union in_addr_union *in_addr);
ec2c5e43 131
eb60f9cd 132void manager_refresh_rrs(Manager *m);
ec2c5e43 133int manager_next_hostname(Manager *m);
74b2466e 134
a4076574
LP
135bool manager_our_packet(Manager *m, DnsPacket *p);
136DnsScope* manager_find_scope(Manager *m, DnsPacket *p);
091a364c 137
902bb5d8
LP
138void manager_verify_all(Manager *m);
139
091a364c 140DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
091a364c 141
623a4c97 142#define EXTRA_CMSG_SPACE 1024
4e945a6f 143
78c6a153
LP
144int manager_is_own_hostname(Manager *m, const char *name);
145
4e945a6f
LP
146const char* support_to_string(Support p) _const_;
147int support_from_string(const char *s) _pure_;