home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GRIPS 2: Government Rast…rocessing Software & Data
/
GRIPS_2.cdr
/
dos
/
ncsa_tel
/
contribu
/
byu_tel2.hqx
/
tcpip
/
datalayer.c
< prev
next >
Wrap
Text File
|
1989-05-17
|
4KB
|
134 lines
/* FastNet Box 2 */
/* Data Layer routines */
#define SCSI_MASTER
#include <stdio.h>
#include <SCSI.h>
#include "BoxLayer.h"
#define RouterProtocol 0x6003
unsigned int decAddr;
unsigned char nodeAddress[6]= {0x08,0x00,0x89,0xf0,0x05,0xaf};
unsigned char allRouters[6]= {0xAB,0x00,0x00,0x03,0x00,0x00};
unsigned char allEndnodes[6]= {0xAB,0x00,0x00,0x04,0x00,0x00};
unsigned char cmdCommand[CMD_LENGTH]= {SENDING_COMMAND,0};
unsigned char reqCommand[CMD_LENGTH]= {REQUEST_DATA,0};
unsigned char sendCommand[CMD_LENGTH]= {SENDING_DATA,0};
unsigned char addrCommand[CMD_LENGTH]= {REQUEST_ADDR,0};
char temp[50];
DoBoxCommand(theBufferPtr,theLength)
void *theBufferPtr;
int theLength;
{
SCSIInstr tibBlock[2];
int status,message;
while(SCSIGet()); /* Arbitration */
while(SCSISelect(SCSI_ID)); /* Selection */
SCSICmd(&cmdCommand[0],CMD_LENGTH); /* Command */
tibBlock[0].scOpcode=scNoInc;
tibBlock[0].scParam1=(long)theBufferPtr;
tibBlock[0].scParam2=(long)theLength;
tibBlock[1].scOpcode=scStop;
tibBlock[1].scParam1=0;
tibBlock[1].scParam2=0;
SCSIWrite( tibBlock); /* Data */
SCSIComplete(&status,&message,60L); /* Completion */
}
int DoBoxAddrRequest(theBufferPtr)
unsigned char *theBufferPtr;
{
SCSIInstr tibBlock[3];
int status,message;
putln("in box request");
while(SCSIGet()); /* Arbitration */
while(SCSISelect(SCSI_ID)); /* Selection */
SCSICmd(&addrCommand[0],CMD_LENGTH); /* Command */
putln("Command called ");
tibBlock[0].scOpcode=scNoInc;
tibBlock[0].scParam1=(long)theBufferPtr;
tibBlock[0].scParam2=(long)6; /* Fixed length - 6 bytes */
tibBlock[1].scOpcode=scStop;
tibBlock[1].scParam1=0;
tibBlock[1].scParam2=0;
putln("Calling Read");
SCSIRead( tibBlock); /* Data */
putln("Calling completion");
SCSIComplete(&status,&message,60L); /* Completion */
putln("Done....");
return(status);
}
int DoBoxDataRequest(theBufferPtr) /* Returns packet length or zero */
void *theBufferPtr;
{
SCSIInstr tibBlock[3];
int status,message;
while(SCSIGet()); /* Arbitration */
while(SCSISelect(SCSI_ID)); /* Selection */
SCSICmd(&reqCommand[0],CMD_LENGTH); /* Command */
tibBlock[0].scOpcode=scNoInc;
tibBlock[0].scParam1=((long)&tibBlock[1].scParam2)+2;
tibBlock[0].scParam2=(long)2;
tibBlock[1].scOpcode=scNoInc;
tibBlock[1].scParam1=(long)theBufferPtr;
tibBlock[1].scParam2=0; /* Length of data */
tibBlock[2].scOpcode=scStop;
tibBlock[2].scParam1=0;
tibBlock[2].scParam2=0;
SCSIRead( tibBlock); /* Data */
SCSIComplete(&status,&message,60L); /* Completion */
return(tibBlock[1].scParam2);
}
DoBoxDataSend(theBufferPtr,theLength)
void *theBufferPtr;
int theLength;
{
SCSIInstr tibBlock[3];
int status,message;
while(SCSIGet()); /* Arbitration */
while(SCSISelect(SCSI_ID)); /* Selection */
SCSICmd(&sendCommand[0],CMD_LENGTH); /* Command */
tibBlock[0].scOpcode=scNoInc;
tibBlock[0].scParam1=(long)&theLength;
tibBlock[0].scParam2=(long)2;
tibBlock[1].scOpcode=scNoInc;
tibBlock[1].scParam1=(long)theBufferPtr;
tibBlock[1].scParam2=(long)theLength;
tibBlock[2].scOpcode=scStop;
tibBlock[2].scParam1=0;
tibBlock[2].scParam2=0;
SCSIWrite( tibBlock); /* Data */
SCSIComplete(&status,&message,60L); /* Completion */
}
InitializeDataLayer(address)
unsigned int address;
{
DataLinkData lanceData;
/* Initialize address globals (DEC and EtherNet forms) */
decAddr=address;
nodeAddress[4]=address; /* LSB */
nodeAddress[5]=address>>8; /* MSB */
lanceData.promiscuousEnable=0;
lanceData.protocolCount=1;
lanceData.protocolType[0]=RouterProtocol;
lanceData.multicastCount=0;
lanceData.broadcastEnable=1;
DoBoxCommand(&lanceData,sizeof(DataLinkData));
}