Removable Ethernet Driver
Removable Ethernet Driver
- Subject: Removable Ethernet Driver
- From: Daniel Sumorok <email@hidden>
- Date: Thu, 29 Jul 2004 14:34:32 -0400 (EDT)
Hello,
I searched the archives and found this question was asked before,
but was not able to find a solution....
I am writing a driver for a USB-To-Ethernet device. How do I
properly notify the interface object (IOEthernetInterface) when device has
been removed?
As of now, at user level I have two "locations", one that enables
my removable device, and one that disables it (by setting IPv4 and IPv6 to
OFF). To use my device, first I plug it in, then switch to the "location"
that uses it. The network stack connects to my device, and all is good at
that point. Then, when I want to unplug it, I switch to the location that
disables the device first, and unplug the device. In this case everything
seems to clean up, and the BSD interface dissappears from the "ifconfig"
output.
The problem occurs when I try to unplug the device before
disabling it (by switching locations). My driver seems to unload (as far
as I can tell), but the interface object does not. From reading the
darwin source code, I believe that in this case the interface still has
clients connected to it. The interface really does not know what to do
when the ethernet controller disappers, and simply waits for its network
clients to close the connection. Of course, the network clients don't
know that anything is wrong...
Now, if I plug the device in again, I believe that a new interface
object is created. In fact, after dhcp does its thing, the ifconfig shows
two ip addresses on the (bsd) interface... Also, I have seen the system
log complain about duplicate services. I guess thare are two interface
objects attached to the DLIL.
One solution I can think of is to create a
IORemovableEthernetInterface class that derives from IOEthernetInterface.
This object would understand when its underlying ethernet controller goes
away. If so, it just waits for its clients to close (like the current
implimentation), before terminating. However, if the device is plugged in
again, and the old interface exists, the device would attach to the old
interface instead of creating a new one. When the removable ethernet
controller loads, it could wait for any existing inteface object to
attach. After a timeout, it could create a new one.
If anyone could offer any suggestions, or help clear up any of my
misunderstandings, I would greatly appreciate it.
Thank you,
-Dan
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.