From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shawn Rutledge Date: Wed, 15 Jun 2005 01:04:21 +0000 Subject: USB device ID to determine network address? Message-Id: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: linux-hotplug@vger.kernel.org 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=3D$((0x$1)) usb_idProduct=3D$((0x$2)) usb_bcdDevice=3D$((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=16492&op=CCk _______________________________________________ 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