]>
Commit | Line | Data |
---|---|---|
52ad194e | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
5eef597e MP |
2 | #pragma once |
3 | ||
5eef597e MP |
4 | #include "list.h" |
5 | ||
6 | typedef struct DnsScope DnsScope; | |
7 | ||
5eef597e | 8 | #include "resolved-dns-cache.h" |
4c89c718 MP |
9 | #include "resolved-dns-dnssec.h" |
10 | #include "resolved-dns-packet.h" | |
8a584da2 MP |
11 | #include "resolved-dns-query.h" |
12 | #include "resolved-dns-search-domain.h" | |
4c89c718 | 13 | #include "resolved-dns-server.h" |
8a584da2 | 14 | #include "resolved-dns-stream.h" |
5eef597e | 15 | #include "resolved-dns-zone.h" |
5eef597e MP |
16 | #include "resolved-link.h" |
17 | ||
18 | typedef enum DnsScopeMatch { | |
19 | DNS_SCOPE_NO, | |
20 | DNS_SCOPE_MAYBE, | |
6e866b33 MB |
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, | |
5eef597e | 23 | _DNS_SCOPE_MATCH_MAX, |
6e866b33 | 24 | _DNS_SCOPE_MATCH_INVALID = -1 |
5eef597e MP |
25 | } DnsScopeMatch; |
26 | ||
27 | struct DnsScope { | |
28 | Manager *manager; | |
29 | ||
30 | DnsProtocol protocol; | |
31 | int family; | |
6e866b33 MB |
32 | |
33 | /* Copied at scope creation time from the link/manager */ | |
4c89c718 | 34 | DnssecMode dnssec_mode; |
b012e921 | 35 | DnsOverTlsMode dns_over_tls_mode; |
5eef597e MP |
36 | |
37 | Link *link; | |
38 | ||
5eef597e MP |
39 | DnsCache cache; |
40 | DnsZone zone; | |
41 | ||
42 | OrderedHashmap *conflict_queue; | |
43 | sd_event_source *conflict_event_source; | |
44 | ||
2897b343 MP |
45 | bool announced:1; |
46 | sd_event_source *announce_event_source; | |
47 | ||
5eef597e MP |
48 | RateLimit ratelimit; |
49 | ||
13d276d0 MP |
50 | usec_t resend_timeout; |
51 | usec_t max_rtt; | |
52 | ||
4c89c718 MP |
53 | LIST_HEAD(DnsQueryCandidate, query_candidates); |
54 | ||
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); | |
5eef597e MP |
65 | |
66 | LIST_FIELDS(DnsScope, scopes); | |
67 | }; | |
68 | ||
69 | int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, int family); | |
70 | DnsScope* dns_scope_free(DnsScope *s); | |
71 | ||
13d276d0 MP |
72 | void dns_scope_packet_received(DnsScope *s, usec_t rtt); |
73 | void dns_scope_packet_lost(DnsScope *s, usec_t usec); | |
74 | ||
4c89c718 | 75 | int dns_scope_emit_udp(DnsScope *s, int fd, DnsPacket *p); |
b012e921 | 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); |
4c89c718 | 77 | int dns_scope_socket_udp(DnsScope *s, DnsServer *server, uint16_t port); |
5eef597e MP |
78 | |
79 | DnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, const char *domain); | |
4c89c718 | 80 | bool dns_scope_good_key(DnsScope *s, const DnsResourceKey *key); |
5eef597e MP |
81 | |
82 | DnsServer *dns_scope_get_dns_server(DnsScope *s); | |
52ad194e | 83 | unsigned dns_scope_get_n_dns_servers(DnsScope *s); |
5eef597e MP |
84 | void dns_scope_next_dns_server(DnsScope *s); |
85 | ||
86 | int dns_scope_llmnr_membership(DnsScope *s, bool b); | |
4c89c718 | 87 | int dns_scope_mdns_membership(DnsScope *s, bool b); |
5eef597e | 88 | |
2897b343 | 89 | int dns_scope_make_reply_packet(DnsScope *s, uint16_t id, int rcode, DnsQuestion *q, DnsAnswer *answer, DnsAnswer *soa, bool tentative, DnsPacket **ret); |
5eef597e MP |
90 | void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p); |
91 | ||
13d276d0 | 92 | DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, bool cache_ok); |
5eef597e MP |
93 | |
94 | int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr); | |
95 | void dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p); | |
13d276d0 MP |
96 | |
97 | void dns_scope_dump(DnsScope *s, FILE *f); | |
4c89c718 MP |
98 | |
99 | DnsSearchDomain *dns_scope_get_search_domains(DnsScope *s); | |
100 | ||
101 | bool dns_scope_name_needs_search_domain(DnsScope *s, const char *name); | |
102 | ||
103 | bool dns_scope_network_good(DnsScope *s); | |
5a920b42 MP |
104 | |
105 | int dns_scope_ifindex(DnsScope *s); | |
2897b343 MP |
106 | |
107 | int dns_scope_announce(DnsScope *scope, bool goodbye); | |
52ad194e MB |
108 | |
109 | int dns_scope_add_dnssd_services(DnsScope *scope); | |
52ad194e | 110 | int dns_scope_remove_dnssd_services(DnsScope *scope); |
6e866b33 MB |
111 | |
112 | bool dns_scope_is_default_route(DnsScope *scope); |