chiark / gitweb /
resolved: fix which return codes we check
[elogind.git] / src / resolve / resolved-dns-query.h
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 #include <inttypes.h>
25
26 #include "sd-bus.h"
27 #include "util.h"
28 #include "set.h"
29
30 typedef struct DnsQuery DnsQuery;
31
32 #include "resolved-dns-scope.h"
33 #include "resolved-dns-rr.h"
34 #include "resolved-dns-question.h"
35 #include "resolved-dns-answer.h"
36 #include "resolved-dns-stream.h"
37 #include "resolved-dns-transaction.h"
38 #include "resolved-manager.h"
39
40 struct DnsQuery {
41         Manager *manager;
42         DnsQuestion *question;
43
44         uint64_t flags;
45         int ifindex;
46
47         DnsTransactionState state;
48         unsigned n_cname_redirects;
49
50         sd_event_source *timeout_event_source;
51
52         /* Discovered data */
53         DnsAnswer *answer;
54         int answer_ifindex;
55         int answer_family;
56         DnsProtocol answer_protocol;
57         int answer_rcode;
58
59         /* Bus client information */
60         sd_bus_message *request;
61         int request_family;
62         const char *request_hostname;
63         union in_addr_union request_address;
64
65         /* Completion callback */
66         void (*complete)(DnsQuery* q);
67         unsigned block_ready;
68
69         Set *transactions;
70
71         sd_bus_track *bus_track;
72
73         LIST_FIELDS(DnsQuery, queries);
74 };
75
76 int dns_query_new(Manager *m, DnsQuery **q, DnsQuestion *question, int family, uint64_t flags);
77 DnsQuery *dns_query_free(DnsQuery *q);
78
79 int dns_query_go(DnsQuery *q);
80 void dns_query_ready(DnsQuery *q);
81
82 int dns_query_cname_redirect(DnsQuery *q, const char *name);
83
84 int dns_query_bus_track(DnsQuery *q, sd_bus *bus, sd_bus_message *m);
85
86 DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free);