return 0; // XXX TODO
}
+static int nw_link_initialize(nw_link* link) {
+ sd_device *device = NULL;
+ int r;
+
+ // Fetch device
+ r = sd_device_new_from_ifindex(&device, link->ifindex);
+ if (r < 0) {
+ WARNING("Could not find device for link %d: %s\n", link->ifindex, strerror(-r));
+ r = 0;
+ goto ERROR;
+ }
+
+ // Check if device is initialized
+ r = sd_device_get_is_initialized(device);
+ switch (r) {
+ // Initialized - fallthrough
+ case 0:
+ break;
+
+ case 1:
+ DEBUG("The device has not been initialized, yet\n");
+ r = 0;
+ goto ERROR;
+
+ default:
+ WARNING("Could not check whether device is initialized, ignoring: %s\n",
+ strerror(-r));
+ goto ERROR;
+ }
+
+ // XXX Check renaming?!
+
+ if (link->device)
+ sd_device_unref(link->device);
+
+ // Store the device
+ link->device = sd_device_ref(device);
+
+ DEBUG("Link %d has been initialized\n", link->ifindex);
+
+ERROR:
+ if (device)
+ sd_device_unref(device);
+
+ return r;
+}
+
static int nw_link_update_ifname(nw_link* link, sd_netlink_message* message) {
const char* ifname = NULL;
int r;
goto ERROR;
}
+ // Initialize the link
+ r = nw_link_initialize(link);
+ if (r < 0)
+ goto ERROR;
+
// Add it to the list
r = nw_links_add_link(links, link);
if (r)