Skip to content

Commit f9df463

Browse files
committed
GUACAMOLE-522: USB Device Redirection integration with RDP.
1 parent 1328e60 commit f9df463

File tree

20 files changed

+1518
-29
lines changed

20 files changed

+1518
-29
lines changed

src/libguac/guacamole/protocol.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,9 @@ int guac_protocol_send_usbdisconnect(guac_socket* socket,
11821182
* The unique identifier of the USB device.
11831183
*
11841184
* @param endpoint_number
1185-
* The endpoint number to send data to.
1185+
* The USB endpoint number identifying the logical communication channel
1186+
* for this data transfer. The valid endpoint numbers for a device are
1187+
* provided in the interface_data parameter during usbconnect.
11861188
*
11871189
* @param data
11881190
* The base64-encoded data to send to the USB device.

src/libguac/guacamole/user-fntypes.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -504,36 +504,36 @@ typedef int guac_user_put_handler(guac_user* user, guac_object* object,
504504
* instruction has been received from a user. This indicates that the user
505505
* has connected a USB device via WebUSB and it is available for redirection.
506506
*
507-
* @param user
508-
* The user that connected the USB device.
509-
*
510507
* @param device_id
511-
* The unique identifier for the USB device.
508+
* The unique identifier for the USB device. Required.
512509
*
513510
* @param vendor_id
514-
* The vendor ID of the USB device.
511+
* The vendor ID of the USB device. Required.
515512
*
516513
* @param product_id
517-
* The product ID of the USB device.
514+
* The product ID of the USB device. Required.
518515
*
519516
* @param device_name
520-
* The human-readable name of the device.
517+
* The human-readable name of the device. Required (may be empty string).
521518
*
522519
* @param serial_number
523-
* The serial number of the device, if available.
520+
* The serial number of the device. Optional (may be NULL or empty string
521+
* if not available).
524522
*
525523
* @param device_class
526-
* The USB device class.
524+
* The USB device class. Required.
527525
*
528526
* @param device_subclass
529-
* The USB device subclass.
527+
* The USB device subclass. Required.
530528
*
531529
* @param device_protocol
532-
* The USB device protocol.
530+
* The USB device protocol. Required.
533531
*
534532
* @param interface_data
535-
* Encoded string containing interface and endpoint information in the
536-
* format: "iface_num:class:subclass:protocol:ep_num:dir:type:size,..."
533+
* Encoded string containing interface and endpoint information. Required.
534+
* Format: "ifaceNum:class:subclass:protocol:ep1Num:ep1Dir:ep1Type:ep1Size;ep2...,iface2..."
535+
* where multiple endpoints within an interface are separated by semicolons
536+
* and multiple interfaces are separated by commas.
537537
*
538538
* @return
539539
* Zero if the USB connect event was handled successfully, or non-zero if
@@ -556,7 +556,9 @@ typedef int guac_user_usbconnect_handler(guac_user* user, const char* device_id,
556556
* The unique identifier for the USB device.
557557
*
558558
* @param endpoint_number
559-
* The endpoint number the data originated from.
559+
* The USB endpoint number that the data originated from. Endpoint
560+
* numbers correspond to the endpoints defined in the device's
561+
* interface_data from the usbconnect instruction.
560562
*
561563
* @param data
562564
* The base64-encoded USB data.

src/libguac/guacamole/user.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,11 @@ struct guac_user {
541541
/**
542542
* Handler for USB connect events sent by the Guacamole web-client.
543543
*
544-
* The handler takes the user that connected the device, the device ID,
545-
* vendor ID, product ID, device name, serial number, device class,
546-
* device subclass, device protocol, and interface data.
544+
* The handler takes the user that connected the device, the device ID
545+
* (required), vendor ID (required), product ID (required), device name
546+
* (required), serial number (optional - may be NULL or empty), device class
547+
* (required), device subclass (required), device protocol (required), and
548+
* interface data (required).
547549
*
548550
* Example:
549551
* @code

src/libguac/user-handlers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,22 +233,22 @@ __guac_instruction_handler __guac_handshake_timezone_handler;
233233

234234
/**
235235
* Internal initial handler for the usbconnect instruction. When a usbconnect
236-
* instruction is received, this handler will be called. The client's
236+
* instruction is received, this handler will be called. The user's
237237
* usbconnect handler will be invoked if defined.
238238
*/
239239
__guac_instruction_handler __guac_handle_usbconnect;
240240

241241
/**
242242
* Internal initial handler for the usbdata instruction. When a usbdata
243-
* instruction is received, this handler will be called. The client's
243+
* instruction is received, this handler will be called. The user's
244244
* usbdata handler will be invoked if defined.
245245
*/
246246
__guac_instruction_handler __guac_handle_usbdata;
247247

248248
/**
249249
* Internal initial handler for the usbdisconnect instruction. When a
250250
* usbdisconnect instruction is received, this handler will be called.
251-
* The client's usbdisconnect handler will be invoked if defined.
251+
* The user's usbdisconnect handler will be invoked if defined.
252252
*/
253253
__guac_instruction_handler __guac_handle_usbdisconnect;
254254

src/protocols/rdp/Makefile.am

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ libguac_client_rdp_la_SOURCES = \
5959
channels/rdpgfx.c \
6060
channels/rdpsnd/rdpsnd-messages.c \
6161
channels/rdpsnd/rdpsnd.c \
62+
channels/usb-redirection/usb-redirection.c \
63+
channels/usb-redirection/usb-manager.c \
6264
client.c \
6365
color.c \
6466
decompose.c \
@@ -104,6 +106,8 @@ noinst_HEADERS = \
104106
channels/rdpgfx.h \
105107
channels/rdpsnd/rdpsnd-messages.h \
106108
channels/rdpsnd/rdpsnd.h \
109+
channels/usb-redirection/usb-redirection.h \
110+
channels/usb-redirection/usb-manager.h \
107111
client.h \
108112
color.h \
109113
decompose.h \
@@ -119,6 +123,8 @@ noinst_HEADERS = \
119123
plugins/channels.h \
120124
plugins/guacai/guacai-messages.h \
121125
plugins/guacai/guacai.h \
126+
plugins/guacusb/guacusb-messages.h \
127+
plugins/guacusb/guacusb.h \
122128
plugins/ptr-string.h \
123129
pointer.h \
124130
print-job.h \
@@ -152,7 +158,8 @@ libguac_client_rdp_la_LIBADD = \
152158

153159
freerdp_LTLIBRARIES = \
154160
libguac-common-svc-client.la \
155-
libguacai-client.la
161+
libguacai-client.la \
162+
libguacusb-client.la
156163

157164
freerdpdir = @FREERDP_PLUGIN_DIR@
158165

@@ -201,6 +208,33 @@ libguacai_client_la_LIBADD = \
201208
@COMMON_LTLIB@ \
202209
@LIBGUAC_LTLIB@
203210

211+
#
212+
# URBDRC USB Redirection Plugin - OWNS ALL USB FUNCTIONALITY
213+
#
214+
215+
libguacusb_client_la_SOURCES = \
216+
channels/usb-redirection/usb-manager.c \
217+
plugins/guacusb/guacusb-messages.c \
218+
plugins/guacusb/guacusb.c \
219+
plugins/ptr-string.c
220+
221+
libguacusb_client_la_CFLAGS = \
222+
-Werror -Wall -Iinclude \
223+
@COMMON_INCLUDE@ \
224+
@COMMON_SSH_INCLUDE@ \
225+
@LIBGUAC_INCLUDE@ \
226+
@RDP_CFLAGS@
227+
228+
libguacusb_client_la_LDFLAGS = \
229+
-module -avoid-version -shared \
230+
-export-dynamic \
231+
@PTHREAD_LIBS@ \
232+
@RDP_LIBS@
233+
234+
libguacusb_client_la_LIBADD = \
235+
@COMMON_LTLIB@ \
236+
@LIBGUAC_LTLIB@
237+
204238
#
205239
# Optional SFTP support
206240
#
@@ -259,4 +293,4 @@ _generated_channel_entry_wrappers.c: $(srcdir)/plugins/channels.h $(srcdir)/plug
259293
EXTRA_DIST = \
260294
$(rdp_keymaps) \
261295
keymaps/generate.pl \
262-
plugins/generate-entry-wrappers.pl
296+
plugins/generate-entry-wrappers.pl

0 commit comments

Comments
 (0)