Detecting ethernet gadget connections

Michael 'Mickey' Lauer mickey at
Thu Mar 5 17:48:29 CET 2009

Am Donnerstag, den 05.03.2009, 10:01 -0500 schrieb Daniel Benoy:
> I'm working on a script that will detect which network interfaces are connected and mess with the routing accordingly, but I'm having trouble detecting whether my USB ethernet gadget connection is up or down.

The best way to do this is to listen for netlink route announcements.
That way it's completely instantaneous and without polling. Look here
for an example using python-netlink:;a=blob;f=tools/dump-netlink

Note that if you're on FSO I expect that after full integration of
connman (milestone6), we will have a global signal like

org.freesmartphone.Network.ConnectionStatus( s:means, b:online )

'means' being a string that indicates the type, like "GPRS/ppp",
"IP/usb0", "IP/bnep0", etc.

that you can use.


More information about the community mailing list