]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
74b2466e LP |
2 | #pragma once |
3 | ||
74b2466e LP |
4 | #include "list.h" |
5 | ||
6 | typedef struct DnsScope DnsScope; | |
7 | ||
322345fd | 8 | #include "resolved-dns-cache.h" |
24710c48 | 9 | #include "resolved-dns-dnssec.h" |
71d35b6b | 10 | #include "resolved-dns-packet.h" |
07f264e4 DM |
11 | #include "resolved-dns-query.h" |
12 | #include "resolved-dns-search-domain.h" | |
71d35b6b | 13 | #include "resolved-dns-server.h" |
07f264e4 | 14 | #include "resolved-dns-stream.h" |
623a4c97 | 15 | #include "resolved-dns-zone.h" |
39d8db04 | 16 | #include "resolved-link.h" |
74b2466e | 17 | |
74b2466e LP |
18 | typedef enum DnsScopeMatch { |
19 | DNS_SCOPE_NO, | |
20 | DNS_SCOPE_MAYBE, | |
a97a3b25 LP |
21 | DNS_SCOPE_YES_BASE, /* Add the number of matching labels to this */ |
22 | DNS_SCOPE_YES_END = DNS_SCOPE_YES_BASE + DNS_N_LABELS_MAX, | |
74b2466e | 23 | _DNS_SCOPE_MATCH_MAX, |
2bfdd6dc | 24 | _DNS_SCOPE_MATCH_INVALID = -1 |
74b2466e LP |
25 | } DnsScopeMatch; |
26 | ||
27 | struct DnsScope { | |
28 | Manager *manager; | |
29 | ||
1716f6dc | 30 | DnsProtocol protocol; |
0dd25fb9 | 31 | int family; |
89307df3 LP |
32 | |
33 | /* Copied at scope creation time from the link/manager */ | |
24710c48 | 34 | DnssecMode dnssec_mode; |
c9299be2 | 35 | DnsOverTlsMode dns_over_tls_mode; |
74b2466e LP |
36 | |
37 | Link *link; | |
38 | ||
322345fd | 39 | DnsCache cache; |
623a4c97 | 40 | DnsZone zone; |
322345fd | 41 | |
1e43061b | 42 | OrderedHashmap *conflict_queue; |
a4076574 LP |
43 | sd_event_source *conflict_event_source; |
44 | ||
53fda2bb DR |
45 | bool announced:1; |
46 | sd_event_source *announce_event_source; | |
47 | ||
aea2429d LP |
48 | RateLimit ratelimit; |
49 | ||
9df3ba6c TG |
50 | usec_t resend_timeout; |
51 | usec_t max_rtt; | |
52 | ||
801ad6a6 | 53 | LIST_HEAD(DnsQueryCandidate, query_candidates); |
74b2466e | 54 | |
f9ebb22a LP |
55 | /* Note that we keep track of ongoing transactions in two |
56 | * ways: once in a hashmap, indexed by the rr key, and once in | |
57 | * a linked list. We use the hashmap to quickly find | |
58 | * transactions we can reuse for a key. But note that there | |
59 | * might be multiple transactions for the same key (because | |
60 | * the zone probing can't reuse a transaction answered from | |
61 | * the zone or the cache), and the hashmap only tracks the | |
62 | * most recent entry. */ | |
63 | Hashmap *transactions_by_key; | |
64 | LIST_HEAD(DnsTransaction, transactions); | |
65 | ||
74b2466e LP |
66 | LIST_FIELDS(DnsScope, scopes); |
67 | }; | |
68 | ||
0dd25fb9 | 69 | int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, int family); |
74b2466e LP |
70 | DnsScope* dns_scope_free(DnsScope *s); |
71 | ||
9df3ba6c TG |
72 | void dns_scope_packet_received(DnsScope *s, usec_t rtt); |
73 | void dns_scope_packet_lost(DnsScope *s, usec_t usec); | |
74 | ||
519ef046 | 75 | int dns_scope_emit_udp(DnsScope *s, int fd, DnsPacket *p); |
91ccab1e | 76 | 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); |
519ef046 | 77 | int dns_scope_socket_udp(DnsScope *s, DnsServer *server, uint16_t port); |
ad867662 | 78 | |
51323288 | 79 | DnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, const char *domain); |
011696f7 | 80 | bool dns_scope_good_key(DnsScope *s, const DnsResourceKey *key); |
74b2466e | 81 | |
2c27fbca | 82 | DnsServer *dns_scope_get_dns_server(DnsScope *s); |
44db02d0 | 83 | unsigned dns_scope_get_n_dns_servers(DnsScope *s); |
74b2466e | 84 | void dns_scope_next_dns_server(DnsScope *s); |
1716f6dc LP |
85 | |
86 | int dns_scope_llmnr_membership(DnsScope *s, bool b); | |
0db4c90a | 87 | int dns_scope_mdns_membership(DnsScope *s, bool b); |
623a4c97 | 88 | |
3b991089 | 89 | int dns_scope_make_reply_packet(DnsScope *s, uint16_t id, int rcode, DnsQuestion *q, DnsAnswer *answer, DnsAnswer *soa, bool tentative, DnsPacket **ret); |
623a4c97 | 90 | void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p); |
ec2c5e43 | 91 | |
f52e61da | 92 | DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, bool cache_ok); |
a4076574 LP |
93 | |
94 | int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr); | |
95 | void dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p); | |
4d506d6b LP |
96 | |
97 | void dns_scope_dump(DnsScope *s, FILE *f); | |
a51c1048 LP |
98 | |
99 | DnsSearchDomain *dns_scope_get_search_domains(DnsScope *s); | |
801ad6a6 | 100 | |
dc477e73 | 101 | bool dns_scope_name_needs_search_domain(DnsScope *s, const char *name); |
edbcc1fd LP |
102 | |
103 | bool dns_scope_network_good(DnsScope *s); | |
97ebebbc LP |
104 | |
105 | int dns_scope_ifindex(DnsScope *s); | |
53fda2bb | 106 | |
1a63fc54 | 107 | int dns_scope_announce(DnsScope *scope, bool goodbye); |
6db6a464 DR |
108 | |
109 | int dns_scope_add_dnssd_services(DnsScope *scope); | |
6db6a464 | 110 | int dns_scope_remove_dnssd_services(DnsScope *scope); |
f76fa088 | 111 | |
ca5394d2 | 112 | bool dns_scope_is_default_route(DnsScope *scope); |