diff options
author | Frediano Ziglio <fziglio@redhat.com> | 2019-02-18 16:30:37 +0000 |
---|---|---|
committer | Frediano Ziglio <freddy77@gmail.com> | 2023-12-16 18:48:20 +0000 |
commit | c234dbde69d12fd9d682a9d37fab75e76c561cd9 (patch) | |
tree | c48d22adcdfd25ca5935fe97273d45e298082194 | |
parent | 2a45c0fe38af21105fbf62c92c412f7c9c503bc2 (diff) |
WIP generate code to marshal/demarshal agent protocolagent_proto2
TODO: not used
TODO: meson
-rw-r--r-- | agent.proto | 227 | ||||
-rw-r--r-- | common/Makefile.am | 13 | ||||
-rw-r--r-- | common/agent-marshallers.h | 23 |
3 files changed, 263 insertions, 0 deletions
diff --git a/agent.proto b/agent.proto new file mode 100644 index 0000000..bf9c982 --- /dev/null +++ b/agent.proto @@ -0,0 +1,227 @@ +enum32 xfer_result { + CAN_SEND_DATA, + CANCELLED, + ERROR, + SUCCESS, + NOT_ENOUGH_SPACE, + SESSION_LOCKED, + VDAGENT_NOT_CONNECTED, + DISABLED, +} @prefix(VD_AGENT_FILE_XFER_STATUS_); + +message FileXferStatus { + uint32 id; + xfer_result result; + /* Used to send additional data for detailed error messages + * to clients with VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS capability. + * Type of data varies with the result: + * result : data type (NULL if no data) + * VD_AGENT_FILE_XFER_STATUS_NOT_ENOUGH_SPACE : uint64_t + * VD_AGENT_FILE_XFER_STATUS_SESSION_LOCKED : NULL + * VD_AGENT_FILE_XFER_STATUS_VDAGENT_NOT_CONNECTED : NULL + * VD_AGENT_FILE_XFER_STATUS_DISABLED : NULL + */ + switch (result) { + case NOT_ENOUGH_SPACE: + uint64 disk_space; + } u; +} @declare; + +message FileXferStart { + uint32 id; + /* this data contains a Glib key file with name and other attributes */ + uint8 data[] @as_ptr(data_size); +} @declare; + +message FileXferData { + uint32 id; + uint32 size; + /* this was supposed to be size but would be easy to exploit and also + * total messages are 32 bit long so is impossible */ + uint32 dummy @zero; + /* XXX as_ptr with array with size ?? possible ?? looks like an error + * declaration get 2 fields, maybe possible if no parameter and identifier! + */ + uint8 data[size]; +} @declare; + +struct MonConfig { + /* + * Note a width and height of 0 can be used to indicate a disabled + * monitor, this may only be used with agents with the + * VD_AGENT_CAP_SPARSE_MONITORS_CONFIG capability. + */ + uint32 height; + uint32 width; + uint32 depth; + int32 x; + int32 y; +} @ctype(VDAgentMonConfig); + +flags32 monitors_flags { + USE_POS +} @prefix(VD_AGENT_CONFIG_MONITORS_FLAG_); + +message MonitorsConfig { + uint32 num_of_monitors; + monitors_flags flags; + MonConfig monitors[num_of_monitors] @end; +} @ctype(VDAgentMonitorsConfig); + +flags32 display_config_flags { + DISABLE_WALLPAPER, + DISABLE_FONT_SMOOTH, + DISABLE_ANIMATION, + SET_COLOR_DEPTH, +} @prefix(VD_AGENT_DISPLAY_CONFIG_FLAG_); + +message DisplayConfig { + display_config_flags flags; + uint32 depth; +} @ctype(VDAgentDisplayConfig); + +message MouseState { + uint32 x; + uint32 y; + uint32 buttons; + uint8 display_id; +} @ctype(VDAgentMouseState); + +message Reply { + uint32 type; + uint32 error; +} @ctype(VDAgentReply); + +message MaxClipboard { + int32 max; +} @ctype(VDAgentMaxClipboard); + +message AudioVolumeSync { + uint8 is_playback; + uint8 mute; + uint8 nchannels; + uint16 volume[nchannels] @end; +} @declare; + +message Empty { +} @ctype(VDAgentClipboardRelease); // FIXME hack + +message ClipboardGrab { + uint8 selection @virtual(0); + uint32 types[] @end; +} @declare; + +message ClipboardRequest { + uint8 selection @virtual(0); + uint32 type; +} @declare; + +message ClipboardRelease { + uint8 selection @virtual(0); +} @declare; + +message Clipboard { + uint8 selection @virtual(0); + uint32 type; + uint8 data[] @as_ptr(data_size); +} @declare; + +message ClipboardGrabSel { + uint8 selection; + uint8 res1 @zero; + uint16 res2 @zero; + uint32 types[] @end; +} @ctype(VDAgentMsgClipboardGrab); + +message ClipboardRequestSel { + uint8 selection; + uint8 res1 @zero; + uint16 res2 @zero; + uint32 type; +} @ctype(VDAgentMsgClipboardRequest); + +message ClipboardReleaseSel { + uint8 selection; + uint8 res1 @zero; + uint16 res2 @zero; +} @ctype(VDAgentMsgClipboardRelease); + +message ClipboardSel { + uint8 selection; + uint8 res1 @zero; + uint16 res2 @zero; + uint32 type; + uint8 data[] @as_ptr(data_size); +} @ctype(VDAgentMsgClipboard); + +message AnnounceCapabilities { + uint32 request; + uint32 caps[] @end; +} @declare; + +struct DeviceDisplayInfo { + uint32 channel_id; + uint32 monitor_id; + uint32 device_display_id; + uint32 device_address_len; + uint8 device_address[device_address_len] @end; // a zero-terminated string +} @ctype(VDAgentDeviceDisplayInfo); + +message GraphicsDeviceInfo { + uint32 count; + DeviceDisplayInfo display_info[count] @ptr_array; +} @declare; + +/* Here terminology can be confused, + * client: sent by SPICE client or SPICE server + * server: sent by VDAgent + */ +channel VDChannelCommon { +client: + MouseState mouse_state = 1; + MonitorsConfig monitors_configs = 2; + DisplayConfig display_config = 5; // used by Windows agent only, TODO ignore in Linux + AnnounceCapabilities announce_capabilities = 6; + FileXferStart file_xfer_start = 10; + FileXferStatus file_xfer_status = 11; + FileXferData file_xfer_data = 12; + Empty client_disconnected = 13; + MaxClipboard max_clipboard = 14; + AudioVolumeSync audio_volume_sync = 15; +server: + Reply reply = 3; + AnnounceCapabilities announce_capabilities = 6; + FileXferStatus file_xfer_status = 11; + GraphicsDeviceInfo graphics_device_info = 16; +}; + +channel VDChannel: VDChannelCommon { +client: + Clipboard clipboard = 4; + ClipboardGrab clipboard_grab = 7; + ClipboardRequest clipboard_request = 8; + ClipboardRelease clipboard_release = 9; +server: + Clipboard clipboard = 4; + ClipboardGrab clipboard_grab = 7; + ClipboardRequest clipboard_request = 8; + ClipboardRelease clipboard_release = 9; +}; + +channel VDChannelSelection: VDChannelCommon { +client: + ClipboardSel clipboard = 4; + ClipboardGrabSel clipboard_grab = 7; + ClipboardRequestSel clipboard_request = 8; + ClipboardReleaseSel clipboard_release = 9; +server: + ClipboardSel clipboard = 4; + ClipboardGrabSel clipboard_grab = 7; + ClipboardRequestSel clipboard_request = 8; + ClipboardReleaseSel clipboard_release = 9; +}; + +protocol VDAgent { + VDChannel main = 1; + VDChannelSelection selection; +}; diff --git a/common/Makefile.am b/common/Makefile.am index 78d2c9a..4631e56 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -5,6 +5,9 @@ CLIENT_MARSHALLERS = \ generated_client_demarshallers.c \ generated_client_marshallers.c \ generated_client_marshallers.h \ + generated_vdagent_demarshallers.c \ + generated_vdagent_marshallers.h \ + generated_vdagent_marshallers.c \ $(NULL) SERVER_MARSHALLERS = \ @@ -125,6 +128,16 @@ MARSHALLERS_DEPS = \ # Note despite being autogenerated these are not part of CLEANFILES, they are # actually a part of EXTRA_DIST, to avoid the need for pyparser by end users +generated_vdagent_demarshallers.c generated_vdagent.h: $(top_srcdir)/agent.proto $(MARSHALLERS_DEPS) + $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --server \ + --generated-declaration-file generated_vdagent.h --include common/agent-marshallers.h $< $@ + +generated_vdagent_marshallers.h: $(top_srcdir)/agent.proto $(MARSHALLERS_DEPS) + $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --client --include common/agent-marshallers.h -H $< $@ + +generated_vdagent_marshallers.c: $(top_srcdir)/agent.proto $(MARSHALLERS_DEPS) + $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include common/agent-marshallers.h --client $< $@ + generated_client_demarshallers.c generated_messages.h: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS) $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --client \ --include spice/vd_agent.h --include common/messages.h \ diff --git a/common/agent-marshallers.h b/common/agent-marshallers.h new file mode 100644 index 0000000..fae4cb7 --- /dev/null +++ b/common/agent-marshallers.h @@ -0,0 +1,23 @@ +#ifndef H_SPICE_COMMON_AGENT +#define H_SPICE_COMMON_AGENT + +#include <stddef.h> +#include <spice/protocol.h> +#include <spice/vd_agent.h> + +#if 0 +typedef struct VDAgentMsgFileXferData { + uint32_t id; + uint64_t size; + uint8_t *data; +} VDAgentMsgFileXferData; +#endif + +#include "common/generated_vdagent.h" +#include "common/generated_vdagent_marshallers.h" + +typedef void (*message_destructor_t)(uint8_t *message); +typedef uint8_t * (*spice_parse_channel_func_t)(uint8_t *message_start, uint8_t *message_end, uint16_t message_type, int minor, + size_t *size_out, message_destructor_t *free_message); + +#endif |