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/>.
29 typedef struct DnsQuery DnsQuery;
30 typedef struct DnsQueryTransaction DnsQueryTransaction;
33 #include "resolved-dns-scope.h"
34 #include "resolved-dns-rr.h"
35 #include "resolved-dns-packet.h"
37 typedef enum DnsQueryState {
44 DNS_QUERY_ATTEMPTS_MAX,
45 DNS_QUERY_INVALID_REPLY,
49 struct DnsQueryTransaction {
56 sd_event_source *timeout_event_source;
59 DnsPacket *sent, *received;
61 /* TCP connection logic */
63 sd_event_source *tcp_event_source;
64 size_t tcp_written, tcp_read;
67 LIST_FIELDS(DnsQueryTransaction, transactions_by_query);
68 LIST_FIELDS(DnsQueryTransaction, transactions_by_scope);
80 sd_event_source *timeout_event_source;
84 /* Bus client information */
85 sd_bus_message *request;
86 unsigned char request_family;
87 const char *request_hostname;
88 union in_addr_union request_address;
90 void (*complete)(DnsQuery* q);
92 LIST_HEAD(DnsQueryTransaction, transactions);
93 LIST_FIELDS(DnsQuery, queries);
96 int dns_query_new(Manager *m, DnsQuery **q, DnsResourceKey *keys, unsigned n_keys);
97 DnsQuery *dns_query_free(DnsQuery *q);
98 int dns_query_start(DnsQuery *q);
99 int dns_query_follow_cname(DnsQuery *q, const char *name);
100 int dns_query_matches_rr(DnsQuery *q, DnsResourceRecord *rr);
101 int dns_query_matches_cname(DnsQuery *q, DnsResourceRecord *rr);
103 DnsQueryTransaction* dns_query_transaction_free(DnsQueryTransaction *t);
104 void dns_query_transaction_reply(DnsQueryTransaction *t, DnsPacket *p);
105 void dns_query_finish(DnsQuery *q);
107 DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free);