Discussion:
[Libusb-devel] Redirect USB input port to output port
Jim Mitchener
2011-05-19 21:51:44 UTC
Permalink
I would like to develop a device that I can place in-between two USB devices
and intercept traffic (preferrably use a driver along with it) and pass the
input out directly to another usb port so that the two devices never know I
am between them. Is this doable with libusb on Linux? Can do I it without
having to develop a kernel driver?

Jim
Greg KH
2011-05-19 23:04:23 UTC
Permalink
Post by Jim Mitchener
I would like to develop a device that I can place in-between two USB devices
and intercept traffic (preferrably use a driver along with it) and pass the
input out directly to another usb port so that the two devices never know I am
between them. Is this doable with libusb on Linux? Can do I it without having
to develop a kernel driver?
You have to do this only in hardware. Look at tools like the USB Beagle
analyzer as examples of hardware that already does this today.

good luck,

greg k-h
Tim Roberts
2011-05-19 23:50:29 UTC
Permalink
Post by Jim Mitchener
I would like to develop a device that I can place in-between two USB
devices and intercept traffic (preferrably use a driver along with it)
and pass the input out directly to another usb port so that the two
devices never know I am between them. Is this doable with libusb on
Linux? Can do I it without having to develop a kernel driver?
There are some things to bear in mind here. Remember that USB is
strictly master/slave. The notion of "between two USB devices" is a bit
awkward; the communication is always between a device and its host, at
the mercy of the host.

Although the cables make it look point-to-point, USB is not actually a
point-to-point protocol. All of outbound data is broadcast to every
device in the tree. You have to know the device ID of the device you
want to monitor, and watch for that ID in the outbound traffic. That
number is assigned during enumeration. Inbound data does not get broadcast.

A device like the one you're talking about could certainly be built.
There are many examples in the wild today. You would probably want it
to behave like a USB hub, so you could expose the downstream port plus
your sniffer device.

A kernel driver is almost never required for USB devices on Linux these
days.
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Xiaofan Chen
2011-05-20 03:09:53 UTC
Permalink
Post by Tim Roberts
A kernel driver is almost never required for USB devices on Linux these
days.
Wow, now that is very brave prediction. If you subscribe to the Linux-usb
mailing list and you will know the above can not be correct.
http://www.linux-usb.org/mailing.html
http://marc.info/?l=linux-usb
Or look at the source tree.
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=tree;f=drivers/usb;hb=HEAD
--
Xiaofan
Tim Roberts
2011-05-20 18:06:59 UTC
Permalink
Post by Xiaofan Chen
Post by Tim Roberts
A kernel driver is almost never required for USB devices on Linux these
days.
Wow, now that is very brave prediction. If you subscribe to the Linux-usb
mailing list and you will know the above can not be correct.
I stand by my statement. There are many devices that HAVE custom kernel
drivers, but that's out of inertia and tradition, not because they were
REQUIRED. The default Linux USB driver is quite good, and is sufficient
for most purposes. Despite being a Microsoft cheerleader, I far prefer
writing code for the default Linux USB driver over writing code for WinUSB.

Now, there are certainly good reasons to go kernel. If you need to
share a device between multiple applications, a kernel driver is often a
better solution than a complicated user-mode sharing solution. And
actually, I can't think of any other reasons right now.
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Michael Bender
2011-05-20 19:26:17 UTC
Permalink
Post by Tim Roberts
Post by Xiaofan Chen
Post by Tim Roberts
A kernel driver is almost never required for USB devices on Linux these
days.
Wow, now that is very brave prediction. If you subscribe to the Linux-usb
mailing list and you will know the above can not be correct.
I stand by my statement. There are many devices that HAVE custom kernel
drivers, but that's out of inertia and tradition, not because they were
REQUIRED. The default Linux USB driver is quite good, and is
sufficient
for most purposes. Despite being a Microsoft cheerleader, I far prefer
writing code for the default Linux USB driver over writing code for WinUSB.
Now, there are certainly good reasons to go kernel. If you need to
share a device between multiple applications, a kernel driver is often a
better solution than a complicated user-mode sharing solution. And
actually, I can't think of any other reasons right now.
For another platform data point, the Sun Ray thin client USB drivers
are all
userspace drivers on both Solaris and Linux - we do mass storage,
serial,
parallel, smart card, and a few others in userspace. This tends to
make the
"kernel-only" crowd's heads explode, but oh well.

We use a few kernel loopback drivers for things like file system
mounting
and for legacy apps that absolutely need to have a block or character
device
to talk to, but these are not USB kernel drivers, they are basically
pseudo
drivers that talk to our userspace device server on one end and to the
consuming application (such as tip, the spooler, etc...) on the other.

Our USB controller is on the end of a network connection and we pass USB
packets over the network between the server and the Sun Ray. We don't
actually provide the notion of an OHCI or EHCI node on the server OS.

mike

Loading...