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