From 73cd8584fa4c8cee6e70ad303c20969b1783ae39 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2012 11:57:42 +0100 Subject: [PATCH 20/35] usb-redir: Let the usb-host know about our device filtering RH-Author: Hans de Goede Message-id: <1330862278-22314-6-git-send-email-hdegoede@redhat.com> Patchwork-id: 37920 O-Subject: [PATCH 05/21] usb-redir: Let the usb-host know about our device filtering Bugzilla: 758104 RH-Acked-by: Hans de Goede RH-Acked-by: Gerd Hoffmann RH-Acked-by: Alon Levy RH-Acked-by: Markus Armbruster libusbredirparser-0.3.4 adds 2 new packets which allows us to notify the usb-host: -about the usb device filter we have (if any), so that it knows not the even try to redirect certain devices -when we reject a device based on filtering (in case it tries anyways) Signed-off-by: Hans de Goede (cherry picked from commit 097a66ef5f6138c22bfdd1cc218eb2704e5eef9c) [ rhel6: resolve conflicts ] --- configure | 2 +- usb-redir.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletions(-) Signed-off-by: Michal Novotny --- configure | 2 +- usb-redir.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletions(-) diff --git a/configure b/configure index 8bf05f7..bde9684 100755 --- a/configure +++ b/configure @@ -2042,7 +2042,7 @@ fi # check for usbredirparser for usb network redirection support if test "$usb_redir" != "no" ; then - if pkg-config --atleast-version=0.3.3 libusbredirparser >/dev/null 2>&1 ; then + if pkg-config --atleast-version=0.3.4 libusbredirparser >/dev/null 2>&1 ; then usb_redir="yes" usb_redir_cflags=$(pkg-config --cflags libusbredirparser 2>/dev/null) usb_redir_libs=$(pkg-config --libs libusbredirparser 2>/dev/null) diff --git a/usb-redir.c b/usb-redir.c index d369bb3..2cf0e53 100644 --- a/usb-redir.c +++ b/usb-redir.c @@ -106,6 +106,7 @@ struct AsyncURB { QTAILQ_ENTRY(AsyncURB)next; }; +static void usbredir_hello(void *priv, struct usb_redir_hello_header *h); static void usbredir_device_connect(void *priv, struct usb_redir_device_connect_header *device_connect); static void usbredir_device_disconnect(void *priv); @@ -808,6 +809,7 @@ static void usbredir_open_close_bh(void *opaque) dev->parser->log_func = usbredir_log; dev->parser->read_func = usbredir_read; dev->parser->write_func = usbredir_write; + dev->parser->hello_func = usbredir_hello; dev->parser->device_connect_func = usbredir_device_connect; dev->parser->device_disconnect_func = usbredir_device_disconnect; dev->parser->interface_info_func = usbredir_interface_info; @@ -826,6 +828,7 @@ static void usbredir_open_close_bh(void *opaque) dev->read_buf_size = 0; usbredirparser_caps_set_cap(caps, usb_redir_cap_connect_device_version); + usbredirparser_caps_set_cap(caps, usb_redir_cap_filter); usbredirparser_init(dev->parser, VERSION, caps, USB_REDIR_CAPS_SIZE, 0); usbredirparser_do_write(dev->parser); } @@ -1013,6 +1016,10 @@ static int usbredir_check_filter(USBRedirDevice *dev) error: usbredir_device_disconnect(dev); + if (usbredirparser_peer_has_cap(dev->parser, usb_redir_cap_filter)) { + usbredirparser_send_filter_reject(dev->parser); + usbredirparser_do_write(dev->parser); + } return -1; } @@ -1038,6 +1045,19 @@ static int usbredir_handle_status(USBRedirDevice *dev, } } +static void usbredir_hello(void *priv, struct usb_redir_hello_header *h) +{ + USBRedirDevice *dev = priv; + + /* Try to send the filter info now that we've the usb-host's caps */ + if (usbredirparser_peer_has_cap(dev->parser, usb_redir_cap_filter) && + dev->filter_rules) { + usbredirparser_send_filter_filter(dev->parser, dev->filter_rules, + dev->filter_rules_count); + usbredirparser_do_write(dev->parser); + } +} + static void usbredir_device_connect(void *priv, struct usb_redir_device_connect_header *device_connect) { -- 1.7.7.6