]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/resolved-dns-scope.h
resolved: rename_DNS_SCOPE_INVALID → _DNS_SCOPE_MATCH_INVALID
[thirdparty/systemd.git] / src / resolve / resolved-dns-scope.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include "list.h"
5
6 typedef struct DnsScope DnsScope;
7
8 #include "resolved-dns-cache.h"
9 #include "resolved-dns-dnssec.h"
10 #include "resolved-dns-packet.h"
11 #include "resolved-dns-query.h"
12 #include "resolved-dns-search-domain.h"
13 #include "resolved-dns-server.h"
14 #include "resolved-dns-stream.h"
15 #include "resolved-dns-zone.h"
16 #include "resolved-link.h"
17
18 typedef enum DnsScopeMatch {
19 DNS_SCOPE_NO,
20 DNS_SCOPE_MAYBE,
21 DNS_SCOPE_YES,
22 _DNS_SCOPE_MATCH_MAX,
23 _DNS_SCOPE_MATCH_INVALID = -1
24 } DnsScopeMatch;
25
26 struct DnsScope {
27 Manager *manager;
28
29 DnsProtocol protocol;
30 int family;
31 DnssecMode dnssec_mode;
32 DnsOverTlsMode dns_over_tls_mode;
33
34 Link *link;
35
36 DnsCache cache;
37 DnsZone zone;
38
39 OrderedHashmap *conflict_queue;
40 sd_event_source *conflict_event_source;
41
42 bool announced:1;
43 sd_event_source *announce_event_source;
44
45 RateLimit ratelimit;
46
47 usec_t resend_timeout;
48 usec_t max_rtt;
49
50 LIST_HEAD(DnsQueryCandidate, query_candidates);
51
52 /* Note that we keep track of ongoing transactions in two
53 * ways: once in a hashmap, indexed by the rr key, and once in
54 * a linked list. We use the hashmap to quickly find
55 * transactions we can reuse for a key. But note that there
56 * might be multiple transactions for the same key (because
57 * the zone probing can't reuse a transaction answered from
58 * the zone or the cache), and the hashmap only tracks the
59 * most recent entry. */
60 Hashmap *transactions_by_key;
61 LIST_HEAD(DnsTransaction, transactions);
62
63 LIST_FIELDS(DnsScope, scopes);
64 };
65
66 int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, int family);
67 DnsScope* dns_scope_free(DnsScope *s);
68
69 void dns_scope_packet_received(DnsScope *s, usec_t rtt);
70 void dns_scope_packet_lost(DnsScope *s, usec_t usec);
71
72 int dns_scope_emit_udp(DnsScope *s, int fd, DnsPacket *p);
73 int dns_scope_socket_tcp(DnsScope *s, int family, const union in_addr_union *address, DnsServer *server, uint16_t port, union sockaddr_union *ret_socket_address);
74 int dns_scope_socket_udp(DnsScope *s, DnsServer *server, uint16_t port);
75
76 DnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, const char *domain);
77 bool dns_scope_good_key(DnsScope *s, const DnsResourceKey *key);
78
79 DnsServer *dns_scope_get_dns_server(DnsScope *s);
80 unsigned dns_scope_get_n_dns_servers(DnsScope *s);
81 void dns_scope_next_dns_server(DnsScope *s);
82
83 int dns_scope_llmnr_membership(DnsScope *s, bool b);
84 int dns_scope_mdns_membership(DnsScope *s, bool b);
85
86 int dns_scope_make_reply_packet(DnsScope *s, uint16_t id, int rcode, DnsQuestion *q, DnsAnswer *answer, DnsAnswer *soa, bool tentative, DnsPacket **ret);
87 void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p);
88
89 DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, bool cache_ok);
90
91 int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr);
92 void dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p);
93
94 void dns_scope_dump(DnsScope *s, FILE *f);
95
96 DnsSearchDomain *dns_scope_get_search_domains(DnsScope *s);
97
98 bool dns_scope_name_needs_search_domain(DnsScope *s, const char *name);
99
100 bool dns_scope_network_good(DnsScope *s);
101
102 int dns_scope_ifindex(DnsScope *s);
103
104 int dns_scope_announce(DnsScope *scope, bool goodbye);
105
106 int dns_scope_add_dnssd_services(DnsScope *scope);
107
108 int dns_scope_remove_dnssd_services(DnsScope *scope);