]>
Commit | Line | Data |
---|---|---|
5eef597e MP |
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 | ||
5eef597e MP |
22 | |
23 | #include "sd-bus.h" | |
4c89c718 | 24 | |
5eef597e MP |
25 | #include "set.h" |
26 | ||
4c89c718 | 27 | typedef struct DnsQueryCandidate DnsQueryCandidate; |
5eef597e MP |
28 | typedef struct DnsQuery DnsQuery; |
29 | ||
5eef597e | 30 | #include "resolved-dns-answer.h" |
4c89c718 | 31 | #include "resolved-dns-question.h" |
5eef597e | 32 | #include "resolved-dns-stream.h" |
4c89c718 MP |
33 | #include "resolved-dns-search-domain.h" |
34 | ||
35 | struct 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 | }; | |
5eef597e MP |
47 | |
48 | struct DnsQuery { | |
49 | Manager *manager; | |
4c89c718 MP |
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 | ||
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; | |
5eef597e MP |
66 | |
67 | uint64_t flags; | |
68 | int ifindex; | |
69 | ||
4c89c718 MP |
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 | ||
5eef597e MP |
74 | DnsTransactionState state; |
75 | unsigned n_cname_redirects; | |
76 | ||
4c89c718 | 77 | LIST_HEAD(DnsQueryCandidate, candidates); |
5eef597e MP |
78 | sd_event_source *timeout_event_source; |
79 | ||
80 | /* Discovered data */ | |
81 | DnsAnswer *answer; | |
5eef597e | 82 | int answer_rcode; |
4c89c718 MP |
83 | DnssecResult answer_dnssec_result; |
84 | bool answer_authenticated; | |
85 | DnsProtocol answer_protocol; | |
86 | int answer_family; | |
87 | DnsSearchDomain *answer_search_domain; | |
88 | int answer_errno; /* if state is DNS_TRANSACTION_ERRNO */ | |
5eef597e MP |
89 | |
90 | /* Bus client information */ | |
91 | sd_bus_message *request; | |
92 | int request_family; | |
4c89c718 | 93 | bool request_address_valid; |
5eef597e | 94 | union in_addr_union request_address; |
4c89c718 MP |
95 | unsigned block_all_complete; |
96 | char *request_address_string; | |
5eef597e MP |
97 | |
98 | /* Completion callback */ | |
99 | void (*complete)(DnsQuery* q); | |
100 | unsigned block_ready; | |
101 | ||
5eef597e MP |
102 | sd_bus_track *bus_track; |
103 | ||
104 | LIST_FIELDS(DnsQuery, queries); | |
4c89c718 | 105 | LIST_FIELDS(DnsQuery, auxiliary_queries); |
5eef597e MP |
106 | }; |
107 | ||
4c89c718 MP |
108 | enum { |
109 | DNS_QUERY_MATCH, | |
110 | DNS_QUERY_NOMATCH, | |
111 | DNS_QUERY_RESTARTED, | |
112 | }; | |
113 | ||
114 | DnsQueryCandidate* dns_query_candidate_free(DnsQueryCandidate *c); | |
115 | void dns_query_candidate_notify(DnsQueryCandidate *c); | |
116 | ||
117 | int dns_query_new(Manager *m, DnsQuery **q, DnsQuestion *question_utf8, DnsQuestion *question_idna, int family, uint64_t flags); | |
5eef597e MP |
118 | DnsQuery *dns_query_free(DnsQuery *q); |
119 | ||
4c89c718 MP |
120 | int dns_query_make_auxiliary(DnsQuery *q, DnsQuery *auxiliary_for); |
121 | ||
5eef597e MP |
122 | int dns_query_go(DnsQuery *q); |
123 | void dns_query_ready(DnsQuery *q); | |
124 | ||
4c89c718 | 125 | int dns_query_process_cname(DnsQuery *q); |
5eef597e | 126 | |
e3bff60a | 127 | int dns_query_bus_track(DnsQuery *q, sd_bus_message *m); |
5eef597e | 128 | |
4c89c718 MP |
129 | DnsQuestion* dns_query_question_for_protocol(DnsQuery *q, DnsProtocol protocol); |
130 | ||
131 | const char *dns_query_string(DnsQuery *q); | |
132 | ||
5eef597e | 133 | DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free); |