You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

telnet.h 10KB

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