
myErr = OpenDriver("\p.ENET", &myRefNum);
theEPB.EParms1.ioRefNum = myRefNum;
theEPB.EParms1.ePointer = NewPtrClear(78);
theEPB.EParms1.eBuffSize = 78;
theEPB.EParms1.ioNamePtr = NULL;
myErr = EGetInfo(&theEPB,false);
How
can I scan through all the installed Ethernet drivers for the one that's active
and obtain information about that one?
1. OpenDriver("\p.ENET", &myRefNum) only opens the first Ethernet driver. If the system has more than one Ethernet card installed, you have to open them explicitly.
2. Machines such as the SE and PowerBooks that have the Ethernet hardware connected via the SCSI port are accessed through ENET0 (most machines have this ability).
The following is a code fragment that you can use:
/* check internal non slotted card
check if enet0 driver is installed
*/
short saveRes;
saveRes = LMGetResLoad();
LMSetResLoad(0)
GetNamedResource('DRVR',"\p.ENET0"); // check if ENET0 is in ROM
LMSetResLoad(saveRes)
if(!ResError()) {
/* Setup Open PB */
PB.slotDevParam.ioNamePtr = "\p.ENET0"; // Attempt to open it
PB.slotDevParam.ioVRefNum = 0;
PB.slotDevParam.csCode = 0;
PB.slotDevParam.ioSlot = 0;
PB.slotDevParam.ioID = 0;
/* try and open the internal non slotted enet card */
ErrNo = PBOpenSync(&PB); // notice I do a regular open call $A000
refnum = PB.ioRefNum;
3.
For NuBus and SE30 devices (and PCI slots), you have to use the Slot Manager to
scan for available Ethernet cards, per this example:
/* Setup Open PB for sloted device */
PB.slotDevParam.ioNamePtr = "\p.ENET";
PB.slotDevParam.ioVRefNum = 0;
PB.slotDevParam.csCode = 0;
/* try Slotmanger Call */
if(!OSTrapAvailable (_SlotManager)) return(Error);
SPB.spExtDev = 0;
SPB.spCategory = 4; /* Network */
SPB.spCType = 1 ; /* EtherNet */
SPB.spTBMask = 0x3;
/* loop on each card */
while((ErrNo = SNextTypeSRsrc(&SPB)) == noErr){
PB.slotDevParam.ioSlot = SPB.spSlot;
PB.slotDevParam.ioID = SPB.spID;
/* try and open the enet card */
ErrNo = PBOpenImmed(&PB); // Notice I Do an OpenImmed $A200
refnum = PB.ioRefNum;
}
4.
An important point to consider: OpenDriver calls fail when Ethernet devices are
not cabled or hooked up, so it's not possible to get the address of Ethernet
cards that aren't hooked up.Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help