discover: Support IPv6 addresses
[petitboot] / discover / user-event.c
index 7f63d43ae331f9794d6936b75605827fe3331987..ee282bb48c7f6b909134e42ef1388e0c27b9cde9 100644 (file)
@@ -390,7 +390,9 @@ static int user_event_dhcp(struct user_event *uev, struct event *event)
 
        uint8_t hwaddr[MAC_ADDR_SIZE];
 
-       if (!event_get_param(event, "mac") || !event_get_param(event, "ip"))
+       if (!event_get_param(event, "mac"))
+               return -1;
+       if (!event_get_param(event, "ip") && !event_get_param(event, "ipv6"))
                return -1;
 
        sscanf(event_get_param(event, "mac"),
@@ -398,8 +400,12 @@ static int user_event_dhcp(struct user_event *uev, struct event *event)
               hwaddr, hwaddr + 1, hwaddr + 2,
               hwaddr + 3, hwaddr + 4, hwaddr + 5);
 
-       system_info_set_interface_address(sizeof(hwaddr), hwaddr,
-                                         event_get_param(event, "ip"));
+       if (event_get_param(event, "ipv6"))
+               system_info_set_interface_address(sizeof(hwaddr), hwaddr,
+                                                 event_get_param(event, "ipv6"));
+       else
+               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);