3
#include "marshallers.h"
8
#include <spice/protocol.h>
9
#include <spice/macros.h>
10
#include <marshaller.h>
13
#pragma warning(disable:4101)
14
#pragma warning(disable:4018)
17
static void spice_marshall_msgc_ack_sync(SpiceMarshaller *m, SpiceMsgcAckSync *msg)
19
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
20
SpiceMsgcAckSync *src;
21
src = (SpiceMsgcAckSync *)msg;
23
spice_marshaller_add_uint32(m, src->generation);
26
static void spice_marshall_SpiceMsgEmpty(SpiceMarshaller *m, SpiceMsgEmpty *msg)
28
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
31
static void spice_marshall_msgc_pong(SpiceMarshaller *m, SpiceMsgPing *msg)
33
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
35
src = (SpiceMsgPing *)msg;
37
spice_marshaller_add_uint32(m, src->id);
38
spice_marshaller_add_uint64(m, src->timestamp);
41
static void spice_marshall_SpiceMsgData(SpiceMarshaller *m, SpiceMsgData *msg)
43
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
46
static void spice_marshall_msgc_disconnecting(SpiceMarshaller *m, SpiceMsgDisconnect *msg)
48
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
49
SpiceMsgDisconnect *src;
50
src = (SpiceMsgDisconnect *)msg;
52
spice_marshaller_add_uint64(m, src->time_stamp);
53
spice_marshaller_add_uint32(m, src->reason);
56
static void spice_marshall_msgc_main_client_info(SpiceMarshaller *m, SpiceMsgcClientInfo *msg)
58
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
59
SpiceMsgcClientInfo *src;
60
src = (SpiceMsgcClientInfo *)msg;
62
spice_marshaller_add_uint64(m, src->cache_size);
65
static void spice_marshall_msgc_main_mouse_mode_request(SpiceMarshaller *m, SpiceMsgcMainMouseModeRequest *msg)
67
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
68
SpiceMsgcMainMouseModeRequest *src;
69
src = (SpiceMsgcMainMouseModeRequest *)msg;
71
spice_marshaller_add_uint16(m, src->mode);
74
static void spice_marshall_msgc_main_agent_start(SpiceMarshaller *m, SpiceMsgcMainAgentStart *msg)
76
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
77
SpiceMsgcMainAgentStart *src;
78
src = (SpiceMsgcMainAgentStart *)msg;
80
spice_marshaller_add_uint32(m, src->num_tokens);
83
static void spice_marshall_msgc_main_agent_token(SpiceMarshaller *m, SpiceMsgcMainAgentTokens *msg)
85
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
86
SpiceMsgcMainAgentTokens *src;
87
src = (SpiceMsgcMainAgentTokens *)msg;
89
spice_marshaller_add_uint32(m, src->num_tokens);
92
static void spice_marshall_msgc_display_init(SpiceMarshaller *m, SpiceMsgcDisplayInit *msg)
94
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
95
SpiceMsgcDisplayInit *src;
96
src = (SpiceMsgcDisplayInit *)msg;
98
spice_marshaller_add_uint8(m, src->pixmap_cache_id);
99
spice_marshaller_add_int64(m, src->pixmap_cache_size);
100
spice_marshaller_add_uint8(m, src->glz_dictionary_id);
101
spice_marshaller_add_int32(m, src->glz_dictionary_window_size);
104
static void spice_marshall_msgc_inputs_key_down(SpiceMarshaller *m, SpiceMsgcKeyDown *msg)
106
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
107
SpiceMsgcKeyDown *src;
108
src = (SpiceMsgcKeyDown *)msg;
110
spice_marshaller_add_uint32(m, src->code);
113
static void spice_marshall_msgc_inputs_key_up(SpiceMarshaller *m, SpiceMsgcKeyUp *msg)
115
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
117
src = (SpiceMsgcKeyUp *)msg;
119
spice_marshaller_add_uint32(m, src->code);
122
static void spice_marshall_msgc_inputs_key_modifiers(SpiceMarshaller *m, SpiceMsgcKeyModifiers *msg)
124
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
125
SpiceMsgcKeyModifiers *src;
126
src = (SpiceMsgcKeyModifiers *)msg;
128
spice_marshaller_add_uint16(m, src->modifiers);
131
static void spice_marshall_msgc_inputs_mouse_motion(SpiceMarshaller *m, SpiceMsgcMouseMotion *msg)
133
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
134
SpiceMsgcMouseMotion *src;
135
src = (SpiceMsgcMouseMotion *)msg;
137
spice_marshaller_add_int32(m, src->dx);
138
spice_marshaller_add_int32(m, src->dy);
139
spice_marshaller_add_uint16(m, src->buttons_state);
142
static void spice_marshall_msgc_inputs_mouse_position(SpiceMarshaller *m, SpiceMsgcMousePosition *msg)
144
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
145
SpiceMsgcMousePosition *src;
146
src = (SpiceMsgcMousePosition *)msg;
148
spice_marshaller_add_uint32(m, src->x);
149
spice_marshaller_add_uint32(m, src->y);
150
spice_marshaller_add_uint16(m, src->buttons_state);
151
spice_marshaller_add_uint8(m, src->display_id);
154
static void spice_marshall_msgc_inputs_mouse_press(SpiceMarshaller *m, SpiceMsgcMousePress *msg)
156
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
157
SpiceMsgcMousePress *src;
158
src = (SpiceMsgcMousePress *)msg;
160
spice_marshaller_add_uint8(m, src->button);
161
spice_marshaller_add_uint16(m, src->buttons_state);
164
static void spice_marshall_msgc_inputs_mouse_release(SpiceMarshaller *m, SpiceMsgcMouseRelease *msg)
166
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
167
SpiceMsgcMouseRelease *src;
168
src = (SpiceMsgcMouseRelease *)msg;
170
spice_marshaller_add_uint8(m, src->button);
171
spice_marshaller_add_uint16(m, src->buttons_state);
174
static void spice_marshall_msgc_record_data(SpiceMarshaller *m, SpiceMsgcRecordPacket *msg)
176
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
177
SpiceMsgcRecordPacket *src;
178
src = (SpiceMsgcRecordPacket *)msg;
180
spice_marshaller_add_uint32(m, src->time);
181
/* Don't marshall @nomarshal data */
184
static void spice_marshall_msgc_record_mode(SpiceMarshaller *m, SpiceMsgcRecordMode *msg)
186
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
187
SpiceMsgcRecordMode *src;
188
src = (SpiceMsgcRecordMode *)msg;
190
spice_marshaller_add_uint32(m, src->time);
191
spice_marshaller_add_uint16(m, src->mode);
192
/* Remaining data must be appended manually */
195
static void spice_marshall_msgc_record_start_mark(SpiceMarshaller *m, SpiceMsgcRecordStartMark *msg)
197
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
198
SpiceMsgcRecordStartMark *src;
199
src = (SpiceMsgcRecordStartMark *)msg;
201
spice_marshaller_add_uint32(m, src->time);
204
SPICE_GNUC_UNUSED static void spice_marshall_array_uint8(SpiceMarshaller *m, uint8_t *ptr, int count)
206
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
209
for (i = 0; i < count; i++) {
210
spice_marshaller_add_uint8(m, *ptr++);
214
static void spice_marshall_msgc_tunnel_service_add(SpiceMarshaller *m, SpiceMsgcTunnelAddGenericService *msg, SpiceMarshaller **name_out, SpiceMarshaller **description_out)
216
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
217
SpiceMsgcTunnelAddGenericService *src;
220
*description_out = NULL;
221
src = (SpiceMsgcTunnelAddGenericService *)msg;
223
spice_marshaller_add_uint16(m, src->type);
224
spice_marshaller_add_uint32(m, src->id);
225
spice_marshaller_add_uint32(m, src->group);
226
spice_marshaller_add_uint32(m, src->port);
227
*name_out = spice_marshaller_get_ptr_submarshaller(m, 0);
228
*description_out = spice_marshaller_get_ptr_submarshaller(m, 0);
229
if (src->type == SPICE_TUNNEL_SERVICE_TYPE_IPP) {
230
uint8_t *ipv4__element;
231
spice_marshaller_add_uint16(m, src->u.ip.type);
232
if (src->u.ip.type == SPICE_TUNNEL_IP_TYPE_IPv4) {
233
ipv4__element = src->u.ip.u.ipv4;
234
for (i = 0; i < 4; i++) {
235
spice_marshaller_add_uint8(m, *ipv4__element);
242
static void spice_marshall_msgc_tunnel_service_remove(SpiceMarshaller *m, SpiceMsgcTunnelRemoveService *msg)
244
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
245
SpiceMsgcTunnelRemoveService *src;
246
src = (SpiceMsgcTunnelRemoveService *)msg;
248
spice_marshaller_add_uint32(m, src->id);
251
static void spice_marshall_msgc_tunnel_socket_open_ack(SpiceMarshaller *m, SpiceMsgcTunnelSocketOpenAck *msg)
253
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
254
SpiceMsgcTunnelSocketOpenAck *src;
255
src = (SpiceMsgcTunnelSocketOpenAck *)msg;
257
spice_marshaller_add_uint16(m, src->connection_id);
258
spice_marshaller_add_uint32(m, src->tokens);
261
static void spice_marshall_msgc_tunnel_socket_open_nack(SpiceMarshaller *m, SpiceMsgcTunnelSocketOpenNack *msg)
263
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
264
SpiceMsgcTunnelSocketOpenNack *src;
265
src = (SpiceMsgcTunnelSocketOpenNack *)msg;
267
spice_marshaller_add_uint16(m, src->connection_id);
270
static void spice_marshall_msgc_tunnel_socket_fin(SpiceMarshaller *m, SpiceMsgcTunnelSocketFin *msg)
272
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
273
SpiceMsgcTunnelSocketFin *src;
274
src = (SpiceMsgcTunnelSocketFin *)msg;
276
spice_marshaller_add_uint16(m, src->connection_id);
279
static void spice_marshall_msgc_tunnel_socket_closed(SpiceMarshaller *m, SpiceMsgcTunnelSocketClosed *msg)
281
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
282
SpiceMsgcTunnelSocketClosed *src;
283
src = (SpiceMsgcTunnelSocketClosed *)msg;
285
spice_marshaller_add_uint16(m, src->connection_id);
288
static void spice_marshall_msgc_tunnel_socket_closed_ack(SpiceMarshaller *m, SpiceMsgcTunnelSocketClosedAck *msg)
290
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
291
SpiceMsgcTunnelSocketClosedAck *src;
292
src = (SpiceMsgcTunnelSocketClosedAck *)msg;
294
spice_marshaller_add_uint16(m, src->connection_id);
297
static void spice_marshall_msgc_tunnel_socket_data(SpiceMarshaller *m, SpiceMsgcTunnelSocketData *msg)
299
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
300
SpiceMsgcTunnelSocketData *src;
301
src = (SpiceMsgcTunnelSocketData *)msg;
303
spice_marshaller_add_uint16(m, src->connection_id);
304
/* Remaining data must be appended manually */
307
static void spice_marshall_msgc_tunnel_socket_token(SpiceMarshaller *m, SpiceMsgcTunnelSocketTokens *msg)
309
SPICE_GNUC_UNUSED SpiceMarshaller *m2;
310
SpiceMsgcTunnelSocketTokens *src;
311
src = (SpiceMsgcTunnelSocketTokens *)msg;
313
spice_marshaller_add_uint16(m, src->connection_id);
314
spice_marshaller_add_uint32(m, src->num_tokens);
317
SpiceMessageMarshallers * spice_message_marshallers_get(void)
319
static SpiceMessageMarshallers marshallers = {NULL};
321
marshallers.msg_SpiceMsgData = spice_marshall_SpiceMsgData;
322
marshallers.msg_SpiceMsgEmpty = spice_marshall_SpiceMsgEmpty;
323
marshallers.msgc_ack_sync = spice_marshall_msgc_ack_sync;
324
marshallers.msgc_disconnecting = spice_marshall_msgc_disconnecting;
325
marshallers.msgc_display_init = spice_marshall_msgc_display_init;
326
marshallers.msgc_inputs_key_down = spice_marshall_msgc_inputs_key_down;
327
marshallers.msgc_inputs_key_modifiers = spice_marshall_msgc_inputs_key_modifiers;
328
marshallers.msgc_inputs_key_up = spice_marshall_msgc_inputs_key_up;
329
marshallers.msgc_inputs_mouse_motion = spice_marshall_msgc_inputs_mouse_motion;
330
marshallers.msgc_inputs_mouse_position = spice_marshall_msgc_inputs_mouse_position;
331
marshallers.msgc_inputs_mouse_press = spice_marshall_msgc_inputs_mouse_press;
332
marshallers.msgc_inputs_mouse_release = spice_marshall_msgc_inputs_mouse_release;
333
marshallers.msgc_main_agent_start = spice_marshall_msgc_main_agent_start;
334
marshallers.msgc_main_agent_token = spice_marshall_msgc_main_agent_token;
335
marshallers.msgc_main_client_info = spice_marshall_msgc_main_client_info;
336
marshallers.msgc_main_mouse_mode_request = spice_marshall_msgc_main_mouse_mode_request;
337
marshallers.msgc_pong = spice_marshall_msgc_pong;
338
marshallers.msgc_record_data = spice_marshall_msgc_record_data;
339
marshallers.msgc_record_mode = spice_marshall_msgc_record_mode;
340
marshallers.msgc_record_start_mark = spice_marshall_msgc_record_start_mark;
341
marshallers.msgc_tunnel_service_add = spice_marshall_msgc_tunnel_service_add;
342
marshallers.msgc_tunnel_service_remove = spice_marshall_msgc_tunnel_service_remove;
343
marshallers.msgc_tunnel_socket_closed = spice_marshall_msgc_tunnel_socket_closed;
344
marshallers.msgc_tunnel_socket_closed_ack = spice_marshall_msgc_tunnel_socket_closed_ack;
345
marshallers.msgc_tunnel_socket_data = spice_marshall_msgc_tunnel_socket_data;
346
marshallers.msgc_tunnel_socket_fin = spice_marshall_msgc_tunnel_socket_fin;
347
marshallers.msgc_tunnel_socket_open_ack = spice_marshall_msgc_tunnel_socket_open_ack;
348
marshallers.msgc_tunnel_socket_open_nack = spice_marshall_msgc_tunnel_socket_open_nack;
349
marshallers.msgc_tunnel_socket_token = spice_marshall_msgc_tunnel_socket_token;