summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-10-16 11:07:56 +0200
committerHans de Goede <hdegoede@redhat.com>2013-10-19 20:36:05 +0200
commit71e55f1dedd458fc57d0150f1d24d7c355c250d8 (patch)
treed546b7232a8cccd9678654eda2e2ede86058eb09
parent78bbaa181d9baf65aba1fe88074e4156150e31b8 (diff)
usb-redir-proto: Extend usb_redir_ep_info_header with a max_streams field
The usb_redir_ep_info_header has been extended with a max_streams field, this is only send / received if both sides have usb_redir_cap_bulk_streams Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--ChangeLog3
-rw-r--r--usb-redirection-protocol.txt20
-rw-r--r--usbredirparser/usbredirparser.c26
-rw-r--r--usbredirparser/usbredirproto-compat.h7
-rw-r--r--usbredirparser/usbredirproto.h1
5 files changed, 52 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 6c48bb4..596531b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
usbredir-0.7 16 October 2013
------------------------------
+-usbredirproto:
+ -the usb_redir_ep_info_header has been extended with a max_streams field,
+ this is only send / received if both sides have usb_redir_cap_bulk_streams
-usbredirparser:
-fix a bug causing parsing breakage when receiving a hello packet with 64 bit
id capabiliy and another packet in succession so that they both got parsed
diff --git a/usb-redirection-protocol.txt b/usb-redirection-protocol.txt
index 66c03c3..abc7e82 100644
--- a/usb-redirection-protocol.txt
+++ b/usb-redirection-protocol.txt
@@ -82,9 +82,14 @@ Version 0.6, released 13 December 2012
usb_redir_bulk_receiving_status, usb_redir_buffered_bulk_packet
New capability: usb_redir_cap_bulk_receiving
+Version 0.7, released 16 October 2013
+- The usb_redir_ep_info_header has been extended with a max_streams field
+ This is only send / received if both sides have the
+ usb_redir_cap_bulk_streams capability.
-USB redirerection protocol version 0.6
---------------------------------------
+
+USB redirection protocol version 0.7
+------------------------------------
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.
@@ -383,6 +388,7 @@ struct usb_redir_ep_info_header {
uint8_t interval[32];
uint8_t interface[32];
uint16_t max_packet_size[32];
+ uint32_t max_streams[32];
}
No packet type specific additional data.
@@ -396,6 +402,16 @@ The max_packet_size field should only be send (and expected on receive)
when both sides have the usb_redir_cap_ep_info_max_packet_size capability.
If this is not the case the length of the packet will be 64 bytes less!
+The max_streams field should only be send (and expected on receive)
+when both sides have the usb_redir_cap_bulk_streams capability. If this is
+not the case the length of the packet will be 128 bytes less!
+
+Note implementations with the usb_redir_cap_bulk_streams capability must
+always also have the usb_redir_cap_ep_info_max_packet_size capability.
+Advertising usb_redir_cap_bulk_streams without
+usb_redir_cap_ep_info_max_packet_size is not allowed!
+
+
usb_redir_set_configuration
---------------------------
diff --git a/usbredirparser/usbredirparser.c b/usbredirparser/usbredirparser.c
index 6dd9d14..2cebada 100644
--- a/usbredirparser/usbredirparser.c
+++ b/usbredirparser/usbredirparser.c
@@ -66,7 +66,7 @@ struct usbredirparser_priv {
struct usb_redir_header header;
struct usb_redir_header_32bit_id header_32bit_id;
};
- uint8_t type_header[256];
+ uint8_t type_header[288];
int header_read;
int type_header_len;
int type_header_read;
@@ -143,6 +143,19 @@ struct usbredirparser *usbredirparser_create(void)
return calloc(1, sizeof(struct usbredirparser_priv));
}
+static void usbredirparser_verify_caps(struct usbredirparser_priv *parser,
+ uint32_t *caps, const char *desc)
+{
+ if (usbredirparser_caps_get_cap(parser, caps,
+ usb_redir_cap_bulk_streams) &&
+ !usbredirparser_caps_get_cap(parser, caps,
+ usb_redir_cap_ep_info_max_packet_size)) {
+ ERROR("error %s caps contains cap_bulk_streams without"
+ "cap_ep_info_max_packet_size", desc);
+ caps[0] &= ~(1 << usb_redir_cap_bulk_streams);
+ }
+}
+
void usbredirparser_init(struct usbredirparser *parser_pub,
const char *version, uint32_t *caps, int caps_len, int flags)
{
@@ -164,6 +177,7 @@ void usbredirparser_init(struct usbredirparser *parser_pub,
if (!(flags & usbredirparser_fl_usb_host))
usbredirparser_caps_set_cap(parser->our_caps,
usb_redir_cap_device_disconnect_ack);
+ usbredirparser_verify_caps(parser, parser->our_caps, "our");
if (!(flags & usbredirparser_fl_no_hello))
usbredirparser_queue(parser_pub, usb_redir_hello, 0, &hello,
(uint8_t *)parser->our_caps,
@@ -262,6 +276,7 @@ static void usbredirparser_handle_hello(struct usbredirparser *parser_pub,
for (i = 0; i < data_len / sizeof(uint32_t); i++) {
parser->peer_caps[i] = peer_caps[i];
}
+ usbredirparser_verify_caps(parser, parser->peer_caps, "peer");
parser->have_peer_caps = 1;
free(data);
@@ -332,10 +347,15 @@ static int usbredirparser_get_type_header_len(
case usb_redir_ep_info:
if (!command_for_host) {
if (usbredirparser_have_cap(parser_pub,
- usb_redir_cap_ep_info_max_packet_size) &&
+ usb_redir_cap_bulk_streams) &&
usbredirparser_peer_has_cap(parser_pub,
- usb_redir_cap_ep_info_max_packet_size)) {
+ usb_redir_cap_bulk_streams)) {
return sizeof(struct usb_redir_ep_info_header);
+ } else if (usbredirparser_have_cap(parser_pub,
+ usb_redir_cap_ep_info_max_packet_size) &&
+ usbredirparser_peer_has_cap(parser_pub,
+ usb_redir_cap_ep_info_max_packet_size)) {
+ return sizeof(struct usb_redir_ep_info_header_no_max_streams);
} else {
return sizeof(struct usb_redir_ep_info_header_no_max_pktsz);
}
diff --git a/usbredirparser/usbredirproto-compat.h b/usbredirparser/usbredirproto-compat.h
index fc8ca16..9155d45 100644
--- a/usbredirparser/usbredirproto-compat.h
+++ b/usbredirparser/usbredirproto-compat.h
@@ -57,6 +57,13 @@ struct usb_redir_ep_info_header_no_max_pktsz {
uint8_t interface[32];
} ATTR_PACKED;
+struct usb_redir_ep_info_header_no_max_streams {
+ uint8_t type[32];
+ uint8_t interval[32];
+ uint8_t interface[32];
+ uint16_t max_packet_size[32];
+} ATTR_PACKED;
+
struct usb_redir_header_32bit_id {
uint32_t type;
uint32_t length;
diff --git a/usbredirparser/usbredirproto.h b/usbredirparser/usbredirproto.h
index b3ee5f0..71ec689 100644
--- a/usbredirparser/usbredirproto.h
+++ b/usbredirparser/usbredirproto.h
@@ -167,6 +167,7 @@ struct usb_redir_ep_info_header {
uint8_t interval[32];
uint8_t interface[32];
uint16_t max_packet_size[32];
+ uint32_t max_streams[32];
} ATTR_PACKED;
struct usb_redir_set_configuration_header {