]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/systemd/sd-network.h
sd-network: add sd_network_linkg_get_domains()
[thirdparty/systemd.git] / src / systemd / sd-network.h
CommitLineData
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
fe8db0c5
TG
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
10b17992 38 * are NULL terminated, and you need to free the array itself in
fe8db0c5
TG
39 * addition to the strings contained.
40 *
10b17992
JSJ
41 * We return error codes as negative errno, kernel-style. On success, we
42 * return 0 or positive.
fe8db0c5 43 *
10b17992
JSJ
44 * These functions access data in /run. This is a virtual file system;
45 * therefore, accesses are relatively cheap.
fe8db0c5
TG
46 *
47 * See sd-network(3) for more information.
48 */
49
50_SD_BEGIN_DECLARATIONS;
51
6436165d 52/* Get overall operational state
54cba0b1 53 * Possible states: down, up, dormant, carrier, degraded, routable
6436165d
LP
54 * Possible return codes:
55 * -ENODATA: networkd is not aware of any links
56 */
57int sd_network_get_operational_state(char **state);
58
03cc0fd1
LP
59/* Get DNS entries for all links. These are string representations of
60 * IP addresses */
61int sd_network_get_dns(char ***addr);
62
63/* Get NTP entries for all links. These are domain names or string
64 * reperesentations of IP addresses */
65int sd_network_get_ntp(char ***addr);
66
438ca2bb 67/* Get setup state from ifindex.
8434fd5c
TG
68 * Possible states:
69 * pending: udev is still processing the link, we don't yet know if we will manage it
70 * failed: networkd failed to manage the link
71 * configuring: in the process of retrieving configuration or configuring the link
72 * configured: link configured successfully
73 * unmanaged: networkd is not handling the link
74 * linger: the link is gone, but has not yet been dropped by networkd
deb2e523
TG
75 * Possible return codes:
76 * -ENODATA: networkd is not aware of the link
deb2e523 77 */
438ca2bb 78int sd_network_link_get_setup_state(int ifindex, char **state);
deb2e523
TG
79
80/* Get operatinal state from ifindex.
d3df0e39
TG
81 * Possible states:
82 * off: the device is powered down
83 * no-carrier: the device is powered up, but it does not yet have a carrier
84 * dormant: the device has a carrier, but is not yet ready for normal traffic
85 * carrier: the link has a carrier
86 * degraded: the link has carrier and addresses valid on the local link configured
87 * routable: the link has carrier and routable address configured
deb2e523
TG
88 * Possible return codes:
89 * -ENODATA: networkd is not aware of the link
90 */
d6731e4c 91int sd_network_link_get_operational_state(int ifindex, char **state);
deb2e523 92
6f4dedb2
TG
93/* Get DNS entries for a given link. These are string representations of
94 * IP addresses */
d6731e4c 95int sd_network_link_get_dns(int ifindex, char ***addr);
7dbf94a9 96
6f4dedb2
TG
97/* Get NTP entries for a given link. These are domain names or string
98 * reperesentations of IP addresses */
d6731e4c 99int sd_network_link_get_ntp(int ifindex, char ***addr);
7dbf94a9 100
03cc0fd1
LP
101/* Indicates whether or not LLMNR should be enabled for the link
102 * Possible levels of support: yes, no, resolve
103 * Possible return codes:
104 * -ENODATA: networkd is not aware of the link*/
d6731e4c 105int sd_network_link_get_llmnr(int ifindex, char **llmnr);
03cc0fd1 106
9b4d1882
TG
107/* Get the DNS domain names for a given link. */
108int sd_network_link_get_domains(int ifindex, char ***domains);
109
fe8db0c5
TG
110/* Monitor object */
111typedef struct sd_network_monitor sd_network_monitor;
112
7e141e49 113/* Create a new monitor. Category must be NULL, "links" or "leases". */
0014a4ad 114int sd_network_monitor_new(sd_network_monitor **ret, const char *category);
fe8db0c5
TG
115
116/* Destroys the passed monitor. Returns NULL. */
117sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m);
118
119/* Flushes the monitor */
120int sd_network_monitor_flush(sd_network_monitor *m);
121
122/* Get FD from monitor */
123int sd_network_monitor_get_fd(sd_network_monitor *m);
124
125/* Get poll() mask to monitor */
126int sd_network_monitor_get_events(sd_network_monitor *m);
127
128/* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */
129int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec);
130
131_SD_END_DECLARATIONS;
132
133#endif