]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/systemd/sd-network.h
pkgconfig: define variables relative to ${prefix}/${rootprefix}/${sysconfdir}
[thirdparty/systemd.git] / src / systemd / sd-network.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #ifndef foosdnetworkhfoo
3 #define foosdnetworkhfoo
4
5 /***
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
20 #include <inttypes.h>
21 #include <sys/types.h>
22
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
32 * are NULL terminated, and you need to free the array itself in
33 * addition to the strings contained.
34 *
35 * We return error codes as negative errno, kernel-style. On success, we
36 * return 0 or positive.
37 *
38 * These functions access data in /run. This is a virtual file system;
39 * therefore, accesses are relatively cheap.
40 *
41 * See sd-network(3) for more information.
42 */
43
44 _SD_BEGIN_DECLARATIONS;
45
46 /* Get overall operational state
47 * Possible states: down, up, dormant, carrier, degraded, routable
48 * Possible return codes:
49 * -ENODATA: networkd is not aware of any links
50 */
51 int sd_network_get_operational_state(char **state);
52
53 /* Get DNS entries for all links. These are string representations of
54 * IP addresses */
55 int sd_network_get_dns(char ***dns);
56
57 /* Get NTP entries for all links. These are domain names or string
58 * representations of IP addresses */
59 int sd_network_get_ntp(char ***ntp);
60
61 /* Get the search domains for all links. */
62 int sd_network_get_search_domains(char ***domains);
63
64 /* Get the search domains for all links. */
65 int sd_network_get_route_domains(char ***domains);
66
67 /* Get setup state from ifindex.
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
75 * Possible return codes:
76 * -ENODATA: networkd is not aware of the link
77 */
78 int sd_network_link_get_setup_state(int ifindex, char **state);
79
80 /* Get operational state from ifindex.
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
88 * Possible return codes:
89 * -ENODATA: networkd is not aware of the link
90 */
91 int sd_network_link_get_operational_state(int ifindex, char **state);
92
93 /* Indicates whether the network is relevant to being online.
94 * Possible return codes:
95 * 0: the connection is not required
96 * 1: the connection is required to consider the system online
97 * <0: networkd is not aware of the link
98 */
99 int sd_network_link_get_required_for_online(int ifindex);
100
101 /* Get path to .network file applied to link */
102 int sd_network_link_get_network_file(int ifindex, char **filename);
103
104 /* Get DNS entries for a given link. These are string representations of
105 * IP addresses */
106 int sd_network_link_get_dns(int ifindex, char ***ret);
107
108 /* Get NTP entries for a given link. These are domain names or string
109 * representations of IP addresses */
110 int sd_network_link_get_ntp(int ifindex, char ***ret);
111
112 /* Indicates whether or not LLMNR should be enabled for the link
113 * Possible levels of support: yes, no, resolve
114 * Possible return codes:
115 * -ENODATA: networkd is not aware of the link
116 */
117 int sd_network_link_get_llmnr(int ifindex, char **llmnr);
118
119 /* Indicates whether or not MulticastDNS should be enabled for the
120 * link.
121 * Possible levels of support: yes, no, resolve
122 * Possible return codes:
123 * -ENODATA: networkd is not aware of the link
124 */
125 int sd_network_link_get_mdns(int ifindex, char **mdns);
126
127 /* Indicates whether or not DNS-over-TLS should be enabled for the
128 * link.
129 * Possible levels of support: strict, no, opportunistic
130 * Possible return codes:
131 * -ENODATA: networkd is not aware of the link
132 */
133 int sd_network_link_get_dns_over_tls(int ifindex, char **dns_over_tls);
134
135 /* Indicates whether or not DNSSEC should be enabled for the link
136 * Possible levels of support: yes, no, allow-downgrade
137 * Possible return codes:
138 * -ENODATA: networkd is not aware of the link
139 */
140 int sd_network_link_get_dnssec(int ifindex, char **dnssec);
141
142 /* Returns the list of per-interface DNSSEC negative trust anchors
143 * Possible return codes:
144 * -ENODATA: networkd is not aware of the link, or has no such data
145 */
146 int sd_network_link_get_dnssec_negative_trust_anchors(int ifindex, char ***nta);
147
148 /* Get the search DNS domain names for a given link. */
149 int sd_network_link_get_search_domains(int ifindex, char ***domains);
150
151 /* Get the route DNS domain names for a given link. */
152 int sd_network_link_get_route_domains(int ifindex, char ***domains);
153
154 /* Get the carrier interface indexes to which current link is bound to. */
155 int sd_network_link_get_carrier_bound_to(int ifindex, int **ifindexes);
156
157 /* Get the CARRIERS that are bound to current link. */
158 int sd_network_link_get_carrier_bound_by(int ifindex, int **ifindexes);
159
160 /* Get the timezone that was learnt on a specific link. */
161 int sd_network_link_get_timezone(int ifindex, char **timezone);
162
163 /* Monitor object */
164 typedef struct sd_network_monitor sd_network_monitor;
165
166 /* Create a new monitor. Category must be NULL, "links" or "leases". */
167 int sd_network_monitor_new(sd_network_monitor **ret, const char *category);
168
169 /* Destroys the passed monitor. Returns NULL. */
170 sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m);
171
172 /* Flushes the monitor */
173 int sd_network_monitor_flush(sd_network_monitor *m);
174
175 /* Get FD from monitor */
176 int sd_network_monitor_get_fd(sd_network_monitor *m);
177
178 /* Get poll() mask to monitor */
179 int sd_network_monitor_get_events(sd_network_monitor *m);
180
181 /* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */
182 int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec);
183
184 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_network_monitor, sd_network_monitor_unref);
185
186 _SD_END_DECLARATIONS;
187
188 #endif