1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #ifndef foosdnetworkhfoo
3 #define foosdnetworkhfoo
6 Copyright 2014 Tom Gundersen
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 #include <sys/types.h>
25 #include "_sd-common.h"
30 * Instead of returning an empty string array or empty integer array, we
33 * Free the data the library returns with libc free(). String arrays
34 * are NULL terminated, and you need to free the array itself in
35 * addition to the strings contained.
37 * We return error codes as negative errno, kernel-style. On success, we
38 * return 0 or positive.
40 * These functions access data in /run. This is a virtual file system;
41 * therefore, accesses are relatively cheap.
43 * See sd-network(3) for more information.
46 _SD_BEGIN_DECLARATIONS
;
48 /* Get overall operational state
49 * Possible states: down, up, dormant, carrier, degraded, routable
50 * Possible return codes:
51 * -ENODATA: networkd is not aware of any links
53 int sd_network_get_operational_state(char **state
);
55 /* Get DNS entries for all links. These are string representations of
57 int sd_network_get_dns(char ***dns
);
59 /* Get NTP entries for all links. These are domain names or string
60 * representations of IP addresses */
61 int sd_network_get_ntp(char ***ntp
);
63 /* Get the search domains for all links. */
64 int sd_network_get_search_domains(char ***domains
);
66 /* Get the search domains for all links. */
67 int sd_network_get_route_domains(char ***domains
);
69 /* Get setup state from ifindex.
71 * pending: udev is still processing the link, we don't yet know if we will manage it
72 * failed: networkd failed to manage the link
73 * configuring: in the process of retrieving configuration or configuring the link
74 * configured: link configured successfully
75 * unmanaged: networkd is not handling the link
76 * linger: the link is gone, but has not yet been dropped by networkd
77 * Possible return codes:
78 * -ENODATA: networkd is not aware of the link
80 int sd_network_link_get_setup_state(int ifindex
, char **state
);
82 /* Get operational state from ifindex.
84 * off: the device is powered down
85 * no-carrier: the device is powered up, but it does not yet have a carrier
86 * dormant: the device has a carrier, but is not yet ready for normal traffic
87 * carrier: the link has a carrier
88 * degraded: the link has carrier and addresses valid on the local link configured
89 * routable: the link has carrier and routable address configured
90 * Possible return codes:
91 * -ENODATA: networkd is not aware of the link
93 int sd_network_link_get_operational_state(int ifindex
, char **state
);
95 /* Indicates whether the network is relevant to being online.
96 * Possible return codes:
97 * 0: the connection is not required
98 * 1: the connection is required to consider the system online
99 * <0: networkd is not aware of the link
101 int sd_network_link_get_required_for_online(int ifindex
);
103 /* Get path to .network file applied to link */
104 int sd_network_link_get_network_file(int ifindex
, char **filename
);
106 /* Get DNS entries for a given link. These are string representations of
108 int sd_network_link_get_dns(int ifindex
, char ***ret
);
110 /* Get NTP entries for a given link. These are domain names or string
111 * representations of IP addresses */
112 int sd_network_link_get_ntp(int ifindex
, char ***ret
);
114 /* Indicates whether or not LLMNR should be enabled for the link
115 * Possible levels of support: yes, no, resolve
116 * Possible return codes:
117 * -ENODATA: networkd is not aware of the link
119 int sd_network_link_get_llmnr(int ifindex
, char **llmnr
);
121 /* Indicates whether or not MulticastDNS should be enabled for the
123 * Possible levels of support: yes, no, resolve
124 * Possible return codes:
125 * -ENODATA: networkd is not aware of the link
127 int sd_network_link_get_mdns(int ifindex
, char **mdns
);
129 /* Indicates whether or not DNS-over-TLS should be enabled for the
131 * Possible levels of support: strict, no, opportunistic
132 * Possible return codes:
133 * -ENODATA: networkd is not aware of the link
135 int sd_network_link_get_dns_over_tls(int ifindex
, char **dns_over_tls
);
137 /* Indicates whether or not DNSSEC should be enabled for the link
138 * Possible levels of support: yes, no, allow-downgrade
139 * Possible return codes:
140 * -ENODATA: networkd is not aware of the link
142 int sd_network_link_get_dnssec(int ifindex
, char **dnssec
);
144 /* Returns the list of per-interface DNSSEC negative trust anchors
145 * Possible return codes:
146 * -ENODATA: networkd is not aware of the link, or has no such data
148 int sd_network_link_get_dnssec_negative_trust_anchors(int ifindex
, char ***nta
);
150 /* Get the search DNS domain names for a given link. */
151 int sd_network_link_get_search_domains(int ifindex
, char ***domains
);
153 /* Get the route DNS domain names for a given link. */
154 int sd_network_link_get_route_domains(int ifindex
, char ***domains
);
156 /* Get the carrier interface indexes to which current link is bound to. */
157 int sd_network_link_get_carrier_bound_to(int ifindex
, int **ifindexes
);
159 /* Get the CARRIERS that are bound to current link. */
160 int sd_network_link_get_carrier_bound_by(int ifindex
, int **ifindexes
);
162 /* Get the timezone that was learnt on a specific link. */
163 int sd_network_link_get_timezone(int ifindex
, char **timezone
);
166 typedef struct sd_network_monitor sd_network_monitor
;
168 /* Create a new monitor. Category must be NULL, "links" or "leases". */
169 int sd_network_monitor_new(sd_network_monitor
**ret
, const char *category
);
171 /* Destroys the passed monitor. Returns NULL. */
172 sd_network_monitor
* sd_network_monitor_unref(sd_network_monitor
*m
);
174 /* Flushes the monitor */
175 int sd_network_monitor_flush(sd_network_monitor
*m
);
177 /* Get FD from monitor */
178 int sd_network_monitor_get_fd(sd_network_monitor
*m
);
180 /* Get poll() mask to monitor */
181 int sd_network_monitor_get_events(sd_network_monitor
*m
);
183 /* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */
184 int sd_network_monitor_get_timeout(sd_network_monitor
*m
, uint64_t *timeout_usec
);
186 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_network_monitor
, sd_network_monitor_unref
);
188 _SD_END_DECLARATIONS
;