int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_id) { #if 0 /* NM_IGNORED */ /* name is a pointer to memory in the udev_device struct, so must have the same scope */ _cleanup_udev_device_unref_ struct udev_device *device = NULL; #else /* NM_IGNORED */ char name_buf[IF_NAMESIZE]; #endif /* NM_IGNORED */ const char *name = NULL; uint64_t id; #if 0 /* NM_IGNORED */ if (detect_container() <= 0) { /* not in a container, udev will be around */ _cleanup_udev_unref_ struct udev *udev; char ifindex_str[2 + DECIMAL_STR_MAX(int)]; udev = udev_new(); if (!udev) return -ENOMEM; sprintf(ifindex_str, "n%d", ifindex); device = udev_device_new_from_device_id(udev, ifindex_str); if (device) { if (udev_device_get_is_initialized(device) <= 0) /* not yet ready */ return -EBUSY; name = net_get_name(device); } }
static int udev_initialized(const char *ifname) { struct udev_device *device; int r; device = udev_device_new_from_subsystem_sysname(udev, "net", ifname); if (device) { #ifndef LIBUDEV_NOINIT r = udev_device_get_is_initialized(device); #else r = 1; #endif udev_device_unref(device); } else r = 0; return r; }