telnet.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. #ifndef _ARPA_TELNET_H
  2. #define _ARPA_TELNET_H
  3. #define IAC 255
  4. #define DONT 254
  5. #define DO 253
  6. #define WONT 252
  7. #define WILL 251
  8. #define SB 250
  9. #define GA 249
  10. #define EL 248
  11. #define EC 247
  12. #define AYT 246
  13. #define AO 245
  14. #define IP 244
  15. #define BREAK 243
  16. #define DM 242
  17. #define NOP 241
  18. #define SE 240
  19. #define EOR 239
  20. #define ABORT 238
  21. #define SUSP 237
  22. #define xEOF 236
  23. #define SYNCH 242
  24. #define telcmds ((char [][6]){ "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0 })
  25. #define TELCMD_FIRST xEOF
  26. #define TELCMD_LAST IAC
  27. #define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
  28. (unsigned int)(x) >= TELCMD_FIRST)
  29. #define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
  30. #define TELOPT_BINARY 0
  31. #define TELOPT_ECHO 1
  32. #define TELOPT_RCP 2
  33. #define TELOPT_SGA 3
  34. #define TELOPT_NAMS 4
  35. #define TELOPT_STATUS 5
  36. #define TELOPT_TM 6
  37. #define TELOPT_RCTE 7
  38. #define TELOPT_NAOL 8
  39. #define TELOPT_NAOP 9
  40. #define TELOPT_NAOCRD 10
  41. #define TELOPT_NAOHTS 11
  42. #define TELOPT_NAOHTD 12
  43. #define TELOPT_NAOFFD 13
  44. #define TELOPT_NAOVTS 14
  45. #define TELOPT_NAOVTD 15
  46. #define TELOPT_NAOLFD 16
  47. #define TELOPT_XASCII 17
  48. #define TELOPT_LOGOUT 18
  49. #define TELOPT_BM 19
  50. #define TELOPT_DET 20
  51. #define TELOPT_SUPDUP 21
  52. #define TELOPT_SUPDUPOUTPUT 22
  53. #define TELOPT_SNDLOC 23
  54. #define TELOPT_TTYPE 24
  55. #define TELOPT_EOR 25
  56. #define TELOPT_TUID 26
  57. #define TELOPT_OUTMRK 27
  58. #define TELOPT_TTYLOC 28
  59. #define TELOPT_3270REGIME 29
  60. #define TELOPT_X3PAD 30
  61. #define TELOPT_NAWS 31
  62. #define TELOPT_TSPEED 32
  63. #define TELOPT_LFLOW 33
  64. #define TELOPT_LINEMODE 34
  65. #define TELOPT_XDISPLOC 35
  66. #define TELOPT_OLD_ENVIRON 36
  67. #define TELOPT_AUTHENTICATION 37/* Authenticate */
  68. #define TELOPT_ENCRYPT 38
  69. #define TELOPT_NEW_ENVIRON 39
  70. #define TELOPT_EXOPL 255
  71. #define NTELOPTS (1+TELOPT_NEW_ENVIRON)
  72. #ifdef TELOPTS
  73. char *telopts[NTELOPTS+1] = {
  74. "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
  75. "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
  76. "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
  77. "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
  78. "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
  79. "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
  80. "TACACS UID", "OUTPUT MARKING", "TTYLOC",
  81. "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
  82. "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
  83. "ENCRYPT", "NEW-ENVIRON",
  84. 0,
  85. };
  86. #define TELOPT_FIRST TELOPT_BINARY
  87. #define TELOPT_LAST TELOPT_NEW_ENVIRON
  88. #define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
  89. #define TELOPT(x) telopts[(x)-TELOPT_FIRST]
  90. #endif
  91. #define TELQUAL_IS 0
  92. #define TELQUAL_SEND 1
  93. #define TELQUAL_INFO 2
  94. #define TELQUAL_REPLY 2
  95. #define TELQUAL_NAME 3
  96. #define LFLOW_OFF 0
  97. #define LFLOW_ON 1
  98. #define LFLOW_RESTART_ANY 2
  99. #define LFLOW_RESTART_XON 3
  100. #define LM_MODE 1
  101. #define LM_FORWARDMASK 2
  102. #define LM_SLC 3
  103. #define MODE_EDIT 0x01
  104. #define MODE_TRAPSIG 0x02
  105. #define MODE_ACK 0x04
  106. #define MODE_SOFT_TAB 0x08
  107. #define MODE_LIT_ECHO 0x10
  108. #define MODE_MASK 0x1f
  109. #define MODE_FLOW 0x0100
  110. #define MODE_ECHO 0x0200
  111. #define MODE_INBIN 0x0400
  112. #define MODE_OUTBIN 0x0800
  113. #define MODE_FORCE 0x1000
  114. #define SLC_SYNCH 1
  115. #define SLC_BRK 2
  116. #define SLC_IP 3
  117. #define SLC_AO 4
  118. #define SLC_AYT 5
  119. #define SLC_EOR 6
  120. #define SLC_ABORT 7
  121. #define SLC_EOF 8
  122. #define SLC_SUSP 9
  123. #define SLC_EC 10
  124. #define SLC_EL 11
  125. #define SLC_EW 12
  126. #define SLC_RP 13
  127. #define SLC_LNEXT 14
  128. #define SLC_XON 15
  129. #define SLC_XOFF 16
  130. #define SLC_FORW1 17
  131. #define SLC_FORW2 18
  132. #define NSLC 18
  133. #define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
  134. "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
  135. "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
  136. #ifdef SLC_NAMES
  137. char *slc_names[] = {
  138. SLC_NAMELIST
  139. };
  140. #else
  141. extern char *slc_names[];
  142. #define SLC_NAMES SLC_NAMELIST
  143. #endif
  144. #define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
  145. #define SLC_NAME(x) slc_names[x]
  146. #define SLC_NOSUPPORT 0
  147. #define SLC_CANTCHANGE 1
  148. #define SLC_VARIABLE 2
  149. #define SLC_DEFAULT 3
  150. #define SLC_LEVELBITS 0x03
  151. #define SLC_FUNC 0
  152. #define SLC_FLAGS 1
  153. #define SLC_VALUE 2
  154. #define SLC_ACK 0x80
  155. #define SLC_FLUSHIN 0x40
  156. #define SLC_FLUSHOUT 0x20
  157. #define OLD_ENV_VAR 1
  158. #define OLD_ENV_VALUE 0
  159. #define NEW_ENV_VAR 0
  160. #define NEW_ENV_VALUE 1
  161. #define ENV_ESC 2
  162. #define ENV_USERVAR 3
  163. #define AUTH_WHO_CLIENT 0
  164. #define AUTH_WHO_SERVER 1
  165. #define AUTH_WHO_MASK 1
  166. #define AUTH_HOW_ONE_WAY 0
  167. #define AUTH_HOW_MUTUAL 2
  168. #define AUTH_HOW_MASK 2
  169. #define AUTHTYPE_NULL 0
  170. #define AUTHTYPE_KERBEROS_V4 1
  171. #define AUTHTYPE_KERBEROS_V5 2
  172. #define AUTHTYPE_SPX 3
  173. #define AUTHTYPE_MINK 4
  174. #define AUTHTYPE_CNT 5
  175. #define AUTHTYPE_TEST 99
  176. #ifdef AUTH_NAMES
  177. char *authtype_names[] = {
  178. "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
  179. };
  180. #else
  181. extern char *authtype_names[];
  182. #endif
  183. #define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
  184. #define AUTHTYPE_NAME(x) authtype_names[x]
  185. #define ENCRYPT_IS 0
  186. #define ENCRYPT_SUPPORT 1
  187. #define ENCRYPT_REPLY 2
  188. #define ENCRYPT_START 3
  189. #define ENCRYPT_END 4
  190. #define ENCRYPT_REQSTART 5
  191. #define ENCRYPT_REQEND 6
  192. #define ENCRYPT_ENC_KEYID 7
  193. #define ENCRYPT_DEC_KEYID 8
  194. #define ENCRYPT_CNT 9
  195. #define ENCTYPE_ANY 0
  196. #define ENCTYPE_DES_CFB64 1
  197. #define ENCTYPE_DES_OFB64 2
  198. #define ENCTYPE_CNT 3
  199. #ifdef ENCRYPT_NAMES
  200. char *encrypt_names[] = {
  201. "IS", "SUPPORT", "REPLY", "START", "END",
  202. "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
  203. 0,
  204. };
  205. char *enctype_names[] = {
  206. "ANY", "DES_CFB64", "DES_OFB64", 0,
  207. };
  208. #else
  209. extern char *encrypt_names[];
  210. extern char *enctype_names[];
  211. #endif
  212. #define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
  213. #define ENCRYPT_NAME(x) encrypt_names[x]
  214. #define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
  215. #define ENCTYPE_NAME(x) enctype_names[x]
  216. #endif