1 /* SPDX-License-Identifier: LGPL-2.1+ */
8 typedef struct DnsQueryCandidate DnsQueryCandidate
;
9 typedef struct DnsQuery DnsQuery
;
11 #include "resolved-dns-answer.h"
12 #include "resolved-dns-question.h"
13 #include "resolved-dns-stream.h"
14 #include "resolved-dns-search-domain.h"
16 struct DnsQueryCandidate
{
20 DnsSearchDomain
*search_domain
;
25 LIST_FIELDS(DnsQueryCandidate
, candidates_by_query
);
26 LIST_FIELDS(DnsQueryCandidate
, candidates_by_scope
);
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
;
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
;
51 /* If true, A or AAAA RR lookups will be suppressed on links with no routable address of the matching address
53 bool suppress_unroutable_family
;
55 /* If true, the RR TTLs of the answer will be clamped by their current left validity in the cache */
58 DnsTransactionState state
;
59 unsigned n_cname_redirects
;
61 LIST_HEAD(DnsQueryCandidate
, candidates
);
62 sd_event_source
*timeout_event_source
;
67 DnssecResult answer_dnssec_result
;
68 bool answer_authenticated
;
69 DnsProtocol answer_protocol
;
71 DnsSearchDomain
*answer_search_domain
;
72 int answer_errno
; /* if state is DNS_TRANSACTION_ERRNO */
73 bool previous_redirect_unauthenticated
;
75 /* Bus client information */
76 sd_bus_message
*request
;
78 bool request_address_valid
;
79 union in_addr_union request_address
;
80 unsigned block_all_complete
;
81 char *request_address_string
;
83 /* DNS stub information */
84 DnsPacket
*request_dns_packet
;
85 DnsStream
*request_dns_stream
;
86 DnsPacket
*reply_dns_packet
;
88 /* Completion callback */
89 void (*complete
)(DnsQuery
* q
);
92 sd_bus_track
*bus_track
;
94 LIST_FIELDS(DnsQuery
, queries
);
95 LIST_FIELDS(DnsQuery
, auxiliary_queries
);
104 DnsQueryCandidate
* dns_query_candidate_free(DnsQueryCandidate
*c
);
105 void dns_query_candidate_notify(DnsQueryCandidate
*c
);
107 int dns_query_new(Manager
*m
, DnsQuery
**q
, DnsQuestion
*question_utf8
, DnsQuestion
*question_idna
, int family
, uint64_t flags
);
108 DnsQuery
*dns_query_free(DnsQuery
*q
);
110 int dns_query_make_auxiliary(DnsQuery
*q
, DnsQuery
*auxiliary_for
);
112 int dns_query_go(DnsQuery
*q
);
113 void dns_query_ready(DnsQuery
*q
);
115 int dns_query_process_cname(DnsQuery
*q
);
117 int dns_query_bus_track(DnsQuery
*q
, sd_bus_message
*m
);
119 DnsQuestion
* dns_query_question_for_protocol(DnsQuery
*q
, DnsProtocol protocol
);
121 const char *dns_query_string(DnsQuery
*q
);
123 DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery
*, dns_query_free
);
125 bool dns_query_fully_authenticated(DnsQuery
*q
);