Hello community, here is the log from the commit of package usbredir for openSUSE:Factory checked in at 2018-09-26 16:02:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/usbredir (Old) and /work/SRC/openSUSE:Factory/.usbredir.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "usbredir" Wed Sep 26 16:02:03 2018 rev:13 rq:636388 version:0.8.0 Changes: -------- --- /work/SRC/openSUSE:Factory/usbredir/usbredir.changes 2016-02-23 16:52:08.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.usbredir.new/usbredir.changes 2018-09-26 16:02:07.588420490 +0200 @@ -1,0 +2,14 @@ +Mon Sep 17 23:13:41 UTC 2018 - Bruce Rogers <[email protected]> + +- Update to version 0.8.0 + + usbredirfilter: + -Fix busy wait due endless recursion when interface_count is zero + + usbredirhost: + -Fix leak on error + + usbredirserver: + -Use 'busnum-devnum' instead of 'usbbus-usbaddr' + -Add support for bind specific address -4 for ipv4, -6 for ipv6 + -Reject empty vendorid from command line + -Enable TCP keepalive + +------------------------------------------------------------------- Old: ---- usbredir-0.7.1.tar.bz2 New: ---- usbredir-0.8.0.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ usbredir.spec ++++++ --- /var/tmp/diff_new_pack.bwlCyo/_old 2018-09-26 16:02:08.068419658 +0200 +++ /var/tmp/diff_new_pack.bwlCyo/_new 2018-09-26 16:02:08.072419651 +0200 @@ -1,7 +1,7 @@ # # spec file for package usbredir # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2011 Dominique Leuenberger, Amsterdam, The Netherlands. # # All modifications and additions to the file contributed by third parties @@ -13,18 +13,18 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: usbredir -Version: 0.7.1 +Version: 0.8.0 Release: 0 Summary: A protocol for redirection USB traffic -License: GPL-2.0+ and LGPL-2.1+ +License: GPL-2.0-or-later AND LGPL-2.1-or-later Group: System/Libraries -Url: http://spice-space.org/page/UsbRedir -Source: http://spice-space.org/download/usbredir/%{name}-%{version}.tar.bz2 +Url: https://www.spice-space.org/usbredir.html +Source: https://www.spice-space.org/download/usbredir/%{name}-%{version}.tar.bz2 BuildRequires: pkg-config BuildRequires: pkgconfig(libusb-1.0) BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -65,7 +65,7 @@ %description devel usbredir is a protocol for redirection USB traffic from a single USB device, -to a different (virtual) machine then the one to which the USB device is +to a different (virtual) machine than the one to which the USB device is attached. See usb-redirection-protocol.txt for the description / definition of this protocol. @@ -86,7 +86,8 @@ %postun -n libusbredirparser1 -p /sbin/ldconfig %files %defattr(-,root,root) -%doc ChangeLog README COPYING +%doc ChangeLog README +%license COPYING %{_mandir}/man1/usbredirserver.1.gz %{_sbindir}/usbredirserver ++++++ usbredir-0.7.1.tar.bz2 -> usbredir-0.8.0.tar.bz2 ++++++ ++++ 4467 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/COPYING.LIB new/usbredir-0.8.0/COPYING.LIB --- old/usbredir-0.7.1/COPYING.LIB 2015-05-11 12:00:22.000000000 +0200 +++ new/usbredir-0.8.0/COPYING.LIB 2018-07-10 11:27:09.000000000 +0200 @@ -55,7 +55,7 @@ that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - + Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a @@ -111,7 +111,7 @@ "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. - + GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @@ -158,7 +158,7 @@ You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - + 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 @@ -216,7 +216,7 @@ ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - + Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. @@ -267,7 +267,7 @@ distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - + 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work @@ -329,7 +329,7 @@ accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - + 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined @@ -370,7 +370,7 @@ restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - + 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or @@ -422,7 +422,7 @@ the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - + 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is @@ -456,7 +456,7 @@ DAMAGES. END OF TERMS AND CONDITIONS - + How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/ChangeLog new/usbredir-0.8.0/ChangeLog --- old/usbredir-0.7.1/ChangeLog 2015-10-30 15:44:08.000000000 +0100 +++ new/usbredir-0.8.0/ChangeLog 2018-08-07 11:20:16.000000000 +0200 @@ -1,3 +1,17 @@ +usbredir-0.8.0 03 Aug 2018 +---------------------------- +-Source code and bug tracker hosted in Freedesktop's instance of Gitlab + -https://gitlab.freedesktop.org/spice/usbredir +-usbredirfilter + -Fix busy wait due endless recursion when interface_count is zero +-usbredirhost: + -Fix leak on error +-usbredirserver: + -Use 'busnum-devnum' instead of 'usbbus-usbaddr' + -Add support for bind specific address -4 for ipv4, -6 for ipv6 + -Reject empty vendorid from command line + -Enable TCP keepalive + usbredir-0.7.1 29 Oct 2015 ---------------------------- -usbredirfilter @@ -76,7 +90,7 @@ usbredir-0.5 7 September 2012 ------------------------------- --Windows support +-Windows support -Add support for 64 bit packet ids -usbredirparser: -Add state serialization support diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/README new/usbredir-0.8.0/README --- old/usbredir-0.7.1/README 2015-05-11 12:00:22.000000000 +0200 +++ new/usbredir-0.8.0/README 2018-08-07 11:20:16.000000000 +0200 @@ -29,5 +29,14 @@ A small testclient for the usbredir protocol over tcp, using usbredirparser +The upstream git repository can be found at +http://gitlab.freedesktop.org/spice/usbredir -Last updated 14 July 2011, by Hans de Goede <[email protected]> +Bug reports can be filed against the Spice/usbredir component: +https://gitlab.freedesktop.org/spice/usbredir/issues + +You can also send patches to the spice-devel mailing list: +http://lists.freedesktop.org/mailman/listinfo/spice-devel + + +Last updated 03 August 2018, by Victor Toso <[email protected]> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/compile new/usbredir-0.8.0/compile --- old/usbredir-0.7.1/compile 2015-11-02 09:03:25.000000000 +0100 +++ new/usbredir-0.8.0/compile 2018-08-07 11:21:36.000000000 +0200 @@ -1,9 +1,9 @@ -#! /bin/sh +#!/bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2012-10-14.11; # UTC +scriptversion=2016-01-11.22; # UTC -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2017 Free Software Foundation, Inc. # Written by Tom Tromey <[email protected]>. # # This program is free software; you can redistribute it and/or modify @@ -255,7 +255,8 @@ echo "compile $scriptversion" exit $? ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac @@ -342,6 +343,6 @@ # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/configure.ac new/usbredir-0.8.0/configure.ac --- old/usbredir-0.7.1/configure.ac 2015-10-30 15:44:08.000000000 +0100 +++ new/usbredir-0.8.0/configure.ac 2018-08-07 11:20:16.000000000 +0200 @@ -1,5 +1,5 @@ AC_PREREQ(2.63) -AC_INIT([usbredir], [0.7.1]) +AC_INIT([usbredir], [0.8.0]) AC_CONFIG_SRCDIR([configure.ac]) AM_CONFIG_HEADER([config.h]) @@ -10,10 +10,10 @@ # changes to the signature and the semantic) # ? :+1 : ? == just internal changes # CURRENT : REVISION : AGE -LIBUSBREDIRHOST_SO_VERSION=1:0:0 +LIBUSBREDIRHOST_SO_VERSION=1:1:0 AC_SUBST(LIBUSBREDIRHOST_SO_VERSION) -LIBUSBREDIRPARSER_SO_VERSION=1:0:0 +LIBUSBREDIRPARSER_SO_VERSION=1:1:0 AC_SUBST(LIBUSBREDIRPARSER_SO_VERSION) AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/missing new/usbredir-0.8.0/missing --- old/usbredir-0.7.1/missing 2015-11-02 09:03:25.000000000 +0100 +++ new/usbredir-0.8.0/missing 2018-08-07 11:21:36.000000000 +0200 @@ -1,9 +1,9 @@ -#! /bin/sh +#!/bin/sh # Common wrapper for a few potentially missing GNU programs. -scriptversion=2013-10-28.13; # UTC +scriptversion=2016-01-11.22; # UTC -# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard <[email protected]>, 1996. # This program is free software; you can redistribute it and/or modify @@ -210,6 +210,6 @@ # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/usb-redirection-protocol.txt new/usbredir-0.8.0/usb-redirection-protocol.txt --- old/usbredir-0.7.1/usb-redirection-protocol.txt 2015-05-11 12:00:22.000000000 +0200 +++ new/usbredir-0.8.0/usb-redirection-protocol.txt 2018-07-10 11:27:09.000000000 +0200 @@ -115,7 +115,7 @@ os which accesses a usb-device over the network as if it is part of the virtual machine. usb-host: The entity making the usb-device available for use by a usb-guest. - For example a deamon on a machine which "exports" the usb-device over the + For example a daemon on a machine which "exports" the usb-device over the network which then "appears" inside a virtual machine on another machine. @@ -159,7 +159,7 @@ the request over to the host os and then *wait* for a response. The usb-host will thus stop processing further packets. Where as for data packets the usb-host hands them over to the host os with the request to let the usb-host -process know when there is a respone from the usb-device. +process know when there is a response from the usb-device. Note that control packets should only be send to the usb-host when no data packets are pending on the device / interface / endpoint affected by the @@ -261,7 +261,7 @@ enum { /* Supports USB 3 bulk streams */ - usb_redir_cap_bulk_streams, + usb_redir_cap_bulk_streams, /* The device_connect packet has the device_version_bcd field */ usb_redir_cap_connect_device_version, /* Supports usb_redir_filter_reject and usb_redir_filter_filter pkts */ @@ -729,7 +729,7 @@ struct usb_redir_start_bulk_receiving_header { uint32_t stream_id; uint32_t bytes_per_transfer; - uint8_t endpoint; + uint8_t endpoint; uint8_t no_transfers; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/usbredirhost/usbredirhost.c new/usbredir-0.8.0/usbredirhost/usbredirhost.c --- old/usbredir-0.7.1/usbredirhost/usbredirhost.c 2015-10-30 15:44:08.000000000 +0100 +++ new/usbredir-0.8.0/usbredirhost/usbredirhost.c 2018-08-03 11:11:16.000000000 +0200 @@ -306,7 +306,7 @@ case LIBUSB_TRANSFER_OVERFLOW: return usb_redir_babble; - case LIBUSB_ERROR_INVALID_PARAM: + case LIBUSB_ERROR_INVALID_PARAM: return usb_redir_inval; case LIBUSB_ERROR_NO_DEVICE: usbredirhost_handle_disconnect(host); @@ -604,7 +604,11 @@ if (!(host->quirks & QUIRK_DO_NOT_RESET)) { r = libusb_reset_device(host->handle); if (r != 0) { - ERROR("error resetting device: %s", libusb_error_name(r)); + /* if we're releasing the device because it was removed, resetting + * will fail. Don't print a warning in this situation */ + if (r != LIBUSB_ERROR_NO_DEVICE) { + ERROR("error resetting device: %s", libusb_error_name(r)); + } return; } } @@ -746,7 +750,11 @@ usbredirparser_init(host->parser, version, caps, USB_REDIR_CAPS_SIZE, parser_flags); +#if LIBUSB_API_VERSION >= 0x01000106 + libusb_set_option(host->ctx, LIBUSB_OPTION_LOG_LEVEL, host->verbose); +#else libusb_set_debug(host->ctx, host->verbose); +#endif if (usbredirhost_set_device(host, usb_dev_handle) != usb_redir_success) { usbredirhost_close(host); @@ -1020,12 +1028,12 @@ size = host->buffered_output_size_func(host->func_priv); if (size >= host->iso_threshold.higher) { if (!host->iso_threshold.dropping) - DEBUG("START dropping isoc packets %lu buffer > %lu hi threshold", + DEBUG("START dropping isoc packets %" PRIu64 " buffer > %" PRIu64 " hi threshold", size, host->iso_threshold.higher); host->iso_threshold.dropping = true; } else if (size < host->iso_threshold.lower) { if (host->iso_threshold.dropping) - DEBUG("STOP dropping isoc packets %lu buffer < %lu low threshold", + DEBUG("STOP dropping isoc packets %" PRIu64 " buffer < %" PRIu64 " low threshold", size, host->iso_threshold.lower); host->iso_threshold.dropping = false; @@ -1159,7 +1167,7 @@ uint64_t reference = pkts_per_transfer * transfer_count * max_packetsize; host->iso_threshold.lower = reference / 2; host->iso_threshold.higher = reference * 3; - DEBUG("higher threshold is %lu bytes | lower threshold is %lu bytes", + DEBUG("higher threshold is %" PRIu64 " bytes | lower threshold is %" PRIu64 " bytes", host->iso_threshold.higher, host->iso_threshold.lower); } @@ -1342,7 +1350,7 @@ wait = host->cancels_pending || host->transfers_head.next; UNLOCK(host); } while (wait); -} +} /* Only called from read callbacks */ static void usbredirhost_cancel_pending_urbs_on_interface( @@ -1409,7 +1417,7 @@ usbredirhost_buffered_output_size buffered_output_size_func) { if (!host) { - ERROR("invalid usbredirhost"); + fprintf(stderr, "%s: invalid usbredirhost", __func__); return; } @@ -2280,6 +2288,7 @@ transfer, BULK_TIMEOUT); #else r = LIBUSB_ERROR_INVALID_PARAM; + free(data); goto error; #endif } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/usbredirparser/usbredirfilter.c new/usbredir-0.8.0/usbredirparser/usbredirfilter.c --- old/usbredir-0.7.1/usbredirparser/usbredirfilter.c 2015-10-19 11:52:48.000000000 +0200 +++ new/usbredir-0.8.0/usbredirparser/usbredirfilter.c 2018-07-10 11:27:09.000000000 +0200 @@ -205,7 +205,7 @@ * by recursively calling this function with a flag that forbids * skipping (usbredirfilter_fl_dont_skip_non_boot_hid) */ - if (num_skipped == interface_count) { + if (interface_count > 0 && num_skipped == interface_count) { rc = usbredirfilter_check(rules, rules_count, device_class, device_subclass, device_protocol, interface_class, interface_subclass, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/usbredirparser/usbredirfilter.h new/usbredir-0.8.0/usbredirparser/usbredirfilter.h --- old/usbredir-0.7.1/usbredirparser/usbredirfilter.h 2015-05-11 12:00:22.000000000 +0200 +++ new/usbredir-0.8.0/usbredirparser/usbredirfilter.h 2018-07-10 11:27:09.000000000 +0200 @@ -88,11 +88,11 @@ Note that under certain circumstances some passes are skipped: - For devices with a device class of 0x00 or 0xef, the pass which checks the device class is skipped. - - If the usbredirfilter_fl_dont_skip_non_boot_hid flag is not passed then - for devices with more then 1 interface and an interface with an interface + - If the usbredirfilter_fl_dont_skip_non_boot_hid flag is not passed, then + for devices with more than 1 interface and an interface with an interface class of 0x03, an interface subclass of 0x00 and an interface protocol - of 0x00. the check is skipped for that interface. This allows to skip ie - checking the interface for volume buttons one some usbaudio class devices. + of 0x00, the check is skipped for that interface. This allows to skip ie + checking the interface for volume buttons on some usbaudio class devices. If the result of all (not skipped) passes is allow, then 0 will be returned, which indicates that redirection should be allowed. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/usbredirparser/usbredirparser.c new/usbredir-0.8.0/usbredirparser/usbredirparser.c --- old/usbredir-0.7.1/usbredirparser/usbredirparser.c 2015-10-29 16:57:50.000000000 +0100 +++ new/usbredir-0.8.0/usbredirparser/usbredirparser.c 2018-07-10 11:27:09.000000000 +0200 @@ -92,7 +92,7 @@ va_start(ap, fmt); vsnprintf(buf + n, sizeof(buf) - n, fmt, ap); va_end(ap); - + parser->callb.log_func(parser->callb.priv, verbose, buf); } @@ -267,7 +267,8 @@ /* In case hello->version is not 0 terminated (which would be a protocol violation)_ */ - snprintf(buf, sizeof(buf), "%s", hello->version); + strncpy(buf, hello->version, sizeof(buf)); + buf[sizeof(buf)-1] = '\0'; memset(parser->peer_caps, 0, sizeof(parser->peer_caps)); if (data_len > sizeof(parser->peer_caps)) { @@ -302,7 +303,7 @@ struct usbredirparser_priv *parser = (struct usbredirparser_priv *)parser_pub; int command_for_host = 0; - + if (parser->flags & usbredirparser_fl_usb_host) { command_for_host = 1; } @@ -1057,7 +1058,7 @@ int w, ret = 0; LOCK(parser); - for (;;) { + for (;;) { wbuf = parser->write_buf; if (!wbuf) break; @@ -1725,8 +1726,8 @@ int type_header_len = usbredirparser_get_type_header_len(parser_pub, parser->header.type, 0); - if (type_header_len < 0 || - type_header_len > sizeof(parser->type_header) || + if (type_header_len < 0 || + type_header_len > sizeof(parser->type_header) || parser->header.length < type_header_len || (parser->header.length > type_header_len && !usbredirparser_expect_extra_data(parser))) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/usbredirparser/usbredirproto.h new/usbredir-0.8.0/usbredirparser/usbredirproto.h --- old/usbredir-0.7.1/usbredirparser/usbredirproto.h 2015-10-30 15:44:08.000000000 +0100 +++ new/usbredir-0.8.0/usbredirparser/usbredirproto.h 2018-07-10 11:27:09.000000000 +0200 @@ -116,7 +116,7 @@ enum { /* Supports USB 3 bulk streams */ - usb_redir_cap_bulk_streams, + usb_redir_cap_bulk_streams, /* The device_connect packet has the device_version_bcd field */ usb_redir_cap_connect_device_version, /* Supports usb_redir_filter_reject and usb_redir_filter_filter pkts */ @@ -138,7 +138,7 @@ struct usb_redir_header { uint32_t type; uint32_t length; - uint64_t id; + uint64_t id; } ATTR_PACKED; struct usb_redir_hello_header { @@ -264,7 +264,7 @@ uint8_t status; uint16_t value; uint16_t index; - uint16_t length; + uint16_t length; } ATTR_PACKED; struct usb_redir_bulk_packet_header { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/usbredirserver/usbredirserver.1 new/usbredir-0.8.0/usbredirserver/usbredirserver.1 --- old/usbredir-0.7.1/usbredirserver/usbredirserver.1 2015-05-11 12:00:22.000000000 +0200 +++ new/usbredir-0.8.0/usbredirserver/usbredirserver.1 2018-08-07 11:20:16.000000000 +0200 @@ -3,7 +3,8 @@ usbredirserver \- exporting an USB device for use from another (virtual) machine .SH SYNOPSIS .B usbredirserver -[\fI-p|--port <port>\fR] [\fI-v|--verbose <0-5>\fR] \fI<usbbus-usbaddr|vendorid:prodid>\fR +[\fI-p|--port <port>\fR] [\fI-v|--verbose <0-5>\fR] [\fI-4 <ipv4_addr|I-6 <ipv6_addr>] +\fI<busnum-devnum|vendorid:prodid>\fR .SH DESCRIPTION usbredirserver is a small standalone server for exporting an USB device for use from another (virtual) machine through the usbredir protocol. @@ -28,11 +29,13 @@ .SH AUTHOR Written by Hans de Goede <[email protected]> .SH REPORTING BUGS -Report bugs to the spice-devel mailinglist: +You can report bugs to the spice-devel mailinglist: http://lists.freedesktop.org/mailman/listinfo/spice-devel +or filing an issue at: +https://gitlab.freedesktop.org/spice/usbredir/issues/new .SH COPYRIGHT Copyright 2010-2012 Red Hat, Inc. License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>. -.br +.br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/usbredirserver/usbredirserver.c new/usbredir-0.8.0/usbredirserver/usbredirserver.c --- old/usbredir-0.7.1/usbredirserver/usbredirserver.c 2015-05-11 12:00:22.000000000 +0200 +++ new/usbredir-0.8.0/usbredirserver/usbredirserver.c 2018-08-03 11:11:16.000000000 +0200 @@ -36,6 +36,8 @@ #include <sys/time.h> #include <netdb.h> #include <netinet/in.h> +#include <arpa/inet.h> +#include <netinet/tcp.h> #include "usbredirhost.h" @@ -49,6 +51,9 @@ static const struct option longopts[] = { { "port", required_argument, NULL, 'p' }, { "verbose", required_argument, NULL, 'v' }, + { "ipv4", required_argument, NULL, '4' }, + { "ipv6", required_argument, NULL, '6' }, + { "keepalive", required_argument, NULL, 'k' }, { "help", no_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; @@ -93,7 +98,10 @@ static void usage(int exit_code, char *argv0) { fprintf(exit_code? stderr:stdout, - "Usage: %s [-p|--port <port>] [-v|--verbose <0-5>] <usbbus-usbaddr|vendorid:prodid>\n", + "Usage: %s [-p|--port <port>] [-v|--verbose <0-5>] " + "[[-4|--ipv4 ipaddr]|[-6|--ipv6 ipaddr]] " + "[-k|--keepalive seconds] " + "<busnum-devnum|vendorid:prodid>\n", argv0); exit(exit_code); } @@ -198,11 +206,16 @@ int usbvendor = -1; int usbproduct = -1; int on = 1; - struct sockaddr_in6 serveraddr; + int keepalive = -1; + char *ipv4_addr = NULL, *ipv6_addr = NULL; + union { + struct sockaddr_in v4; + struct sockaddr_in6 v6; + } serveraddr; struct sigaction act; libusb_device_handle *handle = NULL; - while ((o = getopt_long(argc, argv, "hp:v:", longopts, NULL)) != -1) { + while ((o = getopt_long(argc, argv, "hp:v:4:6:k:", longopts, NULL)) != -1) { switch (o) { case 'p': port = strtol(optarg, &endptr, 10); @@ -218,6 +231,19 @@ usage(1, argv[0]); } break; + case '4': + ipv4_addr = optarg; + break; + case '6': + ipv6_addr = optarg; + break; + case 'k': + keepalive = strtol(optarg, &endptr, 10); + if (*endptr != '\0') { + fprintf(stderr, "Invalid value for -k: '%s'\n", optarg); + usage(1, argv[0]); + } + break; case '?': case 'h': usage(o == '?', argv[0]); @@ -244,11 +270,12 @@ invalid_usb_device_id(argv[optind], argv[0]); } usbvendor = strtol(argv[optind], &endptr, 16); - if (*endptr != ':') { + if (*endptr != ':' || usbvendor <= 0 || usbvendor > 0xffff) { invalid_usb_device_id(argv[optind], argv[0]); } usbproduct = strtol(delim + 1, &endptr, 16); - if (*endptr != '\0') { + /* Product ID 0000 is valid */ + if (*endptr != '\0' || usbproduct < 0 || usbproduct > 0xffff) { invalid_usb_device_id(argv[optind], argv[0]); } } @@ -270,11 +297,19 @@ exit(1); } +#if LIBUSB_API_VERSION >= 0x01000106 + libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, verbose); +#else libusb_set_debug(ctx, verbose); +#endif - server_fd = socket(AF_INET6, SOCK_STREAM, 0); + if (ipv4_addr) { + server_fd = socket(AF_INET, SOCK_STREAM, 0); + } else { + server_fd = socket(AF_INET6, SOCK_STREAM, 0); + } if (server_fd == -1) { - perror("Error creating ipv6 socket"); + perror("Error creating ip socket"); exit(1); } @@ -282,14 +317,34 @@ perror("Error setsockopt(SO_REUSEADDR) failed"); exit(1); } - + memset(&serveraddr, 0, sizeof(serveraddr)); - serveraddr.sin6_family = AF_INET6; - serveraddr.sin6_port = htons(port); - serveraddr.sin6_addr = in6addr_any; - if (bind(server_fd, (struct sockaddr *)&serveraddr, sizeof(serveraddr))) { - fprintf(stderr, "Error binding port %d: %s\n", port, strerror(errno)); + if (ipv4_addr) { + serveraddr.v4.sin_family = AF_INET; + serveraddr.v4.sin_port = htons(port); + if ((inet_pton(AF_INET, ipv4_addr, + &serveraddr.v4.sin_addr)) != 1) { + perror("Error convert ipv4 address"); + exit(1); + } + } else { + serveraddr.v6.sin6_family = AF_INET6; + serveraddr.v6.sin6_port = htons(port); + if (ipv6_addr) { + if ((inet_pton(AF_INET6, ipv6_addr, + &serveraddr.v6.sin6_addr)) != 1) { + perror("Error convert ipv6 address"); + exit(1); + } + } else { + serveraddr.v6.sin6_addr = in6addr_any; + } + } + + if (bind(server_fd, (struct sockaddr *)&serveraddr, + sizeof(serveraddr))) { + perror("Error bind"); exit(1); } @@ -308,6 +363,38 @@ break; } + if (keepalive > 0) { + int optval = 1; + socklen_t optlen = sizeof(optval); + if (setsockopt(client_fd, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) == -1) { + if (errno != ENOTSUP) { + perror("setsockopt SO_KEEPALIVE error."); + break; + } + } + optval = keepalive; /* set default TCP_KEEPIDLE time from cmdline */ + if (setsockopt(client_fd, SOL_TCP, TCP_KEEPIDLE, &optval, optlen) == -1) { + if (errno != ENOTSUP) { + perror("setsockopt TCP_KEEPIDLE error."); + break; + } + } + optval = 10; /* set default TCP_KEEPINTVL time as 10s */ + if (setsockopt(client_fd, SOL_TCP, TCP_KEEPINTVL, &optval, optlen) == -1) { + if (errno != ENOTSUP) { + perror("setsockopt TCP_KEEPINTVL error."); + break; + } + } + optval = 3; /* set default TCP_KEEPCNT as 3 */ + if (setsockopt(client_fd, SOL_TCP, TCP_KEEPCNT, &optval, optlen) == -1) { + if (errno != ENOTSUP) { + perror("setsockopt TCP_KEEPCNT error."); + break; + } + } + } + flags = fcntl(client_fd, F_GETFL); if (flags == -1) { perror("fcntl F_GETFL"); @@ -327,6 +414,14 @@ fprintf(stderr, "Could not open an usb-device with vid:pid %04x:%04x\n", usbvendor, usbproduct); + } else if (verbose >= usbredirparser_info) { + libusb_device *dev; + dev = libusb_get_device(handle); + fprintf(stderr, "Open a usb-device with vid:pid %04x:%04x on " + "bus %03x device %03x\n", + usbvendor, usbproduct, + libusb_get_bus_number(dev), + libusb_get_device_address(dev)); } } else { libusb_device **list = NULL; @@ -341,12 +436,12 @@ if (i < n) { if (libusb_open(list[i], &handle) != 0) { fprintf(stderr, - "Could not open usb-device at bus-addr %d-%d\n", + "Could not open usb-device at busnum-devnum %d-%d\n", usbbus, usbaddr); } } else { fprintf(stderr, - "Could not find an usb-device at bus-addr %d-%d\n", + "Could not find an usb-device at busnum-devnum %d-%d\n", usbbus, usbaddr); } libusb_free_device_list(list, 1); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/usbredir-0.7.1/usbredirtestclient/usbredirtestclient.c new/usbredir-0.8.0/usbredirtestclient/usbredirtestclient.c --- old/usbredir-0.7.1/usbredirtestclient/usbredirtestclient.c 2015-05-11 12:00:22.000000000 +0200 +++ new/usbredir-0.8.0/usbredirtestclient/usbredirtestclient.c 2018-07-10 11:27:09.000000000 +0200 @@ -85,7 +85,7 @@ first_cmdline_id }; -static int verbose = usbredirparser_info; /* 2 */ +static int verbose = usbredirparser_info; /* 3 */ static int client_fd, running = 1; static struct usbredirparser *parser; static int id = first_cmdline_id; @@ -134,6 +134,15 @@ return r; } +static void usbredirtestclient_hello(void *priv, + struct usb_redir_hello_header *h) +{ + /* Queue a reset + set config the other test commands will be send in + response to the status packets of previous commands */ + usbredirparser_send_reset(parser); + usbredirparser_send_get_configuration(parser, get_config_id); +} + static void usage(int exit_code, char *argv0) { fprintf(exit_code? stderr:stdout, @@ -196,6 +205,7 @@ struct sigaction act; char port_str[16]; int port = 4000; + uint32_t caps[USB_REDIR_CAPS_SIZE] = { 0, }; while ((o = getopt_long(argc, argv, "hp:", longopts, NULL)) != -1) { switch (o) { @@ -284,6 +294,7 @@ parser->log_func = usbredirtestclient_log; parser->read_func = usbredirtestclient_read; parser->write_func = usbredirtestclient_write; + parser->hello_func = usbredirtestclient_hello; parser->device_connect_func = usbredirtestclient_device_connect; parser->device_disconnect_func = usbredirtestclient_device_disconnect; parser->interface_info_func = usbredirtestclient_interface_info; @@ -297,12 +308,11 @@ parser->bulk_packet_func = usbredirtestclient_bulk_packet; parser->iso_packet_func = usbredirtestclient_iso_packet; parser->interrupt_packet_func = usbredirtestclient_interrupt_packet; - usbredirparser_init(parser, TESTCLIENT_VERSION, NULL, 0, 0); - /* Queue a reset + set config the other test commands will be send in - response to the status packets of previous commands */ - usbredirparser_send_reset(parser); - usbredirparser_send_get_configuration(parser, get_config_id); + usbredirparser_caps_set_cap(caps, usb_redir_cap_ep_info_max_packet_size); + usbredirparser_caps_set_cap(caps, usb_redir_cap_64bits_ids); + + usbredirparser_init(parser, TESTCLIENT_VERSION, caps, USB_REDIR_CAPS_SIZE, 0); run_main_loop(); @@ -378,7 +388,7 @@ return 0; } - if (!(control_packet.endpoint & 0x80)) { + if (!(control_packet.endpoint & 0x80)) { int i; data = malloc(control_packet.length); @@ -488,9 +498,9 @@ for (i = 0; i < 32; i++) { if (ep_info->type[i] != usb_redir_type_invalid) { - printf("endpoint: %02X, type: %d, interval: %d, interface: %d\n", + printf("endpoint: %02X, type: %d, interval: %d, interface: %d max-packetsize: %d\n", I2EP(i), (int)ep_info->type[i], (int)ep_info->interval[i], - (int)ep_info->interface[i]); + (int)ep_info->interface[i], ep_info->max_packet_size[i]); } } }
