]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
74b2466e LP |
2 | #pragma once |
3 | ||
74b2466e | 4 | #include "sd-bus.h" |
71d35b6b | 5 | |
faa133f3 | 6 | #include "set.h" |
74b2466e | 7 | |
801ad6a6 | 8 | typedef struct DnsQueryCandidate DnsQueryCandidate; |
74b2466e | 9 | typedef struct DnsQuery DnsQuery; |
74b2466e | 10 | |
faa133f3 | 11 | #include "resolved-dns-answer.h" |
71d35b6b | 12 | #include "resolved-dns-question.h" |
623a4c97 | 13 | #include "resolved-dns-stream.h" |
801ad6a6 LP |
14 | #include "resolved-dns-search-domain.h" |
15 | ||
16 | struct DnsQueryCandidate { | |
17 | DnsQuery *query; | |
18 | DnsScope *scope; | |
19 | ||
20 | DnsSearchDomain *search_domain; | |
21 | ||
22 | int error_code; | |
23 | Set *transactions; | |
24 | ||
25 | LIST_FIELDS(DnsQueryCandidate, candidates_by_query); | |
26 | LIST_FIELDS(DnsQueryCandidate, candidates_by_scope); | |
27 | }; | |
74b2466e LP |
28 | |
29 | struct DnsQuery { | |
30 | Manager *manager; | |
45ec7efb LP |
31 | |
32 | /* When resolving a service, we first create a TXT+SRV query, | |
33 | * and then for the hostnames we discover auxiliary A+AAAA | |
34 | * queries. This pointer always points from the auxiliary | |
35 | * queries back to the TXT+SRV query. */ | |
36 | DnsQuery *auxiliary_for; | |
37 | LIST_HEAD(DnsQuery, auxiliary_queries); | |
38 | unsigned n_auxiliary_queries; | |
39 | int auxiliary_result; | |
40 | ||
23b298bc LP |
41 | /* The question, formatted in IDNA for use on classic DNS, and as UTF8 for use in LLMNR or mDNS. Note that even |
42 | * on classic DNS some labels might use UTF8 encoding. Specifically, DNS-SD service names (in contrast to their | |
43 | * domain suffixes) use UTF-8 encoding even on DNS. Thus, the difference between these two fields is mostly | |
44 | * relevant only for explicit *hostname* lookups as well as the domain suffixes of service lookups. */ | |
45 | DnsQuestion *question_idna; | |
46 | DnsQuestion *question_utf8; | |
47 | ||
51323288 LP |
48 | uint64_t flags; |
49 | int ifindex; | |
50 | ||
011696f7 LP |
51 | /* If true, A or AAAA RR lookups will be suppressed on links with no routable address of the matching address |
52 | * family */ | |
53 | bool suppress_unroutable_family; | |
54 | ||
17c8de63 LP |
55 | /* If true, the RR TTLs of the answer will be clamped by their current left validity in the cache */ |
56 | bool clamp_ttl; | |
57 | ||
ec2c5e43 | 58 | DnsTransactionState state; |
faa133f3 | 59 | unsigned n_cname_redirects; |
74b2466e | 60 | |
801ad6a6 | 61 | LIST_HEAD(DnsQueryCandidate, candidates); |
74b2466e LP |
62 | sd_event_source *timeout_event_source; |
63 | ||
322345fd | 64 | /* Discovered data */ |
faa133f3 | 65 | DnsAnswer *answer; |
faa133f3 | 66 | int answer_rcode; |
019036a4 LP |
67 | DnssecResult answer_dnssec_result; |
68 | bool answer_authenticated; | |
ae6a4bbf LP |
69 | DnsProtocol answer_protocol; |
70 | int answer_family; | |
801ad6a6 | 71 | DnsSearchDomain *answer_search_domain; |
7cc6ed7b | 72 | int answer_errno; /* if state is DNS_TRANSACTION_ERRNO */ |
28830a64 | 73 | bool previous_redirect_unauthenticated; |
74b2466e | 74 | |
8ba9fd9c | 75 | /* Bus client information */ |
74b2466e | 76 | sd_bus_message *request; |
0dd25fb9 | 77 | int request_family; |
45ec7efb | 78 | bool request_address_valid; |
74b2466e | 79 | union in_addr_union request_address; |
45ec7efb | 80 | unsigned block_all_complete; |
23b298bc | 81 | char *request_address_string; |
74b2466e | 82 | |
b30bf55d LP |
83 | /* DNS stub information */ |
84 | DnsPacket *request_dns_packet; | |
85 | DnsStream *request_dns_stream; | |
e8d23f92 | 86 | DnsPacket *reply_dns_packet; |
b30bf55d | 87 | |
322345fd | 88 | /* Completion callback */ |
74b2466e | 89 | void (*complete)(DnsQuery* q); |
faa133f3 LP |
90 | unsigned block_ready; |
91 | ||
82bd6ddd LP |
92 | sd_bus_track *bus_track; |
93 | ||
74b2466e | 94 | LIST_FIELDS(DnsQuery, queries); |
45ec7efb | 95 | LIST_FIELDS(DnsQuery, auxiliary_queries); |
74b2466e LP |
96 | }; |
97 | ||
7588460a TG |
98 | enum { |
99 | DNS_QUERY_MATCH, | |
100 | DNS_QUERY_NOMATCH, | |
101 | DNS_QUERY_RESTARTED, | |
102 | }; | |
103 | ||
801ad6a6 | 104 | DnsQueryCandidate* dns_query_candidate_free(DnsQueryCandidate *c); |
547973de | 105 | void dns_query_candidate_notify(DnsQueryCandidate *c); |
801ad6a6 | 106 | |
23b298bc | 107 | int dns_query_new(Manager *m, DnsQuery **q, DnsQuestion *question_utf8, DnsQuestion *question_idna, int family, uint64_t flags); |
74b2466e | 108 | DnsQuery *dns_query_free(DnsQuery *q); |
322345fd | 109 | |
45ec7efb LP |
110 | int dns_query_make_auxiliary(DnsQuery *q, DnsQuery *auxiliary_for); |
111 | ||
322345fd | 112 | int dns_query_go(DnsQuery *q); |
faa133f3 | 113 | void dns_query_ready(DnsQuery *q); |
74b2466e | 114 | |
45ec7efb | 115 | int dns_query_process_cname(DnsQuery *q); |
74b2466e | 116 | |
966c66e3 | 117 | int dns_query_bus_track(DnsQuery *q, sd_bus_message *m); |
82bd6ddd | 118 | |
23b298bc LP |
119 | DnsQuestion* dns_query_question_for_protocol(DnsQuery *q, DnsProtocol protocol); |
120 | ||
121 | const char *dns_query_string(DnsQuery *q); | |
122 | ||
74b2466e | 123 | DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free); |
28830a64 LP |
124 | |
125 | bool dns_query_fully_authenticated(DnsQuery *q); |