]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/resolved-dns-transaction.h
question: drop dns_question_is_superset() which we don't use anymore
[thirdparty/systemd.git] / src / resolve / resolved-dns-transaction.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 typedef struct DnsTransaction DnsTransaction;
25 typedef enum DnsTransactionState DnsTransactionState;
26
27 enum DnsTransactionState {
28 DNS_TRANSACTION_NULL,
29 DNS_TRANSACTION_PENDING,
30 DNS_TRANSACTION_FAILURE,
31 DNS_TRANSACTION_SUCCESS,
32 DNS_TRANSACTION_NO_SERVERS,
33 DNS_TRANSACTION_TIMEOUT,
34 DNS_TRANSACTION_ATTEMPTS_MAX_REACHED,
35 DNS_TRANSACTION_INVALID_REPLY,
36 DNS_TRANSACTION_RESOURCES,
37 DNS_TRANSACTION_ABORTED,
38 _DNS_TRANSACTION_STATE_MAX,
39 _DNS_TRANSACTION_STATE_INVALID = -1
40 };
41
42 #include "resolved-dns-answer.h"
43 #include "resolved-dns-packet.h"
44 #include "resolved-dns-question.h"
45 #include "resolved-dns-scope.h"
46
47 struct DnsTransaction {
48 DnsScope *scope;
49
50 DnsResourceKey *key;
51
52 DnsTransactionState state;
53 uint16_t id;
54
55 bool initial_jitter;
56
57 DnsPacket *sent, *received;
58 DnsAnswer *cached;
59 int cached_rcode;
60
61 usec_t start_usec;
62 sd_event_source *timeout_event_source;
63 unsigned n_attempts;
64
65 int dns_udp_fd;
66 sd_event_source *dns_udp_event_source;
67
68 /* The active server */
69 DnsServer *server;
70
71 /* TCP connection logic, if we need it */
72 DnsStream *stream;
73
74 /* Queries this transaction is referenced by and that shall be
75 * notified about this specific transaction completing. */
76 Set *queries;
77
78 /* Zone items this transaction is referenced by and that shall
79 * be notified about completion. */
80 Set *zone_items;
81
82 unsigned block_gc;
83
84 LIST_FIELDS(DnsTransaction, transactions_by_scope);
85 };
86
87 int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsResourceKey *key);
88 DnsTransaction* dns_transaction_free(DnsTransaction *t);
89
90 void dns_transaction_gc(DnsTransaction *t);
91 int dns_transaction_go(DnsTransaction *t);
92
93 void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p);
94 void dns_transaction_complete(DnsTransaction *t, DnsTransactionState state);
95
96 const char* dns_transaction_state_to_string(DnsTransactionState p) _const_;
97 DnsTransactionState dns_transaction_state_from_string(const char *s) _pure_;
98
99 /* LLMNR Jitter interval, see RFC 4795 Section 7 */
100 #define LLMNR_JITTER_INTERVAL_USEC (100 * USEC_PER_MSEC)
101
102 /* Maximum attempts to send DNS requests, across all DNS servers */
103 #define DNS_TRANSACTION_ATTEMPTS_MAX 16
104
105 /* Maximum attempts to send LLMNR requests, see RFC 4795 Section 2.7 */
106 #define LLMNR_TRANSACTION_ATTEMPTS_MAX 3
107
108 #define TRANSACTION_ATTEMPTS_MAX(p) (p == DNS_PROTOCOL_LLMNR ? LLMNR_TRANSACTION_ATTEMPTS_MAX : DNS_TRANSACTION_ATTEMPTS_MAX)