sd-network.h revision fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
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
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * are NULL terminated and you need to free the array itself in
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * addition to the strings contained.
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * We return error codes as negative errno, kernel-style. 0 or
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * positive on success.
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * These functions access data in /run. This is a virtual file systems,
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * hence the accesses is relatively cheap.
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * See sd-network(3) for more information.
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen/* Get state from ifindex. Possible states: unknown, unmanaged, failed, configuring, configured */
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersenint sd_network_get_link_state(unsigned index, char**state);
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen/* Get DHCPv4 lease from ifindex. */
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersenint sd_network_get_dhcp_lease(unsigned index, sd_dhcp_lease **ret);
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen/* Get all network interfaces indices, store in *indices. Returns the
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen * number of indices. If indices is NULL only returns the number of indices. */
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersenint sd_network_get_ifindices(unsigned **indices);
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen/* Monitor object */
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersentypedef struct sd_network_monitor sd_network_monitor;
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersen/* Create a new monitor. Category must be NULL. */
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersenint sd_network_monitor_new(const char *category, sd_network_monitor** ret);
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 */