networkd-wait-online.c revision b6b8adbff4b1a67a2fffc2c225f1b083d9e4a69e
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen This file is part of systemd.
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen Copyright 2013 Tom Gundersen <teg@jklm.no>
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen systemd is free software; you can redistribute it and/or modify it
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen under the terms of the GNU Lesser General Public License as published by
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen (at your option) any later version.
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen systemd is distributed in the hope that it will be useful, but
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen Lesser General Public License for more details.
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen You should have received a copy of the GNU Lesser General Public License
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersenstatic bool all_configured(void) {
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen return false;
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen for (i = 0; i < n; i++) {
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen r = sd_network_get_link_state(indices[i], &state);
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen return false;
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersenstatic int event_handler(sd_event_source *s, int fd, uint32_t revents,
e1528e085cefce20e93d930a45fce792e32db29aThomas Hindoe Paaboel Andersen _cleanup_event_unref_ sd_event *event = NULL;
e1528e085cefce20e93d930a45fce792e32db29aThomas Hindoe Paaboel Andersen _cleanup_event_source_unref_ sd_event_source *event_source = NULL;
e1528e085cefce20e93d930a45fce792e32db29aThomas Hindoe Paaboel Andersen _cleanup_network_monitor_unref_ sd_network_monitor *monitor = NULL;
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen log_error("This program takes no arguments.");
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen log_error("Could not create monitor: %s", strerror(-r));
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen log_error("Could not create event: %s", strerror(-r));
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen log_error("Could not get monitor fd: %s", strerror(-r));
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen events = sd_network_monitor_get_events(monitor);
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen log_error("Could not get monitor events: %s", strerror(-r));
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen r = sd_event_add_io(event, &event_source, fd, events, &event_handler,
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen log_error("Could not add io event source: %s", strerror(-r));
b6b8adbff4b1a67a2fffc2c225f1b083d9e4a69eTom Gundersen "STATUS=Waiting for network connections...");
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen log_error("Event loop failed: %s", strerror(-r));
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen "STATUS=All interfaces configured...");