chiark / gitweb /
sd-network: remove client-side dhcp API
[elogind.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 <sys/types.h>
27 #include <inttypes.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: unknown, 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 state from ifindex.
60  * Possible states: failed, configuring, configured, unmanaged
61  * Possible return codes:
62  *   -ENODATA: networkd is not aware of the link
63  *   -EBUSY: udev is still processing the link, networkd does not yet know if it will manage it
64  */
65 int sd_network_get_link_state(int ifindex, char **state);
66
67 /* Get operatinal state from ifindex.
68  * Possible states: unknown, dormant, carrier, degraded, routable
69  * Possible return codes:
70  *   -ENODATA: networkd is not aware of the link
71  */
72 int sd_network_get_link_operational_state(int ifindex, char **state);
73
74 /* Indicates whether or not LLMNR should be enabled for the link
75  * Possible levels of support: yes, no, resolve
76  * Possible return codes:
77  *   -ENODATA: networkd is not aware of the link*/
78 int sd_network_get_link_llmnr(int ifindex, char **llmnr);
79
80 /* Get DNS entries for a given link. These are string representations of
81  * IP addresses */
82 int sd_network_get_link_dns(int ifindex, char ***addr);
83
84 /* Get NTP entries for a given link. These are domain names or string
85  * reperesentations of IP addresses */
86 int sd_network_get_link_ntp(int ifindex, char ***addr);
87
88 /* Monitor object */
89 typedef struct sd_network_monitor sd_network_monitor;
90
91 /* Create a new monitor. Category must be NULL, "links" or "leases". */
92 int sd_network_monitor_new(sd_network_monitor **ret, const char *category);
93
94 /* Destroys the passed monitor. Returns NULL. */
95 sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m);
96
97 /* Flushes the monitor */
98 int sd_network_monitor_flush(sd_network_monitor *m);
99
100 /* Get FD from monitor */
101 int sd_network_monitor_get_fd(sd_network_monitor *m);
102
103 /* Get poll() mask to monitor */
104 int sd_network_monitor_get_events(sd_network_monitor *m);
105
106 /* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */
107 int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec);
108
109 _SD_END_DECLARATIONS;
110
111 #endif