From: Shawn Rutledge <shawn.t.rutledge@gmail.com>
To: linux-hotplug@vger.kernel.org
Subject: USB device ID to determine network address?
Date: Wed, 15 Jun 2005 01:04:21 +0000 [thread overview]
Message-ID: <d9a6586e050614180451b2b91c@mail.gmail.com> (raw)
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
next reply other threads:[~2005-06-15 1:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-15 1:04 Shawn Rutledge [this message]
2005-06-16 18:39 ` USB device ID to determine network address? Greg KH
2005-06-16 19:23 ` David Brownell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d9a6586e050614180451b2b91c@mail.gmail.com \
--to=shawn.t.rutledge@gmail.com \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).