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 / fastnet.c < prev    next >
Text File  |  1988-07-15  |  3KB  |  126 lines

  1. #ifndef lint
  2. static char *SCCSid = "%W%    (NCSA)    %G%";
  3. #endif
  4. /*
  5. *    fastnet.c
  6. *     by Gaige B. Paulsen
  7. ****************************************************************************
  8. *                                                                          *
  9. *      Uses    :                                                               *
  10. *      TCP/IP kernel for NCSA Telnet                                       *
  11. *      by Tim Krauskopf                                                    *
  12. *       with Macintosh code by Gaige B. Paulsen                                 *
  13. *                                                                          *
  14. *      National Center for Supercomputing Applications                     *
  15. *      152 Computing Applications Building                                 *
  16. *      605 E. Springfield Ave.                                             *
  17. *      Champaign, IL  61820                                                *
  18. *                                                                          *
  19. *                                                                          *
  20. ****************************************************************************
  21. *
  22. *    FastNet init and shutdown (and utility) procs.    
  23. *
  24. *    Called by:
  25. *        ether.c
  26. *        mactools.c
  27. *        macutil.c
  28. */
  29. #include "stdio.h"
  30. #include "protocol.h"
  31. #include "data.h"
  32.  
  33. #include "BoxLayer.h"
  34.  
  35. extern char nodeAddress[];
  36.  
  37. FNdlayersend(ptr,size)            /*MAC: replaced */
  38. DLAYER *ptr;
  39. unsigned size;
  40. {
  41.     if (size<60) size=60;
  42.     DoBoxDataSend( ptr, size);
  43.     return(0);
  44. }
  45.  
  46. /**********************************************************************/
  47. /*   FNdemux    - FastNet Version of DEMUX routine
  48. *
  49. *  returns the number of packets demuxed
  50. */
  51. FNdemux(all)
  52. int all;
  53. {
  54.     unsigned getcode;
  55.     int nmuxed,sizered;
  56.     typedef struct peek {
  57.         unsigned char dest[DADDLEN],
  58.             me[DADDLEN];
  59.         unsigned type;
  60.     } Dpeek;
  61.  
  62.     Dpeek *firstlook;
  63.  
  64.     nmuxed = 0;
  65.  
  66.     do {                                    /* while all flag is on */
  67.         if (DoBoxDataRequest(bufinfo.buforg))    { /*MAC*/
  68.             nmuxed++;
  69.             firstlook = bufinfo.buforg;     /*MAC where packet is */
  70.  
  71.             getcode = firstlook->type;            /* where does it belong? */
  72.  
  73.             switch (getcode) {                    /* what to do with it? */
  74.                 case EARP:
  75.                 case ERARP:
  76.                     arpinterpret(firstlook->dest);    /* handle [R]ARP packet */
  77.                     break;
  78.                 case EIP:
  79.                     ipinterpret(firstlook->dest);    /* handle IP packet */
  80.                     break;
  81.                 default:
  82.                     break;
  83.             }
  84.         }
  85.         else 
  86.             all = 0;
  87.     } while (all);            /* should we look for more to deal with? */
  88.  
  89.     return(nmuxed);          /* no packets anymore */
  90.  
  91. }
  92.  
  93. FNopen()
  94. {
  95.     DataLinkData lanceData;
  96.     char buffer[1500];
  97.     int i;
  98.  
  99.     getFNaddress(&lanceData.physicalAddress[0]);
  100.  
  101.     /* Initialize address globals (DEC and EtherNet forms) */
  102.     lanceData.promiscuousEnable=0;
  103.     /* movmem(nodeAddress, &lanceData.physicalAddress[0],6); */
  104.     lanceData.protocolCount=3;
  105.     lanceData.protocolType[0]=0x0800;        /*IP  */
  106.     lanceData.protocolType[1]=0x0806;        /*ARP */
  107.     lanceData.protocolType[2]=0x8035;        /*RARP*/
  108.     lanceData.multicastCount=0;
  109.     lanceData.broadcastEnable=1;
  110.  
  111.     DoBoxCommand(&lanceData,sizeof(DataLinkData));
  112.  
  113.     getFNaddress( nnmyaddr);
  114.     return(0);
  115. }
  116.  
  117. getFNaddress( p)
  118. char *p;
  119. {
  120.     DoBoxAddrRequest( p);
  121. }
  122.  
  123. FNclose()
  124. {
  125. }
  126.