]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-dns-transaction.h
resolved: when synthesizing NODATA from cached NSEC bitmaps, honour CNAME/DNAME
[thirdparty/systemd.git] / src / resolve / resolved-dns-transaction.h
CommitLineData
ec2c5e43
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
24typedef struct DnsTransaction DnsTransaction;
25typedef enum DnsTransactionState DnsTransactionState;
c3bc53e6 26typedef enum DnsTransactionSource DnsTransactionSource;
ec2c5e43
LP
27
28enum DnsTransactionState {
29 DNS_TRANSACTION_NULL,
30 DNS_TRANSACTION_PENDING,
31 DNS_TRANSACTION_FAILURE,
32 DNS_TRANSACTION_SUCCESS,
33 DNS_TRANSACTION_NO_SERVERS,
34 DNS_TRANSACTION_TIMEOUT,
35 DNS_TRANSACTION_ATTEMPTS_MAX_REACHED,
36 DNS_TRANSACTION_INVALID_REPLY,
37 DNS_TRANSACTION_RESOURCES,
38 DNS_TRANSACTION_ABORTED,
39 _DNS_TRANSACTION_STATE_MAX,
40 _DNS_TRANSACTION_STATE_INVALID = -1
41};
42
c3bc53e6
LP
43enum DnsTransactionSource {
44 DNS_TRANSACTION_NETWORK,
45 DNS_TRANSACTION_CACHE,
46 DNS_TRANSACTION_ZONE,
0d2cd476 47 DNS_TRANSACTION_TRUST_ANCHOR,
c3bc53e6
LP
48 _DNS_TRANSACTION_SOURCE_MAX,
49 _DNS_TRANSACTION_SOURCE_INVALID = -1
50};
51
71d35b6b 52#include "resolved-dns-answer.h"
ec2c5e43
LP
53#include "resolved-dns-packet.h"
54#include "resolved-dns-question.h"
71d35b6b 55#include "resolved-dns-scope.h"
ec2c5e43
LP
56
57struct DnsTransaction {
58 DnsScope *scope;
59
f52e61da 60 DnsResourceKey *key;
ec2c5e43
LP
61
62 DnsTransactionState state;
63 uint16_t id;
64
6e068472
LP
65 bool initial_jitter;
66
ec2c5e43 67 DnsPacket *sent, *received;
ae6a4bbf
LP
68
69 DnsAnswer *answer;
70 int answer_rcode;
c3bc53e6 71 DnsTransactionSource answer_source;
ec2c5e43 72
9df3ba6c 73 usec_t start_usec;
ec2c5e43
LP
74 sd_event_source *timeout_event_source;
75 unsigned n_attempts;
76
4667e00a
LP
77 int dns_udp_fd;
78 sd_event_source *dns_udp_event_source;
d20b1667 79
4667e00a 80 /* The active server */
8300ba21
TG
81 DnsServer *server;
82
be808ea0
TG
83 /* the features of the DNS server at time of transaction start */
84 DnsServerFeatureLevel current_features;
85
ec2c5e43
LP
86 /* TCP connection logic, if we need it */
87 DnsStream *stream;
88
801ad6a6
LP
89 /* Query candidates this transaction is referenced by and that
90 * shall be notified about this specific transaction
91 * completing. */
92 Set *query_candidates;
ec2c5e43
LP
93
94 /* Zone items this transaction is referenced by and that shall
95 * be notified about completion. */
96 Set *zone_items;
97
98 unsigned block_gc;
99
100 LIST_FIELDS(DnsTransaction, transactions_by_scope);
101};
102
f52e61da 103int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsResourceKey *key);
ec2c5e43
LP
104DnsTransaction* dns_transaction_free(DnsTransaction *t);
105
106void dns_transaction_gc(DnsTransaction *t);
107int dns_transaction_go(DnsTransaction *t);
108
109void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p);
110void dns_transaction_complete(DnsTransaction *t, DnsTransactionState state);
111
112const char* dns_transaction_state_to_string(DnsTransactionState p) _const_;
113DnsTransactionState dns_transaction_state_from_string(const char *s) _pure_;
114
c3bc53e6
LP
115const char* dns_transaction_source_to_string(DnsTransactionSource p) _const_;
116DnsTransactionSource dns_transaction_source_from_string(const char *s) _pure_;
117
ec2c5e43 118/* LLMNR Jitter interval, see RFC 4795 Section 7 */
6e068472 119#define LLMNR_JITTER_INTERVAL_USEC (100 * USEC_PER_MSEC)
ec2c5e43
LP
120
121/* Maximum attempts to send DNS requests, across all DNS servers */
3b31df83 122#define DNS_TRANSACTION_ATTEMPTS_MAX 16
ec2c5e43
LP
123
124/* Maximum attempts to send LLMNR requests, see RFC 4795 Section 2.7 */
125#define LLMNR_TRANSACTION_ATTEMPTS_MAX 3
126
c3bc53e6 127#define TRANSACTION_ATTEMPTS_MAX(p) ((p) == DNS_PROTOCOL_LLMNR ? LLMNR_TRANSACTION_ATTEMPTS_MAX : DNS_TRANSACTION_ATTEMPTS_MAX)