]> git.ipfire.org Git - thirdparty/systemd.git/blame_incremental - src/resolve/resolved-dns-scope.h
ci: enable arm64 runner for build/unit jobs
[thirdparty/systemd.git] / src / resolve / resolved-dns-scope.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2#pragma once
3
4#include "dns-def.h"
5#include "forward.h"
6#include "list.h"
7#include "ratelimit.h"
8#include "resolve-util.h"
9#include "resolved-dns-cache.h"
10#include "resolved-dns-packet.h"
11#include "resolved-dns-zone.h"
12#include "resolved-forward.h"
13
14typedef enum DnsScopeMatch {
15 DNS_SCOPE_NO,
16 DNS_SCOPE_LAST_RESORT,
17 DNS_SCOPE_MAYBE,
18 DNS_SCOPE_YES_BASE, /* Add the number of matching labels to this */
19 DNS_SCOPE_YES_END = DNS_SCOPE_YES_BASE + DNS_N_LABELS_MAX,
20 _DNS_SCOPE_MATCH_MAX,
21 _DNS_SCOPE_MATCH_INVALID = -EINVAL,
22} DnsScopeMatch;
23
24typedef enum DnsScopeOrigin {
25 DNS_SCOPE_GLOBAL,
26 DNS_SCOPE_LINK,
27 DNS_SCOPE_DELEGATE,
28 _DNS_SCOPE_ORIGIN_MAX,
29 _DNS_SCOPE_ORIGIN_INVALID = -EINVAL,
30} DnsScopeOrigin;
31
32typedef struct DnsScope {
33 Manager *manager;
34
35 DnsScopeOrigin origin;
36
37 DnsProtocol protocol;
38 int family;
39
40 /* Copied at scope creation time from the link/manager */
41 DnssecMode dnssec_mode;
42 DnsOverTlsMode dns_over_tls_mode;
43
44 Link *link;
45 DnsDelegate *delegate;
46
47 DnsCache cache;
48 DnsZone zone;
49
50 OrderedHashmap *conflict_queue;
51 sd_event_source *conflict_event_source;
52
53 sd_event_source *announce_event_source;
54
55 sd_event_source *mdns_goodbye_event_source;
56
57 RateLimit ratelimit;
58
59 usec_t resend_timeout;
60 usec_t max_rtt;
61
62 LIST_HEAD(DnsQueryCandidate, query_candidates);
63
64 /* Note that we keep track of ongoing transactions in two ways: once in a hashmap, indexed by the rr
65 * key, and once in a linked list. We use the hashmap to quickly find transactions we can reuse for a
66 * key. But note that there might be multiple transactions for the same key (because the associated
67 * query flags might differ in incompatible ways: e.g. we may not reuse a non-validating transaction
68 * as validating. Hence we maintain a per-key list of transactions, which we iterate through to find
69 * one we can reuse with matching flags. */
70 Hashmap *transactions_by_key;
71 LIST_HEAD(DnsTransaction, transactions);
72
73 LIST_FIELDS(DnsScope, scopes);
74
75 bool announced;
76} DnsScope;
77
78int dns_scope_new(Manager *m, DnsScope **ret, DnsScopeOrigin origin, Link *link, DnsDelegate *delegate, DnsProtocol protocol, int family);
79DnsScope* dns_scope_free(DnsScope *s);
80
81void dns_scope_packet_received(DnsScope *s, usec_t rtt);
82void dns_scope_packet_lost(DnsScope *s, usec_t usec);
83
84int dns_scope_emit_udp(DnsScope *s, int fd, int af, DnsPacket *p);
85int 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);
86int dns_scope_socket_udp(DnsScope *s, DnsServer *server);
87
88DnsScopeMatch dns_scope_good_domain(DnsScope *s, DnsQuery *q, uint64_t query_flags);
89bool dns_scope_good_key(DnsScope *s, const DnsResourceKey *key);
90
91DnsServer *dns_scope_get_dns_server(DnsScope *s);
92unsigned dns_scope_get_n_dns_servers(DnsScope *s);
93void dns_scope_next_dns_server(DnsScope *s, DnsServer *if_current);
94
95int dns_scope_llmnr_membership(DnsScope *s, bool b);
96int dns_scope_mdns_membership(DnsScope *s, bool b);
97
98int dns_scope_make_reply_packet(DnsScope *s, uint16_t id, int rcode, DnsQuestion *q, DnsAnswer *answer, DnsAnswer *soa, bool tentative, DnsPacket **ret);
99void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p);
100
101DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, uint64_t query_flags);
102
103int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr);
104void dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p);
105
106void dns_scope_dump(DnsScope *s, FILE *f);
107
108DnsSearchDomain *dns_scope_get_search_domains(DnsScope *s);
109
110bool dns_scope_name_wants_search_domain(DnsScope *s, const char *name);
111
112bool dns_scope_network_good(DnsScope *s);
113
114int dns_scope_ifindex(DnsScope *s);
115const char* dns_scope_ifname(DnsScope *s);
116
117int dns_scope_announce(DnsScope *scope, bool goodbye);
118
119int dns_scope_add_dnssd_services(DnsScope *scope);
120int dns_scope_remove_dnssd_services(DnsScope *scope);
121
122bool dns_scope_is_default_route(DnsScope *scope);
123
124int dns_scope_dump_cache_to_json(DnsScope *scope, sd_json_variant **ret);
125
126int dns_type_suitable_for_protocol(uint16_t type, DnsProtocol protocol);
127int dns_question_types_suitable_for_protocol(DnsQuestion *q, DnsProtocol protocol);
128
129const char* dns_scope_origin_to_string(DnsScopeOrigin origin) _const_;
130DnsScopeOrigin dns_scope_origin_from_string(const char *s) _pure_;