- if (message->action != PB_PROTOCOL_ACTION_BOOT) {
- pb_log("%s: invalid action %d\n", __func__, message->action);
- return 0;
- }
-
- boot_command = talloc(client, struct boot_command);
-
- rc = pb_protocol_deserialise_boot_command(boot_command, message);
- if (rc) {
- pb_log("%s: no boot command?", __func__);
+ switch (message->action) {
+ case PB_PROTOCOL_ACTION_BOOT:
+ boot_command = talloc(client, struct boot_command);
+
+ rc = pb_protocol_deserialise_boot_command(boot_command,
+ message);
+ if (rc) {
+ pb_log_fn("no boot command?\n");
+ return 0;
+ }
+
+ device_handler_boot(client->server->device_handler,
+ boot_command);
+ break;
+
+ case PB_PROTOCOL_ACTION_CANCEL_DEFAULT:
+ 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_fn("no config?\n");
+ 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;
+
+ case PB_PROTOCOL_ACTION_PLUGIN_INSTALL:
+ url = pb_protocol_deserialise_string((void *) client, message);
+
+ device_handler_install_plugin(client->server->device_handler,
+ url);
+ break;
+
+ case PB_PROTOCOL_ACTION_TEMP_AUTOBOOT:
+ autoboot_opt = talloc_zero(client, struct autoboot_option);
+ rc = pb_protocol_deserialise_temp_autoboot(autoboot_opt,
+ message);
+ if (rc) {
+ pb_log("can't parse temporary autoboot message\n");
+ return 0;
+ }
+
+ device_handler_apply_temp_autoboot(
+ client->server->device_handler,
+ autoboot_opt);
+ break;
+
+ default:
+ pb_log_fn("invalid action %d\n", message->action);