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