Re: musb gadget HUB traffic sniffing/forwarding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2 Jul 2015, Y. Zhang wrote:

> Hi all,
> 
> I'm new to linux usb and would like some guidance on achieving some of
> the following goals.
> I have a beaglebone black (BBB - currently running kernel v3.12) with
> OTG in peripheral mode on usb bus#1 and a host port to connect devices
> on usb bus#2.
> 
> 1. usb bus#1: connect OTG on BBB as a musb gadget (via gadgetfs) to
> another PC host (e.g. linux, windows, etc); usb bus#2: connect a hub
> to BBB host
> + using libusb to control the hub

You cannot use libusb to control a hub.  It won't work.

More precisely, you can _control_ the hub with libusb, but if you do 
then you won't be able to communicate with any devices plugged into the 
hub.

> + relay all traffics from host->musb gadget->libusb->hub->(applicable
> multiple devices hot-plugged to the hub), and vice versa

You can't do this either.  There are all sorts of problems, not least 
of which is that the gadget uses a single USB address but devices 
plugged into the hub will need to use multiple USB addresses.

> So far I'm able to see traffics between the PC host and the hub before

What do you mean?  The PC host is connected to the musb gadget, not to 
the hub.  So how can there be any traffic between the PC and the hub?

> plugging any device into the hub. That is, usb traffics for endpoints
> of the hub itself. Once I plug in a device, after certain actions on
> the hub port, the host will send requests (get_descriptor/set_address)
> to address 0, which are not forwarded to the gadhetfs user space. I'd
> like to know:
> * Are traffics for address 0 visible to musb gadget? What code in
> usb/musb and/or usb/gadget can be used/revised to retrieve/handle
> them?

Traffic for any address other than the gadget's address is not visible 
to the gadget.  This is part of the hardware design; there is nothing 
you can do to change it in software.

> * If it is feasible to accomplish the above, then the PC host would
> enumerate devices plugged into the hub. What code usage/change would
> be necessary to further retrieve messages addressed to endpoints of
> individual devices and relay them to the HUB (so the HUB can broadcast
> to individual devices), and also forward messages from devices
> received via hub (with libusb) back to host via musb gadget?

This is a moot question.

> 2. usb bus#1: connect the BBB OTG to a hub attached to the PC host
>    + using musb gadget if needed: host-hub-OTG-(gadget)
>    + when the host sends any messages to the hub, it would then
> broadcast (at least for usb2.0) to all ports on the hub.
>    + sniff broadcast traffic on the OTG usb port (on bus#1)

A standard USB port (even an OTG port) cannot sniff USB traffic.  Doing 
so requires special hardware -- a USB protocol analyzer such as the 
TotalPhase Beagle-480.

> I don't necessarily need the OTG gadget to respond anything to the hub
> or PC host, but hope to sniff all usb messages broadcast by the hub,
> which means I will be able to see messages sent by the PC host to
> other devices plugged into the hub. What code in usb/musb and/or
> usb/gadget can be used/revised to sniff such traffics? I've tried
> usbmon but it only monitors devices controlled by hcd (on bus#2) not
> the OTG in peripheral mode (on bus#1)

This cannot be done.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux