home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / HSRC_100 / HYDRA.H < prev    next >
C/C++ Source or Header  |  1993-01-11  |  11KB  |  181 lines

  1. /*=============================================================================
  2.  
  3.                               HydraCom Version 1.00
  4.  
  5.                          A sample implementation of the
  6.                    HYDRA Bi-Directional File Transfer Protocol
  7.  
  8.                              HydraCom was written by
  9.                    Arjen G. Lentz, LENTZ SOFTWARE-DEVELOPMENT
  10.                   COPYRIGHT (C) 1991-1993; ALL RIGHTS RESERVED
  11.  
  12.                        The HYDRA protocol was designed by
  13.                  Arjen G. Lentz, LENTZ SOFTWARE-DEVELOPMENT and
  14.                              Joaquim H. Homrighausen
  15.                   COPYRIGHT (C) 1991-1993; ALL RIGHTS RESERVED
  16.  
  17.  
  18.   Revision history:
  19.   06 Sep 1991 - (AGL) First tryout
  20.   .. ... .... - Internal development
  21.   11 Jan 1993 - HydraCom version 1.00, Hydra revision 001 (01 Dec 1992)
  22.  
  23.  
  24.   For complete details of the Hydra and HydraCom licensing restrictions,
  25.   please refer to the license agreements which are published in their entirety
  26.   in HYDRACOM.C and LICENSE.DOC, and also contained in the documentation file
  27.   HYDRACOM.DOC
  28.  
  29.   Use of this file is subject to the restrictions contained in the Hydra and
  30.   HydraCom licensing agreements. If you do not find the text of this agreement
  31.   in any of the aforementioned files, or if you do not have these files, you
  32.   should immediately contact LENTZ SOFTWARE-DEVELOPMENT and/or Joaquim
  33.   Homrighausen at one of the addresses listed below. In no event should you
  34.   proceed to use this file without having accepted the terms of the Hydra and
  35.   HydraCom licensing agreements, or such other agreement as you are able to
  36.   reach with LENTZ SOFTWARE-DEVELOMENT and Joaquim Homrighausen.
  37.  
  38.  
  39.   Hydra protocol design and HydraCom driver:         Hydra protocol design:
  40.   Arjen G. Lentz                                     Joaquim H. Homrighausen
  41.   LENTZ SOFTWARE-DEVELOPMENT                         389, route d'Arlon
  42.   Langegracht 7B                                     L-8011 Strassen
  43.   3811 BT  Amersfoort                                Luxembourg
  44.   The Netherlands
  45.   FidoNet 2:283/512, AINEX-BBS +31-33-633916         FidoNet 2:270/17
  46.   arjen_lentz@f512.n283.z2.fidonet.org               joho@ae.lu
  47.  
  48.   Please feel free to contact us at any time to share your comments about our
  49.   software and/or licensing policies.
  50.  
  51. =============================================================================*/
  52.  
  53.  
  54. /* HYDRA Specification Revision/Timestamp ---------Revision------Date------- */
  55. #define H_REVSTAMP   0x2b1aab00L                /* 001           01 Dec 1992 */
  56. #define H_REVISION   1
  57.  
  58. /* HYDRA Basic Values ------------------------------------------------------ */
  59. #ifndef XON
  60. #define XON          ('Q' - '@')        /* Ctrl-Q (^Q) xmit-on character     */
  61. #define XOFF         ('S' - '@')        /* Ctrl-S (^S) xmit-off character    */
  62. #endif
  63. #define H_DLE        ('X' - '@')        /* Ctrl-X (^X) HYDRA DataLinkEscape  */
  64. #define H_MINBLKLEN    64               /* Min. length of a HYDRA data block */
  65. #define H_MAXBLKLEN  2048               /* Max. length of a HYDRA data block */
  66. #define H_OVERHEAD      8               /* Max. no. control bytes in a pkt   */
  67. #define H_MAXPKTLEN  ((H_MAXBLKLEN + H_OVERHEAD + 5) * 3)     /* Encoded pkt */
  68. #define H_BUFLEN     (H_MAXPKTLEN + 16) /* Buffer sizes: max.enc.pkt + slack */
  69. #define H_PKTPREFIX    31               /* Max length of pkt prefix string   */
  70. #define H_FLAGLEN       3               /* Length of a flag field            */
  71. #define H_RETRIES      10               /* No. retries in case of an error   */
  72. #define H_MINTIMER     10               /* Minimum timeout period            */
  73. #define H_MAXTIMER     60               /* Maximum timeout period            */
  74. #define H_START         5               /* Timeout for re-sending startstuff */
  75. #define H_IDLE         20               /* Idle? tx IDLE pkt every 20 secs   */
  76. #define H_BRAINDEAD   120               /* Braindead in 2 mins (120 secs)    */
  77.  
  78. /* HYDRA Return codes ------------------------------------------------------ */
  79. #define XFER_ABORT    (-1)              /* Failed on this file & abort xfer  */
  80. #define XFER_SKIP       0               /* Skip this file but continue xfer  */
  81. #define XFER_OK         1               /* File was sent, continue transfer  */
  82.  
  83. /* HYDRA Transmitter States ------------------------------------------------ */
  84. #define HTX_DONE        0               /* All over and done                 */
  85. #define HTX_START       1               /* Send start autostr + START pkt    */
  86. #define HTX_SWAIT       2               /* Wait for any pkt or timeout       */
  87. #define HTX_INIT        3               /* Send INIT pkt                     */
  88. #define HTX_INITACK     4               /* Wait for INITACK pkt              */
  89. #define HTX_RINIT       5               /* Wait for HRX_INIT -> HRX_FINFO    */
  90. #define HTX_FINFO       6               /* Send FINFO pkt                    */
  91. #define HTX_FINFOACK    7               /* Wait for FINFOACK pkt             */
  92. #define HTX_XDATA       8               /* Send next packet with file data   */
  93. #define HTX_DATAACK     9               /* Wait for DATAACK packet           */
  94. #define HTX_XWAIT      10               /* Wait for HRX_END                  */
  95. #define HTX_EOF        11               /* Send EOF pkt                      */
  96. #define HTX_EOFACK     12               /* End of file, wait for EOFACK pkt  */
  97. #define HTX_REND       13               /* Wait for HRX_END && HTD_DONE      */
  98. #define HTX_END        14               /* Send END pkt (finish session)     */
  99. #define HTX_ENDACK     15               /* Wait for END pkt from other side  */
  100.  
  101. /* HYDRA Device Packet Transmitter States ---------------------------------- */
  102. #define HTD_DONE        0               /* No device data pkt to send        */
  103. #define HTD_DATA        1               /* Send DEVDATA pkt                  */
  104. #define HTD_DACK        2               /* Wait for DEVDACK pkt              */
  105.  
  106. /* HYDRA Receiver States --------------------------------------------------- */
  107. #define HRX_DONE        0               /* All over and done                 */
  108. #define HRX_INIT        1               /* Wait for INIT pkt                 */
  109. #define HRX_FINFO       2               /* Wait for FINFO pkt of next file   */
  110. #define HRX_DATA        3               /* Wait for next DATA pkt            */
  111.  
  112. /* HYDRA Packet Types ------------------------------------------------------ */
  113. #define HPKT_START     'A'              /* Startup sequence                  */
  114. #define HPKT_INIT      'B'              /* Session initialisation            */
  115. #define HPKT_INITACK   'C'              /* Response to INIT pkt              */
  116. #define HPKT_FINFO     'D'              /* File info (name, size, time)      */
  117. #define HPKT_FINFOACK  'E'              /* Response to FINFO pkt             */
  118. #define HPKT_DATA      'F'              /* File data packet                  */
  119. #define HPKT_DATAACK   'G'              /* File data position ACK packet     */
  120. #define HPKT_RPOS      'H'              /* Transmitter reposition packet     */
  121. #define HPKT_EOF       'I'              /* End of file packet                */
  122. #define HPKT_EOFACK    'J'              /* Response to EOF packet            */
  123. #define HPKT_END       'K'              /* End of session                    */
  124. #define HPKT_IDLE      'L'              /* Idle - just saying I'm alive      */
  125. #define HPKT_DEVDATA   'M'              /* Data to specified device          */
  126. #define HPKT_DEVDACK   'N'              /* Response to DEVDATA pkt           */
  127.  
  128. #define HPKT_HIGHEST   'N'              /* Highest known pkttype in this imp */
  129.  
  130. /* HYDRA Internal Pseudo Packet Types -------------------------------------- */
  131. #define H_NOPKT         0               /* No packet (yet)                   */
  132. #define H_CANCEL      (-1)              /* Received cancel sequence 5*Ctrl-X */
  133. #define H_CARRIER     (-2)              /* Lost carrier                      */
  134. #define H_SYSABORT    (-3)              /* Aborted by operator on this side  */
  135. #define H_TXTIME      (-4)              /* Transmitter timeout               */
  136. #define H_DEVTXTIME   (-5)              /* Device transmitter timeout        */
  137. #define H_BRAINTIME   (-6)              /* Braindead timeout (quite fatal)   */
  138.  
  139. /* HYDRA Packet Format: START[<data>]<type><crc>END ------------------------ */
  140. #define HCHR_PKTEND    'a'              /* End of packet (any format)        */
  141. #define HCHR_BINPKT    'b'              /* Start of binary packet            */
  142. #define HCHR_HEXPKT    'c'              /* Start of hex encoded packet       */
  143. #define HCHR_ASCPKT    'd'              /* Start of shifted 7bit encoded pkt */
  144. #define HCHR_UUEPKT    'e'              /* Start of uuencoded packet         */
  145.  
  146. /* HYDRA Local Storage of INIT Options (Bitmapped) ------------------------- */
  147. #define HOPT_XONXOFF  (0x00000001L)     /* Escape XON/XOFF                   */
  148. #define HOPT_TELENET  (0x00000002L)     /* Escape CR-'@'-CR (Telenet escape) */
  149. #define HOPT_CTLCHRS  (0x00000004L)     /* Escape ASCII 0-31 and 127         */
  150. #define HOPT_HIGHCTL  (0x00000008L)     /* Escape above 3 with 8th bit too   */
  151. #define HOPT_HIGHBIT  (0x00000010L)     /* Escape ASCII 128-255 + strip high */
  152. #define HOPT_CANBRK   (0x00000020L)     /* Can transmit a break signal       */
  153. #define HOPT_CANASC   (0x00000040L)     /* Can transmit/handle ASC packets   */
  154. #define HOPT_CANUUE   (0x00000080L)     /* Can transmit/handle UUE packets   */
  155. #define HOPT_CRC32    (0x00000100L)     /* Packets with CRC-32 allowed       */
  156. #define HOPT_DEVICE   (0x00000200L)     /* DEVICE packets allowed            */
  157. #define HOPT_FPT      (0x00000400L)     /* Can handle filenames with paths   */
  158.  
  159. /* What we can do */
  160. #define HCAN_OPTIONS  (HOPT_XONXOFF|HOPT_TELENET|HOPT_CTLCHRS|HOPT_HIGHCTL|HOPT_HIGHBIT|HOPT_CANASC|HOPT_CANUUE|HOPT_CRC32|HOPT_DEVICE)
  161. /* Vital options if we ask for any; abort if other side doesn't support them */
  162. #define HNEC_OPTIONS  (HOPT_XONXOFF|HOPT_TELENET|HOPT_CTLCHRS|HOPT_HIGHCTL|HOPT_HIGHBIT|HOPT_CANBRK)
  163. /* Non-vital options; nice if other side supports them, but doesn't matter */
  164. #define HUNN_OPTIONS  (HOPT_CANASC|HOPT_CANUUE|HOPT_CRC32|HOPT_DEVICE)
  165. /* Default options */
  166. #define HDEF_OPTIONS  (0x0L)
  167. /* rxoptions during init (needs to handle ANY link yet unknown at that point */
  168. #define HRXI_OPTIONS  (HOPT_XONXOFF|HOPT_TELENET|HOPT_CTLCHRS|HOPT_HIGHCTL|HOPT_HIGHBIT)
  169. /* ditto, but this time txoptions */
  170. #define HTXI_OPTIONS  (0x0L)
  171.  
  172. /* HYDRA Prototypes */
  173. void hydra_init   (dword want_options);
  174. void hydra_deinit (void);
  175. int  hydra        (char *txpathname, char *txalias);
  176. boolean hydra_devfree (void);
  177. boolean hydra_devsend (char *dev, byte *data, word len);
  178. boolean hydra_devfunc (char *dev, void (*func) (byte *data, word len));
  179.  
  180. /* end of hydra.h */
  181.