fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen This file is part of systemd.
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen Copyright 2011 Lennart Poettering
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen Copyright 2014 Tom Gundersen
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen systemd is free software; you can redistribute it and/or modify it
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen under the terms of the GNU Lesser General Public License as published by
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen (at your option) any later version.
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen systemd is distributed in the hope that it will be useful, but
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen Lesser General Public License for more details.
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen You should have received a copy of the GNU Lesser General Public License
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * A few points:
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * Instead of returning an empty string array or empty integer array, we
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * may return NULL.
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * Free the data the library returns with libc free(). String arrays
10b17992ee59ac1d03d6fc210a976bc2b59f6d75Jason St. John * are NULL terminated, and you need to free the array itself in
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * addition to the strings contained.
10b17992ee59ac1d03d6fc210a976bc2b59f6d75Jason St. John * We return error codes as negative errno, kernel-style. On success, we
10b17992ee59ac1d03d6fc210a976bc2b59f6d75Jason St. John * return 0 or positive.
10b17992ee59ac1d03d6fc210a976bc2b59f6d75Jason St. John * These functions access data in /run. This is a virtual file system;
10b17992ee59ac1d03d6fc210a976bc2b59f6d75Jason St. John * therefore, accesses are relatively cheap.
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * See sd-network(3) for more information.
6436165dbc500f14abfec738af28f87a71f6a12aLennart Poettering/* Get overall operational state
54cba0b16cdc94d5c21e8d805a4ade1255d43bc9Tom Gundersen * Possible states: down, up, dormant, carrier, degraded, routable
6436165dbc500f14abfec738af28f87a71f6a12aLennart Poettering * Possible return codes:
6436165dbc500f14abfec738af28f87a71f6a12aLennart Poettering * -ENODATA: networkd is not aware of any links
6436165dbc500f14abfec738af28f87a71f6a12aLennart Poetteringint sd_network_get_operational_state(char **state);
03cc0fd1431b82e59c11ae12a274c1f2df23169dLennart Poettering/* Get DNS entries for all links. These are string representations of
03cc0fd1431b82e59c11ae12a274c1f2df23169dLennart Poettering * IP addresses */
03cc0fd1431b82e59c11ae12a274c1f2df23169dLennart Poettering/* Get NTP entries for all links. These are domain names or string
91c40d86120f3bf033539a53c971d99f5dd70708Torstein Husebø * representations of IP addresses */
3df9bec57c3e2d96f7e2a25961585cfa609b61ebLennart Poettering/* Get the search domains for all links. */
3df9bec57c3e2d96f7e2a25961585cfa609b61ebLennart Poetteringint sd_network_get_search_domains(char ***domains);
3df9bec57c3e2d96f7e2a25961585cfa609b61ebLennart Poettering/* Get the search domains for all links. */
3df9bec57c3e2d96f7e2a25961585cfa609b61ebLennart Poetteringint sd_network_get_route_domains(char ***domains);
438ca2bbd4dc1de6193ec61f3c12e19cded7921dTom Gundersen/* Get setup state from ifindex.
8434fd5cf23f998a0f3a0f947a4308a8c18ba7a5Tom Gundersen * Possible states:
8434fd5cf23f998a0f3a0f947a4308a8c18ba7a5Tom Gundersen * pending: udev is still processing the link, we don't yet know if we will manage it
8434fd5cf23f998a0f3a0f947a4308a8c18ba7a5Tom Gundersen * failed: networkd failed to manage the link
8434fd5cf23f998a0f3a0f947a4308a8c18ba7a5Tom Gundersen * configuring: in the process of retrieving configuration or configuring the link
8434fd5cf23f998a0f3a0f947a4308a8c18ba7a5Tom Gundersen * configured: link configured successfully
8434fd5cf23f998a0f3a0f947a4308a8c18ba7a5Tom Gundersen * unmanaged: networkd is not handling the link
8434fd5cf23f998a0f3a0f947a4308a8c18ba7a5Tom Gundersen * linger: the link is gone, but has not yet been dropped by networkd
deb2e5230b4dcbc0e2e02cc47a0b2d0d7179a044Tom Gundersen * Possible return codes:
deb2e5230b4dcbc0e2e02cc47a0b2d0d7179a044Tom Gundersen * -ENODATA: networkd is not aware of the link
438ca2bbd4dc1de6193ec61f3c12e19cded7921dTom Gundersenint sd_network_link_get_setup_state(int ifindex, char **state);
91c40d86120f3bf033539a53c971d99f5dd70708Torstein Husebø/* Get operational state from ifindex.
d3df0e3982777fd5de8cffaa585eba0af3773c08Tom Gundersen * Possible states:
d3df0e3982777fd5de8cffaa585eba0af3773c08Tom Gundersen * off: the device is powered down
d3df0e3982777fd5de8cffaa585eba0af3773c08Tom Gundersen * no-carrier: the device is powered up, but it does not yet have a carrier
d3df0e3982777fd5de8cffaa585eba0af3773c08Tom Gundersen * dormant: the device has a carrier, but is not yet ready for normal traffic
d3df0e3982777fd5de8cffaa585eba0af3773c08Tom Gundersen * carrier: the link has a carrier
d3df0e3982777fd5de8cffaa585eba0af3773c08Tom Gundersen * degraded: the link has carrier and addresses valid on the local link configured
d3df0e3982777fd5de8cffaa585eba0af3773c08Tom Gundersen * routable: the link has carrier and routable address configured
deb2e5230b4dcbc0e2e02cc47a0b2d0d7179a044Tom Gundersen * Possible return codes:
deb2e5230b4dcbc0e2e02cc47a0b2d0d7179a044Tom Gundersen * -ENODATA: networkd is not aware of the link
d6731e4c7964ee2860d4f5abdb0b52acd7a66960Tom Gundersenint sd_network_link_get_operational_state(int ifindex, char **state);
adc5b2e2ebcb91ee18b6a32681b8ec1e52793473Tom Gundersen/* Get path to .network file applied to link */
adc5b2e2ebcb91ee18b6a32681b8ec1e52793473Tom Gundersenint sd_network_link_get_network_file(int ifindex, char **filename);
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen/* Get DNS entries for a given link. These are string representations of
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen * IP addresses */
d6731e4c7964ee2860d4f5abdb0b52acd7a66960Tom Gundersenint sd_network_link_get_dns(int ifindex, char ***addr);
6f4dedb250f2d607eceefaa491f338becbeee7c0Tom Gundersen/* Get NTP entries for a given link. These are domain names or string
91c40d86120f3bf033539a53c971d99f5dd70708Torstein Husebø * representations of IP addresses */
d6731e4c7964ee2860d4f5abdb0b52acd7a66960Tom Gundersenint sd_network_link_get_ntp(int ifindex, char ***addr);
03cc0fd1431b82e59c11ae12a274c1f2df23169dLennart Poettering/* Indicates whether or not LLMNR should be enabled for the link
03cc0fd1431b82e59c11ae12a274c1f2df23169dLennart Poettering * Possible levels of support: yes, no, resolve
03cc0fd1431b82e59c11ae12a274c1f2df23169dLennart Poettering * Possible return codes:
91c40d86120f3bf033539a53c971d99f5dd70708Torstein Husebø * -ENODATA: networkd is not aware of the link
d6731e4c7964ee2860d4f5abdb0b52acd7a66960Tom Gundersenint sd_network_link_get_llmnr(int ifindex, char **llmnr);
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering/* Indicates whether or not MulticastDNS should be enabled for the
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering * Possible levels of support: yes, no, resolve
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering * Possible return codes:
aaa297d4e5401fd4466632555432774863457f1dLennart Poettering * -ENODATA: networkd is not aware of the link
aaa297d4e5401fd4466632555432774863457f1dLennart Poetteringint sd_network_link_get_mdns(int ifindex, char **mdns);
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering/* Indicates whether or not DNSSEC should be enabled for the link
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering * Possible levels of support: yes, no, allow-downgrade
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering * Possible return codes:
ad6c04756115809d615dede330213d73edf732a8Lennart Poettering * -ENODATA: networkd is not aware of the link
ad6c04756115809d615dede330213d73edf732a8Lennart Poetteringint sd_network_link_get_dnssec(int ifindex, char **dnssec);
8a516214c4412e8a40544bd725a6d499a30cbbbfLennart Poettering/* Returns the list of per-interface DNSSEC negative trust anchors
8a516214c4412e8a40544bd725a6d499a30cbbbfLennart Poettering * Possible return codes:
8a516214c4412e8a40544bd725a6d499a30cbbbfLennart Poettering * -ENODATA: networkd is not aware of the link, or has no such data
8a516214c4412e8a40544bd725a6d499a30cbbbfLennart Poetteringint sd_network_link_get_dnssec_negative_trust_anchors(int ifindex, char ***nta);
49699bac94d24b444274f91f85c82e6fad04d029Susant Sahaniint sd_network_link_get_lldp(int ifindex, char **lldp);
3df9bec57c3e2d96f7e2a25961585cfa609b61ebLennart Poettering/* Get the search DNS domain names for a given link. */
3df9bec57c3e2d96f7e2a25961585cfa609b61ebLennart Poetteringint sd_network_link_get_search_domains(int ifindex, char ***domains);
3df9bec57c3e2d96f7e2a25961585cfa609b61ebLennart Poettering/* Get the route DNS domain names for a given link. */
3df9bec57c3e2d96f7e2a25961585cfa609b61ebLennart Poetteringint sd_network_link_get_route_domains(int ifindex, char ***domains);
0d4ad91dd4fc831c31a9775b0eadf97fea6cd7f6Alin Rauta/* Get the CARRIERS to which current link is bound to. */
0d4ad91dd4fc831c31a9775b0eadf97fea6cd7f6Alin Rautaint sd_network_link_get_carrier_bound_to(int ifindex, char ***carriers);
0d4ad91dd4fc831c31a9775b0eadf97fea6cd7f6Alin Rauta/* Get the CARRIERS that are bound to current link. */
0d4ad91dd4fc831c31a9775b0eadf97fea6cd7f6Alin Rautaint sd_network_link_get_carrier_bound_by(int ifindex, char ***carriers);
8eb9058dc1f99a5eb9b8726a978fcc0720837a10Lennart Poettering/* Get the timezone that was learnt on a specific link. */
8eb9058dc1f99a5eb9b8726a978fcc0720837a10Lennart Poetteringint sd_network_link_get_timezone(int ifindex, char **timezone);
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen/* Monitor object */
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersentypedef struct sd_network_monitor sd_network_monitor;
7e141e498c73ec7c8b61a0df37c4937f1d6becc7Tom Gundersen/* Create a new monitor. Category must be NULL, "links" or "leases". */
0014a4ad505d119c7ac4346d9d774c3f17f663a5Lennart Poetteringint sd_network_monitor_new(sd_network_monitor **ret, const char *category);
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen/* Destroys the passed monitor. Returns NULL. */
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersensd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m);
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen/* Flushes the monitor */
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersenint sd_network_monitor_flush(sd_network_monitor *m);
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen/* Get FD from monitor */
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersenint sd_network_monitor_get_fd(sd_network_monitor *m);
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen/* Get poll() mask to monitor */
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersenint sd_network_monitor_get_events(sd_network_monitor *m);
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen/* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersenint sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec);