home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Internet 2000 May / MICD_2000_05.iso / CBuilder5 / INSTALL / DATA1.CAB / Program_Built_Files / Include / seclink.h < prev    next >
C/C++ Source or Header  |  2000-02-01  |  15KB  |  293 lines

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