static int discover_server_process_message(void *arg)
{
struct pb_protocol_message *message;
+ struct boot_command *boot_command;
struct client *client = arg;
message = pb_protocol_read_message(client, client->fd);
return 0;
}
- /* todo: process boot message */
+ boot_command = pb_protocol_deserialise_boot_command(client, message);
+ if (!boot_command) {
+ pb_log("%s: no boot command?", __func__);
+ return 0;
+ }
+
+ /* todo: pass boot_command to client->server->device_handler */
+
return 0;
}
talloc_free(dev);
return NULL;
}
+
+struct boot_command *pb_protocol_deserialise_boot_command(void *ctx,
+ const struct pb_protocol_message *message)
+{
+ struct boot_command *cmd;
+ const char *pos;
+ unsigned int len;
+
+ len = message->payload_len;
+ pos = message->payload;
+
+ cmd = talloc(ctx, struct boot_command);
+
+ if (read_string(cmd, &pos, &len, &cmd->option_id))
+ goto out_err;
+
+ if (read_string(cmd, &pos, &len, &cmd->boot_image_file))
+ goto out_err;
+
+ if (read_string(cmd, &pos, &len, &cmd->initrd_file))
+ goto out_err;
+
+ if (read_string(cmd, &pos, &len, &cmd->boot_args))
+ goto out_err;
+
+ return cmd;
+
+out_err:
+ talloc_free(cmd);
+ return NULL;
+}
struct device *pb_protocol_deserialise_device(void *ctx,
const struct pb_protocol_message *message);
+struct boot_command *pb_protocol_deserialise_boot_command(void *ctx,
+ const struct pb_protocol_message *message);
+
#endif /* _PB_PROTOCOL_H */