mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-29 17:07:15 +00:00
smartcard: Use generated parse for messages
The generated code handle possible endianess mismatch and check for message format. The copy back to "write_buf" allows to use that buffer to send data back to device. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Victor Toso <victortoso@redhat.com>
This commit is contained in:
parent
5d2b204e48
commit
bae2d1f00f
@ -274,17 +274,15 @@ bool smartcard_channel_client_handle_message(RedChannelClient *rcc,
|
||||
uint32_t size,
|
||||
void *message)
|
||||
{
|
||||
uint8_t *msg = message;
|
||||
VSCMsgHeader* vheader = message;
|
||||
SmartCardChannelClient *scc = SMARTCARD_CHANNEL_CLIENT(rcc);
|
||||
|
||||
if (type != SPICE_MSGC_SMARTCARD_DATA) {
|
||||
/* Handles seamless migration protocol. Also handles ack's,
|
||||
* spicy sends them while spicec does not */
|
||||
return red_channel_client_handle_message(rcc, type, size, msg);
|
||||
return red_channel_client_handle_message(rcc, type, size, message);
|
||||
}
|
||||
|
||||
spice_assert(size == vheader->length + sizeof(VSCMsgHeader));
|
||||
switch (vheader->type) {
|
||||
case VSC_ReaderAdd:
|
||||
smartcard_channel_client_add_reader(scc);
|
||||
@ -315,7 +313,8 @@ bool smartcard_channel_client_handle_message(RedChannelClient *rcc,
|
||||
vheader->reader_id, vheader->type, vheader->length);
|
||||
return FALSE;
|
||||
}
|
||||
spice_assert(scc->priv->write_buf->buf == msg);
|
||||
spice_assert(scc->priv->write_buf->buf_size >= size);
|
||||
memcpy(scc->priv->write_buf->buf, message, size);
|
||||
smartcard_channel_client_write_to_reader(scc);
|
||||
|
||||
return TRUE;
|
||||
|
||||
@ -547,6 +547,7 @@ red_smartcard_channel_class_init(RedSmartcardChannelClass *klass)
|
||||
|
||||
object_class->constructed = red_smartcard_channel_constructed;
|
||||
|
||||
channel_class->parser = spice_get_client_channel_parser(SPICE_CHANNEL_SMARTCARD, NULL);
|
||||
channel_class->handle_message = smartcard_channel_client_handle_message,
|
||||
|
||||
channel_class->send_item = smartcard_channel_send_item;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user