]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/systemd/sd-network.h
resolved: add strict mode for DNS-over-TLS
[thirdparty/systemd.git] / src / systemd / sd-network.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
82bdf8ce
TG
2#ifndef foosdnetworkhfoo
3#define foosdnetworkhfoo
fe8db0c5
TG
4
5/***
fe8db0c5
TG
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
18***/
19
fe8db0c5 20#include <inttypes.h>
71d35b6b 21#include <sys/types.h>
fe8db0c5 22
fe8db0c5
TG
23#include "_sd-common.h"
24
25/*
26 * A few points:
27 *
28 * Instead of returning an empty string array or empty integer array, we
29 * may return NULL.
30 *
31 * Free the data the library returns with libc free(). String arrays
10b17992 32 * are NULL terminated, and you need to free the array itself in
fe8db0c5
TG
33 * addition to the strings contained.
34 *
10b17992
JSJ
35 * We return error codes as negative errno, kernel-style. On success, we
36 * return 0 or positive.
fe8db0c5 37 *
10b17992
JSJ
38 * These functions access data in /run. This is a virtual file system;
39 * therefore, accesses are relatively cheap.
fe8db0c5
TG
40 *
41 * See sd-network(3) for more information.
42 */
43
44_SD_BEGIN_DECLARATIONS;
45
6436165d 46/* Get overall operational state
54cba0b1 47 * Possible states: down, up, dormant, carrier, degraded, routable
6436165d
LP
48 * Possible return codes:
49 * -ENODATA: networkd is not aware of any links
50 */
51int sd_network_get_operational_state(char **state);
52
03cc0fd1
LP
53/* Get DNS entries for all links. These are string representations of
54 * IP addresses */
8612e936 55int sd_network_get_dns(char ***dns);
03cc0fd1
LP
56
57/* Get NTP entries for all links. These are domain names or string
91c40d86 58 * representations of IP addresses */
8612e936
LP
59int sd_network_get_ntp(char ***ntp);
60
3df9bec5
LP
61/* Get the search domains for all links. */
62int sd_network_get_search_domains(char ***domains);
63
64/* Get the search domains for all links. */
65int sd_network_get_route_domains(char ***domains);
03cc0fd1 66
438ca2bb 67/* Get setup state from ifindex.
8434fd5c
TG
68 * Possible states:
69 * pending: udev is still processing the link, we don't yet know if we will manage it
70 * failed: networkd failed to manage the link
71 * configuring: in the process of retrieving configuration or configuring the link
72 * configured: link configured successfully
73 * unmanaged: networkd is not handling the link
74 * linger: the link is gone, but has not yet been dropped by networkd
deb2e523
TG
75 * Possible return codes:
76 * -ENODATA: networkd is not aware of the link
deb2e523 77 */
438ca2bb 78int sd_network_link_get_setup_state(int ifindex, char **state);
deb2e523 79
91c40d86 80/* Get operational state from ifindex.
d3df0e39
TG
81 * Possible states:
82 * off: the device is powered down
83 * no-carrier: the device is powered up, but it does not yet have a carrier
84 * dormant: the device has a carrier, but is not yet ready for normal traffic
85 * carrier: the link has a carrier
86 * degraded: the link has carrier and addresses valid on the local link configured
87 * routable: the link has carrier and routable address configured
deb2e523
TG
88 * Possible return codes:
89 * -ENODATA: networkd is not aware of the link
90 */
d6731e4c 91int sd_network_link_get_operational_state(int ifindex, char **state);
22eab27c 92int sd_network_link_get_required_operstate_for_online(int ifindex, char **state);
deb2e523 93
c1a38904
MTL
94/* Indicates whether the network is relevant to being online.
95 * Possible return codes:
96 * 0: the connection is not required
97 * 1: the connection is required to consider the system online
98 * <0: networkd is not aware of the link
99 */
100int sd_network_link_get_required_for_online(int ifindex);
101
adc5b2e2
TG
102/* Get path to .network file applied to link */
103int sd_network_link_get_network_file(int ifindex, char **filename);
104
6f4dedb2
TG
105/* Get DNS entries for a given link. These are string representations of
106 * IP addresses */
b295beea 107int sd_network_link_get_dns(int ifindex, char ***ret);
7dbf94a9 108
6f4dedb2 109/* Get NTP entries for a given link. These are domain names or string
91c40d86 110 * representations of IP addresses */
b295beea 111int sd_network_link_get_ntp(int ifindex, char ***ret);
7dbf94a9 112
03cc0fd1
LP
113/* Indicates whether or not LLMNR should be enabled for the link
114 * Possible levels of support: yes, no, resolve
115 * Possible return codes:
91c40d86
TH
116 * -ENODATA: networkd is not aware of the link
117 */
d6731e4c 118int sd_network_link_get_llmnr(int ifindex, char **llmnr);
03cc0fd1 119
ad6c0475
LP
120/* Indicates whether or not MulticastDNS should be enabled for the
121 * link.
aaa297d4
LP
122 * Possible levels of support: yes, no, resolve
123 * Possible return codes:
124 * -ENODATA: networkd is not aware of the link
125 */
126int sd_network_link_get_mdns(int ifindex, char **mdns);
127
c9299be2 128/* Indicates whether or not DNS-over-TLS should be enabled for the
d050561a 129 * link.
4310bfc2 130 * Possible levels of support: yes, no, opportunistic
d050561a
IT
131 * Possible return codes:
132 * -ENODATA: networkd is not aware of the link
133 */
c9299be2 134int sd_network_link_get_dns_over_tls(int ifindex, char **dns_over_tls);
d050561a 135
ad6c0475
LP
136/* Indicates whether or not DNSSEC should be enabled for the link
137 * Possible levels of support: yes, no, allow-downgrade
138 * Possible return codes:
139 * -ENODATA: networkd is not aware of the link
140 */
141int sd_network_link_get_dnssec(int ifindex, char **dnssec);
142
8a516214
LP
143/* Returns the list of per-interface DNSSEC negative trust anchors
144 * Possible return codes:
145 * -ENODATA: networkd is not aware of the link, or has no such data
146 */
147int sd_network_link_get_dnssec_negative_trust_anchors(int ifindex, char ***nta);
148
3df9bec5
LP
149/* Get the search DNS domain names for a given link. */
150int sd_network_link_get_search_domains(int ifindex, char ***domains);
151
152/* Get the route DNS domain names for a given link. */
153int sd_network_link_get_route_domains(int ifindex, char ***domains);
9b4d1882 154
c629354e
LP
155/* Get whether this link shall be used as 'default route' for DNS queries */
156int sd_network_link_get_dns_default_route(int ifindex);
157
b295beea
LP
158/* Get the carrier interface indexes to which current link is bound to. */
159int sd_network_link_get_carrier_bound_to(int ifindex, int **ifindexes);
0d4ad91d
AR
160
161/* Get the CARRIERS that are bound to current link. */
b295beea 162int sd_network_link_get_carrier_bound_by(int ifindex, int **ifindexes);
0d4ad91d 163
8eb9058d
LP
164/* Get the timezone that was learnt on a specific link. */
165int sd_network_link_get_timezone(int ifindex, char **timezone);
166
fe8db0c5
TG
167/* Monitor object */
168typedef struct sd_network_monitor sd_network_monitor;
169
7e141e49 170/* Create a new monitor. Category must be NULL, "links" or "leases". */
0014a4ad 171int sd_network_monitor_new(sd_network_monitor **ret, const char *category);
fe8db0c5
TG
172
173/* Destroys the passed monitor. Returns NULL. */
174sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m);
175
176/* Flushes the monitor */
177int sd_network_monitor_flush(sd_network_monitor *m);
178
179/* Get FD from monitor */
180int sd_network_monitor_get_fd(sd_network_monitor *m);
181
182/* Get poll() mask to monitor */
183int sd_network_monitor_get_events(sd_network_monitor *m);
184
185/* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */
186int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec);
187
4afd3348
LP
188_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_network_monitor, sd_network_monitor_unref);
189
fe8db0c5
TG
190_SD_END_DECLARATIONS;
191
192#endif