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 >
Text File  |  1989-05-17  |  4KB  |  134 lines

  1. /*  FastNet Box 2            */
  2. /*  Data Layer routines        */
  3.  
  4. #define SCSI_MASTER
  5.  
  6. #include <stdio.h>
  7. #include <SCSI.h>
  8. #include "BoxLayer.h"
  9.  
  10. #define RouterProtocol    0x6003
  11.  
  12.  
  13. unsigned int decAddr;
  14.  
  15. unsigned char nodeAddress[6]=    {0x08,0x00,0x89,0xf0,0x05,0xaf};
  16. unsigned char allRouters[6]=    {0xAB,0x00,0x00,0x03,0x00,0x00};
  17. unsigned char allEndnodes[6]=    {0xAB,0x00,0x00,0x04,0x00,0x00};
  18.  
  19. unsigned char cmdCommand[CMD_LENGTH]=    {SENDING_COMMAND,0};
  20. unsigned char reqCommand[CMD_LENGTH]=    {REQUEST_DATA,0};
  21. unsigned char sendCommand[CMD_LENGTH]=    {SENDING_DATA,0};
  22. unsigned char addrCommand[CMD_LENGTH]=    {REQUEST_ADDR,0};
  23. char temp[50];
  24.  
  25.  
  26. DoBoxCommand(theBufferPtr,theLength)
  27. void *theBufferPtr;
  28. int theLength;
  29. {
  30. SCSIInstr tibBlock[2];
  31. int status,message;
  32.     while(SCSIGet());                                /* Arbitration */
  33.     while(SCSISelect(SCSI_ID));                        /* Selection */
  34.     SCSICmd(&cmdCommand[0],CMD_LENGTH);                /* Command */
  35.     tibBlock[0].scOpcode=scNoInc;
  36.     tibBlock[0].scParam1=(long)theBufferPtr;
  37.     tibBlock[0].scParam2=(long)theLength;
  38.     tibBlock[1].scOpcode=scStop;
  39.     tibBlock[1].scParam1=0;
  40.     tibBlock[1].scParam2=0;
  41.     SCSIWrite( tibBlock);                            /* Data */
  42.     SCSIComplete(&status,&message,60L);                /* Completion */
  43. }
  44.  
  45. int DoBoxAddrRequest(theBufferPtr)
  46. unsigned char *theBufferPtr;
  47. {
  48.     SCSIInstr tibBlock[3];
  49.     int status,message;
  50.  
  51.     putln("in box request");
  52.     while(SCSIGet());                                /* Arbitration */
  53.     while(SCSISelect(SCSI_ID));                        /* Selection */
  54.     SCSICmd(&addrCommand[0],CMD_LENGTH);                /* Command */
  55.     putln("Command called ");
  56.     tibBlock[0].scOpcode=scNoInc;
  57.     tibBlock[0].scParam1=(long)theBufferPtr;
  58.     tibBlock[0].scParam2=(long)6;                    /* Fixed length - 6 bytes */
  59.     tibBlock[1].scOpcode=scStop;
  60.     tibBlock[1].scParam1=0;
  61.     tibBlock[1].scParam2=0;
  62.     putln("Calling Read");
  63.     SCSIRead( tibBlock);                            /* Data */
  64.     putln("Calling completion");
  65.     SCSIComplete(&status,&message,60L);                /* Completion */
  66.     putln("Done....");
  67.     return(status);
  68. }
  69.  
  70. int DoBoxDataRequest(theBufferPtr)    /* Returns packet length or zero */
  71. void *theBufferPtr;
  72. {
  73. SCSIInstr tibBlock[3];
  74. int status,message;
  75.     while(SCSIGet());                                /* Arbitration */
  76.     while(SCSISelect(SCSI_ID));                        /* Selection */
  77.     SCSICmd(&reqCommand[0],CMD_LENGTH);                /* Command */
  78.     tibBlock[0].scOpcode=scNoInc;
  79.     tibBlock[0].scParam1=((long)&tibBlock[1].scParam2)+2;
  80.     tibBlock[0].scParam2=(long)2;
  81.     tibBlock[1].scOpcode=scNoInc;
  82.     tibBlock[1].scParam1=(long)theBufferPtr;
  83.     tibBlock[1].scParam2=0;                            /* Length of data */
  84.     tibBlock[2].scOpcode=scStop;
  85.     tibBlock[2].scParam1=0;
  86.     tibBlock[2].scParam2=0;
  87.     SCSIRead( tibBlock);                            /* Data */
  88.     SCSIComplete(&status,&message,60L);                /* Completion */
  89.     return(tibBlock[1].scParam2);
  90. }
  91.  
  92.  
  93. DoBoxDataSend(theBufferPtr,theLength)
  94. void *theBufferPtr;
  95. int theLength;
  96. {
  97. SCSIInstr tibBlock[3];
  98. int status,message;
  99.     while(SCSIGet());                                /* Arbitration */
  100.     while(SCSISelect(SCSI_ID));                        /* Selection */
  101.     SCSICmd(&sendCommand[0],CMD_LENGTH);            /* Command */
  102.     tibBlock[0].scOpcode=scNoInc;
  103.     tibBlock[0].scParam1=(long)&theLength;
  104.     tibBlock[0].scParam2=(long)2;
  105.     tibBlock[1].scOpcode=scNoInc;
  106.     tibBlock[1].scParam1=(long)theBufferPtr;
  107.     tibBlock[1].scParam2=(long)theLength;
  108.     tibBlock[2].scOpcode=scStop;
  109.     tibBlock[2].scParam1=0;
  110.     tibBlock[2].scParam2=0;
  111.     SCSIWrite( tibBlock);                            /* Data */
  112.     SCSIComplete(&status,&message,60L);                /* Completion */
  113. }
  114.  
  115.  
  116. InitializeDataLayer(address)
  117. unsigned int address;
  118. {
  119. DataLinkData lanceData;
  120.  
  121.     /* Initialize address globals (DEC and EtherNet forms) */
  122.     decAddr=address;
  123.     nodeAddress[4]=address;        /* LSB */
  124.     nodeAddress[5]=address>>8;    /* MSB */
  125.  
  126.     lanceData.promiscuousEnable=0;
  127.     lanceData.protocolCount=1;
  128.     lanceData.protocolType[0]=RouterProtocol;
  129.     lanceData.multicastCount=0;
  130.     lanceData.broadcastEnable=1;
  131.     
  132.     DoBoxCommand(&lanceData,sizeof(DataLinkData));
  133. }
  134.