]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-dns-transaction.h
machine-id-setup: don't try to read UUID from VM/container manager if we operate...
[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;
26
27enum 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-scope.h"
43#include "resolved-dns-rr.h"
44#include "resolved-dns-packet.h"
45#include "resolved-dns-question.h"
46#include "resolved-dns-answer.h"
47#include "resolved-dns-stream.h"
48
49struct DnsTransaction {
50 DnsScope *scope;
51
52 DnsQuestion *question;
53
54 DnsTransactionState state;
55 uint16_t id;
56
6e068472
LP
57 bool initial_jitter;
58
ec2c5e43
LP
59 DnsPacket *sent, *received;
60 DnsAnswer *cached;
61 int cached_rcode;
62
63 sd_event_source *timeout_event_source;
64 unsigned n_attempts;
65
66 /* TCP connection logic, if we need it */
67 DnsStream *stream;
68
69 /* Queries this transaction is referenced by and that shall be
70 * notified about this specific transaction completing. */
71 Set *queries;
72
73 /* Zone items this transaction is referenced by and that shall
74 * be notified about completion. */
75 Set *zone_items;
76
77 unsigned block_gc;
78
79 LIST_FIELDS(DnsTransaction, transactions_by_scope);
80};
81
82int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsQuestion *q);
83DnsTransaction* dns_transaction_free(DnsTransaction *t);
84
85void dns_transaction_gc(DnsTransaction *t);
86int dns_transaction_go(DnsTransaction *t);
87
88void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p);
89void dns_transaction_complete(DnsTransaction *t, DnsTransactionState state);
90
91const char* dns_transaction_state_to_string(DnsTransactionState p) _const_;
92DnsTransactionState dns_transaction_state_from_string(const char *s) _pure_;
93
94/* After how much time to repeat classic DNS requests */
95#define DNS_TRANSACTION_TIMEOUT_USEC (5 * USEC_PER_SEC)
96
97/* After how much time to repeat LLMNR requests, see RFC 4795 Section 7 */
98#define LLMNR_TRANSACTION_TIMEOUT_USEC (1 * USEC_PER_SEC)
99
100/* LLMNR Jitter interval, see RFC 4795 Section 7 */
6e068472 101#define LLMNR_JITTER_INTERVAL_USEC (100 * USEC_PER_MSEC)
ec2c5e43
LP
102
103/* Maximum attempts to send DNS requests, across all DNS servers */
104#define DNS_TRANSACTION_ATTEMPTS_MAX 8
105
106/* Maximum attempts to send LLMNR requests, see RFC 4795 Section 2.7 */
107#define LLMNR_TRANSACTION_ATTEMPTS_MAX 3
108
109#define TRANSACTION_TIMEOUT_USEC(p) (p == DNS_PROTOCOL_LLMNR ? LLMNR_TRANSACTION_TIMEOUT_USEC : DNS_TRANSACTION_TIMEOUT_USEC)
110#define TRANSACTION_ATTEMPTS_MAX(p) (p == DNS_PROTOCOL_LLMNR ? LLMNR_TRANSACTION_ATTEMPTS_MAX : DNS_TRANSACTION_ATTEMPTS_MAX)