]>
Commit | Line | Data |
---|---|---|
1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ | |
2 | #pragma once | |
3 | ||
4 | #include "in-addr-util.h" | |
5 | #include "resolved-forward.h" | |
6 | ||
7 | typedef enum DnsStubListenerMode { | |
8 | DNS_STUB_LISTENER_NO, | |
9 | DNS_STUB_LISTENER_UDP = 1 << 0, | |
10 | DNS_STUB_LISTENER_TCP = 1 << 1, | |
11 | DNS_STUB_LISTENER_YES = DNS_STUB_LISTENER_UDP | DNS_STUB_LISTENER_TCP, | |
12 | _DNS_STUB_LISTENER_MODE_MAX, | |
13 | _DNS_STUB_LISTENER_MODE_INVALID = -EINVAL, | |
14 | } DnsStubListenerMode; | |
15 | ||
16 | typedef struct DnsStubListenerExtra { | |
17 | Manager *manager; | |
18 | ||
19 | DnsStubListenerMode mode; | |
20 | ||
21 | int family; | |
22 | union in_addr_union address; | |
23 | uint16_t port; | |
24 | ||
25 | sd_event_source *udp_event_source; | |
26 | sd_event_source *tcp_event_source; | |
27 | ||
28 | Hashmap *queries_by_packet; | |
29 | } DnsStubListenerExtra; | |
30 | ||
31 | extern const struct hash_ops dns_stub_listener_extra_hash_ops; | |
32 | ||
33 | int dns_stub_listener_extra_new(Manager *m, DnsStubListenerExtra **ret); | |
34 | DnsStubListenerExtra *dns_stub_listener_extra_free(DnsStubListenerExtra *p); | |
35 | static inline uint16_t dns_stub_listener_extra_port(DnsStubListenerExtra *p) { | |
36 | assert(p); | |
37 | ||
38 | return p->port > 0 ? p->port : 53; | |
39 | } | |
40 | ||
41 | void manager_dns_stub_stop(Manager *m); | |
42 | int manager_dns_stub_start(Manager *m); | |
43 | ||
44 | const char* dns_stub_listener_mode_to_string(DnsStubListenerMode p) _const_; | |
45 | DnsStubListenerMode dns_stub_listener_mode_from_string(const char *s) _pure_; |