home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.sustworks.com 2018
/
ftp.sustworks.com.zip
/
ftp.sustworks.com
/
USBPegasusEthernet_107.dmg
/
src
/
Source
/
USBPegasusEthernetInterface.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2007-03-27
|
3KB
|
89 lines
extern "C" {
#include <sys/param.h>
#include <sys/systm.h>
}
#include "USBPegasusEthernetInterface.h"
#define super IOEthernetInterface
OSDefineMetaClassAndStructors(USBPegasusEthernetInterface,
IOEthernetInterface);
void USBPegasusEthernetInterface::detachFromDataLinkLayer(IOOptionBits options,
void *parameter ) {
#if TIGER
super::detachFromDataLinkLayer(options, parameter);
#else
/* There appears to be an issue with detaching network interfaces in
Mac OS 1.3.9. (and probably earlier). The following code
detaches the bsd network interface, and then blocks until all
clients of the network interface have released it. */
int ret;
boolean_t funnel_state;
int (*oldFree)(struct ifnet *);
detachLock = IOLockAlloc();
if(!detachLock) {
IOLog("USBPegasusEthernetInterface: failed to create detach detach lock.\n");
dlil_if_detach( getIfnet() );
return;
}
ifFinished = false;
funnel_state = thread_funnel_set( network_flock, TRUE );
/* Install our "free" handler routine. */
oldFree = (getIfnet())->if_free;
(getIfnet())->if_free = bsdInterfaceFinished;
/* Attempt to attach interface. */
ret = dlil_if_detach( getIfnet() );
switch(ret) {
case DLIL_WAIT_FOR_FREE:
/* Wait for network interface clients to close. */
thread_funnel_set( network_flock, FALSE );
IOLockLock(detachLock);
while(ifFinished == false) {
IOLockSleep(detachLock, NO_EVENT, THREAD_ABORTSAFE);
}
thread_funnel_set( network_flock, TRUE );
break;
case 0:
/* Network interface detached. */
break;
default:
IOLog("USBPegasusEthernetInterface: dlil_if_detach: 0x%x.\n",
ret);
break;
}
/* Restore old handler routine */
(getIfnet())->if_free = oldFree;
thread_funnel_set( network_flock, funnel_state );
IOLockFree(detachLock);
#endif
}
#if !TIGER
int USBPegasusEthernetInterface::bsdInterfaceFinished( struct ifnet * ifp ) {
USBPegasusEthernetInterface *me;
if(!ifp || !ifp->if_private) {
IOLog("USBPegasusEthernetInterface: No interface.\n");
return 0;
}
me = OSDynamicCast(USBPegasusEthernetInterface, (OSObject *)ifp->if_private);
if(!me) {
IOLog("USBPegasusEthernetInterface: Dynamic cast failed.\n");
} else {
IOLockLock(me->detachLock);
me->ifFinished = true;
IOLockWakeup(me->detachLock, NO_EVENT, true);
IOLockUnlock(me->detachLock);
}
return 0;
}
#endif