networkd-wait-online-link.c revision d6731e4c7964ee2860d4f5abdb0b52acd7a66960
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen This file is part of systemd.
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen Copyright 2014 Lennart Poettering
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen Copyright 2014 Tom Gundersen
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen systemd is free software; you can redistribute it and/or modify it
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen under the terms of the GNU Lesser General Public License as published by
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen (at your option) any later version.
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen systemd is distributed in the hope that it will be useful, but
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen Lesser General Public License for more details.
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen You should have received a copy of the GNU Lesser General Public License
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersenint link_new(Manager *m, Link **ret, int ifindex, const char *ifname) {
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen r = hashmap_ensure_allocated(&m->links, NULL, NULL);
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen r = hashmap_ensure_allocated(&m->links_by_name,
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen r = hashmap_put(m->links_by_name, l->ifname, l);
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen r = hashmap_put(m->links, INT_TO_PTR(ifindex), l);
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen hashmap_remove(l->manager->links, INT_TO_PTR(l->ifindex));
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen hashmap_remove(l->manager->links_by_name, l->ifname);
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersenint link_update_rtnl(Link *l, sd_rtnl_message *m) {
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen r = sd_rtnl_message_link_get_flags(m, &l->flags);
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen r = sd_rtnl_message_read_string(m, IFLA_IFNAME, &ifname);
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen hashmap_remove(l->manager->links_by_name, l->ifname);
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen r = hashmap_put(l->manager->links_by_name, l->ifname, l);
d6731e4c7964ee2860d4f5abdb0b52acd7a66960Tom Gundersen sd_network_link_get_operational_state(l->ifindex, &l->operational_state);
d6731e4c7964ee2860d4f5abdb0b52acd7a66960Tom Gundersen sd_network_link_get_state(l->ifindex, &l->state);
7de12ae764e73730df0658f9fb04bcf42add48e2Tom Gundersen return false;