1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2014 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
29 typedef struct DnsQueryCandidate DnsQueryCandidate
;
30 typedef struct DnsQuery DnsQuery
;
32 #include "resolved-dns-answer.h"
33 #include "resolved-dns-question.h"
34 #include "resolved-dns-stream.h"
35 #include "resolved-dns-search-domain.h"
37 struct DnsQueryCandidate
{
41 DnsSearchDomain
*search_domain
;
46 LIST_FIELDS(DnsQueryCandidate
, candidates_by_query
);
47 LIST_FIELDS(DnsQueryCandidate
, candidates_by_scope
);
53 /* When resolving a service, we first create a TXT+SRV query,
54 * and then for the hostnames we discover auxiliary A+AAAA
55 * queries. This pointer always points from the auxiliary
56 * queries back to the TXT+SRV query. */
57 DnsQuery
*auxiliary_for
;
58 LIST_HEAD(DnsQuery
, auxiliary_queries
);
59 unsigned n_auxiliary_queries
;
62 /* The question, formatted in IDNA for use on classic DNS, and as UTF8 for use in LLMNR or mDNS. Note that even
63 * on classic DNS some labels might use UTF8 encoding. Specifically, DNS-SD service names (in contrast to their
64 * domain suffixes) use UTF-8 encoding even on DNS. Thus, the difference between these two fields is mostly
65 * relevant only for explicit *hostname* lookups as well as the domain suffixes of service lookups. */
66 DnsQuestion
*question_idna
;
67 DnsQuestion
*question_utf8
;
72 /* If true, A or AAAA RR lookups will be suppressed on links with no routable address of the matching address
74 bool suppress_unroutable_family
;
76 DnsTransactionState state
;
77 unsigned n_cname_redirects
;
79 LIST_HEAD(DnsQueryCandidate
, candidates
);
80 sd_event_source
*timeout_event_source
;
85 DnssecResult answer_dnssec_result
;
86 bool answer_authenticated
;
87 DnsProtocol answer_protocol
;
89 DnsSearchDomain
*answer_search_domain
;
90 int answer_errno
; /* if state is DNS_TRANSACTION_ERRNO */
92 /* Bus client information */
93 sd_bus_message
*request
;
95 bool request_address_valid
;
96 union in_addr_union request_address
;
97 unsigned block_all_complete
;
98 char *request_address_string
;
100 /* Completion callback */
101 void (*complete
)(DnsQuery
* q
);
102 unsigned block_ready
;
104 sd_bus_track
*bus_track
;
106 LIST_FIELDS(DnsQuery
, queries
);
107 LIST_FIELDS(DnsQuery
, auxiliary_queries
);
116 DnsQueryCandidate
* dns_query_candidate_free(DnsQueryCandidate
*c
);
117 void dns_query_candidate_notify(DnsQueryCandidate
*c
);
119 int dns_query_new(Manager
*m
, DnsQuery
**q
, DnsQuestion
*question_utf8
, DnsQuestion
*question_idna
, int family
, uint64_t flags
);
120 DnsQuery
*dns_query_free(DnsQuery
*q
);
122 int dns_query_make_auxiliary(DnsQuery
*q
, DnsQuery
*auxiliary_for
);
124 int dns_query_go(DnsQuery
*q
);
125 void dns_query_ready(DnsQuery
*q
);
127 int dns_query_process_cname(DnsQuery
*q
);
129 int dns_query_bus_track(DnsQuery
*q
, sd_bus_message
*m
);
131 DnsQuestion
* dns_query_question_for_protocol(DnsQuery
*q
, DnsProtocol protocol
);
133 const char *dns_query_string(DnsQuery
*q
);
135 DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery
*, dns_query_free
);