home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / andistkt.zip / MACANDIS.C < prev    next >
Text File  |  1995-04-19  |  10KB  |  311 lines

  1. /*****************************************************************************/
  2. /*                                                                           */
  3. /*   Component   : Sample ANDIS MAC Driver                                   */
  4. /*                                                                           */
  5. /*   Module      : MACANDIS.C                                                */
  6. /*                                                                           */
  7. /*   Description : This module contains routines which implement the ANDIS   */
  8. /*                 extentions to NDIS.  These routines talk to a PCM to      */
  9. /*                 establish and take down connections.                      */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12.  
  13. #define INCL_DOS
  14. #include <os2.h>
  15. #include "typedef.h"
  16. #include "ndis.h"
  17. #include "andis.h"
  18. #include "macdef.h"
  19. #include "macproto.h"
  20.  
  21.  
  22. /************************************************************************/
  23. /*                       Port Management                                */
  24. /************************************************************************/
  25.  
  26.  
  27. USHORT _loadds PASCAL FAR PortManagement( USHORT PortID, USHORT ReqHandle,
  28.       USHORT Param1, ULONG Param2, USHORT FunctionCode, USHORT MACDS )
  29. {
  30.    switch( FunctionCode )
  31.       {
  32.          case ANDIS_FC_REG_PCM:
  33.             return RegisterPCM( ReqHandle, Param1, (PENTRYTBL)Param2, MACDS );
  34.          case ANDIS_FC_REL_PCM:
  35.             return ReleasePCM( ReqHandle, Param1, MACDS );
  36.          case ANDIS_FC_ACT_MODE:
  37.             return ActivateMode( ReqHandle, Param1, MACDS );
  38.          case ANDIS_FC_RET_PPI_STAT:
  39.             return RetrievePPIStatus( ReqHandle, (PULONG)Param2, MACDS );
  40.          case ANDIS_FC_GET_PPAT_PARMS:
  41.             return GetPPATParms( ReqHandle, Param1, (PXVPPAT)Param2, MACDS );
  42.          case ANDIS_FC_SET_PPAT_PARMS:
  43.             return SetPPATParms( ReqHandle, (PXVPPAT)Param2, MACDS );
  44.          case ANDIS_FC_RESET_PORT:
  45.             return ResetPort( ReqHandle, Param1, MACDS );
  46.          case ANDIS_FC_ACT_PHYS_CONN:
  47.             return ActivatePhysConn( ReqHandle, Param1, Param2, MACDS );
  48.          case ANDIS_FC_DEACT_PHYS_CONN:
  49.             return DeactivatePhysConn( ReqHandle, Param2, MACDS );
  50.          case ANDIS_FC_REG_NULL_DLC:
  51.             return RegisterNullDLC( ReqHandle,Param1,(PENTRYTBL)Param2,MACDS );
  52.          case ANDIS_FC_REL_NULL_DLC:
  53.             return ReleaseNullDLC( ReqHandle, Param1, MACDS );
  54.          case ANDIS_FC_ACT_DTR:
  55.             return ActivateDTR( ReqHandle, MACDS );
  56.          case ANDIS_FC_ACT_RTS:
  57.             return ActivateRTS( ReqHandle, MACDS );
  58.          default:
  59.             return ANDIS_RC_INVALID_FUNC;
  60.       }
  61. }
  62.  
  63.  
  64. USHORT NEAR RegisterPCM( USHORT ReqHandle, USHORT PortID, PENTRYTBL pEntryTbl,
  65.       USHORT MACDS )
  66. {
  67.    PMODULE pModule = MAKEP(MACDS,0);
  68.  
  69.    if ( pModule->PCMEntryTbl.PortMgmtInd == NULL )
  70.       {
  71.          pModule->PCMEntryTbl.PortMgmtInd    = pEntryTbl->PortMgmtInd;
  72.          pModule->PCMEntryTbl.RecvImmData    = pEntryTbl->RecvImmData;
  73.          pModule->PCMEntryTbl.XmitImmDataCnf = pEntryTbl->XmitImmDataCnf;
  74.          pModule->PCMEntryTbl.pcm_ds         = pEntryTbl->pcm_ds;
  75.       }
  76.    else return ANDIS_RC_ALREADY_REG;
  77.  
  78.    return ANDIS_RC_SUCCESS;
  79. }
  80.  
  81.  
  82. USHORT NEAR ReleasePCM( USHORT ReqHandle, USHORT PortID, USHORT MACDS )
  83. {
  84.    PMODULE pModule = MAKEP(MACDS,0);
  85.  
  86.    pModule->PCMEntryTbl.PortMgmtInd    = NULL;
  87.    pModule->PCMEntryTbl.RecvImmData    = NULL;
  88.    pModule->PCMEntryTbl.XmitImmDataCnf = NULL;
  89.    pModule->PCMEntryTbl.pcm_ds         = 0;
  90.  
  91.    return ANDIS_RC_SUCCESS;
  92. }
  93.  
  94.  
  95. USHORT NEAR ActivateMode( USHORT ReqHandle, USHORT MACMode, USHORT MACDS )
  96. {
  97.    PMODULE pModule = MAKEP(MACDS,0);
  98.  
  99.    return ANDIS_RC_SUCCESS;
  100. }
  101.  
  102.  
  103. USHORT NEAR RetrievePPIStatus( USHORT ReqHandle, PULONG pPPIStatus,
  104.       USHORT MACDS )
  105. {
  106.    PMODULE pModule = MAKEP(MACDS,0);
  107.  
  108.    return ANDIS_RC_SUCCESS;
  109. }
  110.  
  111.  
  112. USHORT NEAR GetPPATParms( USHORT ReqHandle, USHORT PPATSize, PXVPPAT pPPAT,
  113.       USHORT MACDS )
  114. {
  115.    PMODULE pModule = MAKEP(MACDS,0);
  116.  
  117.    return ANDIS_RC_SUCCESS;
  118. }
  119.  
  120.  
  121. USHORT NEAR SetPPATParms( USHORT ReqHandle, PXVPPAT pPPAT, USHORT MACDS )
  122. {
  123.    PMODULE pModule = MAKEP(MACDS,0);
  124.  
  125.    return ANDIS_RC_SUCCESS;
  126. }
  127.  
  128.  
  129. USHORT NEAR ResetPort( USHORT ReqHandle, USHORT ResetType, USHORT MACDS )
  130. {
  131.    PMODULE pModule = MAKEP(MACDS,0);
  132.  
  133.    return ANDIS_RC_SUCCESS;
  134. }
  135.  
  136.  
  137. USHORT NEAR ActivatePhysConn( USHORT ReqHandle, USHORT Mode, ULONG Timeout,
  138.       USHORT MACDS )
  139. {
  140.    PMODULE pModule = MAKEP(MACDS,0);
  141.  
  142.    return ANDIS_RC_SUCCESS;
  143. }
  144.  
  145.  
  146. USHORT NEAR DeactivatePhysConn( USHORT ReqHandle, ULONG Timeout, USHORT MACDS )
  147. {
  148.    PMODULE pModule = MAKEP(MACDS,0);
  149.  
  150.    return ANDIS_RC_SUCCESS;
  151. }
  152.  
  153.  
  154. USHORT NEAR RegisterNullDLC( USHORT ReqHandle, USHORT PortID,
  155.       PENTRYTBL pEntryTbl, USHORT MACDS )
  156. {
  157.    PMODULE pModule = MAKEP(MACDS,0);
  158.  
  159.    return ANDIS_RC_SUCCESS;
  160. }
  161.  
  162.  
  163. USHORT NEAR ReleaseNullDLC( USHORT ReqHandle, USHORT PortID, USHORT MACDS )
  164. {
  165.    PMODULE pModule = MAKEP(MACDS,0);
  166.  
  167.    return ANDIS_RC_SUCCESS;
  168. }
  169.  
  170.  
  171. USHORT NEAR ActivateDTR( USHORT ReqHandle, USHORT MACDS )
  172. {
  173.    PMODULE pModule = MAKEP(MACDS,0);
  174.  
  175.    return ANDIS_RC_SUCCESS;
  176. }
  177.  
  178.  
  179. USHORT NEAR ActivateRTS( USHORT ReqHandle, USHORT MACDS )
  180. {
  181.    PMODULE pModule = MAKEP(MACDS,0);
  182.  
  183.    return ANDIS_RC_SUCCESS;
  184. }
  185.  
  186.  
  187. /************************************************************************/
  188. /*                   Port Management Indications                        */
  189. /************************************************************************/
  190.  
  191.  
  192. USHORT NEAR ConnectionActive( USHORT ReqHandle, PMODULE pModule )
  193. {
  194.    return pModule->PCMEntryTbl.PortMgmtInd( pModule->PPAT.Header.Port_ID,
  195.          ReqHandle, pModule->PPAT.PPI_Status, pModule->PPAT.Xmit_Speed,
  196.          ANDIS_FC_CONN_ACTIVE, pModule->PCMEntryTbl.pcm_ds );
  197. }
  198.  
  199.  
  200. USHORT NEAR ConnectionInactive( USHORT ReqHandle, PMODULE pModule )
  201. {
  202.    return pModule->PCMEntryTbl.PortMgmtInd( pModule->PPAT.Header.Port_ID,
  203.          ReqHandle, pModule->PPAT.PPI_Status, 0L, ANDIS_FC_CONN_INACTIVE,
  204.          pModule->PCMEntryTbl.pcm_ds );
  205. }
  206.  
  207.  
  208. USHORT NEAR PPISignal( USHORT ReqHandle, PMODULE pModule )
  209. {
  210.    return pModule->PCMEntryTbl.PortMgmtInd( pModule->PPAT.Header.Port_ID,
  211.          ReqHandle, pModule->PPAT.PPI_Status, 0L, ANDIS_FC_PPI_SIGNAL,
  212.          pModule->PCMEntryTbl.pcm_ds );
  213. }
  214.  
  215.  
  216. USHORT NEAR PPIException( USHORT ReqHandle, USHORT Exception, PMODULE pModule )
  217. {
  218.    return pModule->PCMEntryTbl.PortMgmtInd( pModule->PPAT.Header.Port_ID,
  219.          ReqHandle, Exception, 0L, ANDIS_FC_PPI_EXCEPTION,
  220.          pModule->PCMEntryTbl.pcm_ds );
  221. }
  222.  
  223.  
  224. USHORT NEAR PortMgmtReqComplete( USHORT ReqHandle, USHORT Status,
  225.       PMODULE pModule )
  226. {
  227.    return pModule->PCMEntryTbl.PortMgmtInd( pModule->PPAT.Header.Port_ID,
  228.          ReqHandle, pModule->PPAT.PPI_Status, (ULONG)Status,
  229.          ANDIS_FC_PM_REQ_COMPLETE, pModule->PCMEntryTbl.pcm_ds );
  230. }
  231.  
  232.  
  233. /************************************************************************/
  234. /*                     Transmit Immediate Data                          */
  235. /************************************************************************/
  236.  
  237.  
  238. USHORT _loadds PASCAL FAR TransmitImmData( USHORT PortID, USHORT ReqHandle,
  239.       USHORT DataLength, ULONG pImmData, USHORT FunctionCode, USHORT MACDS )
  240. {
  241.    PMODULE pModule = MAKEP(MACDS,0);
  242.  
  243.    if ( FunctionCode != ANDIS_FC_TX_IMM_DATA ) return ANDIS_RC_INVALID_FUNC;
  244.  
  245.    return ANDIS_RC_SUCCESS;
  246. }
  247.  
  248.  
  249. /************************************************************************/
  250. /*                 Transmit Immediate Data Confirm                      */
  251. /************************************************************************/
  252.  
  253.  
  254. USHORT NEAR TransmitImmDataConfirm( USHORT ReqHandle, USHORT Status,
  255.       PMODULE pModule )
  256. {
  257.    return pModule->PCMEntryTbl.XmitImmDataCnf( pModule->PPAT.Header.Port_ID,
  258.          ReqHandle, pModule->PPAT.PPI_Status, (ULONG)Status,
  259.          ANDIS_FC_TX_IMM_DATA_CNF, pModule->PCMEntryTbl.pcm_ds );
  260. }
  261.  
  262.  
  263. /************************************************************************/
  264. /*                     Receive Immediate Data                           */
  265. /************************************************************************/
  266.  
  267.  
  268. USHORT NEAR ReceiveImmData( USHORT ReqHandle, USHORT DataLength,
  269.       PUCHAR pImmData, PMODULE pModule )
  270. {
  271.    return pModule->PCMEntryTbl.RecvImmData( pModule->PPAT.Header.Port_ID,
  272.          ReqHandle, DataLength, (ULONG)pImmData, ANDIS_FC_RX_IMM_DATA,
  273.          pModule->PCMEntryTbl.pcm_ds );
  274. }
  275.  
  276.  
  277. /************************************************************************/
  278. /*                 Receive Immediate Data Confirm                       */
  279. /************************************************************************/
  280.  
  281.  
  282. USHORT _loadds PASCAL FAR ReceiveImmDataConfirm( USHORT PortID,
  283.       USHORT ReqHandle, USHORT Param1, ULONG Param2, USHORT FunctionCode,
  284.       USHORT MACDS )
  285. {
  286.    PMODULE pModule = MAKEP(MACDS,0);
  287.  
  288.    if ( FunctionCode != ANDIS_FC_RX_IMM_DATA_CNF )
  289.       return ANDIS_RC_INVALID_FUNC;
  290.  
  291.    return ANDIS_RC_SUCCESS;
  292. }
  293.  
  294.  
  295. /************************************************************************/
  296. /*                         PPAT Management                              */
  297. /************************************************************************/
  298.  
  299.  
  300. USHORT _loadds PASCAL FAR PPATManagement( USHORT PortID, USHORT ReqHandle,
  301.       USHORT Param1, ULONG pPPAT, USHORT FunctionCode, USHORT MACDS )
  302. {
  303.    PMODULE pModule = MAKEP(MACDS,0);
  304.  
  305.    if ( FunctionCode != ANDIS_FC_UPDATE_PPAT ) return ANDIS_RC_INVALID_FUNC;
  306.  
  307.    return ANDIS_RC_SUCCESS;
  308. }
  309.  
  310.  
  311.