home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- static char *SCCSid = "%W% (NCSA) %G%";
- #endif
- /*
- * ether.c
- * by Gaige B. Paulsen
- ****************************************************************************
- * *
- * Uses : *
- * TCP/IP kernel for NCSA Telnet *
- * by Tim Krauskopf *
- * with Macintosh code by Gaige B. Paulsen *
- * *
- * National Center for Supercomputing Applications *
- * 152 Computing Applications Building *
- * 605 E. Springfield Ave. *
- * Champaign, IL 61820 *
- * *
- * *
- ****************************************************************************
- *
- * EtherNet init and shutdown (and utility) procs.
- *
- * Called by:
- * dlayer.c
- * mactools.c
- * macutil.c
- */
-
- #include <StdLib.h>
- #include <ctype.h>
-
- #include <Devices.h>
- #include <Dialogs.h>
- #include <Files.h>
- #include <ROMDefs.h>
- #include <Slots.h>
- #include <stdio.h>
- #include <String.h>
- #include <AppleTalk.h>
-
- #include "configrec.h"
- #include "protocol.h"
- #include "data.h"
- #include "EtherTalk.h"
- #include "hostform.h"
-
- #include "event.h" /* BYU 2.4.15 */
- #include "fastnet.h"
- #include "maclook.h"
- #include "confile.h"
- #include "croft.h"
-
-
- typedef struct {
- char node[26];
- char net[2];
- } ABusVarStruct, *ABusVarPtr, **ABusVarHdl;
-
- extern int EtherNet;
- short ENETdriver;
-
- extern ETListen();
-
- void ETcall
- (
- EtParam *ep,
- int call
- )
- {
- int bkgr=-1;
-
- ep->ioCompletion=0L;
- ep->ioCRefNum = ENETdriver;
- ep->csCode= call;
-
- if (call = EWrite) bkgr=0;
-
- PBControl((ParmBlkPtr) ep, bkgr);
- }
-
- void getETaddress
- (
- char *store
- )
- {
- EtParam EP;
-
- if (EtherNet==-2)
- getFNaddress(store);
- EP.address= store;
- EP.bufsize= 6;
- ETcall(&EP, EGetInfo);
- }
-
- /*
- * ETfindcard()
- *
- * Finds the EtherNet Card in a Mac II
- * if *slotp is != 0, then look on that slot for the sResource ID #
- *
- */
-
- int ETfindcard
- (
- int *slotp,
- int *spidp
- )
- {
- OSErr err;
- SpBlock spb;
-
- spb.spSlot = *slotp;
- spb.spID = 0;
- spb.spExtDev = 0;
- spb.spCategory = catNetwork;
- spb.spCType = typeEtherNet;
- spb.spTBMask = 0x03;
-
- err = SNextTypeSRsrc( &spb);
- *slotp= spb.spSlot;
- *spidp= spb.spID;
-
- if (err)
- return(-1);
- else
- return( 0);
- }
- #ifdef AZTEC
- #asm
- public _SNextTypeSRsrc
- _SNextTypeSRsrc
- move.l 4(sp),a0
- moveq #$15,D0
- dc.w $A06E
- rts
-
- public _OpenSlot
- _OpenSlot
- move.l 4(sp),a0
- move.w 8(sp),d0
- bne.s os1
- dc.w $a200
- bra.s os2
- os1:
- dc.w $a600
- os2:
- rts
- #endasm
- #endif AZTEC
-
- int ETclose
- (
- void
- )
- {
- /* int err; */
- EtParam EP;
-
- EP.protocol= EARP;
- /* err = */ ETcall(&EP, EDetachPH);
-
- EP.protocol= ERARP;
- /* err = */ ETcall(&EP, EDetachPH);
-
- EP.protocol= EIP;
- /* err = */ ETcall(&EP, EDetachPH);
-
- /*Close( ENETdriver); */
-
- return
- 0;
- }
-
- int ETopen
- (
- void
- )
- {
- short err;
- short socket=72; /* BYU 2.4.15 MPW */
- char buffr[100];
- DialogPtr dtemp;
- EtParam EP;
-
- if (EtherNet<0) {
- #ifndef MPW
- err=opendriver("\P.ENET0",&ENETdriver );
- #else
- err=opendriver(".ENET0",&ENETdriver );
- #endif MPW
- ETcall(&EP, 1010); /* Turn off the Kinetics stuff */
- ETcall(&EP, 1011);
- }
- else {
- SlotDevParam sdpb;
- int slot, spid;
-
- err=-1; /* So we can be an error by default */
-
- if (EtherNet <9) /* No Slot Specified */
- slot=0;
- else
- slot=EtherNet;
-
- if (!ETfindcard( &slot, &spid)) {
- sdpb.ioSlot = slot;
- sdpb.ioID = spid;
- sdpb.ioCompletion = 0L;
- #ifndef MPW
- sdpb.ioNamePtr = "\P.ENET";
- #else
- sdpb.ioNamePtr = "\p.ENET";
- #endif MPW
- sdpb.ioPermssn = fsCurPerm;
- sdpb.ioVRefNum = 0;
- sdpb.ioMix = 0L;
- sdpb.ioFlags = 0;
-
- sprintf(buffr, "Opening the ENET driver for %d(%d)",slot,spid);
- EtherNet = slot;
- putln(buffr);
-
- /* Mac Quadra with Friendly Net Adaptor is /* BYU 2.4.20 */
- /* slot 0, which causes a problem here for /* BYU 2.4.20 */
- /* the NCSA driver because EtherNet = 0 /* BYU 2.4.20 */
- /* means AppleTalk. /* BYU 2.4.20 */
- if (!slot) /* BYU 2.4.20 */
- EtherNet = 1; /* BYU 2.4.20 */
- else /* BYU 2.4.20 */
- EtherNet = slot; /* BYU 2.4.20 */
-
- OpenSlot((ParmBlkPtr) &sdpb, FALSE);
- err= sdpb.ioResult;
- ENETdriver = sdpb.ioRefNum;
- }
- }
-
- if (err!=0) {
- sprintf(buffr,"Failed EtherTalk initialization (%d)\015",err); /* BYU 2.4.18 - changed \n to \015 */
- putln(buffr);
- #ifndef MPW
- paramtext(0L,0L,0L,"\PCouldn't open driver[E]");
- #else
- paramtext(0L,0L,0L,"Couldn't open driver[E]");
- #endif MPW
- dtemp=GetNewDialog(302, (Ptr) 0L, (WindowPtr) -1L);
- #if 1 /* BYU 2.4.15 */
- DrawDialog(dtemp); /* BYU 2.4.15 */
- WaitSeconds(5); /* BYU 2.4.15 */
- EtherNet = -100; /* BYU 2.4.15 */
- #else /* BYU 2.4.15 */
- ModalDialog(0L,&item);
- #endif /* BYU 2.4.15 */
- DisposDialog(dtemp);
- /* exit(1); /* BYU 2.4.15 */
- }
-
- EP.address=ETListen;
- EP.protocol= EIP;
- /*err = */ ETcall(&EP, EAttachPH);
- if (/* err != */ 0) {
- sprintf(buffr,"Failed EtherTalk initialization (%d)\015",err); /* BYU 2.4.18 - changed \n to \015 */
- putln(buffr);
- #ifndef MPW
- paramtext(0L,0L,0L,"\PCouldn't Install IP Handler[E]");
- #else
- paramtext(0L,0L,0L,"Couldn't Install IP Handler[E]");
- #endif MPW
- dtemp=GetNewDialog(302,(Ptr) 0L,(WindowPtr) -1L);
- #if 1 /* BYU 2.4.15 */
- DrawDialog(dtemp); /* BYU 2.4.15 */
- WaitSeconds(5); /* BYU 2.4.15 */
- EtherNet = -100; /* BYU 2.4.15 */
- #else /* BYU 2.4.15 */
- ModalDialog(0L,&item);
- #endif /* BYU 2.4.15 */
- DisposDialog(dtemp);
- ETclose();
- /* exit(1); /* BYU 2.4.15 */
- }
-
- EP.address=ETListen;
- EP.protocol= EARP;
- /* err = */ ETcall(&EP, EAttachPH);
- if (/* err != */ 0) {
- sprintf(buffr,"Failed EtherTalk initialization (%d)\015",err); /* BYU 2.4.18 - changed \n to \015 */
- putln(buffr);
- #ifndef MPW
- paramtext(0L,0L,0L,"\PCouldn't Install ARP Handler[E]");
- #else
- paramtext(0L,0L,0L,"Couldn't Install ARP Handler[E]");
- #endif MPW
- dtemp=GetNewDialog(302,(Ptr) 0L,(WindowPtr) -1L);
- #if 1 /* BYU 2.4.15 */
- DrawDialog(dtemp); /* BYU 2.4.15 */
- WaitSeconds(5); /* BYU 2.4.15 */
- EtherNet = -100; /* BYU 2.4.15 */
- #else /* BYU 2.4.15 */
- ModalDialog(0L,&item);
- #endif /* BYU 2.4.15 */
- DisposDialog(dtemp);
- ETclose();
- /* exit(1); /* BYU 2.4.15 */
- }
-
- EP.address=ETListen;
- EP.protocol= ERARP;
- /* err = */ ETcall(&EP, EAttachPH);
- if (/* err != */ 0) {
- sprintf(buffr,"Failed EtherTalk initialization (%d)\015",err); /* BYU 2.4.18 - changed \n to \015 */
- putln(buffr);
- #ifndef MPW
- paramtext(0L,0L,0L,"\PCouldn't Install RARP Handler[E]");
- #else
- paramtext(0L,0L,0L,"Couldn't Install RARP Handler[E]");
- #endif MPW
- dtemp=GetNewDialog(302,(Ptr) 0L,(WindowPtr) -1L);
- #if 1 /* BYU 2.4.15 */
- DrawDialog(dtemp); /* BYU 2.4.15 */
- WaitSeconds(5); /* BYU 2.4.15 */
- EtherNet = -100; /* BYU 2.4.15 */
- #else /* BYU 2.4.15 */
- ModalDialog(0L,&item);
- #endif /* BYU 2.4.15 */
- DisposDialog(dtemp);
- ETclose();
- /* exit(1); /* BYU 2.4.15 */
- }
-
-
- ETcall(&EP, ESetGeneral);
-
- getETaddress( &nnmyaddr[0]);
- return(0);
- }
-
- int netconfig
- (
- char *hardware
- )
- {
- extern int nnemac;
- int len;
- char *p, temp[50];
-
- len = strlen(hardware);
-
- p=hardware;
- /*
- if (len <=0)
- return(-1);
- */
-
- while (len--) {
- *p= toupper( *p);
- p++;
- }
-
- if (!strncmp( hardware, "SERIAL", 5)) /* BYU 2.4.15 */
- EtherNet = -100; /* BYU 2.4.15 */
-
- if (!strncmp( hardware, "MACTCP", 5)) /* BYU 2.4.16 */
- EtherNet = -99; /* BYU 2.4.16 */
-
- if (!strncmp( hardware, "ETHER", 5)) {
- p=hardware+5;
- if (!strncmp( p, "SE",2) || !strncmp(p,"SC",2))
- EtherNet=-1;
- else {
- if (sscanf(p, "%d", &EtherNet)>0) {
- if (EtherNet>14 || EtherNet<9)
- EtherNet=1;
- }
- else
- EtherNet=1;
- }
- sprintf( temp, "We got ether something (%d)", EtherNet);
- putln(temp);
- }
-
- if (!strncmp( hardware,"FASTNET",7)) {
- extern int SCSI_ID; /* The Fastnet Scuzzi ID */
- char temp[100];
-
- EtherNet=-2;
- if (sscanf(hardware+7L,"%d",&len)==1)
- SCSI_ID = len;
- sprintf(temp, "Got one of them FastNet thingies(%d)", SCSI_ID);
- putln(temp);
- }
-
- nnemac = (EtherNet != 0);
- if (!EtherNet) {
- struct config c;
-
- Sgetconfig(&c);
- KIPsetzone(c.zone);
- }
- initipnum(0);
-
- return(0);
- }
-