]> git.ozlabs.org Git - petitboot/blobdiff - ui/common/discover-client.c
config: Implement config messages
[petitboot] / ui / common / discover-client.c
index 90cd3b419101c051e35f5da1539eb975673c22ee..de210bd785bd940af1a27eac7784dc6c87133529 100644 (file)
@@ -126,6 +126,13 @@ static void update_sysinfo(struct discover_client *client,
        talloc_free(sysinfo);
 }
 
+static void update_config(struct discover_client *client,
+               struct config *config)
+{
+       if (client->ops.update_config)
+               client->ops.update_config(config, client->ops.cb_arg);
+}
+
 static int discover_client_process(void *arg)
 {
        struct discover_client *client = arg;
@@ -133,6 +140,7 @@ static int discover_client_process(void *arg)
        struct system_info *sysinfo;
        struct boot_status *status;
        struct boot_option *opt;
+       struct config *config;
        struct device *dev;
        char *dev_id;
        int rc;
@@ -194,6 +202,16 @@ static int discover_client_process(void *arg)
                }
                update_sysinfo(client, sysinfo);
                break;
+       case PB_PROTOCOL_ACTION_CONFIG:
+               config = talloc_zero(ctx, struct config);
+
+               rc = pb_protocol_deserialise_config(config, message);
+               if (rc) {
+                       pb_log("%s: invalid config message?\n", __func__);
+                       return 0;
+               }
+               update_config(client, config);
+               break;
        default:
                pb_log("%s: unknown action %d\n", __func__, message->action);
        }
@@ -264,8 +282,7 @@ static void create_boot_command(struct boot_command *command,
                const struct boot_option *boot_option,
                const struct pb_boot_data *data)
 {
-
-       command->option_id = boot_option->id;
+       command->option_id = boot_option ? boot_option->id : NULL;
        command->boot_image_file = data->image;
        command->initrd_file = data->initrd;
        command->dtb_file = data->dtb;