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/>.
30 typedef struct DnsQuery DnsQuery;
31 typedef struct DnsQueryTransaction DnsQueryTransaction;
34 #include "resolved-dns-scope.h"
35 #include "resolved-dns-rr.h"
36 #include "resolved-dns-packet.h"
37 #include "resolved-dns-question.h"
38 #include "resolved-dns-answer.h"
40 typedef enum DnsQueryState {
47 DNS_QUERY_ATTEMPTS_MAX,
48 DNS_QUERY_INVALID_REPLY,
53 struct DnsQueryTransaction {
56 DnsQuestion *question;
61 DnsPacket *sent, *received;
65 sd_event_source *timeout_event_source;
68 /* TCP connection logic */
70 sd_event_source *tcp_event_source;
71 size_t tcp_written, tcp_read;
74 /* Queries this transaction is referenced by and that shall by
75 * notified about this specific transaction completing. */
80 LIST_FIELDS(DnsQueryTransaction, transactions_by_scope);
85 DnsQuestion *question;
88 unsigned n_cname_redirects;
90 sd_event_source *timeout_event_source;
97 /* Bus client information */
98 sd_bus_message *request;
100 const char *request_hostname;
101 union in_addr_union request_address;
103 /* Completion callback */
104 void (*complete)(DnsQuery* q);
105 unsigned block_ready;
109 LIST_FIELDS(DnsQuery, queries);
112 DnsQueryTransaction* dns_query_transaction_free(DnsQueryTransaction *t);
113 void dns_query_transaction_complete(DnsQueryTransaction *t, DnsQueryState state);
115 void dns_query_transaction_process_reply(DnsQueryTransaction *t, DnsPacket *p);
117 int dns_query_new(Manager *m, DnsQuery **q, DnsQuestion *question);
118 DnsQuery *dns_query_free(DnsQuery *q);
120 int dns_query_go(DnsQuery *q);
121 void dns_query_ready(DnsQuery *q);
123 int dns_query_cname_redirect(DnsQuery *q, const char *name);
125 DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free);