home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / IE3802.ZIP / IEEE8022 / DIRINTF.H next >
Text File  |  1991-12-12  |  10KB  |  278 lines

  1. /******************************************************************************
  2. *   Module name :    DIRINTF                                                  *
  3. *                                                                             *
  4. *   Function :       Lan adapter direct interface functions                   *
  5. *                                                                             *
  6. *   Routines in                                                               *
  7. *   this module:      dir_status      (adapternum)                            *
  8. *                     dir_initialize  (adapternum)                            *
  9. *                     dir_openadapter (adapternum)                            *
  10. *                     receive         (adapternum,station)                    *
  11. *                                                                             *
  12. * Parameters:                                                                 *
  13. *                                                                             *
  14. *         Input:     The adapter number. Other parms are supplied as necessary*
  15. *                                                                             *
  16. *        Output:     Return code is based upon the kind of CCB executed.      *
  17. *                    If the return code is 0xFF then the CCB is one that      *
  18. *                    does not make the program wait while it runs, so the     *
  19. *                    CCB command is valid, but incomplete when it returns.    *
  20. *                    The return code for a successful "no-wait" CCB is zero.  *
  21. *                    Otherwise the return code from the CCB is returned,      *
  22. *                    indicating that an error was detected.                   *
  23. *                                                                             *
  24. *   OS/2 Required:   Extended Edition 1.1 or higher.                          *
  25. *                                                                             *
  26. *******************************************************************************/
  27.  
  28. /* DIR.STATUS routine */
  29.  
  30. byte dir_status (ccb_parm,adapternum,sem,wait)
  31. struct ccb_pt *ccb_parm;
  32. byte adapternum;
  33. #ifdef E32TO16
  34. HSYSSEM _Seg16 sem;
  35. #else
  36. HSYSSEM sem;
  37. #endif
  38. BOOL wait;
  39. {
  40.         struct command_control_block_dlr *status_ccb;
  41.         struct dir_status_parms *pt;
  42.  
  43.         status_ccb = &ccb_parm->ccb;
  44.         pt = &ccb_parm->pt.status;
  45.         memset (status_ccb,0,sizeof(struct command_control_block_dlr));
  46.  
  47.         status_ccb->ccb_command     = LLC_DIR_STATUS;
  48.         status_ccb->ccb_adapter     = adapternum;
  49.         status_ccb->ccb_retcode     = 0xff;
  50. #ifdef E32TO16
  51.         status_ccb->parm_1.ccb_parm_offset = (address)pt;
  52. #else
  53.         status_ccb->parm_1.parm.off_12.ccb_parm_offset = FP_OFF (pt);
  54. #endif
  55.         status_ccb->ccb_pointer     = ZEROADDRESS;
  56.         status_ccb->ccb_appl_key    = ApplKey;
  57.         status_ccb->ccb_appl_id     = ApplId;
  58. #ifdef E32TO16
  59.         status_ccb->ccb_semaphore   = sem;
  60. #else
  61.         status_ccb->ccb_semaphore   = (dword)sem;
  62. #endif
  63.  
  64.         memset(pt,0,sizeof(struct dir_status_parms));
  65.  
  66.         if(sem)
  67.           DosSemSet(sem);
  68.         pass_ccb (status_ccb);
  69.         if(wait)
  70.           {
  71.           if(sem)
  72.             DosSemWait(sem,-1L);
  73.           else
  74.             while (status_ccb->ccb_retcode == 0xff);
  75.           }
  76.         return status_ccb->ccb_retcode;
  77. }
  78.  
  79. /*-------------------------------------------------------------------+
  80. │ dir_initialize: Initializes the adapter support interface areas    │
  81. │                 in the PC, resets all adapter tables and buffers,  │
  82. │                 and directs the adapter to run the bring-up tests. │
  83. │                                                                    │
  84. │                 Note: This command completely resets the adapter,  │
  85. │                       so it should not be used if other programs   │
  86. │                       could have pending commands in the adapter.  │
  87. │                                                                    │
  88. +--------------------------------------------------------------------*/
  89.  
  90. byte dir_initialize (ccb_parm,adapternum,sem,wait)
  91. struct ccb_pt *ccb_parm;
  92. byte adapternum;
  93. #ifdef E32TO16
  94. HSYSSEM _Seg16 sem;
  95. #else
  96. HSYSSEM sem;
  97. #endif
  98. BOOL wait;
  99. {
  100. char c;
  101.         struct command_control_block_dlr *ccb;
  102.         struct dir_initialize_parms *pt;
  103.  
  104.         ccb = &ccb_parm->ccb;
  105.         pt = &ccb_parm->pt.init;
  106.         memset(ccb,0,sizeof(struct command_control_block_dlr));
  107.  
  108.         ccb->ccb_command     = LLC_DIR_INITIALIZE;
  109.         ccb->ccb_adapter     = adapternum;
  110.         ccb->ccb_retcode     = 0xFF;
  111. #ifdef E32TO16
  112.         ccb->parm_1.ccb_parm_offset = (address)pt;
  113. #else
  114.         ccb->parm_1.parm.off_12.ccb_parm_offset = FP_OFF (pt);
  115. #endif
  116.         ccb->ccb_pointer     = ZEROADDRESS;
  117.         ccb->ccb_appl_key    = ApplKey;
  118.         ccb->parm_2.system_key      = SystemKey;
  119. #ifdef E32TO16
  120.         ccb->ccb_semaphore   = sem;
  121. #else
  122.         ccb->ccb_semaphore   = (dword)sem;
  123. #endif
  124.  
  125.         memset(pt,0,sizeof(struct dir_initialize_parms));
  126.         if(sem)
  127.           DosSemSet(sem);
  128.         pass_ccb (ccb);
  129.         if(wait)
  130.           {
  131.           if(sem)
  132.             DosSemWait(sem,-1L);
  133.           else
  134.             while (ccb->ccb_retcode == 0xff);
  135.           }
  136.         return ccb->ccb_retcode;
  137. }
  138.  
  139.  
  140. /*-------------------------------------------------------------------+
  141. │ dir_openadapter: This command makes the adapter ready for normal   │
  142. │                  ring communication.  All buffers & tables will be │
  143. │                  re-initialized.                                   │
  144. │                                                                    │
  145. +-------------------------------------------------------------------*/
  146.  
  147. byte dir_openadapter (ccb_parm,adapternum,product_code,sem,wait)
  148. struct ccb_pt *ccb_parm;
  149. byte adapternum;
  150. byte product_code[];
  151. #ifdef E32TO16
  152. HSYSSEM _Seg16 sem;
  153. #else
  154. HSYSSEM sem;
  155. #endif
  156. BOOL wait;
  157. {
  158.         struct command_control_block_dlr *open_ccb;
  159.         struct dir_open_adapter_parms *pt;
  160.         struct dir_open_ad_parms      *pt1;
  161.         struct dir_open_dlc_parms     *pt2;
  162.         int i;
  163.  
  164.         open_ccb = &ccb_parm->ccb;
  165.         pt  = &ccb_parm->pt.open;
  166.         pt1 = &ccb_parm->opt.adpt;
  167.         pt2 = &ccb_parm->opt.dlcpt;
  168.         memset(open_ccb,0,sizeof(struct command_control_block_dlr));
  169.         memset(pt,0,sizeof(struct dir_open_adapter_parms));
  170.         memset(pt1,0,sizeof(struct dir_open_ad_parms));
  171.         memset(pt2,0,sizeof(struct dir_open_dlc_parms));
  172.  
  173.         open_ccb->ccb_command     = LLC_DIR_OPEN_ADAPTER;
  174.         open_ccb->ccb_adapter     = adapternum;
  175.         open_ccb->ccb_retcode     = 0xff;
  176. #ifdef E32TO16
  177.         open_ccb->parm_1.ccb_parm_offset = (address)pt;
  178. #else
  179.         open_ccb->parm_1.parm.off_12.ccb_parm_offset = FP_OFF (pt);
  180. #endif
  181.         open_ccb->ccb_pointer     = ZEROADDRESS;
  182.         open_ccb->ccb_appl_key    = ApplKey;
  183. #ifdef E32TO16
  184.         open_ccb->ccb_semaphore   = sem;
  185. #else
  186.         open_ccb->ccb_semaphore   = (dword)sem;
  187. #endif
  188.  
  189. #ifdef E32TO16
  190.         ccb_parm->pt.open.adapter_parms_offset = (address)pt1;
  191.         ccb_parm->pt.open.dlc_parms_offset     = (address)pt2;
  192. #else
  193.         ccb_parm->pt.open.adapter_parms_offset = FP_OFF (pt1);
  194.         ccb_parm->pt.open.dlc_parms_offset     = FP_OFF (pt2);
  195. #endif
  196.  
  197.         ccb_parm->opt.adpt.open_options      = 0;
  198.         ccb_parm->opt.adpt.node_address[0]   = 0;
  199.         ccb_parm->opt.adpt.group_address     = 0;
  200.         ccb_parm->opt.adpt.functional_address[0]= 0;
  201.  
  202. #ifdef E32TO16
  203.         ccb_parm->opt.adpt.product_id_offset = product_code;
  204. #else
  205.         ccb_parm->opt.adpt.product_id_offset = FP_OFF (product_code);
  206. #endif
  207.  
  208.         if(sem)
  209.           DosSemSet(sem);
  210.         pass_ccb (open_ccb);
  211.         if(wait)
  212.           {
  213.           if(sem)
  214.             DosSemWait(sem,-1L);
  215.           else
  216.             while (open_ccb->ccb_retcode == 0xff);
  217.           }
  218.         return open_ccb->ccb_retcode;
  219. }
  220.  
  221.  
  222. /*-------------------------------------------------------------------+
  223. │ receive      :  Enables the adapter to receive data for the        │
  224. │                 specified station.                                 │
  225. │                                                                    │
  226. +-------------------------------------------------------------------*/
  227.  
  228. receive (ccb_parm,adapternum,stationid,sem,wait)
  229. struct ccb_pt *ccb_parm;
  230. byte adapternum;
  231. word stationid;
  232. #ifdef E32TO16
  233. HSYSSEM _Seg16 sem;
  234. #else
  235. HSYSSEM sem;
  236. #endif
  237. BOOL wait;
  238. {
  239.         struct command_control_block_dlr *ccb;
  240.         struct receive_parms *pt;
  241.  
  242.         ccb = &ccb_parm->ccb;
  243.         pt  = &ccb_parm->pt.receive;
  244.         memset (ccb,0,sizeof(struct command_control_block_dlr));
  245.         memset (pt,0,sizeof(struct receive_parms) );
  246.  
  247.         ccb->ccb_command     = LLC_RECEIVE;
  248.         ccb->ccb_adapter     = adapternum;
  249.         ccb->ccb_retcode     = 0xff;
  250.         ccb->ccb_pointer     = ZEROADDRESS;
  251. #ifdef E32TO16
  252.         ccb->parm_1.ccb_parm_offset = (address)pt;
  253. #else
  254.         ccb->parm_1.parm.off_12.ccb_parm_offset = FP_OFF (pt);
  255. #endif
  256.         ccb->ccb_appl_key    = ApplKey;
  257.         ccb->ccb_appl_id     = ApplId;
  258. #ifdef E32TO16
  259.         ccb->ccb_semaphore   = sem;
  260. #else
  261.         ccb->ccb_semaphore   = (dword)sem;
  262. #endif
  263.  
  264.         pt->station_id = stationid;
  265.  
  266.         if(sem)
  267.           DosSemSet(sem);
  268.         pass_ccb (ccb);
  269.         if(wait)
  270.           {
  271.           if(sem)
  272.             DosSemWait(sem,-1L);
  273.           else
  274.             while (ccb->ccb_retcode == 0xff);
  275.           }
  276.         return ccb->ccb_retcode;
  277. }
  278.