]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-dns-query.h
resolved: add a DNS client stub resolver
[thirdparty/systemd.git] / src / resolve / resolved-dns-query.h
CommitLineData
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
24#include <inttypes.h>
25
26#include "sd-bus.h"
27#include "util.h"
28
29typedef struct DnsQuery DnsQuery;
30typedef struct DnsQueryTransaction DnsQueryTransaction;
31
32#include "resolved.h"
33#include "resolved-dns-scope.h"
34#include "resolved-dns-rr.h"
35#include "resolved-dns-packet.h"
36
37typedef enum DnsQueryState {
38 DNS_QUERY_NULL,
39 DNS_QUERY_SENT,
40 DNS_QUERY_FAILURE,
41 DNS_QUERY_SUCCESS,
42 DNS_QUERY_SKIPPED,
43 DNS_QUERY_TIMEOUT,
44 DNS_QUERY_ATTEMPTS_MAX,
45 DNS_QUERY_INVALID_REPLY,
46} DnsQueryState;
47
48struct DnsQueryTransaction {
49 DnsQuery *query;
50 DnsScope *scope;
51
52 DnsQueryState state;
53 uint16_t id;
54
55 sd_event_source *timeout_event_source;
56 unsigned n_attempts;
57
58 DnsPacket *packet;
59
60 LIST_FIELDS(DnsQueryTransaction, transactions_by_query);
61 LIST_FIELDS(DnsQueryTransaction, transactions_by_scope);
62};
63
64struct DnsQuery {
65 Manager *manager;
66
67 DnsResourceKey *keys;
68 unsigned n_keys;
69
70 DnsQueryState state;
71
72 sd_event_source *timeout_event_source;
73
74 uint16_t rcode;
75 DnsPacket *packet;
76
77 sd_bus_message *request;
78 unsigned char request_family;
79 const char *request_hostname;
80 union in_addr_union request_address;
81
82 void (*complete)(DnsQuery* q);
83
84 LIST_HEAD(DnsQueryTransaction, transactions);
85 LIST_FIELDS(DnsQuery, queries);
86};
87
88int dns_query_new(Manager *m, DnsQuery **q, DnsResourceKey *keys, unsigned n_keys);
89DnsQuery *dns_query_free(DnsQuery *q);
90int dns_query_start(DnsQuery *q);
91void dns_query_finish(DnsQuery *q);
92
93DnsQueryTransaction* dns_query_transaction_free(DnsQueryTransaction *t);
94int dns_query_transaction_start(DnsQueryTransaction *t);
95int dns_query_transaction_reply(DnsQueryTransaction *t, DnsPacket *p);
96
97DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free);