In a nutshell, I'm developing an embedded system that requires, amongst other things, a bridge from a USB host port to a device port (this is just a first step, later the information transmitted will be filtered and altered).
Considering that this is basically a USB snooper/sniffer I figured that someone should have written a module capable of this, but my search has proven futile.
So, to the question: What's the simplest way to redirect a USB host to a USB device in Linux? The data must be identical, all descriptors and endpoints must match. It must be Linux friendly, I can code in C/C++ and have some experience with coding kernel modules, drivers, etc.
A USB bridge is a device that implements a fixed-function bridge between one USB port and one or two other mass storage device ports.
The USB “TO DEVICE” port is for connecting USB flash drives or other external USB devices to the instrument. The USB “TO HOST” port is specifically for connecting to a computer, smart device, or other host. USB memory devices cannot be connected to the USB “TO HOST” port.
USB On-The-Go (OTG) is a standardized specification that allows a device to read data from a USB device without requiring a PC. With an OTG cable, the device itself becomes the USB host. You can do a lot over an OTG connection, like connecting a USB flash drive or a video game controller to your phone.
A device that can serve as a “master” USB device, to which other “client” peripherals can be attached, is referred to as a “USB host.” Computers are USB hosts by default.
I found previous work at http://www.elinux.org/BeagleBoard/GSoC/2010_Projects/USBSniffer
The simplest way to redirect a USB host to a USB device in Linux is in my opinion to use both the Linux' peripheral USB stack and Linux' gadget USB stack. Those stacks take care of the low level, so your code should only concern high level interfacing between those two stacks. Added bonus is that the sniffer (via usbmon) will come for almost free.
As that way will be dealing with the Linux kernel, it must be Linux friendly. The interface to both stacks is (at least) available in C. So, your conditions are met.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With