]>
Commit | Line | Data |
---|---|---|
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 | ||
8 | Copyright 2013 Tom Gundersen <teg@jklm.no> | |
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 TG |
27 | #include "util.h" |
28 | #include "list.h" | |
3b653205 | 29 | #include "in-addr-util.h" |
74b2466e | 30 | #include "hashmap.h" |
091a364c | 31 | |
091a364c TG |
32 | typedef struct Manager Manager; |
33 | ||
74b2466e LP |
34 | #include "resolved-dns-query.h" |
35 | #include "resolved-dns-server.h" | |
36 | #include "resolved-dns-scope.h" | |
623a4c97 | 37 | #include "resolved-dns-stream.h" |
091a364c TG |
38 | |
39 | struct Manager { | |
40 | sd_event *event; | |
41 | ||
1716f6dc LP |
42 | bool use_llmnr:1; |
43 | ||
44 | /* Network */ | |
74b2466e LP |
45 | Hashmap *links; |
46 | ||
47 | sd_rtnl *rtnl; | |
48 | sd_event_source *rtnl_event_source; | |
49 | ||
091a364c | 50 | sd_network_monitor *network_monitor; |
74b2466e LP |
51 | sd_event_source *network_event_source; |
52 | ||
1716f6dc | 53 | /* DNS query management */ |
ec2c5e43 | 54 | Hashmap *dns_transactions; |
1716f6dc LP |
55 | LIST_HEAD(DnsQuery, dns_queries); |
56 | unsigned n_dns_queries; | |
57 | ||
623a4c97 LP |
58 | LIST_HEAD(DnsStream, dns_streams); |
59 | unsigned n_dns_streams; | |
60 | ||
1716f6dc | 61 | /* Unicast dns */ |
74b2466e LP |
62 | int dns_ipv4_fd; |
63 | int dns_ipv6_fd; | |
64 | ||
65 | sd_event_source *dns_ipv4_event_source; | |
66 | sd_event_source *dns_ipv6_event_source; | |
67 | ||
74b2466e LP |
68 | LIST_HEAD(DnsServer, dns_servers); |
69 | DnsServer *current_dns_server; | |
70 | ||
71 | LIST_HEAD(DnsScope, dns_scopes); | |
72 | DnsScope *unicast_scope; | |
73 | ||
1716f6dc LP |
74 | /* LLMNR */ |
75 | int llmnr_ipv4_udp_fd; | |
76 | int llmnr_ipv6_udp_fd; | |
623a4c97 LP |
77 | int llmnr_ipv4_tcp_fd; |
78 | int llmnr_ipv6_tcp_fd; | |
1716f6dc LP |
79 | |
80 | sd_event_source *llmnr_ipv4_udp_event_source; | |
81 | sd_event_source *llmnr_ipv6_udp_event_source; | |
623a4c97 LP |
82 | sd_event_source *llmnr_ipv4_tcp_event_source; |
83 | sd_event_source *llmnr_ipv6_tcp_event_source; | |
1716f6dc | 84 | |
74b2466e LP |
85 | /* dbus */ |
86 | sd_bus *bus; | |
87 | sd_event_source *bus_retry_event_source; | |
623a4c97 LP |
88 | |
89 | /* The hostname we publish on LLMNR and mDNS */ | |
90 | char *hostname; | |
91 | DnsResourceKey *host_ipv4_key; | |
92 | DnsResourceKey *host_ipv6_key; | |
091a364c TG |
93 | }; |
94 | ||
95 | /* Manager */ | |
96 | ||
97 | int manager_new(Manager **ret); | |
74b2466e LP |
98 | Manager* manager_free(Manager *m); |
99 | ||
100 | int manager_parse_config_file(Manager *m); | |
101 | int manager_write_resolv_conf(Manager *m); | |
102 | ||
623a4c97 | 103 | DnsServer* manager_find_dns_server(Manager *m, int family, const union in_addr_union *in_addr); |
74b2466e LP |
104 | DnsServer *manager_get_dns_server(Manager *m); |
105 | void manager_next_dns_server(Manager *m); | |
ec2c5e43 | 106 | |
e1c95994 | 107 | uint32_t manager_find_mtu(Manager *m); |
091a364c | 108 | |
623a4c97 | 109 | int manager_send(Manager *m, int fd, int ifindex, int family, const union in_addr_union *addr, uint16_t port, DnsPacket *p); |
1716f6dc | 110 | int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret); |
74b2466e | 111 | |
1716f6dc | 112 | int manager_dns_ipv4_fd(Manager *m); |
74b2466e | 113 | int manager_dns_ipv6_fd(Manager *m); |
1716f6dc LP |
114 | int manager_llmnr_ipv4_udp_fd(Manager *m); |
115 | int manager_llmnr_ipv6_udp_fd(Manager *m); | |
623a4c97 LP |
116 | int manager_llmnr_ipv4_tcp_fd(Manager *m); |
117 | int manager_llmnr_ipv6_tcp_fd(Manager *m); | |
118 | ||
119 | int manager_ifindex_is_loopback(Manager *m, int ifindex); | |
120 | int manager_find_ifindex(Manager *m, int family, const union in_addr_union *in_addr); | |
ec2c5e43 LP |
121 | LinkAddress* manager_find_address(Manager *m, int family, const union in_addr_union *in_addr); |
122 | ||
123 | int manager_next_hostname(Manager *m); | |
74b2466e | 124 | |
ec2c5e43 | 125 | int manager_our_packet(Manager *m, DnsPacket *p); |
74b2466e | 126 | int manager_connect_bus(Manager *m); |
091a364c TG |
127 | |
128 | DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free); | |
091a364c TG |
129 | |
130 | const struct ConfigPerfItem* resolved_gperf_lookup(const char *key, unsigned length); | |
74b2466e | 131 | int config_parse_dnsv(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); |
623a4c97 LP |
132 | |
133 | #define EXTRA_CMSG_SPACE 1024 |