discover: extend URL in UI to support auto-discovery
[petitboot] / discover / discover-server.c
index bd631f61bf86eac57c76dbfb8dfcb43476ad741a..68065895f4dc52b85ccb04633f87e7201398c950 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "device-handler.h"
 #include "discover-server.h"
+#include "platform.h"
 #include "sysinfo.h"
 
 struct discover_server {
@@ -214,6 +215,8 @@ static int discover_server_process_message(void *arg)
        struct pb_protocol_message *message;
        struct boot_command *boot_command;
        struct client *client = arg;
+       struct config *config;
+       char *url;
        int rc;
 
        message = pb_protocol_read_message(client, client->fd);
@@ -243,6 +246,30 @@ static int discover_server_process_message(void *arg)
                device_handler_cancel_default(client->server->device_handler);
                break;
 
+       case PB_PROTOCOL_ACTION_REINIT:
+               device_handler_reinit(client->server->device_handler);
+               break;
+
+       case PB_PROTOCOL_ACTION_CONFIG:
+               config = talloc_zero(client, struct config);
+
+               rc = pb_protocol_deserialise_config(config, message);
+               if (rc) {
+                       pb_log("%s: no config?", __func__);
+                       return 0;
+               }
+
+               device_handler_update_config(client->server->device_handler,
+                               config);
+               break;
+
+       case PB_PROTOCOL_ACTION_ADD_URL:
+               url = pb_protocol_deserialise_string((void *) client, message);
+
+               device_handler_process_url(client->server->device_handler,
+                               url, NULL, NULL);
+               break;
+
        default:
                pb_log("%s: invalid action %d\n", __func__, message->action);
                return 0;