]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/resolved-dns-scope.h
Merge pull request #8863 from evelikov/shell-completion-fixes
[thirdparty/systemd.git] / src / resolve / resolved-dns-scope.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 This file is part of systemd.
6
7 Copyright 2014 Lennart Poettering
8 ***/
9
10 #include "list.h"
11
12 typedef struct DnsScope DnsScope;
13
14 #include "resolved-dns-cache.h"
15 #include "resolved-dns-dnssec.h"
16 #include "resolved-dns-packet.h"
17 #include "resolved-dns-query.h"
18 #include "resolved-dns-search-domain.h"
19 #include "resolved-dns-server.h"
20 #include "resolved-dns-stream.h"
21 #include "resolved-dns-zone.h"
22 #include "resolved-link.h"
23
24 typedef enum DnsScopeMatch {
25 DNS_SCOPE_NO,
26 DNS_SCOPE_MAYBE,
27 DNS_SCOPE_YES,
28 _DNS_SCOPE_MATCH_MAX,
29 _DNS_SCOPE_INVALID = -1
30 } DnsScopeMatch;
31
32 struct DnsScope {
33 Manager *manager;
34
35 DnsProtocol protocol;
36 int family;
37 DnssecMode dnssec_mode;
38 PrivateDnsMode private_dns_mode;
39
40 Link *link;
41
42 DnsCache cache;
43 DnsZone zone;
44
45 OrderedHashmap *conflict_queue;
46 sd_event_source *conflict_event_source;
47
48 bool announced:1;
49 sd_event_source *announce_event_source;
50
51 RateLimit ratelimit;
52
53 usec_t resend_timeout;
54 usec_t max_rtt;
55
56 LIST_HEAD(DnsQueryCandidate, query_candidates);
57
58 /* Note that we keep track of ongoing transactions in two
59 * ways: once in a hashmap, indexed by the rr key, and once in
60 * a linked list. We use the hashmap to quickly find
61 * transactions we can reuse for a key. But note that there
62 * might be multiple transactions for the same key (because
63 * the zone probing can't reuse a transaction answered from
64 * the zone or the cache), and the hashmap only tracks the
65 * most recent entry. */
66 Hashmap *transactions_by_key;
67 LIST_HEAD(DnsTransaction, transactions);
68
69 LIST_FIELDS(DnsScope, scopes);
70 };
71
72 int dns_scope_new(Manager *m, DnsScope **ret, Link *l, DnsProtocol p, int family);
73 DnsScope* dns_scope_free(DnsScope *s);
74
75 void dns_scope_packet_received(DnsScope *s, usec_t rtt);
76 void dns_scope_packet_lost(DnsScope *s, usec_t usec);
77
78 int dns_scope_emit_udp(DnsScope *s, int fd, DnsPacket *p);
79 int dns_scope_socket_tcp(DnsScope *s, int family, const union in_addr_union *address, DnsServer *server, uint16_t port, union sockaddr_union *ret_socket_address);
80 int dns_scope_socket_udp(DnsScope *s, DnsServer *server, uint16_t port);
81
82 DnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, const char *domain);
83 bool dns_scope_good_key(DnsScope *s, const DnsResourceKey *key);
84
85 DnsServer *dns_scope_get_dns_server(DnsScope *s);
86 unsigned dns_scope_get_n_dns_servers(DnsScope *s);
87 void dns_scope_next_dns_server(DnsScope *s);
88
89 int dns_scope_llmnr_membership(DnsScope *s, bool b);
90 int dns_scope_mdns_membership(DnsScope *s, bool b);
91
92 int dns_scope_make_reply_packet(DnsScope *s, uint16_t id, int rcode, DnsQuestion *q, DnsAnswer *answer, DnsAnswer *soa, bool tentative, DnsPacket **ret);
93 void dns_scope_process_query(DnsScope *s, DnsStream *stream, DnsPacket *p);
94
95 DnsTransaction *dns_scope_find_transaction(DnsScope *scope, DnsResourceKey *key, bool cache_ok);
96
97 int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr);
98 void dns_scope_check_conflicts(DnsScope *scope, DnsPacket *p);
99
100 void dns_scope_dump(DnsScope *s, FILE *f);
101
102 DnsSearchDomain *dns_scope_get_search_domains(DnsScope *s);
103
104 bool dns_scope_name_needs_search_domain(DnsScope *s, const char *name);
105
106 bool dns_scope_network_good(DnsScope *s);
107
108 int dns_scope_ifindex(DnsScope *s);
109
110 int dns_scope_announce(DnsScope *scope, bool goodbye);
111
112 int dns_scope_add_dnssd_services(DnsScope *scope);
113
114 int dns_scope_remove_dnssd_services(DnsScope *scope);