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

  1. /*****************************************************************************/
  2. /*                                                                           */
  3. /*   Component   : Sample ANDIS MAC Driver                                   */
  4. /*                                                                           */
  5. /*   Module      : MACNDIS.C                                                 */
  6. /*                                                                           */
  7. /*   Description : This module contains routines which implement the NDIS    */
  8. /*                 interface.  These routines talk to a protocol stack.      */
  9. /*                                                                           */
  10. /*****************************************************************************/
  11.  
  12. #define INCL_DOS
  13. #include <os2.h>
  14. #include "typedef.h"
  15. #include "ndis.h"
  16. #include "andis.h"
  17. #include "macdef.h"
  18. #include "macproto.h"
  19.  
  20.  
  21. /************************************************************************/
  22. /*                       System Requests                                */
  23. /************************************************************************/
  24.  
  25.  
  26. USHORT _loadds PASCAL FAR SystemRequest( ULONG Param1, ULONG Param2,
  27.       USHORT Param3, USHORT Opcode, USHORT MACDS )
  28. {
  29.    switch( Opcode )
  30.       {
  31.          case InitiateBind:
  32.             return NOT_SUPPORTED;
  33.          case Bind:
  34.             return SRBind( (struct CommChar *)Param1,
  35.                   (struct CommChar **)Param2, MACDS );
  36.          default:
  37.             return INVALID_FUNCTION;
  38.       }
  39. }
  40.  
  41.  
  42. USHORT NEAR SRBind( struct CommChar *pProtCCT, struct CommChar **ppMACCCT,
  43.       USHORT MACDS )
  44. {
  45.    PMODULE pModule = MAKEP(MACDS,0);
  46.  
  47.    if ( pModule->pProtCCT == NULL )
  48.       {
  49.          /* Exchange Common Characteristics Tables */
  50.          pModule->pProtCCT = pProtCCT;
  51.          *ppMACCCT = &(pModule->CCT);
  52.  
  53.          /* Save the protocol's DS */
  54.          pModule->ProtDS = pProtCCT->CcDataSeg;
  55.  
  56.          /* Save the protocol's lower dispatch entry points */
  57.          pModule->ProtLDT.PldReqConfirm  = pProtCCT->CcLDp->PldReqConfirm;
  58.          pModule->ProtLDT.PldXmitConfirm = pProtCCT->CcLDp->PldXmitConfirm;
  59.          pModule->ProtLDT.PldRcvLkAhead  = pProtCCT->CcLDp->PldRcvLkAhead;
  60.          pModule->ProtLDT.PldIndComplete = pProtCCT->CcLDp->PldIndComplete;
  61.          pModule->ProtLDT.PldRcvChain    = pProtCCT->CcLDp->PldRcvChain;
  62.          pModule->ProtLDT.PldStatInd     = pProtCCT->CcLDp->PldStatInd;
  63.  
  64.          return SUCCESS;
  65.       }
  66.    else return GENERAL_FAILURE;
  67. }
  68.  
  69.  
  70. /************************************************************************/
  71. /*                       General Requests                               */
  72. /************************************************************************/
  73.  
  74.  
  75. USHORT _loadds PASCAL FAR GeneralRequest( USHORT ProtID, USHORT ReqHandle,
  76.       USHORT Param1, PUCHAR Param2, USHORT Opcode, USHORT MACDS )
  77. {
  78.    switch( Opcode )
  79.       {
  80.          case InitiateDiagnostics:
  81.             return GRInitiateDiagnostics( ProtID, ReqHandle, MACDS );
  82.          case ReadErrorLog:
  83.             return GRReadErrorLog( ProtID, ReqHandle, Param1, Param2, MACDS );
  84.          case SetStationAddress:
  85.             return GRSetStationAddress( ProtID, ReqHandle, Param2, MACDS );
  86.          case OpenAdapter:
  87.             return GROpenAdapter( ProtID, ReqHandle, Param1, MACDS );
  88.          case CloseAdapter:
  89.             return GRCloseAdapter( ProtID, ReqHandle, MACDS );
  90.          case ResetMAC:
  91.             return GRResetMAC( ProtID, ReqHandle, MACDS );
  92.          case SetPacketFilter:
  93.             return GRSetPacketFilter( ProtID, ReqHandle, Param1, MACDS );
  94.          case AddMulticastAddress:
  95.             return GRAddMulticastAddress( ProtID, ReqHandle, Param2, MACDS );
  96.          case DeleteMulticastAddress:
  97.             return GRDeleteMulticastAddress( ProtID, ReqHandle, Param2, MACDS );
  98.          case UpdateStatistics:
  99.             return GRUpdateStatistics( ProtID, ReqHandle, MACDS );
  100.          case ClearStatistics:
  101.             return GRClearStatistics( ProtID, ReqHandle, MACDS );
  102.          case Interrupt:
  103.             return GRInterrupt( ProtID, MACDS );
  104.          case SetFunctionalAddress:
  105.             return GRSetFunctionalAddress( ProtID, ReqHandle, Param2, MACDS );
  106.          case SetLookAhead:
  107.             return GRSetLookAhead( ProtID, ReqHandle, Param1, MACDS );
  108.          default:
  109.             return INVALID_FUNCTION;
  110.       }
  111. }
  112.  
  113.  
  114. USHORT NEAR GRInitiateDiagnostics( USHORT ProtID, USHORT ReqHandle,
  115.       USHORT MACDS )
  116. {
  117.    PMODULE pModule = MAKEP(MACDS,0);
  118.  
  119.    return SUCCESS;
  120. }
  121.  
  122.  
  123. USHORT NEAR GRReadErrorLog( USHORT ProtID, USHORT ReqHandle, USHORT LogLen,
  124.       PUCHAR pLogBuff, USHORT MACDS )
  125. {
  126.    PMODULE pModule = MAKEP(MACDS,0);
  127.  
  128.    return SUCCESS;
  129. }
  130.  
  131.  
  132. USHORT NEAR GRSetStationAddress( USHORT ProtID, USHORT ReqHandle,
  133.       PUCHAR pAdaptAddr, USHORT MACDS )
  134. {
  135.    PMODULE pModule = MAKEP(MACDS,0);
  136.  
  137.    return SUCCESS;
  138. }
  139.  
  140.  
  141. USHORT NEAR GROpenAdapter( USHORT ProtID, USHORT ReqHandle, USHORT OpenOptions,
  142.       USHORT MACDS )
  143. {
  144.    PMODULE pModule = MAKEP(MACDS,0);
  145.  
  146.    return SUCCESS;
  147. }
  148.  
  149.  
  150. USHORT NEAR GRCloseAdapter( USHORT ProtID, USHORT ReqHandle, USHORT MACDS )
  151. {
  152.    PMODULE pModule = MAKEP(MACDS,0);
  153.  
  154.    return SUCCESS;
  155. }
  156.  
  157.  
  158. USHORT NEAR GRResetMAC( USHORT ProtID, USHORT ReqHandle, USHORT MACDS )
  159. {
  160.    PMODULE pModule = MAKEP(MACDS,0);
  161.  
  162.    return SUCCESS;
  163. }
  164.  
  165.  
  166. USHORT NEAR GRSetPacketFilter( USHORT ProtID, USHORT ReqHandle,
  167.       USHORT FilterMask, USHORT MACDS )
  168. {
  169.    PMODULE pModule = MAKEP(MACDS,0);
  170.  
  171.    return SUCCESS;
  172. }
  173.  
  174.  
  175. USHORT NEAR GRAddMulticastAddress( USHORT ProtID, USHORT ReqHandle,
  176.       PUCHAR pMultiAddr, USHORT MACDS )
  177. {
  178.    PMODULE pModule = MAKEP(MACDS,0);
  179.  
  180.    return SUCCESS;
  181. }
  182.  
  183.  
  184. USHORT NEAR GRDeleteMulticastAddress( USHORT ProtID, USHORT ReqHandle,
  185.       PUCHAR pMultiAddr, USHORT MACDS )
  186. {
  187.    PMODULE pModule = MAKEP(MACDS,0);
  188.  
  189.    return SUCCESS;
  190. }
  191.  
  192.  
  193. USHORT NEAR GRUpdateStatistics( USHORT ProtID, USHORT ReqHandle, USHORT MACDS )
  194. {
  195.    PMODULE pModule = MAKEP(MACDS,0);
  196.  
  197.    return SUCCESS;
  198. }
  199.  
  200.  
  201. USHORT NEAR GRClearStatistics( USHORT ProtID, USHORT ReqHandle, USHORT MACDS )
  202. {
  203.    PMODULE pModule = MAKEP(MACDS,0);
  204.  
  205.    return SUCCESS;
  206. }
  207.  
  208.  
  209. USHORT NEAR GRInterrupt( USHORT ProtID, USHORT MACDS )
  210. {
  211.    PMODULE pModule = MAKEP(MACDS,0);
  212.  
  213.    return SUCCESS;
  214. }
  215.  
  216.  
  217. USHORT NEAR GRSetFunctionalAddress( USHORT ProtID, USHORT ReqHandle,
  218.       PUCHAR pFunctAddr, USHORT MACDS )
  219. {
  220.    PMODULE pModule = MAKEP(MACDS,0);
  221.  
  222.    return SUCCESS;
  223. }
  224.  
  225.  
  226. USHORT NEAR GRSetLookAhead( USHORT ProtID, USHORT ReqHandle, USHORT Length,
  227.       USHORT MACDS )
  228. {
  229.    PMODULE pModule = MAKEP(MACDS,0);
  230.  
  231.    return SUCCESS;
  232. }
  233.  
  234.  
  235. USHORT NEAR RequestConfirm( USHORT ProtID, USHORT ReqHandle, USHORT Status,
  236.       USHORT Request, PMODULE pModule )
  237. {
  238.    return (USHORT)pModule->ProtLDT.PldReqConfirm( ProtID,
  239.          pModule->CCT.CcModuleID, ReqHandle, Status, Request, pModule->ProtDS );
  240. }
  241.  
  242.  
  243. /************************************************************************/
  244. /*                       Status Indications                             */
  245. /************************************************************************/
  246.  
  247.  
  248. USHORT NEAR SIRingStatus( USHORT Status, PUCHAR pIndicate, PMODULE pModule )
  249. {
  250.    return (USHORT)pModule->ProtLDT.PldStatInd( pModule->CCT.CcModuleID, Status,
  251.          pIndicate, RingStatus, pModule->ProtDS );
  252. }
  253.  
  254.  
  255. USHORT NEAR SIAdapterCheck( USHORT Reason, PUCHAR pIndicate, PMODULE pModule )
  256. {
  257.    return (USHORT)pModule->ProtLDT.PldStatInd( pModule->CCT.CcModuleID, Reason,
  258.          pIndicate, AdapterCheck, pModule->ProtDS );
  259. }
  260.  
  261.  
  262. USHORT NEAR SIStartReset( PUCHAR pIndicate, PMODULE pModule )
  263. {
  264.    return (USHORT)pModule->ProtLDT.PldStatInd( pModule->CCT.CcModuleID, 0,
  265.          pIndicate, StartReset, pModule->ProtDS );
  266. }
  267.  
  268.  
  269. USHORT NEAR SIEndReset( PUCHAR pIndicate, PMODULE pModule )
  270. {
  271.    return (USHORT)pModule->ProtLDT.PldStatInd( pModule->CCT.CcModuleID, 0,
  272.          pIndicate, EndReset, pModule->ProtDS );
  273. }
  274.  
  275.  
  276. USHORT NEAR SIInterrupt( PUCHAR pIndicate, PMODULE pModule )
  277. {
  278.    return (USHORT)pModule->ProtLDT.PldStatInd( pModule->CCT.CcModuleID, 0,
  279.          pIndicate, InterruptStatus, pModule->ProtDS );
  280. }
  281.  
  282.  
  283. /************************************************************************/
  284. /*                        Direct Primitives                             */
  285. /************************************************************************/
  286.  
  287.  
  288. USHORT _loadds PASCAL FAR TransmitChain( USHORT ProtID, USHORT ReqHandle,
  289.       struct TxBufDesc *pTxBufDesc, USHORT MACDS )
  290. {
  291.    PMODULE pModule = MAKEP(MACDS,0);
  292.  
  293.    return SUCCESS;
  294. }
  295.  
  296.  
  297. USHORT NEAR TransmitConfirm( USHORT ProtID, USHORT ReqHandle, USHORT Status,
  298.       PMODULE pModule )
  299. {
  300.    return (USHORT)pModule->ProtLDT.PldXmitConfirm( ProtID,
  301.          pModule->CCT.CcModuleID, ReqHandle, Status, pModule->ProtDS );
  302. }
  303.  
  304.  
  305. USHORT NEAR ReceiveLookahead( USHORT FrameSize, USHORT BytesAvail,
  306.       PUCHAR pBuffer, PUCHAR pIndicate, PMODULE pModule )
  307. {
  308.    return (USHORT)pModule->ProtLDT.PldRcvLkAhead( pModule->CCT.CcModuleID,
  309.          FrameSize, BytesAvail, pBuffer, pIndicate, pModule->ProtDS );
  310. }
  311.  
  312.  
  313. USHORT _loadds PASCAL FAR TransferData( PUSHORT pBytesCopied,
  314.       USHORT FrameOffset, struct TDBufDesc *pTDBufDesc, USHORT MACDS )
  315. {
  316.    PMODULE pModule = MAKEP(MACDS,0);
  317.  
  318.    return SUCCESS;
  319. }
  320.  
  321.  
  322. USHORT NEAR IndicationComplete( PMODULE pModule )
  323. {
  324.    return (USHORT)pModule->ProtLDT.PldIndComplete( pModule->CCT.CcModuleID,
  325.          pModule->ProtDS );
  326. }
  327.  
  328.  
  329. USHORT NEAR ReceiveChain( USHORT FrameSize, USHORT ReqHandle,
  330.       struct RxBufDesc *pRxBufDesc, PUCHAR pIndicate, PMODULE pModule )
  331. {
  332.    return (USHORT)pModule->ProtLDT.PldRcvChain( pModule->CCT.CcModuleID,
  333.          FrameSize, ReqHandle, (PUCHAR)pRxBufDesc, pIndicate, pModule->ProtDS );
  334. }
  335.  
  336.  
  337. USHORT _loadds PASCAL FAR ReceiveRelease( USHORT ReqHandle, USHORT MACDS )
  338. {
  339.    PMODULE pModule = MAKEP(MACDS,0);
  340.  
  341.    return SUCCESS;
  342. }
  343.  
  344.  
  345. USHORT _loadds PASCAL FAR IndicationsOff( USHORT MACDS )
  346. {
  347.    PMODULE pModule = MAKEP(MACDS,0);
  348.  
  349.    return SUCCESS;
  350. }
  351.  
  352.  
  353. USHORT _loadds PASCAL FAR IndicationsOn( USHORT MACDS )
  354. {
  355.    PMODULE pModule = MAKEP(MACDS,0);
  356.  
  357.    return SUCCESS;
  358. }
  359.  
  360.  
  361.