]>
Commit | Line | Data |
---|---|---|
60f067b4 JS |
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 <sys/types.h> | |
27 | #include <inttypes.h> | |
28 | ||
60f067b4 JS |
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 | ||
5eef597e MP |
52 | /* Get overall operational state |
53 | * Possible states: down, up, dormant, carrier, degraded, routable | |
60f067b4 | 54 | * Possible return codes: |
5eef597e | 55 | * -ENODATA: networkd is not aware of any links |
60f067b4 | 56 | */ |
5eef597e | 57 | int sd_network_get_operational_state(char **state); |
60f067b4 | 58 | |
5eef597e MP |
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/routing domains for all links. */ | |
68 | int sd_network_get_domains(char ***domains); | |
69 | ||
70 | /* Get setup state from ifindex. | |
71 | * Possible states: | |
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 | |
60f067b4 JS |
78 | * Possible return codes: |
79 | * -ENODATA: networkd is not aware of the link | |
80 | */ | |
5eef597e MP |
81 | int sd_network_link_get_setup_state(int ifindex, char **state); |
82 | ||
83 | /* Get operational state from ifindex. | |
84 | * Possible states: | |
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 | |
60f067b4 | 91 | * Possible return codes: |
5eef597e | 92 | * -ENODATA: networkd is not aware of the link |
60f067b4 | 93 | */ |
5eef597e | 94 | int sd_network_link_get_operational_state(int ifindex, char **state); |
60f067b4 | 95 | |
5eef597e MP |
96 | /* Get path to .network file applied to link */ |
97 | int sd_network_link_get_network_file(int ifindex, char **filename); | |
60f067b4 | 98 | |
5eef597e MP |
99 | /* Get DNS entries for a given link. These are string representations of |
100 | * IP addresses */ | |
101 | int sd_network_link_get_dns(int ifindex, char ***addr); | |
60f067b4 | 102 | |
5eef597e MP |
103 | /* Get NTP entries for a given link. These are domain names or string |
104 | * representations of IP addresses */ | |
105 | int sd_network_link_get_ntp(int ifindex, char ***addr); | |
60f067b4 | 106 | |
5eef597e MP |
107 | /* Indicates whether or not LLMNR should be enabled for the link |
108 | * Possible levels of support: yes, no, resolve | |
109 | * Possible return codes: | |
110 | * -ENODATA: networkd is not aware of the link | |
111 | */ | |
112 | int sd_network_link_get_llmnr(int ifindex, char **llmnr); | |
60f067b4 | 113 | |
e735f4d4 MP |
114 | int sd_network_link_get_lldp(int ifindex, char **lldp); |
115 | ||
5eef597e MP |
116 | /* Get the DNS domain names for a given link. */ |
117 | int sd_network_link_get_domains(int ifindex, char ***domains); | |
60f067b4 | 118 | |
e3bff60a MP |
119 | /* Get the CARRIERS to which current link is bound to. */ |
120 | int sd_network_link_get_carrier_bound_to(int ifindex, char ***carriers); | |
121 | ||
122 | /* Get the CARRIERS that are bound to current link. */ | |
123 | int sd_network_link_get_carrier_bound_by(int ifindex, char ***carriers); | |
124 | ||
5eef597e MP |
125 | /* Returns whether or not domains that don't match any link should be resolved |
126 | * on this link. 1 for yes, 0 for no and negative value for error */ | |
127 | int sd_network_link_get_wildcard_domain(int ifindex); | |
60f067b4 JS |
128 | |
129 | /* Monitor object */ | |
130 | typedef struct sd_network_monitor sd_network_monitor; | |
131 | ||
132 | /* Create a new monitor. Category must be NULL, "links" or "leases". */ | |
5eef597e | 133 | int sd_network_monitor_new(sd_network_monitor **ret, const char *category); |
60f067b4 JS |
134 | |
135 | /* Destroys the passed monitor. Returns NULL. */ | |
136 | sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m); | |
137 | ||
138 | /* Flushes the monitor */ | |
139 | int sd_network_monitor_flush(sd_network_monitor *m); | |
140 | ||
141 | /* Get FD from monitor */ | |
142 | int sd_network_monitor_get_fd(sd_network_monitor *m); | |
143 | ||
144 | /* Get poll() mask to monitor */ | |
145 | int sd_network_monitor_get_events(sd_network_monitor *m); | |
146 | ||
147 | /* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */ | |
148 | int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec); | |
149 | ||
150 | _SD_END_DECLARATIONS; | |
151 | ||
152 | #endif |