discover: Record IP address of network interfaces
[petitboot] / discover / user-event.c
index 20b2bea928ea75b221deac7ed675fd9f44345f81..fb3fddb5c4bc5f7390f114ec7820f33d7ec45e77 100644 (file)
@@ -37,6 +37,7 @@
 #include "resource.h"
 #include "event.h"
 #include "user-event.h"
+#include "sysinfo.h"
 
 
 #define MAC_ADDR_SIZE  6
@@ -385,6 +386,16 @@ static int user_event_dhcp(struct user_event *uev, struct event *event)
        struct device_handler *handler = uev->handler;
        struct discover_device *dev;
 
+       uint8_t hwaddr[MAC_ADDR_SIZE];
+
+       sscanf(event_get_param(event, "mac"),
+              "%hhX:%hhX:%hhX:%hhX:%hhX:%hhX",
+              hwaddr, hwaddr + 1, hwaddr + 2,
+              hwaddr + 3, hwaddr + 4, hwaddr + 5);
+
+       system_info_set_interface_address(sizeof(hwaddr), hwaddr,
+                                         event_get_param(event, "ip"));
+
        dev = discover_device_create(handler, event_get_param(event, "mac"),
                                        event->device);