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