4 This file is part of systemd.
6 Copyright 2014 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
27 typedef struct DnsQueryCandidate DnsQueryCandidate
;
28 typedef struct DnsQuery DnsQuery
;
30 #include "resolved-dns-answer.h"
31 #include "resolved-dns-question.h"
32 #include "resolved-dns-stream.h"
33 #include "resolved-dns-search-domain.h"
35 struct DnsQueryCandidate
{
39 DnsSearchDomain
*search_domain
;
44 LIST_FIELDS(DnsQueryCandidate
, candidates_by_query
);
45 LIST_FIELDS(DnsQueryCandidate
, candidates_by_scope
);
51 /* When resolving a service, we first create a TXT+SRV query,
52 * and then for the hostnames we discover auxiliary A+AAAA
53 * queries. This pointer always points from the auxiliary
54 * queries back to the TXT+SRV query. */
55 DnsQuery
*auxiliary_for
;
56 LIST_HEAD(DnsQuery
, auxiliary_queries
);
57 unsigned n_auxiliary_queries
;
60 /* The question, formatted in IDNA for use on classic DNS, and as UTF8 for use in LLMNR or mDNS. Note that even
61 * on classic DNS some labels might use UTF8 encoding. Specifically, DNS-SD service names (in contrast to their
62 * domain suffixes) use UTF-8 encoding even on DNS. Thus, the difference between these two fields is mostly
63 * relevant only for explicit *hostname* lookups as well as the domain suffixes of service lookups. */
64 DnsQuestion
*question_idna
;
65 DnsQuestion
*question_utf8
;
70 /* If true, A or AAAA RR lookups will be suppressed on links with no routable address of the matching address
72 bool suppress_unroutable_family
;
74 /* If true, the RR TTLs of the answer will be clamped by their current left validity in the cache */
77 DnsTransactionState state
;
78 unsigned n_cname_redirects
;
80 LIST_HEAD(DnsQueryCandidate
, candidates
);
81 sd_event_source
*timeout_event_source
;
86 DnssecResult answer_dnssec_result
;
87 bool answer_authenticated
;
88 DnsProtocol answer_protocol
;
90 DnsSearchDomain
*answer_search_domain
;
91 int answer_errno
; /* if state is DNS_TRANSACTION_ERRNO */
92 bool previous_redirect_unauthenticated
;
94 /* Bus client information */
95 sd_bus_message
*request
;
97 bool request_address_valid
;
98 union in_addr_union request_address
;
99 unsigned block_all_complete
;
100 char *request_address_string
;
102 /* DNS stub information */
103 DnsPacket
*request_dns_packet
;
104 DnsStream
*request_dns_stream
;
105 DnsPacket
*reply_dns_packet
;
107 /* Completion callback */
108 void (*complete
)(DnsQuery
* q
);
109 unsigned block_ready
;
111 sd_bus_track
*bus_track
;
113 LIST_FIELDS(DnsQuery
, queries
);
114 LIST_FIELDS(DnsQuery
, auxiliary_queries
);
123 DnsQueryCandidate
* dns_query_candidate_free(DnsQueryCandidate
*c
);
124 void dns_query_candidate_notify(DnsQueryCandidate
*c
);
126 int dns_query_new(Manager
*m
, DnsQuery
**q
, DnsQuestion
*question_utf8
, DnsQuestion
*question_idna
, int family
, uint64_t flags
);
127 DnsQuery
*dns_query_free(DnsQuery
*q
);
129 int dns_query_make_auxiliary(DnsQuery
*q
, DnsQuery
*auxiliary_for
);
131 int dns_query_go(DnsQuery
*q
);
132 void dns_query_ready(DnsQuery
*q
);
134 int dns_query_process_cname(DnsQuery
*q
);
136 int dns_query_bus_track(DnsQuery
*q
, sd_bus_message
*m
);
138 DnsQuestion
* dns_query_question_for_protocol(DnsQuery
*q
, DnsProtocol protocol
);
140 const char *dns_query_string(DnsQuery
*q
);
142 DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery
*, dns_query_free
);
144 bool dns_query_fully_authenticated(DnsQuery
*q
);