diff options
author | Hans de Goede <hdegoede@redhat.com> | 2012-10-06 11:13:49 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2012-10-06 11:16:35 +0200 |
commit | 14476dabacb3fd189261e866e96907ba0aa35b96 (patch) | |
tree | 827b38417e39dc423ac91620e185551e880d78fa | |
parent | cf0c0b5b7230aa47edec430d8eb624750ac3f233 (diff) |
usbredirparser: Add support for bulk packets longer then 65535 bytes
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | usb-redirection-protocol.txt | 16 | ||||
-rw-r--r-- | usbredirparser/usbredirparser.c | 26 | ||||
-rw-r--r-- | usbredirparser/usbredirproto-compat.h | 7 | ||||
-rw-r--r-- | usbredirparser/usbredirproto.h | 3 |
6 files changed, 52 insertions, 7 deletions
@@ -1,3 +1,8 @@ +usbredir-0.5.3 7 October 2012 +------------------------------ +-usbredirparser: + -add support for bulk packets longer then 65535 bytes + usbredir-0.5.2 25 September 2012 -------------------------------- -usbredirparser: diff --git a/configure.ac b/configure.ac index d73e749..35761a5 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.63) -AC_INIT([usbredir], [0.5.2]) +AC_INIT([usbredir], [0.5.3]) AC_CONFIG_SRCDIR([configure.ac]) AM_CONFIG_HEADER([config.h]) diff --git a/usb-redirection-protocol.txt b/usb-redirection-protocol.txt index 9d9c4c6..226e32a 100644 --- a/usb-redirection-protocol.txt +++ b/usb-redirection-protocol.txt @@ -71,9 +71,14 @@ Version 0.4.2, released 6 March 2012 Version 0.5, released 7 September 2012 - Add the posibility to use 64 bits packet ids +Version 0.5.3, released 7 October 2012 +- Extend the length field in bulk packets headers to 32 bits, the extra 16 + bits are only send / received if both sides have the + usb_redir_cap_32bits_bulk_length capability -USB redirerection protocol version 0.5 --------------------------------------- + +USB redirerection protocol version 0.5.3 +---------------------------------------- The protocol described in this document is meant for tunneling usb transfers to a single usb device. Note: not an entire hub, only a single device. @@ -248,6 +253,8 @@ enum { usb_redir_cap_ep_info_max_packet_size, /* Supports 64 bits ids in usb_redir_header */ usb_redir_cap_64bits_ids, + /* Supports 32 bits length in usb_redir_bulk_packet_header */ + usb_redir_cap_32bits_bulk_length, }; usb_redir_device_connect @@ -796,6 +803,7 @@ struct usb_redir_bulk_packet_header { uint8_t status; uint16_t length; uint32_t stream_id; + uint16_t length_high; /* High 16 bits of the packet length */ } The additional data contains the bulk msg data to be send / received. @@ -806,6 +814,10 @@ their standard meaning for usb bulk messages. The status field is only used in the usb-host's response. length is the amount of data the usb-guest is sending / expects to read (depending on the direction of the endpoint). +length_high contains the 16 high bits of length to allow packets larger +then 65535 bytes, it is only send/received if both sides have the +usb_redir_cap_32bits_bulk_length capability. + When the bulk msg has been processed by the usb-device the usb-host sends a usb_redir_bulk_packet back to the usb-guest, with the status field and length updated to match the actual results. diff --git a/usbredirparser/usbredirparser.c b/usbredirparser/usbredirparser.c index 64875df..e68fc28 100644 --- a/usbredirparser/usbredirparser.c +++ b/usbredirparser/usbredirparser.c @@ -448,7 +448,14 @@ static int usbredirparser_get_type_header_len( case usb_redir_control_packet: return sizeof(struct usb_redir_control_packet_header); case usb_redir_bulk_packet: - return sizeof(struct usb_redir_bulk_packet_header); + if (usbredirparser_have_cap(parser_pub, + usb_redir_cap_32bits_bulk_length) && + usbredirparser_peer_has_cap(parser_pub, + usb_redir_cap_32bits_bulk_length)) { + return sizeof(struct usb_redir_bulk_packet_header); + } else { + return sizeof(struct usb_redir_bulk_packet_header_16bit_length); + } case usb_redir_iso_packet: return sizeof(struct usb_redir_iso_packet_header); case usb_redir_interrupt_packet: @@ -541,10 +548,21 @@ static int usbredirparser_verify_type_header( length = ((struct usb_redir_control_packet_header *)header)->length; ep = ((struct usb_redir_control_packet_header *)header)->endpoint; break; - case usb_redir_bulk_packet: - length = ((struct usb_redir_bulk_packet_header *)header)->length; - ep = ((struct usb_redir_bulk_packet_header *)header)->endpoint; + case usb_redir_bulk_packet: { + struct usb_redir_bulk_packet_header *bulk_packet = header; + if (usbredirparser_have_cap(parser_pub, + usb_redir_cap_32bits_bulk_length) && + usbredirparser_peer_has_cap(parser_pub, + usb_redir_cap_32bits_bulk_length)) { + length = (bulk_packet->length_high << 16) | bulk_packet->length; + } else { + length = bulk_packet->length; + if (!send) + bulk_packet->length_high = 0; + } + ep = bulk_packet->endpoint; break; + } case usb_redir_iso_packet: length = ((struct usb_redir_iso_packet_header *)header)->length; ep = ((struct usb_redir_iso_packet_header *)header)->endpoint; diff --git a/usbredirparser/usbredirproto-compat.h b/usbredirparser/usbredirproto-compat.h index c647c91..fc8ca16 100644 --- a/usbredirparser/usbredirproto-compat.h +++ b/usbredirparser/usbredirproto-compat.h @@ -63,6 +63,13 @@ struct usb_redir_header_32bit_id { uint32_t id; } ATTR_PACKED; +struct usb_redir_bulk_packet_header_16bit_length { + uint8_t endpoint; + uint8_t status; + uint16_t length; + uint32_t stream_id; +} ATTR_PACKED; + #undef ATTR_PACKED #if defined(__MINGW32__) || !defined(__GNUC__) diff --git a/usbredirparser/usbredirproto.h b/usbredirparser/usbredirproto.h index ede0e7f..cdbd1c3 100644 --- a/usbredirparser/usbredirproto.h +++ b/usbredirparser/usbredirproto.h @@ -117,6 +117,8 @@ enum { usb_redir_cap_ep_info_max_packet_size, /* Supports 64 bits ids in usb_redir_header */ usb_redir_cap_64bits_ids, + /* Supports 32 bits length in usb_redir_bulk_packet_header */ + usb_redir_cap_32bits_bulk_length, }; /* Number of uint32_t-s needed to hold all (known) capabilities */ #define USB_REDIR_CAPS_SIZE 1 @@ -239,6 +241,7 @@ struct usb_redir_bulk_packet_header { uint8_t status; uint16_t length; uint32_t stream_id; + uint16_t length_high; /* High 16 bits of the packet length */ } ATTR_PACKED; struct usb_redir_iso_packet_header { |