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