* USB device ID to determine network address?
@ 2005-06-15 1:04 Shawn Rutledge
2005-06-16 18:39 ` Greg KH
2005-06-16 19:23 ` David Brownell
0 siblings, 2 replies; 3+ messages in thread
From: Shawn Rutledge @ 2005-06-15 1:04 UTC (permalink / raw)
To: linux-hotplug
I'm trying to come up with a way to have a different network address
assigned to different USB devices (a Zaurus and a cell phone; the
former uses usbnet, the latter usblan). This would be a lot like the
case of having two USB ethernet devices for a router, or a USB
ethernet device and a USB cable modem. So far in
/etc/hotplug/usb.agent I have added stuff like this:
usb_idVendor=$((0x$1))
usb_idProduct=$((0x$2))
usb_bcdDevice=$((0x$3))
ifconfig > /tmp/nets
rm -rf /tmp/lastusb
mkdir /tmp/lastusb
touch /tmp/lastusb/"${usb_idVendor}:${usb_idProduct}"
echo -n "${usb_idVendor}:${usb_idProduct}" > /tmp/lastusbdev
/bin/sync
sleep 1
then /etc/init.d/net.usb0 and net.usb1 both look like this:
start() {
ebegin "Bringing ${IFACE} up"
echo "Bringing ${IFACE} up" > /var/log/usb0.log
if [ -e /tmp/lastusb/1245:36914 ]
then
/sbin/ifconfig ${IFACE} 192.168.129.200 up 2>/dev/null
else
/sbin/ifconfig ${IFACE} 192.168.1.1 up 2>/dev/null
fi
/etc/init.d/dhcp start
eend 0
}
It's acting as though the file modifications in /tmp are not completed
before the init.d script gets called, because for example after
plugging in the zaurus, I have to plug in the phone twice before it
gets the correct address, and vice-versa. But I added the /tmp/nets
thing to see if that is true, and actually /tmp/nets ends up
containing the network state before the hotplug, just as I would have
expected.
Anyway it's kindof inelegant, and I was wondering if this problem has
already been solved in some other way?
Actually, it might be better if there was some way to have one device
always get interface usb0 and the other always get usb1, even if only
one of them is actually plugged in; then I could just configure the
different addresses in /etc/conf.d/net. (This is a gentoo system.)
Alternatively if the init.d script had some other way to get the
device which is being configured....
Or, if there was a config file to map devices to their properties like
network address for network devices, mount location for mass storage
devices, tty for modem devices or printers, etc. so all that stuff
could be maintained in one config file.
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id\x16492&opÌk
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: USB device ID to determine network address?
2005-06-15 1:04 USB device ID to determine network address? Shawn Rutledge
@ 2005-06-16 18:39 ` Greg KH
2005-06-16 19:23 ` David Brownell
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2005-06-16 18:39 UTC (permalink / raw)
To: linux-hotplug
On Tue, Jun 14, 2005 at 06:04:21PM -0700, Shawn Rutledge wrote:
>
> Or, if there was a config file to map devices to their properties like
> network address for network devices, mount location for mass storage
> devices, tty for modem devices or printers, etc. so all that stuff
> could be maintained in one config file.
Yes there is. Try using udev to manage your network devices instead of
custom scripts :)
thanks,
greg k-h
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id\x16492&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: USB device ID to determine network address?
2005-06-15 1:04 USB device ID to determine network address? Shawn Rutledge
2005-06-16 18:39 ` Greg KH
@ 2005-06-16 19:23 ` David Brownell
1 sibling, 0 replies; 3+ messages in thread
From: David Brownell @ 2005-06-16 19:23 UTC (permalink / raw)
To: linux-hotplug
On Tuesday 14 June 2005 6:04 pm, Shawn Rutledge wrote:
> I'm trying to come up with a way to have a different network address
> assigned to different USB devices (a Zaurus and a cell phone; the
> former uses usbnet, the latter usblan).
As of 2.6.13 both should work just fine with "usbnet".
- Dave
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id\x16492&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-06-16 19:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-15 1:04 USB device ID to determine network address? Shawn Rutledge
2005-06-16 18:39 ` Greg KH
2005-06-16 19:23 ` David Brownell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).