Seclink.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:15k
源码类别:

模拟服务器

开发平台:

C/C++

  1. /* Copyright Data Connection Ltd. 1989 */
  2. /*****************************************************************************/
  3. /* Link Device Driver interface constants and structures.                    */
  4. /*****************************************************************************/
  5. /*****************************************************************************/
  6. /* WIN32  16/04/92  SW   Added more helpful names from WIN32 hdr file        */
  7. /* IHV    03/06/92  MF2  Add semfisui.h                                      */
  8. /* CDDD1  06/04/93  CD   Change TxFrame DevIoctl code                        */
  9. /* STAT1  21/01/94  CD   Fix what we do with stats (& general cleanup)       */
  10. /* MODEM  06/04/95  AB   Add support for the modem status program            */
  11. /*****************************************************************************/
  12. /*****************************************************************************/
  13. /* This include file is used in 3 components                                 */
  14. /*                                                                           */
  15. /* - the NT   driver                         LINK_NTDRIVER                   */
  16. /* - the X25  link service for NT            LINK_NTX25                      */
  17. /* - the SDLC link service for NT            LINK_NTSDLC                     */
  18. /*                                                                           */
  19. /* These are distinguished based on #defines as set in the following         */
  20. /*                                                                           */
  21. /*****************************************************************************/
  22. #ifdef        IMADRIVER
  23.   #define     LINK_NTDRIVER
  24. #else
  25.   #ifdef      SDLC
  26.     #define LINK_NTSDLC
  27.   #else
  28.     #define LINK_NTX25
  29.   #endif
  30. #endif
  31. /*****************************************************************************/
  32. /* Device function codes for DosDevIOCtl to link device driver               */
  33. /*****************************************************************************/
  34. #define IoctlCodeSetEvent               0x410
  35. #define IoctlCodeSetLinkChar            0x420
  36. #define IoctlCodeSetV24                 0x430
  37. #define IoctlCodeTxFrame                0x441   /* Main Tx so 1         CDDD1*/
  38. #define IoctlCodeAbortTransmit          0x450
  39. #define IoctlCodeAbortReceiver          0x460
  40. #define IoctlCodeSetInterfaceRecord     0x610   /* Retired                   */
  41. #define IoctlCodeGetV24                 0x623   /* No data buffer so 3       */
  42. #define IoctlCodeRxFrame                0x632   /* Main Rx so 2              */
  43. #define IoctlCodeReadInterfaceRecord    0x642
  44. /*****************************************************************************/
  45. /* Constants for the driver-specific IOCtl return codes.                     */
  46. /*****************************************************************************/
  47. #define CEDNODMA 0xff80     /* Warning (NO DMA!) from set link chrctrstcs    */
  48. /*****************************************************************************/
  49. /* Equates for the link options byte 1.                                      */
  50. /*****************************************************************************/
  51. #define CEL4WIRE 0x80
  52. #define CELNRZI  0x40
  53. #define CELPDPLX 0x20
  54. #define CELSDPLX 0x10
  55. #define CELCLOCK 0x08
  56. #define CELDSRS  0x04
  57. #define CELSTNBY 0x02
  58. #define CELDMA   0x01
  59. /*****************************************************************************/
  60. /* Equates for the driver set link characteristics byte 1.                   */
  61. /*****************************************************************************/
  62. #define CED4WIRE 0x80
  63. #define CEDNRZI  0x40
  64. #define CEDHDLC  0x20
  65. #define CEDFDPLX 0x10
  66. #define CEDCLOCK 0x08
  67. #define CEDDMA   0x04
  68. #define CEDRSTAT 0x02
  69. #define CEDCSTAT 0x01
  70. /* Nicer names for NT-style code */
  71. #define LinkOption_4Wire           CED4WIRE
  72. #define LinkOption_NRZI            CEDNRZI
  73. #define LinkOption_HDLC            CEDHDLC
  74. #define LinkOption_FullDuplex      CEDFDPLX
  75. #define LinkOption_InternalClock   CEDCLOCK
  76. #define LinkOption_DMA             CEDDMA
  77. #define LinkOption_ResetStatistics CEDRSTAT
  78. /*****************************************************************************/
  79. /* Equates for the ouput V24 interface flags.                                */
  80. /*****************************************************************************/
  81. #define CED24RTS 0x01
  82. #define CED24DTR 0x02
  83. #define CED24DRS 0x04
  84. #define CED24SLS 0x08
  85. #define CED24TST 0x10
  86. /* Nicer names for NT-style code */
  87. #define IR_OV24RTS  CED24RTS
  88. #define IR_OV24DTR  CED24DTR
  89. #define IR_OV24DSRS CED24DRS
  90. #define IR_OV24SlSt CED24SLS
  91. #define IR_OV24Test CED24TST
  92. /*****************************************************************************/
  93. /* Equates for the input V24 interface flags.                                */
  94. /*****************************************************************************/
  95. #define CED24CTS 0x01
  96. #define CED24DSR 0x02
  97. #define CED24DCD 0x04
  98. #define CED24RI  0x08
  99. /* Nicer names for NT-style code */
  100. #define IR_IV24CTS  CED24CTS
  101. #define IR_IV24DSR  CED24DSR
  102. #define IR_IV24DCD  CED24DCD
  103. #define IR_IV24RI   CED24RI
  104. #define IR_IV24Test 0x10
  105. /*****************************************************************************/
  106. /* Structure for the device driver interface record.                         */
  107. /*****************************************************************************/
  108. #define CEDSTCRC  0         /* Frames received with incorrect CRC            */
  109. #define CEDSTOFL  1         /* Frames received longer than the maximum       */
  110. #define CEDSTUFL  2         /* Frames received less than 4 octets long       */
  111. #define CEDSTSPR  3         /* Frames received ending on a non-octet bndry   */
  112. #define CEDSTABT  4         /* Aborted frames received                       */
  113. #define CEDSTTXU  5         /* Transmitter interrupt underruns               */
  114. #define CEDSTRXO  6         /* Receiver    interrupt overruns                */
  115. #define CEDSTDCD  7         /* DCD (RLSD) lost during frame reception        */
  116. #define CEDSTCTS  8         /* CTS lost while transmitting                   */
  117. #define CEDSTDSR  9         /* DSR drops                                     */
  118. #define CEDSTHDW 10         /* Hardware failures - adapter errors            */
  119. #define CEDSTMAX 11
  120. #define SA_CRC_Error       CEDSTCRC
  121. #define SA_RxFrameTooBig   CEDSTOFL
  122. #define SA_RxFrameTooShort CEDSTUFL
  123. #define SA_Spare           CEDSTSPR
  124. #define SA_RxAbort         CEDSTABT
  125. #define SA_TxUnderrun      CEDSTTXU
  126. #define SA_RxOverrun       CEDSTRXO
  127. #define SA_DCDDrop         CEDSTDCD
  128. #define SA_CTSDrop         CEDSTCTS
  129. #define SA_DSRDrop         CEDSTDSR
  130. #define SA_HardwareError   CEDSTHDW  /* e.g. CmdBufferFull not set  */
  131. #define SA_Max_Stat        CEDSTMAX
  132. typedef struct         _INTERFACE_RECORD
  133. {
  134.   /***************************************************************************/
  135.   /* Note: we are here trying to mirror the OS/2 layout, complete with       */
  136.   /*       lengths.  However, due to the (justifiable) pickiness of the 32-  */
  137.   /*       bit compiler, all shorts have been changed to 'int's - that way   */
  138.   /*       the results of calculations can be assigned to them without a lot */
  139.   /*       of shenanigans (or typecasting).                                  */
  140.   /***************************************************************************/
  141.   int                   RxFrameCount;   /* incremented after each frame rx'd */
  142.   int                   TxMaxFrSizeNow; /* max available frame size av. now  */
  143.                                         /* (changes after each Tx DevIoctl   */
  144.                                         /* to DD or after Tx completed)      */
  145.   int                   StatusCount;    /* How many status events have been  */
  146.                                         /* triggered.                        */
  147.   UCHAR                 V24In;          /* Last 'getv24i/f' value got        */
  148.   UCHAR                 V24Out;         /* Last 'setv24 outputs' value set   */
  149. /*       The values for the indices into the link statistics array of the    */
  150. /*       various types of statistic.                                         */
  151.   int                   StatusArray[SA_Max_Stat];
  152. }                       IR,
  153.                      * PIR;
  154. /*****************************************************************************/
  155. /* New structure used by the link to acumulate stats                   *STAT1*/
  156. /*****************************************************************************/
  157. typedef struct _STATS
  158. {
  159.   int                   StatusCount;
  160.   int                   StatusArray[SA_Max_Stat];
  161. } STATS;
  162. /*****************************************************************************/
  163. /* Structure for the set link characteristics parameter block.               */
  164. /*****************************************************************************/
  165. typedef struct  _SLPARMS
  166. {
  167.         int     SLFrameSize;            /* max frame size on link - must be  */
  168.                                          /* in range 270 to ?2K-ish          */
  169.         LONG    SLDataRate;             /* not used by us - external clocks  */
  170.         UCHAR   SLOurAddress1;          /* ) e.g C1/FF or 00/00 or 01/03     */
  171.         UCHAR   SLOurAddress2;          /* )                                 */
  172.         UCHAR   SLLinkOptionsByte;      /* see documentation & LinkOption_*  */
  173.         UCHAR   SLSpare1;
  174. }
  175.                 SLPARMS;
  176. #ifndef IMADRIVER
  177. /*****************************************************************************/
  178. /* DEVICEIOCTL macros                                                        */
  179. /*****************************************************************************/
  180. /* NT_SUCCESS ripped of from DDK's ntdef.h, which we do not want to include  */
  181. /* for now temporarily (12/5/92)                                             */
  182. #define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
  183. #define SETEVENTHANDLE(H)                                                    
  184.            NtDeviceIoControlFile(seldrvrh,H,NULL,NULL,&IoStatus,             
  185.                                    IoctlCodeSetEvent,NULL,0L,NULL,0L)
  186. #define SETINTERFACERECORD(R)                                                
  187.            NtDeviceIoControlFile(seldrvrh,NULL,NULL,NULL,&IoStatus,          
  188.                                    IoctlCodeSetInterfaceRecord,&R,sizeof(R), 
  189.                                    NULL,0L)
  190. #define SETV24STATUS                                                         
  191.            NtDeviceIoControlFile(seldrvrh,NULL,NULL,NULL,&IoStatus,          
  192.                                    IoctlCodeSetV24,NULL,0L,                  
  193.                                    &pInterfaceRecord->V24Out,1L);            
  194.                                                                              
  195.          if (SavedIROut != (pInterfaceRecord->V24Out & 0x03))                
  196.          {                                                                   
  197.            SavedIROut = (pInterfaceRecord->V24Out & 0x03);                   
  198.            pModemStatus->V24Out = pInterfaceRecord->V24Out;                  
  199.          }
  200. #define GETV24STATUS(rc)                                                     
  201.          rc |= NtDeviceIoControlFile(seldrvrh,NULL,NULL,NULL,&IoStatus,      
  202.                                    IoctlCodeGetV24,NULL,0L,NULL,0L);         
  203.          rc |= READINTERFACERECORD;                                          
  204.          if (SavedIRIn != (InterfaceRecord.V24In & 0x0F))                    
  205.          {                                                                   
  206.            SavedIRIn = (InterfaceRecord.V24In & 0x0F);                       
  207.            pModemStatus->V24In = InterfaceRecord.V24In;                      
  208.          }
  209. /*****************************************************************************/
  210. /* Check for reset stats request and reset if required                 *STAT1*/
  211. /*****************************************************************************/
  212. #define SETLINKCHARACTERISTICS(A,rc)                                         
  213.            rc = NtDeviceIoControlFile(seldrvrh,NULL,NULL,NULL,&IoStatus,     
  214.                                   IoctlCodeSetLinkChar,&A,sizeof(A),NULL,0L);
  215.            if (A.SLLinkOptionsByte & CEDRSTAT)                               
  216.            {                                                                 
  217.              memset(&Stats,0,sizeof(STATS));                                 
  218.            }
  219. /*****************************************************************************/
  220. /* Note we now pass the user buffer in the input fields, not the output      */
  221. /* fields                                                               CDDD1*/
  222. /*****************************************************************************/
  223. #define TRANSMITFRAME(A,B)                                                   
  224.            NtDeviceIoControlFile(seldrvrh,NULL,NULL,NULL,&IoStatus,          
  225.                                    IoctlCodeTxFrame,A,B,NULL,0L);
  226. #define RECEIVEFRAME(A,B)                                                    
  227.            NtDeviceIoControlFile(seldrvrh,NULL,NULL,NULL,&IoStatus,          
  228.                                    IoctlCodeRxFrame,NULL,0L,A,B);
  229. /*****************************************************************************/
  230. /* Due to a problem sharing a structure between the driver and link we're    */
  231. /* going to get the driver to reset it's stats after every call to read the  */
  232. /* interface record, and get the link to accumulate the stats          *STAT1*/
  233. /*****************************************************************************/
  234. #define READINTERFACERECORD                                                  
  235.            NtDeviceIoControlFile(seldrvrh,NULL,NULL,NULL,&IoStatus,          
  236.                                    IoctlCodeReadInterfaceRecord,NULL,0L,     
  237.                                    &InterfaceRecord,sizeof(InterfaceRecord));
  238.            if (!rc)                                                          
  239.            {                                                                 
  240.              int i;                                                          
  241.              Stats.StatusCount += InterfaceRecord.StatusCount;               
  242.              for (i=0;i<SA_Max_Stat;i++)                                     
  243.              {                                                               
  244.                Stats.StatusArray[i] += InterfaceRecord.StatusArray[i];       
  245.              }                                                               
  246.            }
  247. #endif