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