]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-dns-transaction.h
Merge pull request #1945 from phomes/indentation-fix
[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"
ec2c5e43
LP
43#include "resolved-dns-packet.h"
44#include "resolved-dns-question.h"
45#include "resolved-dns-answer.h"
ec2c5e43
LP
46
47struct DnsTransaction {
48 DnsScope *scope;
49
f52e61da 50 DnsResourceKey *key;
ec2c5e43
LP
51
52 DnsTransactionState state;
53 uint16_t id;
54
6e068472
LP
55 bool initial_jitter;
56
ec2c5e43
LP
57 DnsPacket *sent, *received;
58 DnsAnswer *cached;
59 int cached_rcode;
60
9df3ba6c 61 usec_t start_usec;
ec2c5e43
LP
62 sd_event_source *timeout_event_source;
63 unsigned n_attempts;
64
4667e00a
LP
65 int dns_udp_fd;
66 sd_event_source *dns_udp_event_source;
d20b1667 67
4667e00a 68 /* The active server */
8300ba21
TG
69 DnsServer *server;
70
ec2c5e43
LP
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
f52e61da 87int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsResourceKey *key);
ec2c5e43
LP
88DnsTransaction* dns_transaction_free(DnsTransaction *t);
89
90void dns_transaction_gc(DnsTransaction *t);
91int dns_transaction_go(DnsTransaction *t);
92
93void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p);
94void dns_transaction_complete(DnsTransaction *t, DnsTransactionState state);
95
96const char* dns_transaction_state_to_string(DnsTransactionState p) _const_;
97DnsTransactionState dns_transaction_state_from_string(const char *s) _pure_;
98
ec2c5e43 99/* LLMNR Jitter interval, see RFC 4795 Section 7 */
6e068472 100#define LLMNR_JITTER_INTERVAL_USEC (100 * USEC_PER_MSEC)
ec2c5e43
LP
101
102/* Maximum attempts to send DNS requests, across all DNS servers */
3b31df83 103#define DNS_TRANSACTION_ATTEMPTS_MAX 16
ec2c5e43
LP
104
105/* Maximum attempts to send LLMNR requests, see RFC 4795 Section 2.7 */
106#define LLMNR_TRANSACTION_ATTEMPTS_MAX 3
107
ec2c5e43 108#define TRANSACTION_ATTEMPTS_MAX(p) (p == DNS_PROTOCOL_LLMNR ? LLMNR_TRANSACTION_ATTEMPTS_MAX : DNS_TRANSACTION_ATTEMPTS_MAX)