sd-network.h revision 71d35b6b5563817dfbe757ab9e3b9f018b2db491
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering
12b42c76672a66c2d4ea7212c14f8f1b5a62b78dTom Gundersen#ifndef foosdnetworkhfoo
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering#define foosdnetworkhfoo
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering/***
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering This file is part of systemd.
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering Copyright 2011 Lennart Poettering
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering Copyright 2014 Tom Gundersen
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering systemd is free software; you can redistribute it and/or modify it
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering under the terms of the GNU Lesser General Public License as published by
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering (at your option) any later version.
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering systemd is distributed in the hope that it will be useful, but
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering Lesser General Public License for more details.
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering You should have received a copy of the GNU Lesser General Public License
30f10abf42f9e4d251a0b45b07812aafdef6be7cLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
efd51554aea0f226a7f6704a72aa6a3c9fc6cb2fMichael Biebl***/
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include <inttypes.h>
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include <sys/types.h>
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#include "_sd-common.h"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/*
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * A few points:
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek *
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Instead of returning an empty string array or empty integer array, we
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * may return NULL.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek *
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Free the data the library returns with libc free(). String arrays
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * are NULL terminated, and you need to free the array itself in
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * addition to the strings contained.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek *
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * We return error codes as negative errno, kernel-style. On success, we
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * return 0 or positive.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek *
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * These functions access data in /run. This is a virtual file system;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * therefore, accesses are relatively cheap.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek *
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * See sd-network(3) for more information.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek_SD_BEGIN_DECLARATIONS;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get overall operational state
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Possible states: down, up, dormant, carrier, degraded, routable
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Possible return codes:
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * -ENODATA: networkd is not aware of any links
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_get_operational_state(char **state);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get DNS entries for all links. These are string representations of
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * IP addresses */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_get_dns(char ***dns);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get NTP entries for all links. These are domain names or string
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * representations of IP addresses */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_get_ntp(char ***ntp);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get the search/routing domains for all links. */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_get_domains(char ***domains);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get setup state from ifindex.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Possible states:
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * pending: udev is still processing the link, we don't yet know if we will manage it
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * failed: networkd failed to manage the link
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * configuring: in the process of retrieving configuration or configuring the link
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * configured: link configured successfully
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * unmanaged: networkd is not handling the link
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * linger: the link is gone, but has not yet been dropped by networkd
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Possible return codes:
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * -ENODATA: networkd is not aware of the link
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_link_get_setup_state(int ifindex, char **state);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
a8eaaee72a2f06e0fb64fb71de3b71ecba31dafbJan Engelhardt/* Get operational state from ifindex.
a8eaaee72a2f06e0fb64fb71de3b71ecba31dafbJan Engelhardt * Possible states:
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * off: the device is powered down
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * no-carrier: the device is powered up, but it does not yet have a carrier
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * dormant: the device has a carrier, but is not yet ready for normal traffic
b938cb902c3b5bca807a94b277672c64d6767886Jan Engelhardt * carrier: the link has a carrier
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * degraded: the link has carrier and addresses valid on the local link configured
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * routable: the link has carrier and routable address configured
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Possible return codes:
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * -ENODATA: networkd is not aware of the link
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek */
3ba3a79df4ae094d1008c04a9af8d1ff970124c4Zbigniew Jędrzejewski-Szmekint sd_network_link_get_operational_state(int ifindex, char **state);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get path to .network file applied to link */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_link_get_network_file(int ifindex, char **filename);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get DNS entries for a given link. These are string representations of
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * IP addresses */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_link_get_dns(int ifindex, char ***addr);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get NTP entries for a given link. These are domain names or string
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * representations of IP addresses */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_link_get_ntp(int ifindex, char ***addr);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Indicates whether or not LLMNR should be enabled for the link
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Possible levels of support: yes, no, resolve
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Possible return codes:
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * -ENODATA: networkd is not aware of the link
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_link_get_llmnr(int ifindex, char **llmnr);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_link_get_lldp(int ifindex, char **lldp);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get the DNS domain names for a given link. */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_link_get_domains(int ifindex, char ***domains);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get the CARRIERS to which current link is bound to. */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_link_get_carrier_bound_to(int ifindex, char ***carriers);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get the CARRIERS that are bound to current link. */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_link_get_carrier_bound_by(int ifindex, char ***carriers);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get the timezone that was learnt on a specific link. */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_link_get_timezone(int ifindex, char **timezone);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
3ba3a79df4ae094d1008c04a9af8d1ff970124c4Zbigniew Jędrzejewski-Szmek/* Returns whether or not domains that don't match any link should be resolved
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * on this link. 1 for yes, 0 for no and negative value for error */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_link_get_wildcard_domain(int ifindex);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Monitor object */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmektypedef struct sd_network_monitor sd_network_monitor;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Create a new monitor. Category must be NULL, "links" or "leases". */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_monitor_new(sd_network_monitor **ret, const char *category);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Destroys the passed monitor. Returns NULL. */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmeksd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Flushes the monitor */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_monitor_flush(sd_network_monitor *m);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get FD from monitor */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_monitor_get_fd(sd_network_monitor *m);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get poll() mask to monitor */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_monitor_get_events(sd_network_monitor *m);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekint sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec);
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek_SD_END_DECLARATIONS;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek#endif
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek