1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #ifndef foosdnetworkhfoo
3 #define foosdnetworkhfoo
6 Copyright 2011 Lennart Poettering
7 Copyright 2014 Tom Gundersen
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include <sys/types.h>
26 #include "_sd-common.h"
31 * Instead of returning an empty string array or empty integer array, we
34 * Free the data the library returns with libc free(). String arrays
35 * are NULL terminated, and you need to free the array itself in
36 * addition to the strings contained.
38 * We return error codes as negative errno, kernel-style. On success, we
39 * return 0 or positive.
41 * These functions access data in /run. This is a virtual file system;
42 * therefore, accesses are relatively cheap.
44 * See sd-network(3) for more information.
47 _SD_BEGIN_DECLARATIONS
;
49 /* Get overall operational state
50 * Possible states: down, up, dormant, carrier, degraded, routable
51 * Possible return codes:
52 * -ENODATA: networkd is not aware of any links
54 int sd_network_get_operational_state(char **state
);
56 /* Get DNS entries for all links. These are string representations of
58 int sd_network_get_dns(char ***dns
);
60 /* Get NTP entries for all links. These are domain names or string
61 * representations of IP addresses */
62 int sd_network_get_ntp(char ***ntp
);
64 /* Get the search domains for all links. */
65 int sd_network_get_search_domains(char ***domains
);
67 /* Get the search domains for all links. */
68 int sd_network_get_route_domains(char ***domains
);
70 /* Get setup state from ifindex.
72 * pending: udev is still processing the link, we don't yet know if we will manage it
73 * failed: networkd failed to manage the link
74 * configuring: in the process of retrieving configuration or configuring the link
75 * configured: link configured successfully
76 * unmanaged: networkd is not handling the link
77 * linger: the link is gone, but has not yet been dropped by networkd
78 * Possible return codes:
79 * -ENODATA: networkd is not aware of the link
81 int sd_network_link_get_setup_state(int ifindex
, char **state
);
83 /* Get operational state from ifindex.
85 * off: the device is powered down
86 * no-carrier: the device is powered up, but it does not yet have a carrier
87 * dormant: the device has a carrier, but is not yet ready for normal traffic
88 * carrier: the link has a carrier
89 * degraded: the link has carrier and addresses valid on the local link configured
90 * routable: the link has carrier and routable address configured
91 * Possible return codes:
92 * -ENODATA: networkd is not aware of the link
94 int sd_network_link_get_operational_state(int ifindex
, char **state
);
96 /* Indicates whether the network is relevant to being online.
97 * Possible return codes:
98 * 0: the connection is not required
99 * 1: the connection is required to consider the system online
100 * <0: networkd is not aware of the link
102 int sd_network_link_get_required_for_online(int ifindex
);
104 /* Get path to .network file applied to link */
105 int sd_network_link_get_network_file(int ifindex
, char **filename
);
107 /* Get DNS entries for a given link. These are string representations of
109 int sd_network_link_get_dns(int ifindex
, char ***ret
);
111 /* Get NTP entries for a given link. These are domain names or string
112 * representations of IP addresses */
113 int sd_network_link_get_ntp(int ifindex
, char ***ret
);
115 /* Indicates whether or not LLMNR should be enabled for the link
116 * Possible levels of support: yes, no, resolve
117 * Possible return codes:
118 * -ENODATA: networkd is not aware of the link
120 int sd_network_link_get_llmnr(int ifindex
, char **llmnr
);
122 /* Indicates whether or not MulticastDNS should be enabled for the
124 * Possible levels of support: yes, no, resolve
125 * Possible return codes:
126 * -ENODATA: networkd is not aware of the link
128 int sd_network_link_get_mdns(int ifindex
, char **mdns
);
130 /* Indicates whether or not DNS-over-TLS should be enabled for the
132 * Possible levels of support: strict, no, opportunistic
133 * Possible return codes:
134 * -ENODATA: networkd is not aware of the link
136 int sd_network_link_get_dns_over_tls(int ifindex
, char **dns_over_tls
);
138 /* Indicates whether or not DNSSEC should be enabled for the link
139 * Possible levels of support: yes, no, allow-downgrade
140 * Possible return codes:
141 * -ENODATA: networkd is not aware of the link
143 int sd_network_link_get_dnssec(int ifindex
, char **dnssec
);
145 /* Returns the list of per-interface DNSSEC negative trust anchors
146 * Possible return codes:
147 * -ENODATA: networkd is not aware of the link, or has no such data
149 int sd_network_link_get_dnssec_negative_trust_anchors(int ifindex
, char ***nta
);
151 /* Get the search DNS domain names for a given link. */
152 int sd_network_link_get_search_domains(int ifindex
, char ***domains
);
154 /* Get the route DNS domain names for a given link. */
155 int sd_network_link_get_route_domains(int ifindex
, char ***domains
);
157 /* Get the carrier interface indexes to which current link is bound to. */
158 int sd_network_link_get_carrier_bound_to(int ifindex
, int **ifindexes
);
160 /* Get the CARRIERS that are bound to current link. */
161 int sd_network_link_get_carrier_bound_by(int ifindex
, int **ifindexes
);
163 /* Get the timezone that was learnt on a specific link. */
164 int sd_network_link_get_timezone(int ifindex
, char **timezone
);
167 typedef struct sd_network_monitor sd_network_monitor
;
169 /* Create a new monitor. Category must be NULL, "links" or "leases". */
170 int sd_network_monitor_new(sd_network_monitor
**ret
, const char *category
);
172 /* Destroys the passed monitor. Returns NULL. */
173 sd_network_monitor
* sd_network_monitor_unref(sd_network_monitor
*m
);
175 /* Flushes the monitor */
176 int sd_network_monitor_flush(sd_network_monitor
*m
);
178 /* Get FD from monitor */
179 int sd_network_monitor_get_fd(sd_network_monitor
*m
);
181 /* Get poll() mask to monitor */
182 int sd_network_monitor_get_events(sd_network_monitor
*m
);
184 /* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */
185 int sd_network_monitor_get_timeout(sd_network_monitor
*m
, uint64_t *timeout_usec
);
187 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_network_monitor
, sd_network_monitor_unref
);
189 _SD_END_DECLARATIONS
;