]>
Commit | Line | Data |
---|---|---|
fe8db0c5 TG |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
82bdf8ce TG |
3 | #ifndef foosdnetworkhfoo |
4 | #define foosdnetworkhfoo | |
fe8db0c5 TG |
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 | ||
29 | #include "sd-dhcp-lease.h" | |
30 | ||
31 | #include "_sd-common.h" | |
32 | ||
33 | /* | |
34 | * A few points: | |
35 | * | |
36 | * Instead of returning an empty string array or empty integer array, we | |
37 | * may return NULL. | |
38 | * | |
39 | * Free the data the library returns with libc free(). String arrays | |
10b17992 | 40 | * are NULL terminated, and you need to free the array itself in |
fe8db0c5 TG |
41 | * addition to the strings contained. |
42 | * | |
10b17992 JSJ |
43 | * We return error codes as negative errno, kernel-style. On success, we |
44 | * return 0 or positive. | |
fe8db0c5 | 45 | * |
10b17992 JSJ |
46 | * These functions access data in /run. This is a virtual file system; |
47 | * therefore, accesses are relatively cheap. | |
fe8db0c5 TG |
48 | * |
49 | * See sd-network(3) for more information. | |
50 | */ | |
51 | ||
52 | _SD_BEGIN_DECLARATIONS; | |
53 | ||
deb2e523 TG |
54 | /* Get state from ifindex. |
55 | * Possible states: failed, configuring, configured | |
56 | * Possible return codes: | |
57 | * -ENODATA: networkd is not aware of the link | |
58 | * -EUNATCH: networkd is not managing this link | |
59 | * -EBUSY: udev is still processing the link, networkd does not yet know if it will manage it | |
60 | */ | |
61 | int sd_network_get_link_state(unsigned index, char **state); | |
62 | ||
63 | /* Get operatinal state from ifindex. | |
64 | * Possible states: unknown, dormant, carrier | |
65 | * Possible return codes: | |
66 | * -ENODATA: networkd is not aware of the link | |
67 | */ | |
68 | int sd_network_get_link_operational_state(unsigned index, char **state); | |
69 | ||
bbf7c048 TG |
70 | /* Get overall opeartional state |
71 | * Possible states: unknown, dormant, carrier | |
72 | * Possible return codes: | |
73 | * -ENODATA: networkd is not aware of any links | |
74 | */ | |
75 | int sd_network_get_operational_state(char **state); | |
76 | ||
deb2e523 TG |
77 | /* Returns true if link exists and is loopback, and false otherwise */ |
78 | int sd_network_link_is_loopback(unsigned index); | |
fe8db0c5 TG |
79 | |
80 | /* Get DHCPv4 lease from ifindex. */ | |
81 | int sd_network_get_dhcp_lease(unsigned index, sd_dhcp_lease **ret); | |
82 | ||
7dbf94a9 TG |
83 | /* Returns true if link is configured to respect DNS entries received by DHCP */ |
84 | int sd_network_dhcp_use_dns(unsigned index); | |
85 | ||
bcb7a07e TG |
86 | /* Returns true if link is configured to respect NTP entries received by DHCP */ |
87 | int sd_network_dhcp_use_ntp(unsigned index); | |
88 | ||
7dbf94a9 TG |
89 | /* Get IPv4 DNS entries statically configured for the link */ |
90 | int sd_network_get_dns(unsigned index, struct in_addr **addr, size_t *addr_size); | |
91 | ||
bcb7a07e TG |
92 | /* Get IPv4 NTP entries statically configured for the link */ |
93 | int sd_network_get_ntp(unsigned index, struct in_addr **addr, size_t *addr_size); | |
94 | ||
7dbf94a9 TG |
95 | /* Get IPv6 DNS entries statically configured for the link */ |
96 | int sd_network_get_dns6(unsigned index, struct in6_addr **addr, size_t *addr_size); | |
bcb7a07e TG |
97 | |
98 | /* Get IPv6 NTP entries statically configured for the link */ | |
99 | int sd_network_get_ntp6(unsigned index, struct in6_addr **addr, size_t *addr_size); | |
7dbf94a9 | 100 | |
10b17992 JSJ |
101 | /* Get all network interfaces' indices, and store them in *indices. Returns |
102 | * the number of indices. If indices is NULL, only returns the number of indices. */ | |
fe8db0c5 TG |
103 | int sd_network_get_ifindices(unsigned **indices); |
104 | ||
105 | /* Monitor object */ | |
106 | typedef struct sd_network_monitor sd_network_monitor; | |
107 | ||
7e141e49 | 108 | /* Create a new monitor. Category must be NULL, "links" or "leases". */ |
deb2e523 | 109 | int sd_network_monitor_new(const char *category, sd_network_monitor **ret); |
fe8db0c5 TG |
110 | |
111 | /* Destroys the passed monitor. Returns NULL. */ | |
112 | sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m); | |
113 | ||
114 | /* Flushes the monitor */ | |
115 | int sd_network_monitor_flush(sd_network_monitor *m); | |
116 | ||
117 | /* Get FD from monitor */ | |
118 | int sd_network_monitor_get_fd(sd_network_monitor *m); | |
119 | ||
120 | /* Get poll() mask to monitor */ | |
121 | int sd_network_monitor_get_events(sd_network_monitor *m); | |
122 | ||
123 | /* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */ | |
124 | int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec); | |
125 | ||
126 | _SD_END_DECLARATIONS; | |
127 | ||
128 | #endif |