Add spice_server_set_name() and spice_server_set_uuid() that allows the client to identify a Spice server (useful to associate settings with a particular server)
The SPICE_MSG_MAIN_NAME and SPICE_MSG_MAIN_UUID messages are only sent to capable clients, announcing SPICE_MAIN_CAP_NAME and SPICE_MAIN_CAP_UUID respectively. --- common/messages.h | 9 ++++++ server/main_channel.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++ server/main_channel.h | 3 ++ server/reds.c | 20 ++++++++++++++ server/reds.h | 1 + server/spice-server.syms | 6 ++++ server/spice.h | 5 +++- spice-protocol | 2 +- spice.proto | 10 +++++++ 9 files changed, 119 insertions(+), 2 deletions(-) diff --git a/common/messages.h b/common/messages.h index a54190f..ec58da5 100644 --- a/common/messages.h +++ b/common/messages.h @@ -149,6 +149,15 @@ typedef struct SpiceMsgChannels { SpiceChannelId channels[0]; } SpiceMsgChannels; +typedef struct SpiceMsgMainName { + uint32_t name_len; + uint8_t name[0]; +} SpiceMsgMainName; + +typedef struct SpiceMsgMainUuid { + uint8_t uuid[16]; +} SpiceMsgMainUuid; + typedef struct SpiceMsgMainMouseMode { uint32_t supported_modes; uint32_t current_mode; diff --git a/server/main_channel.c b/server/main_channel.c index 878f62d..bc1ac3c 100644 --- a/server/main_channel.c +++ b/server/main_channel.c @@ -103,6 +103,16 @@ typedef struct InitPipeItem { int ram_hint; } InitPipeItem; +typedef struct NamePipeItem { + PipeItem base; + SpiceMsgMainName msg; +} NamePipeItem; + +typedef struct UuidPipeItem { + PipeItem base; + SpiceMsgMainUuid msg; +} UuidPipeItem; + typedef struct NotifyPipeItem { PipeItem base; uint8_t *mess; @@ -267,6 +277,29 @@ static PipeItem *main_init_item_new(MainChannelClient *mcc, return &item->base; } +static PipeItem *main_name_item_new(MainChannelClient *mcc, const char *name) +{ + NamePipeItem *item = spice_malloc(sizeof(NamePipeItem) + strlen(name) + 1); + + red_channel_pipe_item_init(mcc->base.channel, &item->base, + SPICE_MSG_MAIN_NAME); + item->msg.name_len = strlen(name) + 1; + memcpy(&item->msg.name, name, item->msg.name_len); + + return &item->base; +} + +static PipeItem *main_uuid_item_new(MainChannelClient *mcc, const uint8_t uuid[16]) +{ + UuidPipeItem *item = spice_malloc(sizeof(UuidPipeItem)); + + red_channel_pipe_item_init(mcc->base.channel, &item->base, + SPICE_MSG_MAIN_UUID); + memcpy(item->msg.uuid, uuid, sizeof(item->msg.uuid)); + + return &item->base; +} + typedef struct NotifyPipeInfo { uint8_t *mess; int mess_len; @@ -501,6 +534,30 @@ static void main_channel_marshall_init(SpiceMarshaller *m, spice_marshall_msg_main_init(m, &init); } +void main_channel_push_name(MainChannelClient *mcc, const char *name) +{ + PipeItem *item; + + if (!red_channel_client_test_remote_cap(&mcc->base, + SPICE_MAIN_CAP_NAME)) + return; + + item = main_name_item_new(mcc, name); + red_channel_client_pipe_add_push(&mcc->base, item); +} + +void main_channel_push_uuid(MainChannelClient *mcc, const uint8_t uuid[16]) +{ + PipeItem *item; + + if (!red_channel_client_test_remote_cap(&mcc->base, + SPICE_MAIN_CAP_UUID)) + return; + + item = main_uuid_item_new(mcc, uuid); + red_channel_client_pipe_add_push(&mcc->base, item); +} + // TODO - some notifications are new client only (like "keyboard is insecure" on startup) void main_channel_push_notify(MainChannel *main_chan, uint8_t *mess, const int mess_len) { @@ -692,6 +749,14 @@ static void main_channel_send_item(RedChannelClient *rcc, PipeItem *base) case SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST: main_channel_marshall_migrate_switch(m, rcc); break; + case SPICE_MSG_MAIN_NAME: + spice_marshall_msg_main_name(m, &SPICE_CONTAINEROF(base, NamePipeItem, base)->msg); + break; + case SPICE_MSG_MAIN_UUID: + spice_marshall_msg_main_uuid(m, &SPICE_CONTAINEROF(base, UuidPipeItem, base)->msg); + break; + default: + break; }; red_channel_client_begin_send_message(rcc); } diff --git a/server/main_channel.h b/server/main_channel.h index c5d407e..afff313 100644 --- a/server/main_channel.h +++ b/server/main_channel.h @@ -103,4 +103,7 @@ int main_channel_migrate_connect(MainChannel *main_channel, RedsMigSpice *mig_ta void main_channel_migrate_cancel_wait(MainChannel *main_chan); /* returns the number of clients for which SPICE_MSG_MAIN_MIGRATE_END was sent*/ int main_channel_migrate_complete(MainChannel *main_chan, int success); +void main_channel_push_name(MainChannelClient *mcc, const char *name); +void main_channel_push_uuid(MainChannelClient *mcc, const uint8_t uuid[16]); + #endif diff --git a/server/reds.c b/server/reds.c index 797d9d5..5906e59 100644 --- a/server/reds.c +++ b/server/reds.c @@ -35,6 +35,7 @@ #include <fcntl.h> #include <errno.h> #include <ctype.h> +#include <stdbool.h> #include <openssl/bio.h> #include <openssl/pem.h> @@ -100,6 +101,9 @@ static int sasl_enabled = 0; // sasl disabled by default #if HAVE_SASL static char *sasl_appname = NULL; // default to "spice" if NULL #endif +static char *spice_name = NULL; +static bool spice_uuid_is_set = FALSE; +static uint8_t spice_uuid[16] = { 0, }; static int ticketing_enabled = 1; //Ticketing is enabled by default static pthread_mutex_t *lock_cs; @@ -1668,6 +1672,10 @@ static void reds_handle_main_link(RedLinkInfo *link) reds->mouse_mode, reds->is_client_mouse_allowed, reds_get_mm_time() - MM_TIME_DELTA, red_dispatcher_qxl_ram_size()); + if (spice_name) + main_channel_push_name(mcc, spice_name); + if (spice_uuid_is_set) + main_channel_push_uuid(mcc, spice_uuid); main_channel_client_start_net_test(mcc); /* Now that we have a client, forward any pending agent data */ @@ -3799,6 +3807,18 @@ SPICE_GNUC_VISIBLE int spice_server_set_sasl_appname(SpiceServer *s, const char #endif } +SPICE_GNUC_VISIBLE void spice_server_set_name(SpiceServer *s, const char *name) +{ + free(spice_name); + spice_name = strdup(name); +} + +SPICE_GNUC_VISIBLE void spice_server_set_uuid(SpiceServer *s, const uint8_t uuid[16]) +{ + memcpy(spice_uuid, uuid, sizeof(spice_uuid)); + spice_uuid_is_set = TRUE; +} + SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *s, const char *passwd, int lifetime, int fail_if_connected, diff --git a/server/reds.h b/server/reds.h index 1fd18a7..1c59e68 100644 --- a/server/reds.h +++ b/server/reds.h @@ -152,4 +152,5 @@ void reds_on_main_migrate_connected(void); //should be called when all the clien void reds_on_main_receive_migrate_data(MainMigrateData *data, uint8_t *end); void reds_on_main_mouse_mode_request(void *message, size_t size); void reds_on_client_migrate_complete(RedClient *client); + #endif diff --git a/server/spice-server.syms b/server/spice-server.syms index d9beec3..272548e 100644 --- a/server/spice-server.syms +++ b/server/spice-server.syms @@ -101,3 +101,9 @@ global: spice_server_add_client; spice_server_add_ssl_client; } SPICE_SERVER_0.10.0; + +SPICE_SERVER_0.10.2 { +global: + spice_server_set_name; + spice_server_set_uuid; +} SPICE_SERVER_0.10.1; diff --git a/server/spice.h b/server/spice.h index 7397655..151b3db 100644 --- a/server/spice.h +++ b/server/spice.h @@ -22,7 +22,7 @@ #include <sys/socket.h> #include <spice/qxl_dev.h> -#define SPICE_SERVER_VERSION 0x000a01 /* release 0.10.1 */ +#define SPICE_SERVER_VERSION 0x000a02 /* release 0.10.2 */ /* interface base type */ @@ -519,4 +519,7 @@ int spice_server_migrate_connect(SpiceServer *s, const char* dest, int spice_server_migrate_start(SpiceServer *s); int spice_server_migrate_end(SpiceServer *s, int completed); +void spice_server_set_name(SpiceServer *s, const char *name); +void spice_server_set_uuid(SpiceServer *s, const uint8_t uuid[16]); + #endif diff --git a/spice-protocol b/spice-protocol index d5edafd..18b03ac 160000 --- a/spice-protocol +++ b/spice-protocol @@ -1 +1 @@ -Subproject commit d5edafd28ab762b1b5f663aec449d3e3743f1184 +Subproject commit 18b03ac201048e8b2edafa1541cc4e9c1f55fe67 diff --git a/spice.proto b/spice.proto index 0e15fe7..ae27c8d 100644 --- a/spice.proto +++ b/spice.proto @@ -134,6 +134,7 @@ channel BaseChannel { } notify; Data list; /* the msg body is SpiceSubMessageList */ + client: message { uint32 generation; @@ -222,6 +223,15 @@ channel MainChannel : BaseChannel { Empty migrate_end; + message { + uint32 name_len; + uint8 name[name_len]; + } name; + + message { + uint8 uuid[16]; + } uuid; + client: message { uint64 cache_size; -- 1.7.7.6 _______________________________________________ Spice-devel mailing list Spice-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/spice-devel