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