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