]>
Commit | Line | Data |
---|---|---|
74b2466e LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | #pragma once | |
4 | ||
5 | /*** | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2014 Lennart Poettering | |
9 | ||
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. | |
14 | ||
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. | |
19 | ||
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/>. | |
22 | ***/ | |
23 | ||
74b2466e LP |
24 | |
25 | #include "sd-bus.h" | |
71d35b6b | 26 | |
faa133f3 | 27 | #include "set.h" |
74b2466e | 28 | |
801ad6a6 | 29 | typedef struct DnsQueryCandidate DnsQueryCandidate; |
74b2466e | 30 | typedef struct DnsQuery DnsQuery; |
74b2466e | 31 | |
faa133f3 | 32 | #include "resolved-dns-answer.h" |
71d35b6b | 33 | #include "resolved-dns-question.h" |
623a4c97 | 34 | #include "resolved-dns-stream.h" |
801ad6a6 LP |
35 | #include "resolved-dns-search-domain.h" |
36 | ||
37 | struct DnsQueryCandidate { | |
38 | DnsQuery *query; | |
39 | DnsScope *scope; | |
40 | ||
41 | DnsSearchDomain *search_domain; | |
42 | ||
43 | int error_code; | |
44 | Set *transactions; | |
45 | ||
46 | LIST_FIELDS(DnsQueryCandidate, candidates_by_query); | |
47 | LIST_FIELDS(DnsQueryCandidate, candidates_by_scope); | |
48 | }; | |
74b2466e LP |
49 | |
50 | struct DnsQuery { | |
51 | Manager *manager; | |
45ec7efb LP |
52 | |
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; | |
60 | int auxiliary_result; | |
61 | ||
23b298bc LP |
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; | |
68 | ||
51323288 LP |
69 | uint64_t flags; |
70 | int ifindex; | |
71 | ||
ec2c5e43 | 72 | DnsTransactionState state; |
faa133f3 | 73 | unsigned n_cname_redirects; |
74b2466e | 74 | |
801ad6a6 | 75 | LIST_HEAD(DnsQueryCandidate, candidates); |
74b2466e LP |
76 | sd_event_source *timeout_event_source; |
77 | ||
322345fd | 78 | /* Discovered data */ |
faa133f3 | 79 | DnsAnswer *answer; |
faa133f3 | 80 | int answer_rcode; |
019036a4 LP |
81 | DnssecResult answer_dnssec_result; |
82 | bool answer_authenticated; | |
ae6a4bbf LP |
83 | DnsProtocol answer_protocol; |
84 | int answer_family; | |
801ad6a6 | 85 | DnsSearchDomain *answer_search_domain; |
7cc6ed7b | 86 | int answer_errno; /* if state is DNS_TRANSACTION_ERRNO */ |
74b2466e | 87 | |
8ba9fd9c | 88 | /* Bus client information */ |
74b2466e | 89 | sd_bus_message *request; |
0dd25fb9 | 90 | int request_family; |
45ec7efb | 91 | bool request_address_valid; |
74b2466e | 92 | union in_addr_union request_address; |
45ec7efb | 93 | unsigned block_all_complete; |
23b298bc | 94 | char *request_address_string; |
74b2466e | 95 | |
322345fd | 96 | /* Completion callback */ |
74b2466e | 97 | void (*complete)(DnsQuery* q); |
faa133f3 LP |
98 | unsigned block_ready; |
99 | ||
82bd6ddd LP |
100 | sd_bus_track *bus_track; |
101 | ||
74b2466e | 102 | LIST_FIELDS(DnsQuery, queries); |
45ec7efb | 103 | LIST_FIELDS(DnsQuery, auxiliary_queries); |
74b2466e LP |
104 | }; |
105 | ||
7588460a TG |
106 | enum { |
107 | DNS_QUERY_MATCH, | |
108 | DNS_QUERY_NOMATCH, | |
109 | DNS_QUERY_RESTARTED, | |
110 | }; | |
111 | ||
801ad6a6 | 112 | DnsQueryCandidate* dns_query_candidate_free(DnsQueryCandidate *c); |
547973de | 113 | void dns_query_candidate_notify(DnsQueryCandidate *c); |
801ad6a6 | 114 | |
23b298bc | 115 | int dns_query_new(Manager *m, DnsQuery **q, DnsQuestion *question_utf8, DnsQuestion *question_idna, int family, uint64_t flags); |
74b2466e | 116 | DnsQuery *dns_query_free(DnsQuery *q); |
322345fd | 117 | |
45ec7efb LP |
118 | int dns_query_make_auxiliary(DnsQuery *q, DnsQuery *auxiliary_for); |
119 | ||
322345fd | 120 | int dns_query_go(DnsQuery *q); |
faa133f3 | 121 | void dns_query_ready(DnsQuery *q); |
74b2466e | 122 | |
45ec7efb | 123 | int dns_query_process_cname(DnsQuery *q); |
74b2466e | 124 | |
966c66e3 | 125 | int dns_query_bus_track(DnsQuery *q, sd_bus_message *m); |
82bd6ddd | 126 | |
23b298bc LP |
127 | DnsQuestion* dns_query_question_for_protocol(DnsQuery *q, DnsProtocol protocol); |
128 | ||
129 | const char *dns_query_string(DnsQuery *q); | |
130 | ||
74b2466e | 131 | DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free); |