home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 036 / emxfix02.zip / emx / include / arpa / telnet.h < prev   
C/C++ Source or Header  |  1994-12-07  |  10KB  |  311 lines

  1. /*
  2.  * Copyright (c) 1983 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)telnet.h    5.14 (Berkeley) 4/3/91
  34.  */
  35.  
  36. #ifndef _TELNET_H_
  37. #define    _TELNET_H_
  38.  
  39. /*
  40.  * Definitions for the TELNET protocol.
  41.  */
  42. #define    IAC    255        /* interpret as command: */
  43. #define    DONT    254        /* you are not to use option */
  44. #define    DO    253        /* please, you use option */
  45. #define    WONT    252        /* I won't use option */
  46. #define    WILL    251        /* I will use option */
  47. #define    SB    250        /* interpret as subnegotiation */
  48. #define    GA    249        /* you may reverse the line */
  49. #define    EL    248        /* erase the current line */
  50. #define    EC    247        /* erase the current character */
  51. #define    AYT    246        /* are you there */
  52. #define    AO    245        /* abort output--but let prog finish */
  53. #define    IP    244        /* interrupt process--permanently */
  54. #define    BREAK    243        /* break */
  55. #define    DM    242        /* data mark--for connect. cleaning */
  56. #define    NOP    241        /* nop */
  57. #define    SE    240        /* end sub negotiation */
  58. #define EOR     239             /* end of record (transparent mode) */
  59. #define    ABORT    238        /* Abort process */
  60. #define    SUSP    237        /* Suspend process */
  61. #define    xEOF    236        /* End of file: EOF is already used... */
  62.  
  63. #define SYNCH    242        /* for telfunc calls */
  64.  
  65. #ifdef TELCMDS
  66. char *telcmds[] = {
  67.     "EOF", "SUSP", "ABORT", "EOR",
  68.     "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
  69.     "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
  70. };
  71. #else
  72. extern char *telcmds[];
  73. #endif
  74.  
  75. #define    TELCMD_FIRST    xEOF
  76. #define    TELCMD_LAST    IAC
  77. #define    TELCMD_OK(x)    ((x) <= TELCMD_LAST && (x) >= TELCMD_FIRST)
  78. #define    TELCMD(x)    telcmds[(x)-TELCMD_FIRST]
  79.  
  80. /* telnet options */
  81. #define TELOPT_BINARY    0    /* 8-bit data path */
  82. #define TELOPT_ECHO    1    /* echo */
  83. #define    TELOPT_RCP    2    /* prepare to reconnect */
  84. #define    TELOPT_SGA    3    /* suppress go ahead */
  85. #define    TELOPT_NAMS    4    /* approximate message size */
  86. #define    TELOPT_STATUS    5    /* give status */
  87. #define    TELOPT_TM    6    /* timing mark */
  88. #define    TELOPT_RCTE    7    /* remote controlled transmission and echo */
  89. #define TELOPT_NAOL     8    /* negotiate about output line width */
  90. #define TELOPT_NAOP     9    /* negotiate about output page size */
  91. #define TELOPT_NAOCRD    10    /* negotiate about CR disposition */
  92. #define TELOPT_NAOHTS    11    /* negotiate about horizontal tabstops */
  93. #define TELOPT_NAOHTD    12    /* negotiate about horizontal tab disposition */
  94. #define TELOPT_NAOFFD    13    /* negotiate about formfeed disposition */
  95. #define TELOPT_NAOVTS    14    /* negotiate about vertical tab stops */
  96. #define TELOPT_NAOVTD    15    /* negotiate about vertical tab disposition */
  97. #define TELOPT_NAOLFD    16    /* negotiate about output LF disposition */
  98. #define TELOPT_XASCII    17    /* extended ascic character set */
  99. #define    TELOPT_LOGOUT    18    /* force logout */
  100. #define    TELOPT_BM    19    /* byte macro */
  101. #define    TELOPT_DET    20    /* data entry terminal */
  102. #define    TELOPT_SUPDUP    21    /* supdup protocol */
  103. #define    TELOPT_SUPDUPOUTPUT 22    /* supdup output */
  104. #define    TELOPT_SNDLOC    23    /* send location */
  105. #define    TELOPT_TTYPE    24    /* terminal type */
  106. #define    TELOPT_EOR    25    /* end or record */
  107. #define    TELOPT_TUID    26    /* TACACS user identification */
  108. #define    TELOPT_OUTMRK    27    /* output marking */
  109. #define    TELOPT_TTYLOC    28    /* terminal location number */
  110. #define    TELOPT_3270REGIME 29    /* 3270 regime */
  111. #define    TELOPT_X3PAD    30    /* X.3 PAD */
  112. #define    TELOPT_NAWS    31    /* window size */
  113. #define    TELOPT_TSPEED    32    /* terminal speed */
  114. #define    TELOPT_LFLOW    33    /* remote flow control */
  115. #define TELOPT_LINEMODE    34    /* Linemode option */
  116. #define TELOPT_XDISPLOC    35    /* X Display Location */
  117. #define TELOPT_ENVIRON    36    /* Environment variables */
  118. #define    TELOPT_AUTHENTICATION 37/* Authenticate */
  119. #define    TELOPT_ENCRYPT    38    /* Encryption option */
  120. #define    TELOPT_EXOPL    255    /* extended-options-list */
  121.  
  122.  
  123. #define    NTELOPTS    (1+TELOPT_ENCRYPT)
  124. #ifdef TELOPTS
  125. char *telopts[NTELOPTS+1] = {
  126.     "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
  127.     "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
  128.     "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
  129.     "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
  130.     "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
  131.     "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
  132.     "TACACS UID", "OUTPUT MARKING", "TTYLOC",
  133.     "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
  134.     "LINEMODE", "XDISPLOC", "ENVIRON", "AUTHENTICATION",
  135.     "ENCRYPT",
  136.     0,
  137. };
  138. #define    TELOPT_FIRST    TELOPT_BINARY
  139. #define    TELOPT_LAST    TELOPT_ENCRYPT
  140. #define    TELOPT_OK(x)    ((x) <= TELOPT_LAST && (x) >= TELOPT_FIRST)
  141. #define    TELOPT(x)    telopts[(x)-TELOPT_FIRST]
  142. #endif
  143.  
  144. /* sub-option qualifiers */
  145. #define    TELQUAL_IS    0    /* option is... */
  146. #define    TELQUAL_SEND    1    /* send option */
  147. #define    TELQUAL_INFO    2    /* ENVIRON: informational version of IS */
  148. #define    TELQUAL_REPLY    2    /* AUTHENTICATION: client version of IS */
  149. #define    TELQUAL_NAME    3    /* AUTHENTICATION: client version of IS */
  150.  
  151. /*
  152.  * LINEMODE suboptions
  153.  */
  154.  
  155. #define    LM_MODE        1
  156. #define    LM_FORWARDMASK    2
  157. #define    LM_SLC        3
  158.  
  159. #define    MODE_EDIT    0x01
  160. #define    MODE_TRAPSIG    0x02
  161. #define    MODE_ACK    0x04
  162. #define MODE_SOFT_TAB    0x08
  163. #define MODE_LIT_ECHO    0x10
  164.  
  165. #define    MODE_MASK    0x1f
  166.  
  167. /* Not part of protocol, but needed to simplify things... */
  168. #define MODE_FLOW        0x0100
  169. #define MODE_ECHO        0x0200
  170. #define MODE_INBIN        0x0400
  171. #define MODE_OUTBIN        0x0800
  172. #define MODE_FORCE        0x1000
  173.  
  174. #define    SLC_SYNCH    1
  175. #define    SLC_BRK        2
  176. #define    SLC_IP        3
  177. #define    SLC_AO        4
  178. #define    SLC_AYT        5
  179. #define    SLC_EOR        6
  180. #define    SLC_ABORT    7
  181. #define    SLC_EOF        8
  182. #define    SLC_SUSP    9
  183. #define    SLC_EC        10
  184. #define    SLC_EL        11
  185. #define    SLC_EW        12
  186. #define    SLC_RP        13
  187. #define    SLC_LNEXT    14
  188. #define    SLC_XON        15
  189. #define    SLC_XOFF    16
  190. #define    SLC_FORW1    17
  191. #define    SLC_FORW2    18
  192.  
  193. #define    NSLC        18
  194.  
  195. /*
  196.  * For backwards compatability, we define SLC_NAMES to be the
  197.  * list of names if SLC_NAMES is not defined.
  198.  */
  199. #define    SLC_NAMELIST    "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
  200.             "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
  201.             "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
  202. #ifdef    SLC_NAMES
  203. char *slc_names[] = {
  204.     SLC_NAMELIST
  205. };
  206. #else
  207. extern char *slc_names[];
  208. #define    SLC_NAMES SLC_NAMELIST
  209. #endif
  210.  
  211. #define    SLC_NAME_OK(x)    ((x) >= 0 && (x) < NSLC)
  212. #define SLC_NAME(x)    slc_names[x]
  213.  
  214. #define    SLC_NOSUPPORT    0
  215. #define    SLC_CANTCHANGE    1
  216. #define    SLC_VARIABLE    2
  217. #define    SLC_DEFAULT    3
  218. #define    SLC_LEVELBITS    0x03
  219.  
  220. #define    SLC_FUNC    0
  221. #define    SLC_FLAGS    1
  222. #define    SLC_VALUE    2
  223.  
  224. #define    SLC_ACK        0x80
  225. #define    SLC_FLUSHIN    0x40
  226. #define    SLC_FLUSHOUT    0x20
  227.  
  228. #define    ENV_VALUE    0
  229. #define    ENV_VAR        1
  230. #define    ENV_ESC        2
  231.  
  232. /*
  233.  * AUTHENTICATION suboptions
  234.  */
  235.  
  236. /*
  237.  * Who is authenticating who ...
  238.  */
  239. #define    AUTH_WHO_CLIENT        0    /* Client authenticating server */
  240. #define    AUTH_WHO_SERVER        1    /* Server authenticating client */
  241. #define    AUTH_WHO_MASK        1
  242.  
  243. /*
  244.  * amount of authentication done
  245.  */
  246. #define    AUTH_HOW_ONE_WAY    0
  247. #define    AUTH_HOW_MUTUAL        2
  248. #define    AUTH_HOW_MASK        2
  249.  
  250. #define    AUTHTYPE_NULL        0
  251. #define    AUTHTYPE_KERBEROS_V4    1
  252. #define    AUTHTYPE_KERBEROS_V5    2
  253. #define    AUTHTYPE_SPX        3
  254. #define    AUTHTYPE_MINK        4
  255. #define    AUTHTYPE_CNT        5
  256.  
  257. #define    AUTHTYPE_TEST        99
  258.  
  259. #ifdef    AUTH_NAMES
  260. char *authtype_names[] = {
  261.     "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
  262. };
  263. #else
  264. extern char *authtype_names[];
  265. #endif
  266.  
  267. #define    AUTHTYPE_NAME_OK(x)    ((x) >= 0 && (x) < AUTHTYPE_CNT)
  268. #define    AUTHTYPE_NAME(x)    authtype_names[x]
  269.  
  270. /*
  271.  * ENCRYPTion suboptions
  272.  */
  273. #define    ENCRYPT_IS        0    /* I pick encryption type ... */
  274. #define    ENCRYPT_SUPPORT        1    /* I support encryption types ... */
  275. #define    ENCRYPT_REPLY        2    /* Initial setup response */
  276. #define    ENCRYPT_START        3    /* Am starting to send encrypted */
  277. #define    ENCRYPT_END        4    /* Am ending encrypted */
  278. #define    ENCRYPT_REQSTART    5    /* Request you start encrypting */
  279. #define    ENCRYPT_REQEND        6    /* Request you send encrypting */
  280. #define    ENCRYPT_ENC_KEYID    7
  281. #define    ENCRYPT_DEC_KEYID    8
  282. #define    ENCRYPT_CNT        9
  283.  
  284. #define    ENCTYPE_ANY        0
  285. #define    ENCTYPE_DES_CFB64    1
  286. #define    ENCTYPE_DES_OFB64    2
  287. #define    ENCTYPE_CNT        3
  288.  
  289. #ifdef    ENCRYPT_NAMES
  290. char *encrypt_names[] = {
  291.     "IS", "SUPPORT", "REPLY", "START", "END",
  292.     "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
  293.     0,
  294. };
  295. char *enctype_names[] = {
  296.     "ANY", "DES_CFB64",  "DES_OFB64",  0,
  297. };
  298. #else
  299. extern char *encrypt_names[];
  300. extern char *enctype_names[];
  301. #endif
  302.  
  303.  
  304. #define    ENCRYPT_NAME_OK(x)    ((x) >= 0 && (x) < ENCRYPT_CNT)
  305. #define    ENCRYPT_NAME(x)        encrypt_names[x]
  306.  
  307. #define    ENCTYPE_NAME_OK(x)    ((x) >= 0 && (x) < ENCTYPE_CNT)
  308. #define    ENCTYPE_NAME(x)        enctype_names[x]
  309.  
  310. #endif /* !_TELNET_H_ */
  311.