]>
Commit | Line | Data |
---|---|---|
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 | ||
24 | ||
25 | #include "sd-bus.h" | |
26 | ||
27 | #include "set.h" | |
28 | ||
29 | typedef struct DnsQueryCandidate DnsQueryCandidate; | |
30 | typedef struct DnsQuery DnsQuery; | |
31 | ||
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" | |
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 | }; | |
49 | ||
50 | struct DnsQuery { | |
51 | Manager *manager; | |
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 | ||
62 | DnsQuestion *question; | |
63 | uint64_t flags; | |
64 | int ifindex; | |
65 | ||
66 | DnsTransactionState state; | |
67 | unsigned n_cname_redirects; | |
68 | ||
69 | LIST_HEAD(DnsQueryCandidate, candidates); | |
70 | sd_event_source *timeout_event_source; | |
71 | ||
72 | /* Discovered data */ | |
73 | DnsAnswer *answer; | |
74 | int answer_rcode; | |
75 | DnsProtocol answer_protocol; | |
76 | int answer_family; | |
77 | DnsSearchDomain *answer_search_domain; | |
78 | bool answer_authenticated; | |
79 | ||
80 | /* Bus client information */ | |
81 | sd_bus_message *request; | |
82 | int request_family; | |
83 | bool request_address_valid; | |
84 | union in_addr_union request_address; | |
85 | unsigned block_all_complete; | |
86 | ||
87 | /* Completion callback */ | |
88 | void (*complete)(DnsQuery* q); | |
89 | unsigned block_ready; | |
90 | ||
91 | sd_bus_track *bus_track; | |
92 | ||
93 | LIST_FIELDS(DnsQuery, queries); | |
94 | LIST_FIELDS(DnsQuery, auxiliary_queries); | |
95 | }; | |
96 | ||
97 | DnsQueryCandidate* dns_query_candidate_free(DnsQueryCandidate *c); | |
98 | void dns_query_candidate_notify(DnsQueryCandidate *c); | |
99 | ||
100 | int dns_query_new(Manager *m, DnsQuery **q, DnsQuestion *question, int family, uint64_t flags); | |
101 | DnsQuery *dns_query_free(DnsQuery *q); | |
102 | ||
103 | int dns_query_make_auxiliary(DnsQuery *q, DnsQuery *auxiliary_for); | |
104 | ||
105 | int dns_query_go(DnsQuery *q); | |
106 | void dns_query_ready(DnsQuery *q); | |
107 | ||
108 | int dns_query_process_cname(DnsQuery *q); | |
109 | ||
110 | int dns_query_bus_track(DnsQuery *q, sd_bus_message *m); | |
111 | ||
112 | DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free); |