return client_write_message(server, client, message);
}
+static int write_boot_status_message(struct discover_server *server,
+ struct client *client, const struct boot_status *status)
+{
+ struct pb_protocol_message *message;
+ int len;
+
+ len = pb_protocol_boot_status_len(status);
+
+ message = pb_protocol_create_message(client,
+ PB_PROTOCOL_ACTION_STATUS, len);
+ if (!message)
+ return -1;
+
+ pb_protocol_serialise_boot_status(status, message->payload, len);
+
+ return client_write_message(server, client, message);
+}
+
static int discover_server_process_message(void *arg)
{
struct pb_protocol_message *message;
/* send existing devices to client */
n_devices = device_handler_get_device_count(server->device_handler);
for (i = 0; i < n_devices; i++) {
- const struct device *device;
- struct boot_option *opt;
+ const struct discover_boot_option *opt;
+ const struct discover_device *device;
device = device_handler_get_device(server->device_handler, i);
- write_device_add_message(server, client, device);
+ write_device_add_message(server, client, device->device);
list_for_each_entry(&device->boot_options, opt, list)
- discover_server_notify_boot_option_add(server, opt);
+ discover_server_notify_boot_option_add(server,
+ opt->option);
}
}
+void discover_server_notify_boot_status(struct discover_server *server,
+ struct boot_status *status)
+{
+ struct client *client;
+
+ list_for_each_entry(&server->clients, client, list)
+ write_boot_status_message(server, client, status);
+}
+
void discover_server_set_device_source(struct discover_server *server,
struct device_handler *handler)
{