]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/resolved-dns-scope.h
resolved: cache stringified transaction key once per transaction
[thirdparty/systemd.git] / src / resolve / resolved-dns-scope.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6 This file is part of systemd.
7
8 Copyright 2014 Lennart Poettering
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
24 #include "list.h"
25
26 typedef struct DnsScope DnsScope;
27
28 #include "resolved-dns-cache.h"
29 #include "resolved-dns-dnssec.h"
30 #include "resolved-dns-packet.h"
31 #include "resolved-dns-server.h"
32 #include "resolved-dns-zone.h"
33 #include "resolved-link.h"
34
35 typedef enum DnsScopeMatch {
36 DNS_SCOPE_NO,
37 DNS_SCOPE_MAYBE,
38 DNS_SCOPE_YES,
39 _DNS_SCOPE_MATCH_MAX,
40 _DNS_SCOPE_INVALID = -1
41 } DnsScopeMatch;
42
43 struct DnsScope {
44 Manager *manager;
45
46 DnsProtocol protocol;
47 int family;
48 DnssecMode dnssec_mode;
49
50 Link *link;
51
52 DnsCache cache;
53 DnsZone zone;
54
55 OrderedHashmap *conflict_queue;
56 sd_event_source *conflict_event_source;
57
58 RateLimit ratelimit;
59
60 usec_t resend_timeout;
61 usec_t max_rtt;
62
63 LIST_HEAD(DnsQueryCandidate, query_candidates);
64
65 /* Note that we keep track of ongoing transactions in two
66 * ways: once in a hashmap, indexed by the rr key, and once in
67 * a linked list. We use the hashmap to quickly find
68 * transactions we can reuse for a key. But note that there
69 * might be multiple transactions for the same key (because
70 * the zone probing can't reuse a transaction answered from
71 * the zone or the cache), and the hashmap only tracks the
72 * most recent entry. */
73 Hashmap *transactions_by_key;
74 LIST_HEAD(DnsTransaction, transactions);
75
76 LIST_FIELDS(DnsScope, scopes);
77 };
78
79 int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, int family);
80 DnsScope* dns_scope_free(DnsScope *s);
81
82 void dns_scope_packet_received(DnsScope *s, usec_t rtt);
83 void dns_scope_packet_lost(DnsScope *s, usec_t usec);
84
85 int dns_scope_emit(DnsScope *s, int fd, DnsServer *server, DnsPacket *p);
86 int dns_scope_tcp_socket(DnsScope *s, int family, const union in_addr_union *address, uint16_t port, DnsServer **server);
87 int dns_scope_udp_dns_socket(DnsScope *s, DnsServer **server);
88
89 DnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, const char *domain);
90 int dns_scope_good_key(DnsScope *s, DnsResourceKey *key);
91
92 DnsServer *dns_scope_get_dns_server(DnsScope *s);
93 void dns_scope_next_dns_server(DnsScope *s);
94
95 int dns_scope_llmnr_membership(DnsScope *s, bool b);
96 int dns_scope_mdns_membership(DnsScope *s, bool b);
97
98 void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p);
99
100 DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, bool cache_ok);
101
102 int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr);
103 void dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p);
104
105 void dns_scope_dump(DnsScope *s, FILE *f);
106
107 DnsSearchDomain *dns_scope_get_search_domains(DnsScope *s);
108
109 bool dns_scope_name_needs_search_domain(DnsScope *s, const char *name);