static void cursor_marshall(RedChannelClient *rcc, SpiceMarshaller *m, CursorPipeItem *cursor_pipe_item) { CursorChannel *cursor_channel = SPICE_CONTAINEROF(rcc->channel, CursorChannel, common.base); CursorChannelClient *ccc = RCC_TO_CCC(rcc); CursorItem *item = cursor_pipe_item->cursor_item; PipeItem *pipe_item = &cursor_pipe_item->base; RedCursorCmd *cmd; spice_return_if_fail(cursor_channel); cmd = item->red_cursor; switch (cmd->type) { case QXL_CURSOR_MOVE: { SpiceMsgCursorMove cursor_move; red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_MOVE, pipe_item); cursor_move.position = cmd->u.position; spice_marshall_msg_cursor_move(m, &cursor_move); break; } case QXL_CURSOR_SET: { SpiceMsgCursorSet cursor_set; AddBufInfo info; red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_SET, pipe_item); cursor_set.position = cmd->u.set.position; cursor_set.visible = cursor_channel->cursor_visible; cursor_fill(ccc, &cursor_set.cursor, item, &info); spice_marshall_msg_cursor_set(m, &cursor_set); add_buf_from_info(m, &info); break; } case QXL_CURSOR_HIDE: red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_HIDE, pipe_item); break; case QXL_CURSOR_TRAIL: { SpiceMsgCursorTrail cursor_trail; red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_TRAIL, pipe_item); cursor_trail.length = cmd->u.trail.length; cursor_trail.frequency = cmd->u.trail.frequency; spice_marshall_msg_cursor_trail(m, &cursor_trail); } break; default: spice_error("bad cursor command %d", cmd->type); } }
static void cursor_channel_send_item(RedChannelClient *rcc, PipeItem *pipe_item) { SpiceMarshaller *m = red_channel_client_get_marshaller(rcc); CursorChannelClient *ccc = RCC_TO_CCC(rcc); switch (pipe_item->type) { case PIPE_ITEM_TYPE_CURSOR: cursor_marshall(rcc, m, SPICE_CONTAINEROF(pipe_item, CursorPipeItem, base)); break; case PIPE_ITEM_TYPE_INVAL_ONE: red_marshall_inval(rcc, m, (CacheItem *)pipe_item); break; case PIPE_ITEM_TYPE_VERB: red_marshall_verb(rcc, (VerbItem*)pipe_item); break; case PIPE_ITEM_TYPE_CURSOR_INIT: red_reset_cursor_cache(rcc); red_marshall_cursor_init(rcc, m, pipe_item); break; case PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE: red_reset_cursor_cache(rcc); red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INVAL_ALL, NULL); break; default: spice_error("invalid pipe item type"); } cursor_channel_client_release_item_before_push(ccc, pipe_item); red_channel_client_begin_send_message(rcc); }
static void smartcard_channel_send_migrate_data(RedChannelClient *rcc, SpiceMarshaller *m, PipeItem *item) { SmartCardChannelClient *scc; SmartCardDeviceState *state; SpiceMarshaller *m2; scc = SPICE_CONTAINEROF(rcc, SmartCardChannelClient, base); state = scc->smartcard_state; red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA, item); spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SMARTCARD_MAGIC); spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SMARTCARD_VERSION); if (!state) { spice_char_device_state_migrate_data_marshall_empty(m); spice_marshaller_add_uint8(m, 0); spice_marshaller_add_uint32(m, 0); spice_marshaller_add_uint32(m, 0); spice_debug("null char dev state"); } else { spice_char_device_state_migrate_data_marshall(state->chardev_st, m); spice_marshaller_add_uint8(m, state->reader_added); spice_marshaller_add_uint32(m, state->buf_used); m2 = spice_marshaller_get_ptr_submarshaller(m, 0); spice_marshaller_add_ref(m2, state->buf, state->buf_used); spice_debug("reader added %d partial read size %u", state->reader_added, state->buf_used); } }
static void spicevmc_red_channel_send_data(RedChannelClient *rcc, SpiceMarshaller *m, PipeItem *item) { SpiceVmcPipeItem *i = SPICE_CONTAINEROF(item, SpiceVmcPipeItem, base); red_channel_client_init_send_data(rcc, SPICE_MSG_SPICEVMC_DATA, item); spice_marshaller_add_ref(m, i->buf, i->buf_used); }
static inline void red_marshall_inval(RedChannelClient *rcc, SpiceMarshaller *base_marshaller, CacheItem *cach_item) { SpiceMsgDisplayInvalOne inval_one; red_channel_client_init_send_data(rcc, cach_item->inval_type, NULL); inval_one.id = *(uint64_t *)&cach_item->id; spice_marshall_msg_cursor_inval_one(base_marshaller, &inval_one); }
static void spicevmc_red_channel_send_port_event(RedChannelClient *rcc, SpiceMarshaller *m, PipeItem *item) { PortEventPipeItem *i = SPICE_CONTAINEROF(item, PortEventPipeItem, base); SpiceMsgPortEvent event; red_channel_client_init_send_data(rcc, SPICE_MSG_PORT_EVENT, item); event.event = i->event; spice_marshall_msg_port_event(m, &event); }
static void smartcard_channel_send_data(RedChannelClient *rcc, SpiceMarshaller *m, PipeItem *item, VSCMsgHeader *vheader) { spice_assert(rcc); spice_assert(vheader); red_channel_client_init_send_data(rcc, SPICE_MSG_SMARTCARD_DATA, item); spice_marshaller_add_ref(m, (uint8_t*)vheader, sizeof(VSCMsgHeader)); if (vheader->length > 0) { spice_marshaller_add_ref(m, (uint8_t*)(vheader+1), vheader->length); } }
static void spicevmc_red_channel_send_port_init(RedChannelClient *rcc, SpiceMarshaller *m, PipeItem *item) { PortInitPipeItem *i = SPICE_CONTAINEROF(item, PortInitPipeItem, base); SpiceMsgPortInit init; red_channel_client_init_send_data(rcc, SPICE_MSG_PORT_INIT, item); init.name = (uint8_t *)i->name; init.name_size = strlen(i->name) + 1; init.opened = i->opened; spice_marshall_msg_port_init(m, &init); }
static void spicevmc_red_channel_send_migrate_data(RedChannelClient *rcc, SpiceMarshaller *m, PipeItem *item) { SpiceVmcState *state; state = SPICE_CONTAINEROF(rcc->channel, SpiceVmcState, channel); red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA, item); spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SPICEVMC_MAGIC); spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SPICEVMC_VERSION); spice_char_device_state_migrate_data_marshall(state->chardev_st, m); }
static void red_marshall_cursor_init(RedChannelClient *rcc, SpiceMarshaller *base_marshaller, PipeItem *pipe_item) { CursorChannel *cursor_channel; CursorChannelClient *ccc = RCC_TO_CCC(rcc); SpiceMsgCursorInit msg; AddBufInfo info; spice_assert(rcc); cursor_channel = SPICE_CONTAINEROF(rcc->channel, CursorChannel, common.base); red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INIT, NULL); msg.visible = cursor_channel->cursor_visible; msg.position = cursor_channel->cursor_position; msg.trail_length = cursor_channel->cursor_trail_length; msg.trail_frequency = cursor_channel->cursor_trail_frequency; cursor_fill(ccc, &msg.cursor, cursor_channel->item, &info); spice_marshall_msg_cursor_init(base_marshaller, &msg); add_buf_from_info(base_marshaller, &info); }