|
Hans de Goede |
1b1995 |
From f04315d9210f22e5d7317f1cfb3c076fb93b3c08 Mon Sep 17 00:00:00 2001
|
|
Hans de Goede |
1b1995 |
From: Hans de Goede <hdegoede@redhat.com>
|
|
Hans de Goede |
1b1995 |
Date: Sun, 19 Feb 2012 09:58:03 +0100
|
|
Hans de Goede |
1b1995 |
Subject: [PATCH 123/140] usb-redir: Let the usb-host know about our device
|
|
Hans de Goede |
1b1995 |
filtering
|
|
Hans de Goede |
1b1995 |
|
|
Hans de Goede |
1b1995 |
libusbredirparser-0.3.4 adds 2 new packets which allows us to notify
|
|
Hans de Goede |
1b1995 |
the usb-host:
|
|
Hans de Goede |
1b1995 |
-about the usb device filter we have (if any), so that it knows not the even
|
|
Hans de Goede |
1b1995 |
try to redirect certain devices
|
|
Hans de Goede |
1b1995 |
-when we reject a device based on filtering (in case it tries anyways)
|
|
Hans de Goede |
1b1995 |
|
|
Hans de Goede |
1b1995 |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Hans de Goede |
1b1995 |
---
|
|
Hans de Goede |
1b1995 |
configure | 2 +-
|
|
Hans de Goede |
1b1995 |
usb-redir.c | 20 ++++++++++++++++++++
|
|
Hans de Goede |
1b1995 |
2 files changed, 21 insertions(+), 1 deletion(-)
|
|
Hans de Goede |
1b1995 |
|
|
Hans de Goede |
1b1995 |
diff --git a/configure b/configure
|
|
Hans de Goede |
1b1995 |
index c7e37df..a4848a4 100755
|
|
Hans de Goede |
1b1995 |
--- a/configure
|
|
Hans de Goede |
1b1995 |
+++ b/configure
|
|
Hans de Goede |
1b1995 |
@@ -2541,7 +2541,7 @@ fi
|
|
Hans de Goede |
1b1995 |
|
|
Hans de Goede |
1b1995 |
# check for usbredirparser for usb network redirection support
|
|
Hans de Goede |
1b1995 |
if test "$usb_redir" != "no" ; then
|
|
Hans de Goede |
1b1995 |
- if $pkg_config --atleast-version=0.3.3 libusbredirparser >/dev/null 2>&1 ; then
|
|
Hans de Goede |
1b1995 |
+ if $pkg_config --atleast-version=0.3.4 libusbredirparser >/dev/null 2>&1 ; then
|
|
Hans de Goede |
1b1995 |
usb_redir="yes"
|
|
Hans de Goede |
1b1995 |
usb_redir_cflags=$($pkg_config --cflags libusbredirparser 2>/dev/null)
|
|
Hans de Goede |
1b1995 |
usb_redir_libs=$($pkg_config --libs libusbredirparser 2>/dev/null)
|
|
Hans de Goede |
1b1995 |
diff --git a/usb-redir.c b/usb-redir.c
|
|
Hans de Goede |
1b1995 |
index fe3b0a3..d10d8de 100644
|
|
Hans de Goede |
1b1995 |
--- a/usb-redir.c
|
|
Hans de Goede |
1b1995 |
+++ b/usb-redir.c
|
|
Hans de Goede |
1b1995 |
@@ -106,6 +106,7 @@ struct AsyncURB {
|
|
Hans de Goede |
1b1995 |
QTAILQ_ENTRY(AsyncURB)next;
|
|
Hans de Goede |
1b1995 |
};
|
|
Hans de Goede |
1b1995 |
|
|
Hans de Goede |
1b1995 |
+static void usbredir_hello(void *priv, struct usb_redir_hello_header *h);
|
|
Hans de Goede |
1b1995 |
static void usbredir_device_connect(void *priv,
|
|
Hans de Goede |
1b1995 |
struct usb_redir_device_connect_header *device_connect);
|
|
Hans de Goede |
1b1995 |
static void usbredir_device_disconnect(void *priv);
|
|
Hans de Goede |
1b1995 |
@@ -812,6 +813,7 @@ static void usbredir_open_close_bh(void *opaque)
|
|
Hans de Goede |
1b1995 |
dev->parser->log_func = usbredir_log;
|
|
Hans de Goede |
1b1995 |
dev->parser->read_func = usbredir_read;
|
|
Hans de Goede |
1b1995 |
dev->parser->write_func = usbredir_write;
|
|
Hans de Goede |
1b1995 |
+ dev->parser->hello_func = usbredir_hello;
|
|
Hans de Goede |
1b1995 |
dev->parser->device_connect_func = usbredir_device_connect;
|
|
Hans de Goede |
1b1995 |
dev->parser->device_disconnect_func = usbredir_device_disconnect;
|
|
Hans de Goede |
1b1995 |
dev->parser->interface_info_func = usbredir_interface_info;
|
|
Hans de Goede |
1b1995 |
@@ -830,6 +832,7 @@ static void usbredir_open_close_bh(void *opaque)
|
|
Hans de Goede |
1b1995 |
dev->read_buf_size = 0;
|
|
Hans de Goede |
1b1995 |
|
|
Hans de Goede |
1b1995 |
usbredirparser_caps_set_cap(caps, usb_redir_cap_connect_device_version);
|
|
Hans de Goede |
1b1995 |
+ usbredirparser_caps_set_cap(caps, usb_redir_cap_filter);
|
|
Hans de Goede |
1b1995 |
usbredirparser_init(dev->parser, VERSION, caps, USB_REDIR_CAPS_SIZE, 0);
|
|
Hans de Goede |
1b1995 |
usbredirparser_do_write(dev->parser);
|
|
Hans de Goede |
1b1995 |
}
|
|
Hans de Goede |
1b1995 |
@@ -1018,6 +1021,10 @@ static int usbredir_check_filter(USBRedirDevice *dev)
|
|
Hans de Goede |
1b1995 |
|
|
Hans de Goede |
1b1995 |
error:
|
|
Hans de Goede |
1b1995 |
usbredir_device_disconnect(dev);
|
|
Hans de Goede |
1b1995 |
+ if (usbredirparser_peer_has_cap(dev->parser, usb_redir_cap_filter)) {
|
|
Hans de Goede |
1b1995 |
+ usbredirparser_send_filter_reject(dev->parser);
|
|
Hans de Goede |
1b1995 |
+ usbredirparser_do_write(dev->parser);
|
|
Hans de Goede |
1b1995 |
+ }
|
|
Hans de Goede |
1b1995 |
return -1;
|
|
Hans de Goede |
1b1995 |
}
|
|
Hans de Goede |
1b1995 |
|
|
Hans de Goede |
1b1995 |
@@ -1043,6 +1050,19 @@ static int usbredir_handle_status(USBRedirDevice *dev,
|
|
Hans de Goede |
1b1995 |
}
|
|
Hans de Goede |
1b1995 |
}
|
|
Hans de Goede |
1b1995 |
|
|
Hans de Goede |
1b1995 |
+static void usbredir_hello(void *priv, struct usb_redir_hello_header *h)
|
|
Hans de Goede |
1b1995 |
+{
|
|
Hans de Goede |
1b1995 |
+ USBRedirDevice *dev = priv;
|
|
Hans de Goede |
1b1995 |
+
|
|
Hans de Goede |
1b1995 |
+ /* Try to send the filter info now that we've the usb-host's caps */
|
|
Hans de Goede |
1b1995 |
+ if (usbredirparser_peer_has_cap(dev->parser, usb_redir_cap_filter) &&
|
|
Hans de Goede |
1b1995 |
+ dev->filter_rules) {
|
|
Hans de Goede |
1b1995 |
+ usbredirparser_send_filter_filter(dev->parser, dev->filter_rules,
|
|
Hans de Goede |
1b1995 |
+ dev->filter_rules_count);
|
|
Hans de Goede |
1b1995 |
+ usbredirparser_do_write(dev->parser);
|
|
Hans de Goede |
1b1995 |
+ }
|
|
Hans de Goede |
1b1995 |
+}
|
|
Hans de Goede |
1b1995 |
+
|
|
Hans de Goede |
1b1995 |
static void usbredir_device_connect(void *priv,
|
|
Hans de Goede |
1b1995 |
struct usb_redir_device_connect_header *device_connect)
|
|
Hans de Goede |
1b1995 |
{
|
|
Hans de Goede |
1b1995 |
--
|
|
Hans de Goede |
1b1995 |
1.7.9.3
|
|
Hans de Goede |
1b1995 |
|