]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/resolved-dns-scope.h
Merge pull request #3540 from poettering/resolved-various
[thirdparty/systemd.git] / src / resolve / resolved-dns-scope.h
1 #pragma once
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2014 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include "list.h"
23
24 typedef struct DnsScope DnsScope;
25
26 #include "resolved-dns-cache.h"
27 #include "resolved-dns-dnssec.h"
28 #include "resolved-dns-packet.h"
29 #include "resolved-dns-server.h"
30 #include "resolved-dns-zone.h"
31 #include "resolved-link.h"
32
33 typedef enum DnsScopeMatch {
34 DNS_SCOPE_NO,
35 DNS_SCOPE_MAYBE,
36 DNS_SCOPE_YES,
37 _DNS_SCOPE_MATCH_MAX,
38 _DNS_SCOPE_INVALID = -1
39 } DnsScopeMatch;
40
41 struct DnsScope {
42 Manager *manager;
43
44 DnsProtocol protocol;
45 int family;
46 DnssecMode dnssec_mode;
47
48 Link *link;
49
50 DnsCache cache;
51 DnsZone zone;
52
53 OrderedHashmap *conflict_queue;
54 sd_event_source *conflict_event_source;
55
56 RateLimit ratelimit;
57
58 usec_t resend_timeout;
59 usec_t max_rtt;
60
61 LIST_HEAD(DnsQueryCandidate, query_candidates);
62
63 /* Note that we keep track of ongoing transactions in two
64 * ways: once in a hashmap, indexed by the rr key, and once in
65 * a linked list. We use the hashmap to quickly find
66 * transactions we can reuse for a key. But note that there
67 * might be multiple transactions for the same key (because
68 * the zone probing can't reuse a transaction answered from
69 * the zone or the cache), and the hashmap only tracks the
70 * most recent entry. */
71 Hashmap *transactions_by_key;
72 LIST_HEAD(DnsTransaction, transactions);
73
74 LIST_FIELDS(DnsScope, scopes);
75 };
76
77 int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, int family);
78 DnsScope* dns_scope_free(DnsScope *s);
79
80 void dns_scope_packet_received(DnsScope *s, usec_t rtt);
81 void dns_scope_packet_lost(DnsScope *s, usec_t usec);
82
83 int dns_scope_emit_udp(DnsScope *s, int fd, DnsPacket *p);
84 int dns_scope_socket_tcp(DnsScope *s, int family, const union in_addr_union *address, DnsServer *server, uint16_t port);
85 int dns_scope_socket_udp(DnsScope *s, DnsServer *server, uint16_t port);
86
87 DnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, const char *domain);
88 bool dns_scope_good_key(DnsScope *s, const DnsResourceKey *key);
89
90 DnsServer *dns_scope_get_dns_server(DnsScope *s);
91 void dns_scope_next_dns_server(DnsScope *s);
92
93 int dns_scope_llmnr_membership(DnsScope *s, bool b);
94 int dns_scope_mdns_membership(DnsScope *s, bool b);
95
96 void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p);
97
98 DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, bool cache_ok);
99
100 int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr);
101 void dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p);
102
103 void dns_scope_dump(DnsScope *s, FILE *f);
104
105 DnsSearchDomain *dns_scope_get_search_domains(DnsScope *s);
106
107 bool dns_scope_name_needs_search_domain(DnsScope *s, const char *name);
108
109 bool dns_scope_network_good(DnsScope *s);
110
111 int dns_scope_ifindex(DnsScope *s);