]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-dns-query.h
Merge pull request #7388 from keszybz/doc-tweak
[thirdparty/systemd.git] / src / resolve / resolved-dns-query.h
CommitLineData
74b2466e
LP
1#pragma once
2
3/***
4 This file is part of systemd.
5
6 Copyright 2014 Lennart Poettering
7
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.
12
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.
17
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/>.
20***/
21
74b2466e
LP
22
23#include "sd-bus.h"
71d35b6b 24
faa133f3 25#include "set.h"
74b2466e 26
801ad6a6 27typedef struct DnsQueryCandidate DnsQueryCandidate;
74b2466e 28typedef struct DnsQuery DnsQuery;
74b2466e 29
faa133f3 30#include "resolved-dns-answer.h"
71d35b6b 31#include "resolved-dns-question.h"
623a4c97 32#include "resolved-dns-stream.h"
801ad6a6
LP
33#include "resolved-dns-search-domain.h"
34
35struct DnsQueryCandidate {
36 DnsQuery *query;
37 DnsScope *scope;
38
39 DnsSearchDomain *search_domain;
40
41 int error_code;
42 Set *transactions;
43
44 LIST_FIELDS(DnsQueryCandidate, candidates_by_query);
45 LIST_FIELDS(DnsQueryCandidate, candidates_by_scope);
46};
74b2466e
LP
47
48struct DnsQuery {
49 Manager *manager;
45ec7efb
LP
50
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;
58 int auxiliary_result;
59
23b298bc
LP
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;
66
51323288
LP
67 uint64_t flags;
68 int ifindex;
69
011696f7
LP
70 /* If true, A or AAAA RR lookups will be suppressed on links with no routable address of the matching address
71 * family */
72 bool suppress_unroutable_family;
73
17c8de63
LP
74 /* If true, the RR TTLs of the answer will be clamped by their current left validity in the cache */
75 bool clamp_ttl;
76
ec2c5e43 77 DnsTransactionState state;
faa133f3 78 unsigned n_cname_redirects;
74b2466e 79
801ad6a6 80 LIST_HEAD(DnsQueryCandidate, candidates);
74b2466e
LP
81 sd_event_source *timeout_event_source;
82
322345fd 83 /* Discovered data */
faa133f3 84 DnsAnswer *answer;
faa133f3 85 int answer_rcode;
019036a4
LP
86 DnssecResult answer_dnssec_result;
87 bool answer_authenticated;
ae6a4bbf
LP
88 DnsProtocol answer_protocol;
89 int answer_family;
801ad6a6 90 DnsSearchDomain *answer_search_domain;
7cc6ed7b 91 int answer_errno; /* if state is DNS_TRANSACTION_ERRNO */
28830a64 92 bool previous_redirect_unauthenticated;
74b2466e 93
8ba9fd9c 94 /* Bus client information */
74b2466e 95 sd_bus_message *request;
0dd25fb9 96 int request_family;
45ec7efb 97 bool request_address_valid;
74b2466e 98 union in_addr_union request_address;
45ec7efb 99 unsigned block_all_complete;
23b298bc 100 char *request_address_string;
74b2466e 101
b30bf55d
LP
102 /* DNS stub information */
103 DnsPacket *request_dns_packet;
104 DnsStream *request_dns_stream;
e8d23f92 105 DnsPacket *reply_dns_packet;
b30bf55d 106
322345fd 107 /* Completion callback */
74b2466e 108 void (*complete)(DnsQuery* q);
faa133f3
LP
109 unsigned block_ready;
110
82bd6ddd
LP
111 sd_bus_track *bus_track;
112
74b2466e 113 LIST_FIELDS(DnsQuery, queries);
45ec7efb 114 LIST_FIELDS(DnsQuery, auxiliary_queries);
74b2466e
LP
115};
116
7588460a
TG
117enum {
118 DNS_QUERY_MATCH,
119 DNS_QUERY_NOMATCH,
120 DNS_QUERY_RESTARTED,
121};
122
801ad6a6 123DnsQueryCandidate* dns_query_candidate_free(DnsQueryCandidate *c);
547973de 124void dns_query_candidate_notify(DnsQueryCandidate *c);
801ad6a6 125
23b298bc 126int dns_query_new(Manager *m, DnsQuery **q, DnsQuestion *question_utf8, DnsQuestion *question_idna, int family, uint64_t flags);
74b2466e 127DnsQuery *dns_query_free(DnsQuery *q);
322345fd 128
45ec7efb
LP
129int dns_query_make_auxiliary(DnsQuery *q, DnsQuery *auxiliary_for);
130
322345fd 131int dns_query_go(DnsQuery *q);
faa133f3 132void dns_query_ready(DnsQuery *q);
74b2466e 133
45ec7efb 134int dns_query_process_cname(DnsQuery *q);
74b2466e 135
966c66e3 136int dns_query_bus_track(DnsQuery *q, sd_bus_message *m);
82bd6ddd 137
23b298bc
LP
138DnsQuestion* dns_query_question_for_protocol(DnsQuery *q, DnsProtocol protocol);
139
140const char *dns_query_string(DnsQuery *q);
141
74b2466e 142DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free);
28830a64
LP
143
144bool dns_query_fully_authenticated(DnsQuery *q);