From 85bd33ca9777c386359b9b3899888316354a4e1f Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Wed, 2 Apr 2014 14:53:07 +0800 Subject: [PATCH] protocol: expose discovery reinit over client/server protocol Now that we can re-initialise the device handler, allow this to be triggered from UIs over the petitboot protocol. Signed-off-by: Jeremy Kerr --- discover/device-handler.c | 2 +- discover/device-handler.h | 1 + discover/discover-server.c | 4 ++++ lib/pb-protocol/pb-protocol.h | 1 + ui/common/discover-client.c | 13 +++++++++++++ ui/common/discover-client.h | 3 +++ 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/discover/device-handler.c b/discover/device-handler.c index f5dc32c..dd3aee9 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -294,7 +294,7 @@ struct device_handler *device_handler_init(struct discover_server *server, return handler; } -static void device_handler_reinit(struct device_handler *handler) +void device_handler_reinit(struct device_handler *handler) { struct discover_boot_option *opt, *tmp; unsigned int i; diff --git a/discover/device-handler.h b/discover/device-handler.h index bad7447..246abf9 100644 --- a/discover/device-handler.h +++ b/discover/device-handler.h @@ -117,6 +117,7 @@ void device_handler_boot(struct device_handler *handler, void device_handler_cancel_default(struct device_handler *handler); void device_handler_update_config(struct device_handler *handler, struct config *config); +void device_handler_reinit(struct device_handler *handler); int device_request_write(struct discover_device *dev, bool *release); void device_release_write(struct discover_device *dev, bool release); diff --git a/discover/discover-server.c b/discover/discover-server.c index 1765074..80919fd 100644 --- a/discover/discover-server.c +++ b/discover/discover-server.c @@ -245,6 +245,10 @@ 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); diff --git a/lib/pb-protocol/pb-protocol.h b/lib/pb-protocol/pb-protocol.h index 901bb9d..d6f149c 100644 --- a/lib/pb-protocol/pb-protocol.h +++ b/lib/pb-protocol/pb-protocol.h @@ -21,6 +21,7 @@ enum pb_protocol_action { PB_PROTOCOL_ACTION_CANCEL_DEFAULT = 0x7, PB_PROTOCOL_ACTION_SYSTEM_INFO = 0x8, PB_PROTOCOL_ACTION_CONFIG = 0x9, + PB_PROTOCOL_ACTION_REINIT = 0xa, }; struct pb_protocol_message { diff --git a/ui/common/discover-client.c b/ui/common/discover-client.c index 0e7da9d..fbf70ba 100644 --- a/ui/common/discover-client.c +++ b/ui/common/discover-client.c @@ -333,6 +333,19 @@ int discover_client_cancel_default(struct discover_client *client) return pb_protocol_write_message(client->fd, message); } +int discover_client_send_reinit(struct discover_client *client) +{ + struct pb_protocol_message *message; + + message = pb_protocol_create_message(client, + PB_PROTOCOL_ACTION_REINIT, 0); + + if (!message) + return -1; + + return pb_protocol_write_message(client->fd, message); +} + int discover_client_send_config(struct discover_client *client, struct config *config) { diff --git a/ui/common/discover-client.h b/ui/common/discover-client.h index 68be8a5..405bd24 100644 --- a/ui/common/discover-client.h +++ b/ui/common/discover-client.h @@ -76,6 +76,9 @@ int discover_client_boot(struct discover_client *client, */ int discover_client_cancel_default(struct discover_client *client); +/* Tell the discover server to reinitialise */ +int discover_client_send_reinit(struct discover_client *client); + /* Send new configuration data to the discover server */ int discover_client_send_config(struct discover_client *client, struct config *config); -- 2.39.2