]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/resolve/resolved-dns-scope.h
resolved: reuse dns_transaction_stop() when destructing transaction objects
[thirdparty/systemd.git] / src / resolve / resolved-dns-scope.h
CommitLineData
74b2466e
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
24#include "list.h"
25
26typedef struct DnsScope DnsScope;
27
322345fd 28#include "resolved-dns-cache.h"
24710c48 29#include "resolved-dns-dnssec.h"
71d35b6b
TA
30#include "resolved-dns-packet.h"
31#include "resolved-dns-server.h"
623a4c97 32#include "resolved-dns-zone.h"
39d8db04 33#include "resolved-link.h"
74b2466e 34
74b2466e
LP
35typedef enum DnsScopeMatch {
36 DNS_SCOPE_NO,
37 DNS_SCOPE_MAYBE,
38 DNS_SCOPE_YES,
39 _DNS_SCOPE_MATCH_MAX,
40 _DNS_SCOPE_INVALID = -1
41} DnsScopeMatch;
42
43struct DnsScope {
44 Manager *manager;
45
1716f6dc 46 DnsProtocol protocol;
0dd25fb9 47 int family;
24710c48 48 DnssecMode dnssec_mode;
74b2466e
LP
49
50 Link *link;
51
322345fd 52 DnsCache cache;
623a4c97 53 DnsZone zone;
322345fd 54
1e43061b 55 OrderedHashmap *conflict_queue;
a4076574
LP
56 sd_event_source *conflict_event_source;
57
aea2429d
LP
58 RateLimit ratelimit;
59
9df3ba6c
TG
60 usec_t resend_timeout;
61 usec_t max_rtt;
62
801ad6a6 63 LIST_HEAD(DnsQueryCandidate, query_candidates);
74b2466e 64
f9ebb22a
LP
65 /* Note that we keep track of ongoing transactions in two
66 * ways: once in a hashmap, indexed by the rr key, and once in
67 * a linked list. We use the hashmap to quickly find
68 * transactions we can reuse for a key. But note that there
69 * might be multiple transactions for the same key (because
70 * the zone probing can't reuse a transaction answered from
71 * the zone or the cache), and the hashmap only tracks the
72 * most recent entry. */
73 Hashmap *transactions_by_key;
74 LIST_HEAD(DnsTransaction, transactions);
75
74b2466e
LP
76 LIST_FIELDS(DnsScope, scopes);
77};
78
0dd25fb9 79int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, int family);
74b2466e
LP
80DnsScope* dns_scope_free(DnsScope *s);
81
9df3ba6c
TG
82void dns_scope_packet_received(DnsScope *s, usec_t rtt);
83void dns_scope_packet_lost(DnsScope *s, usec_t usec);
84
49cce12d
LP
85int dns_scope_emit_udp(DnsScope *s, int fd, DnsServer *server, DnsPacket *p);
86int dns_scope_socket_tcp(DnsScope *s, int family, const union in_addr_union *address, uint16_t port, DnsServer **server);
87int dns_scope_socket_udp(DnsScope *s, DnsServer **server);
ad867662 88
51323288 89DnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, const char *domain);
1716f6dc 90int dns_scope_good_key(DnsScope *s, DnsResourceKey *key);
74b2466e 91
2c27fbca 92DnsServer *dns_scope_get_dns_server(DnsScope *s);
74b2466e 93void dns_scope_next_dns_server(DnsScope *s);
1716f6dc
LP
94
95int dns_scope_llmnr_membership(DnsScope *s, bool b);
0db4c90a 96int dns_scope_mdns_membership(DnsScope *s, bool b);
623a4c97
LP
97
98void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p);
ec2c5e43 99
f52e61da 100DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, bool cache_ok);
a4076574
LP
101
102int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr);
103void dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p);
4d506d6b
LP
104
105void dns_scope_dump(DnsScope *s, FILE *f);
a51c1048
LP
106
107DnsSearchDomain *dns_scope_get_search_domains(DnsScope *s);
801ad6a6 108
dc477e73 109bool dns_scope_name_needs_search_domain(DnsScope *s, const char *name);