]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-manager.h
Merge pull request #179 from l10n-tw/master
[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
TG
24#include "sd-event.h"
25#include "sd-network.h"
74b2466e 26#include "sd-rtnl.h"
091a364c 27#include "list.h"
74b2466e 28#include "hashmap.h"
091a364c 29
091a364c 30typedef struct Manager Manager;
19b50b5b 31typedef enum Support Support;
091a364c 32
19b50b5b 33enum Support {
4e945a6f
LP
34 SUPPORT_NO,
35 SUPPORT_YES,
36 SUPPORT_RESOLVE,
37 _SUPPORT_MAX,
38 _SUPPORT_INVALID = -1
19b50b5b
LP
39};
40
41#include "resolved-dns-query.h"
19b50b5b
LP
42#include "resolved-dns-stream.h"
43#include "resolved-link.h"
4e945a6f 44
091a364c
TG
45struct Manager {
46 sd_event *event;
47
4e945a6f 48 Support llmnr_support;
1716f6dc
LP
49
50 /* Network */
74b2466e
LP
51 Hashmap *links;
52
53 sd_rtnl *rtnl;
54 sd_event_source *rtnl_event_source;
55
091a364c 56 sd_network_monitor *network_monitor;
74b2466e
LP
57 sd_event_source *network_event_source;
58
1716f6dc 59 /* DNS query management */
ec2c5e43 60 Hashmap *dns_transactions;
1716f6dc
LP
61 LIST_HEAD(DnsQuery, dns_queries);
62 unsigned n_dns_queries;
63
623a4c97
LP
64 LIST_HEAD(DnsStream, dns_streams);
65 unsigned n_dns_streams;
66
1716f6dc 67 /* Unicast dns */
74b2466e
LP
68 int dns_ipv4_fd;
69 int dns_ipv6_fd;
70
71 sd_event_source *dns_ipv4_event_source;
72 sd_event_source *dns_ipv6_event_source;
73
74b2466e 74 LIST_HEAD(DnsServer, dns_servers);
4e945a6f 75 LIST_HEAD(DnsServer, fallback_dns_servers);
74b2466e
LP
76 DnsServer *current_dns_server;
77
5cb36f41
LP
78 bool read_resolv_conf;
79 usec_t resolv_conf_mtime;
80
74b2466e
LP
81 LIST_HEAD(DnsScope, dns_scopes);
82 DnsScope *unicast_scope;
83
1716f6dc
LP
84 /* LLMNR */
85 int llmnr_ipv4_udp_fd;
86 int llmnr_ipv6_udp_fd;
623a4c97
LP
87 int llmnr_ipv4_tcp_fd;
88 int llmnr_ipv6_tcp_fd;
1716f6dc
LP
89
90 sd_event_source *llmnr_ipv4_udp_event_source;
91 sd_event_source *llmnr_ipv6_udp_event_source;
623a4c97
LP
92 sd_event_source *llmnr_ipv4_tcp_event_source;
93 sd_event_source *llmnr_ipv6_tcp_event_source;
1716f6dc 94
74b2466e
LP
95 /* dbus */
96 sd_bus *bus;
97 sd_event_source *bus_retry_event_source;
623a4c97
LP
98
99 /* The hostname we publish on LLMNR and mDNS */
100 char *hostname;
101 DnsResourceKey *host_ipv4_key;
102 DnsResourceKey *host_ipv6_key;
eb60f9cd
LP
103
104 /* Watch the system hostname */
105 int hostname_fd;
106 sd_event_source *hostname_event_source;
902bb5d8
LP
107
108 /* Watch for system suspends */
109 sd_bus_slot *prepare_for_sleep_slot;
091a364c
TG
110};
111
112/* Manager */
113
114int manager_new(Manager **ret);
74b2466e
LP
115Manager* manager_free(Manager *m);
116
edc501d4 117int manager_start(Manager *m);
5cb36f41 118int manager_read_resolv_conf(Manager *m);
74b2466e
LP
119int manager_write_resolv_conf(Manager *m);
120
2c27fbca
LP
121DnsServer *manager_set_dns_server(Manager *m, DnsServer *s);
122DnsServer *manager_find_dns_server(Manager *m, int family, const union in_addr_union *in_addr);
74b2466e
LP
123DnsServer *manager_get_dns_server(Manager *m);
124void manager_next_dns_server(Manager *m);
ec2c5e43 125
e1c95994 126uint32_t manager_find_mtu(Manager *m);
091a364c 127
623a4c97 128int manager_send(Manager *m, int fd, int ifindex, int family, const union in_addr_union *addr, uint16_t port, DnsPacket *p);
1716f6dc 129int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret);
74b2466e 130
1716f6dc 131int manager_dns_ipv4_fd(Manager *m);
74b2466e 132int manager_dns_ipv6_fd(Manager *m);
1716f6dc
LP
133int manager_llmnr_ipv4_udp_fd(Manager *m);
134int manager_llmnr_ipv6_udp_fd(Manager *m);
623a4c97
LP
135int manager_llmnr_ipv4_tcp_fd(Manager *m);
136int manager_llmnr_ipv6_tcp_fd(Manager *m);
137
623a4c97 138int manager_find_ifindex(Manager *m, int family, const union in_addr_union *in_addr);
4e945a6f 139LinkAddress* manager_find_link_address(Manager *m, int family, const union in_addr_union *in_addr);
ec2c5e43 140
eb60f9cd 141void manager_refresh_rrs(Manager *m);
ec2c5e43 142int manager_next_hostname(Manager *m);
74b2466e 143
a4076574
LP
144bool manager_our_packet(Manager *m, DnsPacket *p);
145DnsScope* manager_find_scope(Manager *m, DnsPacket *p);
091a364c 146
902bb5d8
LP
147void manager_verify_all(Manager *m);
148
3e684349
LP
149void manager_flush_dns_servers(Manager *m, DnsServerType t);
150
091a364c 151DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
091a364c 152
623a4c97 153#define EXTRA_CMSG_SPACE 1024
4e945a6f
LP
154
155const char* support_to_string(Support p) _const_;
156int support_from_string(const char *s) _pure_;