]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-dns-scope.h
man: fix typo 'ot' -> 'or'
[thirdparty/systemd.git] / src / resolve / resolved-dns-scope.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
74b2466e
LP
2#pragma once
3
74b2466e 4#include "list.h"
be28f72d 5#include "ratelimit.h"
74b2466e 6
be28f72d 7typedef struct DnsQueryCandidate DnsQueryCandidate;
74b2466e
LP
8typedef struct DnsScope DnsScope;
9
322345fd 10#include "resolved-dns-cache.h"
24710c48 11#include "resolved-dns-dnssec.h"
71d35b6b 12#include "resolved-dns-packet.h"
176a9a2c 13#include "resolved-dns-query.h"
07f264e4 14#include "resolved-dns-search-domain.h"
71d35b6b 15#include "resolved-dns-server.h"
07f264e4 16#include "resolved-dns-stream.h"
623a4c97 17#include "resolved-dns-zone.h"
74b2466e 18
74b2466e
LP
19typedef enum DnsScopeMatch {
20 DNS_SCOPE_NO,
da920fe1 21 DNS_SCOPE_LAST_RESORT,
74b2466e 22 DNS_SCOPE_MAYBE,
a97a3b25
LP
23 DNS_SCOPE_YES_BASE, /* Add the number of matching labels to this */
24 DNS_SCOPE_YES_END = DNS_SCOPE_YES_BASE + DNS_N_LABELS_MAX,
74b2466e 25 _DNS_SCOPE_MATCH_MAX,
2d93c20e 26 _DNS_SCOPE_MATCH_INVALID = -EINVAL,
74b2466e
LP
27} DnsScopeMatch;
28
29struct DnsScope {
30 Manager *manager;
31
1716f6dc 32 DnsProtocol protocol;
0dd25fb9 33 int family;
89307df3
LP
34
35 /* Copied at scope creation time from the link/manager */
24710c48 36 DnssecMode dnssec_mode;
c9299be2 37 DnsOverTlsMode dns_over_tls_mode;
74b2466e
LP
38
39 Link *link;
40
322345fd 41 DnsCache cache;
623a4c97 42 DnsZone zone;
322345fd 43
1e43061b 44 OrderedHashmap *conflict_queue;
a4076574
LP
45 sd_event_source *conflict_event_source;
46
53fda2bb
DR
47 sd_event_source *announce_event_source;
48
d08566fa
VCS
49 sd_event_source *mdns_goodbye_event_source;
50
aea2429d
LP
51 RateLimit ratelimit;
52
9df3ba6c
TG
53 usec_t resend_timeout;
54 usec_t max_rtt;
55
801ad6a6 56 LIST_HEAD(DnsQueryCandidate, query_candidates);
74b2466e 57
775ae354
LP
58 /* Note that we keep track of ongoing transactions in two ways: once in a hashmap, indexed by the rr
59 * key, and once in a linked list. We use the hashmap to quickly find transactions we can reuse for a
60 * key. But note that there might be multiple transactions for the same key (because the associated
61 * query flags might differ in incompatible ways: e.g. we may not reuse a non-validating transaction
62 * as validating. Hence we maintain a per-key list of transactions, which we iterate through to find
63 * one we can reuse with matching flags. */
f9ebb22a
LP
64 Hashmap *transactions_by_key;
65 LIST_HEAD(DnsTransaction, transactions);
66
74b2466e 67 LIST_FIELDS(DnsScope, scopes);
ebfdf45a
ZJS
68
69 bool announced;
74b2466e
LP
70};
71
0dd25fb9 72int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, int family);
74b2466e
LP
73DnsScope* dns_scope_free(DnsScope *s);
74
9df3ba6c
TG
75void dns_scope_packet_received(DnsScope *s, usec_t rtt);
76void dns_scope_packet_lost(DnsScope *s, usec_t usec);
77
d79677ab 78int dns_scope_emit_udp(DnsScope *s, int fd, int af, DnsPacket *p);
91ccab1e 79int 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);
da9de738 80int dns_scope_socket_udp(DnsScope *s, DnsServer *server);
ad867662 81
d0eae64c 82DnsScopeMatch dns_scope_good_domain(DnsScope *s, DnsQuery *q, uint64_t query_flags);
011696f7 83bool dns_scope_good_key(DnsScope *s, const DnsResourceKey *key);
74b2466e 84
2c27fbca 85DnsServer *dns_scope_get_dns_server(DnsScope *s);
44db02d0 86unsigned dns_scope_get_n_dns_servers(DnsScope *s);
5e8bc852 87void dns_scope_next_dns_server(DnsScope *s, DnsServer *if_current);
1716f6dc
LP
88
89int dns_scope_llmnr_membership(DnsScope *s, bool b);
0db4c90a 90int dns_scope_mdns_membership(DnsScope *s, bool b);
623a4c97 91
3b991089 92int dns_scope_make_reply_packet(DnsScope *s, uint16_t id, int rcode, DnsQuestion *q, DnsAnswer *answer, DnsAnswer *soa, bool tentative, DnsPacket **ret);
623a4c97 93void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p);
ec2c5e43 94
775ae354 95DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, uint64_t query_flags);
a4076574
LP
96
97int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr);
98void dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p);
4d506d6b
LP
99
100void dns_scope_dump(DnsScope *s, FILE *f);
a51c1048
LP
101
102DnsSearchDomain *dns_scope_get_search_domains(DnsScope *s);
801ad6a6 103
3b5bd7d6 104bool dns_scope_name_wants_search_domain(DnsScope *s, const char *name);
edbcc1fd
LP
105
106bool dns_scope_network_good(DnsScope *s);
97ebebbc
LP
107
108int dns_scope_ifindex(DnsScope *s);
53fda2bb 109
1a63fc54 110int dns_scope_announce(DnsScope *scope, bool goodbye);
6db6a464
DR
111
112int dns_scope_add_dnssd_services(DnsScope *scope);
6db6a464 113int dns_scope_remove_dnssd_services(DnsScope *scope);
f76fa088 114
ca5394d2 115bool dns_scope_is_default_route(DnsScope *scope);
e0930aa6
LP
116
117int dns_scope_dump_cache_to_json(DnsScope *scope, JsonVariant **ret);
8841d1ce
LP
118
119int dns_type_suitable_for_protocol(uint16_t type, DnsProtocol protocol);
120int dns_question_types_suitable_for_protocol(DnsQuestion *q, DnsProtocol protocol);