diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-07-31 17:46:40 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-07-31 17:47:19 +0200 |
commit | ec2c5e4398f9d65e5dfe61530f2556224733d1e6 (patch) | |
tree | 396107863c59c3e949f69f4a8050185c360b7f70 /src/resolve/resolved-dns-transaction.h | |
parent | b5df2eabf3fdd3e1663bc4c948812472084f3e96 (diff) |
resolved: implement LLMNR uniqueness verification
Diffstat (limited to 'src/resolve/resolved-dns-transaction.h')
-rw-r--r-- | src/resolve/resolved-dns-transaction.h | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/src/resolve/resolved-dns-transaction.h b/src/resolve/resolved-dns-transaction.h new file mode 100644 index 0000000000..d825b3ec85 --- /dev/null +++ b/src/resolve/resolved-dns-transaction.h @@ -0,0 +1,108 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +#pragma once + +/*** + This file is part of systemd. + + Copyright 2014 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see <http://www.gnu.org/licenses/>. +***/ + +typedef struct DnsTransaction DnsTransaction; +typedef enum DnsTransactionState DnsTransactionState; + +enum DnsTransactionState { + DNS_TRANSACTION_NULL, + DNS_TRANSACTION_PENDING, + DNS_TRANSACTION_FAILURE, + DNS_TRANSACTION_SUCCESS, + DNS_TRANSACTION_NO_SERVERS, + DNS_TRANSACTION_TIMEOUT, + DNS_TRANSACTION_ATTEMPTS_MAX_REACHED, + DNS_TRANSACTION_INVALID_REPLY, + DNS_TRANSACTION_RESOURCES, + DNS_TRANSACTION_ABORTED, + _DNS_TRANSACTION_STATE_MAX, + _DNS_TRANSACTION_STATE_INVALID = -1 +}; + +#include "resolved-dns-scope.h" +#include "resolved-dns-rr.h" +#include "resolved-dns-packet.h" +#include "resolved-dns-question.h" +#include "resolved-dns-answer.h" +#include "resolved-dns-stream.h" + +struct DnsTransaction { + DnsScope *scope; + + DnsQuestion *question; + + DnsTransactionState state; + uint16_t id; + + DnsPacket *sent, *received; + DnsAnswer *cached; + int cached_rcode; + + sd_event_source *timeout_event_source; + unsigned n_attempts; + + /* TCP connection logic, if we need it */ + DnsStream *stream; + + /* Queries this transaction is referenced by and that shall be + * notified about this specific transaction completing. */ + Set *queries; + + /* Zone items this transaction is referenced by and that shall + * be notified about completion. */ + Set *zone_items; + + unsigned block_gc; + + LIST_FIELDS(DnsTransaction, transactions_by_scope); +}; + +int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsQuestion *q); +DnsTransaction* dns_transaction_free(DnsTransaction *t); + +void dns_transaction_gc(DnsTransaction *t); +int dns_transaction_go(DnsTransaction *t); + +void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p); +void dns_transaction_complete(DnsTransaction *t, DnsTransactionState state); + +const char* dns_transaction_state_to_string(DnsTransactionState p) _const_; +DnsTransactionState dns_transaction_state_from_string(const char *s) _pure_; + +/* After how much time to repeat classic DNS requests */ +#define DNS_TRANSACTION_TIMEOUT_USEC (5 * USEC_PER_SEC) + +/* After how much time to repeat LLMNR requests, see RFC 4795 Section 7 */ +#define LLMNR_TRANSACTION_TIMEOUT_USEC (1 * USEC_PER_SEC) + +/* LLMNR Jitter interval, see RFC 4795 Section 7 */ +#define LLMNR_TRANSACTION_JITTER_INTERVAL_USEC (100 * USEC_PER_MSEC) + +/* Maximum attempts to send DNS requests, across all DNS servers */ +#define DNS_TRANSACTION_ATTEMPTS_MAX 8 + +/* Maximum attempts to send LLMNR requests, see RFC 4795 Section 2.7 */ +#define LLMNR_TRANSACTION_ATTEMPTS_MAX 3 + +#define TRANSACTION_TIMEOUT_USEC(p) (p == DNS_PROTOCOL_LLMNR ? LLMNR_TRANSACTION_TIMEOUT_USEC : DNS_TRANSACTION_TIMEOUT_USEC) +#define TRANSACTION_ATTEMPTS_MAX(p) (p == DNS_PROTOCOL_LLMNR ? LLMNR_TRANSACTION_ATTEMPTS_MAX : DNS_TRANSACTION_ATTEMPTS_MAX) |