-
Notifications
You must be signed in to change notification settings - Fork 736
GUACAMOLE-522: USB Device Redirection. #610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -499,5 +499,95 @@ typedef int guac_user_get_handler(guac_user* user, guac_object* object, | |
| typedef int guac_user_put_handler(guac_user* user, guac_object* object, | ||
| guac_stream* stream, char* mimetype, char* name); | ||
|
|
||
| #endif | ||
| /** | ||
| * Handler for Guacamole USB connect events, invoked when a "usbconnect" | ||
| * instruction has been received from a user. This indicates that the user | ||
| * has connected a USB device via WebUSB and it is available for redirection. | ||
| * | ||
| * @param device_id | ||
| * The unique identifier for the USB device. Required. | ||
| * | ||
| * @param vendor_id | ||
| * The vendor ID of the USB device. Required. | ||
| * | ||
| * @param product_id | ||
| * The product ID of the USB device. Required. | ||
| * | ||
| * @param device_name | ||
| * The human-readable name of the device. Required (may be empty string). | ||
| * | ||
| * @param serial_number | ||
| * The serial number of the device. Optional (may be NULL or empty string | ||
| * if not available). | ||
| * | ||
| * @param device_class | ||
| * The USB device class. Required. | ||
| * | ||
| * @param device_subclass | ||
| * The USB device subclass. Required. | ||
| * | ||
| * @param device_protocol | ||
| * The USB device protocol. Required. | ||
| * | ||
| * @param interface_data | ||
| * Encoded string containing interface and endpoint information. Required. | ||
| * Format: "ifaceNum:class:subclass:protocol:ep1Num:ep1Dir:ep1Type:ep1Size;ep2...,iface2..." | ||
| * where multiple endpoints within an interface are separated by semicolons | ||
| * and multiple interfaces are separated by commas. | ||
|
Comment on lines
+532
to
+536
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A couple of more question from me, here, regarding this... First, are the format and fields of this Somewhat related, it looks like some of the data in this I ask for two reasons:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The format The data itself comes from standard USB descriptors that the browser's WebUSB API provides automatically. We can see in ManagedUSB.js in our client PR that we're just reading properties that WebUSB gives us: These are all standard USB descriptor fields defined in the USB specification. We're just encoding them into a string format for sending over the Guacamole protocol. As you pointed out thoguh we can see that USB has class/subclass/protocol at two levels. These describe the overall device and are often set to 0 for composite devices:
Composite devices like webcams with microphones commonly use:
These describe each individual interface and is where the actual functionality is usually defined:
HID devices like keyboards/mice commonly have:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay - I'd suggest this all of this - both the encoding of the fields for Guacamole, and the way composite devices are handled - get documented somewhere - I'm not really sure if the code is the best place, or the manual, but I think it'd be useful for folks looking to implement USB functionality with Guacamole to know how we're handling this data. |
||
| * | ||
| * @return | ||
| * Zero if the USB connect event was handled successfully, or non-zero if | ||
| * an error occurred. | ||
| */ | ||
| typedef int guac_user_usbconnect_handler(guac_user* user, const char* device_id, | ||
| int vendor_id, int product_id, const char* device_name, | ||
| const char* serial_number, int device_class, int device_subclass, | ||
| int device_protocol, const char* interface_data); | ||
necouchman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Handler for Guacamole USB data events, invoked when a "usbdata" instruction | ||
| * has been received from a user. This carries data from a client-side USB | ||
| * device to be processed on the server side. | ||
| * | ||
| * @param user | ||
| * The user that sent the USB data. | ||
| * | ||
| * @param device_id | ||
| * The unique identifier for the USB device. | ||
| * | ||
| * @param endpoint_number | ||
| * The USB endpoint number that the data originated from. Endpoint | ||
| * numbers correspond to the endpoints defined in the device's | ||
| * interface_data from the usbconnect instruction. | ||
| * | ||
| * @param data | ||
| * The base64-encoded USB data. | ||
| * | ||
| * @param transfer_type | ||
| * The type of USB transfer (bulk, interrupt, isochronous, control). | ||
| * | ||
| * @return | ||
| * Zero if the USB data was handled successfully, or non-zero if an error | ||
| * occurred. | ||
| */ | ||
| typedef int guac_user_usbdata_handler(guac_user* user, const char* device_id, | ||
| int endpoint_number, const char* data, const char* transfer_type); | ||
|
|
||
| /** | ||
| * Handler for Guacamole USB disconnect events, invoked when a "usbdisconnect" | ||
| * instruction has been received from a user. This indicates that the user | ||
| * has disconnected a USB device that was previously available for redirection. | ||
| * | ||
| * @param user | ||
| * The user that disconnected the USB device. | ||
| * | ||
| * @param device_id | ||
| * The unique identifier for the USB device that was disconnected. | ||
| * | ||
| * @return | ||
| * Zero if the USB disconnect event was handled successfully, or non-zero | ||
| * if an error occurred. | ||
| */ | ||
| typedef int guac_user_usbdisconnect_handler(guac_user* user, const char* device_id); | ||
|
|
||
| #endif | ||
Uh oh!
There was an error while loading. Please reload this page.