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