ckctel.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338
  1. /* ckctel.h -- Symbol and macro definitions for C-Kermit telnet support */
  2. /*
  3. Authors: Jeffrey E Altman <jaltman@secure-endpoints.com>,
  4. Secure Endpoints Inc., New York City
  5. Frank da Cruz <fdc@columbia.edu>
  6. Columbia University Academic Information Systems, New York City.
  7. Copyright (C) 1985, 2009,
  8. Trustees of Columbia University in the City of New York.
  9. All rights reserved. See the C-Kermit COPYING.TXT file or the
  10. copyright text in the ckcmai.c module for disclaimer and permissions.
  11. Notes:
  12. . This file should be used in place of "arpa/telnet.h"
  13. . Only one source file should include #defines for
  14. TELCMDS, TELOPTS, TELOPT_STATES, SLC_NAMES, and AUTH_NAMES.
  15. */
  16. #ifndef CKCTEL_H
  17. #define CKCTEL_H
  18. #ifdef TNCODE
  19. /*
  20. Definitions for the TELNET protocol.
  21. can't rely on library header files for any of them.
  22. */
  23. #ifdef COMMENT
  24. /* In some compilers these are prone to sign extension */
  25. #ifndef IAC /* First the telnet commands */
  26. #define IAC 255
  27. #endif /* IAC */
  28. #ifndef DONT
  29. #define DONT 254
  30. #endif /* DONT */
  31. #ifndef DO
  32. #define DO 253
  33. #endif /* DO */
  34. #ifndef WONT
  35. #define WONT 252
  36. #endif /* WONT */
  37. #ifndef WILL
  38. #define WILL 251
  39. #endif /* WILL */
  40. #ifndef SB
  41. #define SB 250
  42. #endif /* SB */
  43. #ifndef TN_GA
  44. #define TN_GA 249
  45. #endif /* TN_GA */
  46. #ifndef TN_EL
  47. #define TN_EL 248
  48. #endif /* TN_EL */
  49. #ifndef TN_EC
  50. #define TN_EC 247
  51. #endif /* TN_EC */
  52. #ifndef TN_AYT
  53. #define TN_AYT 246
  54. #endif /* TN_AYT */
  55. #ifndef TN_AO
  56. #define TN_AO 245
  57. #endif /* TN_AO */
  58. #ifndef TN_IP
  59. #define TN_IP 244
  60. #endif /* TN_IP */
  61. #ifndef BREAK
  62. #define BREAK 243
  63. #endif /* BREAK */
  64. #ifndef TN_DM
  65. #define TN_DM 242
  66. #endif /* TN_DM */
  67. #ifndef TN_NOP
  68. #define TN_NOP 241
  69. #endif /* TN_NOP */
  70. #ifndef SE
  71. #define SE 240
  72. #endif /* SE */
  73. #ifndef TN_EOR
  74. #define TN_EOR 239
  75. #endif /* TN_EOR */
  76. #ifndef TN_ABORT
  77. #define TN_ABORT 238
  78. #endif /* TN_ABORT */
  79. #ifndef TN_SUSP
  80. #define TN_SUSP 237
  81. #endif /* TN_SUSP */
  82. #ifndef TN_EOF
  83. #define TN_EOF 236
  84. #endif /* TN_EOF */
  85. #ifndef LAST_TN_CMD
  86. #define LAST_TN_CMD 236
  87. #define TN_SAK 200 /* IBM Secure Attention Key */
  88. #endif /* LAST_TN_CMD */
  89. #define SYNCH 242 /* for telfunc calls */
  90. #else
  91. /* Hex notation seems to suppress the sugn extension effect */
  92. #ifndef IAC /* First the telnet commands */
  93. #define IAC 0xff
  94. #endif /* IAC */
  95. #ifndef DONT
  96. #define DONT 0xfe /* 254 */
  97. #endif /* DONT */
  98. #ifndef DO
  99. #define DO 0xfd /* 253 */
  100. #endif /* DO */
  101. #ifndef WONT
  102. #define WONT 0xfc /* 252 */
  103. #endif /* WONT */
  104. #ifndef WILL
  105. #define WILL 0xfb /* 251 */
  106. #endif /* WILL */
  107. #ifndef SB
  108. #define SB 0xfa /* 250 */
  109. #endif /* SB */
  110. #ifndef TN_GA
  111. #define TN_GA 0xf9 /* 249 */
  112. #endif /* TN_GA */
  113. #ifndef TN_EL
  114. #define TN_EL 0xf8 /* 248 */
  115. #endif /* TN_EL */
  116. #ifndef TN_EC
  117. #define TN_EC 0xf7 /* 247 */
  118. #endif /* TN_EC */
  119. #ifndef TN_AYT
  120. #define TN_AYT 0xf6 /* 246 */
  121. #endif /* TN_AYT */
  122. #ifndef TN_AO
  123. #define TN_AO 0xf5 /* 245 */
  124. #endif /* TN_AO */
  125. #ifndef TN_IP
  126. #define TN_IP 0xf4 /* 244 */
  127. #endif /* TN_IP */
  128. #ifndef BREAK
  129. #define BREAK 0xf3 /* 243 */
  130. #endif /* BREAK */
  131. #ifndef TN_DM
  132. #define TN_DM 0xf2 /* 242 */
  133. #endif /* TN_DM */
  134. #ifndef TN_NOP
  135. #define TN_NOP 0xf1 /* 241 */
  136. #endif /* TN_NOP */
  137. #ifndef SE
  138. #define SE 0xf0 /* 240 */
  139. #endif /* SE */
  140. #ifndef TN_EOR
  141. #define TN_EOR 0xef /* 239 */
  142. #endif /* TN_EOR */
  143. #ifndef TN_ABORT
  144. #define TN_ABORT 0xee /* 238 */
  145. #endif /* TN_ABORT */
  146. #ifndef TN_SUSP
  147. #define TN_SUSP 0xed /* 237 */
  148. #endif /* TN_SUSP */
  149. #ifndef TN_EOF
  150. #define TN_EOF 0xec /* 236 */
  151. #endif /* TN_EOF */
  152. #ifndef LAST_TN_CMD
  153. #define LAST_TN_CMD 0xec /* 236 */
  154. #define TN_SAK 0xc8 /* 200 - IBM Secure Attention Key */
  155. #endif /* LAST_TN_CMD */
  156. #define SYNCH 0xf2 /* 242 - for telfunc calls */
  157. #endif /* COMMENT */
  158. #ifdef TELCMDS
  159. char *telcmds[] = {
  160. "EOF", "SUSP", "ABORT", "EOR",
  161. "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
  162. "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0
  163. };
  164. #else /* TELCMDS */
  165. extern char *telcmds[];
  166. #endif /* TELCMDS */
  167. #define TELCMD_FIRST TN_EOF
  168. #define TELCMD_LAST IAC
  169. #define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
  170. (unsigned int)(x) >= TELCMD_FIRST || \
  171. (unsigned int)(x) == TN_SAK)
  172. #define TELCMD(x) (TELCMD_OK(x)? ((x) == TN_SAK?"SAK": \
  173. telcmds[(x)-TELCMD_FIRST]):"UNKNOWN")
  174. /* Then the options */
  175. /* NB: the following platforms have TELOPT_AUTHENTICATION defined as */
  176. /* 45 instead of 37. */
  177. #ifdef TELOPT_AUTHENTICATION
  178. #ifdef __osf__
  179. #undef TELOPT_AUTHENTICATION
  180. #endif /* __osf__ */
  181. #ifndef IRIX
  182. #undef TELOPT_AUTHENTICATION
  183. #endif /* IRIX */
  184. #ifndef ultrix
  185. #undef TELOPT_AUTHENTICATION
  186. #endif /* ultrix */
  187. #endif /* TELOPT_AUTHENTICATION */
  188. /* telnet options */
  189. #ifndef TELOPT_BINARY
  190. #define TELOPT_BINARY 0 /* 8-bit data path (RFC 856)*/
  191. #endif
  192. #ifndef TELOPT_ECHO
  193. #define TELOPT_ECHO 1 /* echo (RFC 857)*/
  194. #endif
  195. #ifndef TELOPT_RCP
  196. #define TELOPT_RCP 2 /* prepare to reconnect (NIC 50005)*/
  197. #endif
  198. #ifndef TELOPT_SGA
  199. #define TELOPT_SGA 3 /* suppress go ahead (RFC 858) */
  200. #endif
  201. #ifndef TELOPT_NAMS
  202. #define TELOPT_NAMS 4 /* approximate message size (ETHERNET) */
  203. #endif
  204. #ifndef TELOPT_STATUS
  205. #define TELOPT_STATUS 5 /* give status (RFC 859) */
  206. #endif
  207. #ifndef TELOPT_TM
  208. #define TELOPT_TM 6 /* timing mark (RFC 860) */
  209. #endif
  210. #ifndef TELOPT_RCTE
  211. #define TELOPT_RCTE 7 /* remote controlled transmission and echo */
  212. #endif /* (RFC 726) */
  213. #ifndef TELOPT_NAOL
  214. #define TELOPT_NAOL 8 /* negotiate about output line width */
  215. #endif /* (NIC 50005) */
  216. #ifndef TELOPT_NAOP
  217. #define TELOPT_NAOP 9 /* negotiate about output page size */
  218. #endif /* (NIC 50005) */
  219. #ifndef TELOPT_NAOCRD
  220. #define TELOPT_NAOCRD 10 /* negotiate about CR disposition (RFC 652) */
  221. #endif /* [Historic] */
  222. #ifndef TELOPT_NAOHTS
  223. #define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
  224. #endif /* (RFC 653) [Historic] */
  225. #ifndef TELOPT_NAOHTD
  226. #define TELOPT_NAOHTD 12 /* negotiate about horiz tab disposition */
  227. #endif /* (RFC 654) [Historic] */
  228. #ifndef TELOPT_NAOFFD
  229. #define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
  230. #endif /* (RFC 655) [Historic] */
  231. #ifndef TELOPT_NAOVTS
  232. #define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
  233. #endif /* (RFC 656) [Historic] */
  234. #ifndef TELOPT_NAOVTD
  235. #define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
  236. #endif /* (RFC 657) [Historic] */
  237. #ifndef TELOPT_NAOLFD
  238. #define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
  239. #endif /* (RFC 658) [Historic] */
  240. #ifndef TELOPT_XASCII
  241. #define TELOPT_XASCII 17 /* extended ascii character set */
  242. #endif /* (RFC 698) */
  243. #ifndef TELOPT_LOGOUT
  244. #define TELOPT_LOGOUT 18 /* force logout (RFC 727) */
  245. #endif
  246. #ifndef TELOPT_BM
  247. #define TELOPT_BM 19 /* byte macro (RFC 735) */
  248. #endif
  249. #ifndef TELOPT_DET
  250. #define TELOPT_DET 20 /* data entry terminal (RFC 1043, 732) */
  251. #endif
  252. #ifndef TELOPT_SUPDUP
  253. #define TELOPT_SUPDUP 21 /* supdup protocol (RFC 736, 734) */
  254. #endif
  255. #ifndef TELOPT_SUPDUPOUTPUT
  256. #define TELOPT_SUPDUPOUTPUT 22 /* supdup output (RFC 749) */
  257. #endif
  258. #ifndef TELOPT_SNDLOC
  259. #define TELOPT_SNDLOC 23 /* send location (RFC 779) */
  260. #endif
  261. #ifndef TELOPT_TTYPE
  262. #define TELOPT_TTYPE 24 /* terminal type (RFC 1091) */
  263. #endif
  264. #ifndef TELOPT_EOR
  265. #define TELOPT_EOR 25 /* end of record (RFC 885) */
  266. #endif
  267. #ifndef TELOPT_TUID
  268. #define TELOPT_TUID 26 /* TACACS user identification (RFC 927) */
  269. #endif
  270. #ifndef TELOPT_OUTMRK
  271. #define TELOPT_OUTMRK 27 /* output marking (RFC 933) */
  272. #endif
  273. #ifndef TELOPT_TTYLOC
  274. #define TELOPT_TTYLOC 28 /* terminal location number (RFC 946) */
  275. #endif
  276. #ifndef TELOPT_3270REGIME
  277. #define TELOPT_3270REGIME 29 /* 3270 regime (RFC 1041) */
  278. #endif
  279. #ifndef TELOPT_X3PAD
  280. #define TELOPT_X3PAD 30 /* X.3 PAD (RFC 1053) */
  281. #endif
  282. #ifndef TELOPT_NAWS
  283. #define TELOPT_NAWS 31 /* window size (RFC 1073) */
  284. #endif
  285. #ifndef TELOPT_TSPEED
  286. #define TELOPT_TSPEED 32 /* terminal speed (RFC 1079) */
  287. #endif
  288. #ifndef TELOPT_LFLOW
  289. #define TELOPT_LFLOW 33 /* remote flow control (RFC 1372) */
  290. #endif
  291. #ifndef TELOPT_LINEMODE
  292. #define TELOPT_LINEMODE 34 /* Linemode option (RFC 1184) */
  293. #endif
  294. #ifndef TELOPT_XDISPLOC
  295. #define TELOPT_XDISPLOC 35 /* X Display Location (RFC 1096) */
  296. #endif
  297. #ifndef TELOPT_OLD_ENVIRON
  298. #define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables (RFC 1408) */
  299. #endif
  300. #ifndef TELOPT_AUTHENTICATION
  301. #define TELOPT_AUTHENTICATION 37/* Authenticate (RFC 2941) */
  302. #endif
  303. #ifndef TELOPT_ENCRYPTION
  304. #define TELOPT_ENCRYPTION 38 /* Encryption option (RFC 2946) */
  305. #endif
  306. #ifndef TELOPT_NEWENVIRON
  307. #define TELOPT_NEWENVIRON 39 /* New - Environment variables (RFC 1572) */
  308. #endif
  309. #ifndef TELOPT_3270E
  310. #define TELOPT_3270E 40 /* 3270 Extended (RFC 1647) */
  311. #endif
  312. #ifndef TELOPT_XAUTH
  313. #define TELOPT_XAUTH 41 /* ??? (Earhart) */
  314. #endif
  315. #ifndef TELOPT_CHARSET
  316. #define TELOPT_CHARSET 42 /* Character-set (RFC 2066) */
  317. #endif
  318. #ifndef TELOPT_RSP
  319. #define TELOPT_RSP 43 /* Remote Serial Port (Barnes) */
  320. #endif
  321. #ifndef TELOPT_COMPORT
  322. #define TELOPT_COMPORT 44 /* Com Port Control (RFC 2217) */
  323. #endif
  324. #ifndef TELOPT_SLE
  325. #define TELOPT_SLE 45 /* Suppress Local Echo (Atmar) - [rejected] */
  326. #endif
  327. #ifndef TELOPT_START_TLS
  328. #define TELOPT_START_TLS 46 /* Telnet over Transport Layer Security */
  329. #endif /* (Boe) */
  330. #ifndef TELOPT_KERMIT
  331. #define TELOPT_KERMIT 47 /* Kermit (RFC 2840) */
  332. #endif
  333. #ifndef TELOPT_SEND_URL
  334. #define TELOPT_SEND_URL 48 /* Send URL */
  335. #endif
  336. #ifndef TELOPT_FORWARD_X
  337. #define TELOPT_FORWARD_X 49 /* X Windows Forwarding (Altman) */
  338. #endif /* TELOPT_FORWARD_X */
  339. #ifndef TELOPT_STDERR
  340. #define TELOPT_STDERR 50 /* Redirected Stderr (Altman) */
  341. #endif /* TELOPT_STDERR */
  342. #ifndef TELOPT_PRAGMA_LOGON
  343. #define TELOPT_PRAGMA_LOGON 138 /* Encrypted Logon option (PragmaSys) */
  344. #endif
  345. #ifndef TELOPT_SSPI_LOGON
  346. #define TELOPT_SSPI_LOGON 139 /* MS SSPI Logon option (PragmaSys) */
  347. #endif
  348. #ifndef TELOPT_PRAGMA_HEARTBEAT
  349. /* Server Send Heartbeat option (PragmaSys) */
  350. #define TELOPT_PRAGMA_HEARTBEAT 140
  351. #endif
  352. #define TELOPT_IBM_SAK 200 /* IBM Secure Attention Key */
  353. /*
  354. IBM Secure Attention Key (SAK) Option
  355. In addition to terminal negotiation, the telnet command allows
  356. negotiation for the Secure Attention Key (SAK)
  357. option. This option, when supported, provides the local user with
  358. a secure communication path to the remote
  359. host for tasks such as changing user IDs or passwords. If the remote
  360. host supports the SAK function, a trusted
  361. shell is opened on the remote host when the telnet send sak
  362. subcommand is issued. The SAK function can
  363. also be assigned to a single key available in telnet input mode,
  364. using the set sak subcommand.
  365. TN_SAK
  366. Sends the TELNET SAK (Secure Attention Key) sequence, which causes
  367. the remote system to invoke the trusted shell. If the SAK is not
  368. supported, then an error message is displayed that reads:
  369. Remote side does not support SAK.
  370. */
  371. #ifndef TELOPT_EXOPL
  372. #define TELOPT_EXOPL 255 /* Extended-options-list (RFC 861) */
  373. #endif
  374. #ifdef NTELOPTS
  375. #undef NTELOPTS
  376. #endif /* NTELOPTS */
  377. /* The Telnet Option space is no longer being allocated by ICANN as a */
  378. /* continuous list. In other words it is becoming sparse. But we do */
  379. /* not want to have to allocate memory for a long list of strings and */
  380. /* structs which will never be used. Therefore, the NTELOPTS define */
  381. /* can no longer be equal to TELOPT_LAST+1. In fact, the notion of */
  382. /* TELOPT_FIRST and TELOPT_LAST no longer make sense. */
  383. #define NTELOPTS 55
  384. #define TELOPT_FIRST TELOPT_BINARY
  385. #define TELOPT_LAST TELOPT_IBM_SAK
  386. /*
  387. The following macros speed us up at runtime but are too complex
  388. for some preprocessors / compilers; if your compiler bombs on ckctel.c
  389. with "Instruction table overflow" or somesuch, rebuild with -DNOTOMACROS.
  390. */
  391. #ifndef NOTOMACROS
  392. #ifndef TELOPT_MACRO
  393. #define TELOPT_MACRO
  394. #endif /* TELOPT_MACRO */
  395. #endif /* NOTOMACROS */
  396. #ifdef TELOPT_MACRO
  397. #define TELOPT_INDEX(x) (((x)>=0 && (x)<= TELOPT_STDERR)?(x):\
  398. ((x)>=TELOPT_PRAGMA_LOGON && (x)<=TELOPT_PRAGMA_HEARTBEAT)?(x)-87: \
  399. ((x) == TELOPT_IBM_SAK)?(x)-146: NTELOPTS)
  400. #define TELOPT_OK(x) (((x) >= TELOPT_BINARY && (x) <= TELOPT_STDERR) ||\
  401. ((x) >= TELOPT_PRAGMA_LOGON && (x) <= TELOPT_PRAGMA_HEARTBEAT) ||\
  402. ((x) == TELOPT_IBM_SAK))
  403. #define TELOPT(x) (TELOPT_OK(x)?telopts[TELOPT_INDEX(x)]:"UNKNOWN")
  404. #else /* TELOPT_MACRO */
  405. _PROTOTYP(int telopt_index,(int));
  406. _PROTOTYP(int telopt_ok,(int));
  407. _PROTOTYP(CHAR * telopt, (int));
  408. #define TELOPT_INDEX(x) telopt_index(x)
  409. #define TELOPT_OK(x) telopt_ok(x)
  410. #define TELOPT(x) telopt(x)
  411. #endif /* TELOPT_MACRO */
  412. #ifdef TELOPTS
  413. char *telopts[NTELOPTS+2] = {
  414. /* 0 */ "BINARY", "ECHO", "RCP", "SUPPRESS-GO-AHEAD",
  415. /* 4 */ "NAME", "STATUS", "TIMING-MARK", "RCTE",
  416. /* 8 */ "NAOL", "NAOP", "NAOCRD", "NAOHTS",
  417. /* 12 */ "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD",
  418. /* 16 */ "NAOLFD", "EXTEND-ASCII", "LOGOUT", "BYTE-MACRO",
  419. /* 20 */ "DATA-ENTRY-TERMINAL", "SUPDUP", "SUPDUP-OUTPUT", "SEND-LOCATION",
  420. /* 24 */ "TERMINAL-TYPE", "END-OF-RECORD", "TACACS-UID", "OUTPUT-MARKING",
  421. /* 28 */ "TTYLOC", "3270-REGIME", "X.3-PAD", "NAWS",
  422. /* 32 */ "TSPEED", "LFLOW", "LINEMODE", "XDISPLOC",
  423. /* 36 */ "OLD-ENVIRON", "AUTHENTICATION", "ENCRYPTION", "NEW-ENVIRONMENT",
  424. /* 40 */ "TN3270E","xauth","CHARSET", "remote-serial-port",
  425. /* 44 */ "COM-PORT-CONTROL","suppress-local-echo","START-TLS","KERMIT",
  426. /* 48 */ "send-url","FORWARD-X","stderr",
  427. /* 138 */ "pragma-logon", "sspi-logon", "pragma-heartbeat",
  428. /* 200 */ "ibm-sak",
  429. "unknown",
  430. 0
  431. };
  432. #else /*TELOPTS */
  433. extern char * telopts[];
  434. #endif /* TELOPTS */
  435. /* TELNET Newline Mode */
  436. #define TNL_CR 0 /* CR sends bare carriage return */
  437. #define TNL_CRNUL 1 /* CR and NUL */
  438. #define TNL_CRLF 2 /* CR and LF */
  439. #define TNL_LF 3 /* LF instead of CR */
  440. /* TELNET Negotiation Mode */
  441. #define TN_NG_RF 0 /* Negotiation REFUSED */
  442. #define TN_NG_AC 1 /* Negotiation ACCEPTED */
  443. #define TN_NG_RQ 2 /* Negotiation REQUESTED */
  444. #define TN_NG_MU 3 /* Negotiation REQUIRED (must) */
  445. /* Systems where we know we can define TELNET NAWS automatically. */
  446. #ifndef CK_NAWS /* In other words, if both */
  447. #ifdef CK_TTGWSIZ /* TNCODE and TTGWSIZ are defined */
  448. #define CK_NAWS /* then we can do NAWS. */
  449. #endif /* CK_TTGWSIZ */
  450. #endif /* CK_NAWS */
  451. #ifdef CK_FORWARD_X
  452. #ifndef MAXFWDX
  453. #define MAXFWDX 64 /* Num of X windows to be fwd'd */
  454. #endif /* MAXFWDX */
  455. #endif /* CK_FORWARD_X */
  456. /* Telnet State structures and definitions */
  457. struct _telopt_state {
  458. unsigned char def_server_me_mode; /* Default Negotiation Mode */
  459. unsigned char def_server_u_mode; /* Default Negotiation Mode */
  460. unsigned char def_client_me_mode; /* Default Negotiation Mode */
  461. unsigned char def_client_u_mode; /* Default Negotiation Mode */
  462. unsigned char me_mode; /* Telnet Negotiation Mode */
  463. unsigned char u_mode; /* Telnet Negotiation Mode */
  464. unsigned char me; /* Am I ? */
  465. unsigned char u; /* Are you? */
  466. unsigned char unanswered_will; /* Sent Will, Waiting for DO/DONT */
  467. unsigned char unanswered_do; /* Send DO, Waiting for WILL/WONT */
  468. unsigned char unanswered_wont; /* Sent WONT, Waiting for DONT */
  469. unsigned char unanswered_dont; /* Sent DONT, Waiting for WONT */
  470. unsigned char unanswered_sb; /* Sent SB, Waiting for SB (server) */
  471. union {
  472. #ifdef IKS_OPTION
  473. struct _telopt_kermit { /* Kermit Option States */
  474. unsigned char me_start; /* I have a Server active */
  475. unsigned char me_req_start; /* Sent Req-Start, Waiting for response */
  476. unsigned char me_req_stop; /* Sent Req-Stop, Waiting for response */
  477. unsigned char u_start; /* You have a Server active */
  478. unsigned char sop; /* Have we received the SOP char? */
  479. } kermit;
  480. #endif /* IKS_OPTION */
  481. #ifdef CK_ENCRYPTION
  482. struct _telopt_encrypt { /* Encryption Option States */
  483. unsigned char need_to_send;
  484. unsigned char stop; /* Is encryption stopped? */
  485. } encrypt;
  486. #endif /* CK_ENCRYPTION */
  487. #ifdef CK_NAWS
  488. struct _telopt_naws { /* NAWS Option Information */
  489. unsigned char need_to_send;
  490. int x; /* Last Width */
  491. int y; /* Last Height */
  492. } naws;
  493. #endif /* CK_NAWS */
  494. #ifdef CK_SSL
  495. struct _telopt_start_tls { /* Start TLS Option */
  496. unsigned char u_follows; /* u ready for TLS negotiation */
  497. unsigned char me_follows; /* me ready for TLS negotiation */
  498. unsigned char auth_request; /* Rcvd WILL AUTH before WONT START_TLS */
  499. } start_tls;
  500. #endif /* CK_SSL */
  501. struct _telopt_term { /* Terminal Type */
  502. unsigned char need_to_send;
  503. unsigned char type[41]; /* Last terminal type */
  504. } term;
  505. #ifdef CK_ENVIRONMENT
  506. struct _telopt_new_env {
  507. unsigned char need_to_send;
  508. unsigned char * str;
  509. int len;
  510. } env;
  511. #ifdef CK_XDISPLOC
  512. struct _telopt_xdisp {
  513. unsigned char need_to_send;
  514. } xdisp;
  515. #endif /* CK_XDISPLOC */
  516. #endif /* CK_ENVIRONMENT */
  517. #ifdef CK_SNDLOC
  518. struct _telopt_sndloc {
  519. unsigned char need_to_send;
  520. } sndloc;
  521. #endif /* CK_SNDLOC */
  522. #ifdef CK_FORWARD_X
  523. struct _telopt_fwd_x {
  524. unsigned char need_to_send;
  525. int listen_socket;
  526. struct _channel {
  527. int fd;
  528. int id;
  529. unsigned char need_to_send_xauth;
  530. unsigned char suspend;
  531. } channel[MAXFWDX];
  532. #ifdef NT
  533. int thread_started;
  534. #endif /* NT */
  535. } forward_x;
  536. #endif /* CK_FORWARD_X */
  537. #ifdef TN_COMPORT
  538. struct _telopt_comport {
  539. unsigned char need_to_send;
  540. unsigned char wait_for_sb;
  541. unsigned char wait_for_ms;
  542. } comport;
  543. #endif /* TN_COMPORT */
  544. /* additional options such as New Environment or Send Location */
  545. } sb;
  546. };
  547. typedef struct _telopt_state telopt_state, *p_telopt_state;
  548. /* telopt_states[] is the array of structs which the state of each telnet */
  549. /* option is stored. We allocate one more than we need in case we are */
  550. /* sent telnet options that we do not recognize. If by some chance the */
  551. /* TELOPT_OK() check is skipped, TELOPT_INDEX() will force the option to */
  552. /* use the extra cell. */
  553. #ifdef TELOPT_STATES
  554. telopt_state telopt_states[NTELOPTS+1];
  555. #else /* TELOPT_STATES */
  556. extern telopt_state telopt_states[];
  557. #endif /* TELOPT_STATES */
  558. #define TELOPT_ME(x) (telopt_states[TELOPT_INDEX(x)].me)
  559. #define TELOPT_U(x) (telopt_states[TELOPT_INDEX(x)].u)
  560. #define TELOPT_ME_MODE(x) \
  561. (telopt_states[TELOPT_INDEX(x)].me_mode)
  562. #define TELOPT_U_MODE(x) \
  563. (telopt_states[TELOPT_INDEX(x)].u_mode)
  564. #define TELOPT_UNANSWERED_WILL(x) \
  565. (telopt_states[TELOPT_INDEX(x)].unanswered_will)
  566. #define TELOPT_UNANSWERED_DO(x) \
  567. (telopt_states[TELOPT_INDEX(x)].unanswered_do)
  568. #define TELOPT_UNANSWERED_WONT(x) \
  569. (telopt_states[TELOPT_INDEX(x)].unanswered_wont)
  570. #define TELOPT_UNANSWERED_DONT(x) \
  571. (telopt_states[TELOPT_INDEX(x)].unanswered_dont)
  572. #define TELOPT_UNANSWERED_SB(x) \
  573. (telopt_states[TELOPT_INDEX(x)].unanswered_sb)
  574. #define TELOPT_SB(x) \
  575. (telopt_states[TELOPT_INDEX(x)].sb)
  576. #define TELOPT_DEF_S_ME_MODE(x) \
  577. (telopt_states[TELOPT_INDEX(x)].def_server_me_mode)
  578. #define TELOPT_DEF_S_U_MODE(x) \
  579. (telopt_states[TELOPT_INDEX(x)].def_server_u_mode)
  580. #define TELOPT_DEF_C_ME_MODE(x) \
  581. (telopt_states[TELOPT_INDEX(x)].def_client_me_mode)
  582. #define TELOPT_DEF_C_U_MODE(x) \
  583. (telopt_states[TELOPT_INDEX(x)].def_client_u_mode)
  584. #ifdef TELOPT_MODES
  585. char * telopt_modes[4] = {
  586. "REFUSED", "ACCEPTED", "REQUESTED", "REQUIRED"
  587. };
  588. #else /* TELOPT_MODES */
  589. extern char * telopt_modes[];
  590. #endif /* TELOPT_MODES */
  591. #ifdef TELOPT_MACRO
  592. #define TELOPT_MODE_OK(x) ((unsigned int)(x) <= TN_NG_MU)
  593. #define TELOPT_MODE(x) (TELOPT_MODE_OK(x)?telopt_modes[(x)-TN_NG_RF]:"UNKNOWN")
  594. #else /* TELOPT_MACRO */
  595. _PROTOTYP(int telopt_mode_ok,(int));
  596. _PROTOTYP(CHAR * telopt_mode,(int));
  597. #define TELOPT_MODE_OK(x) telopt_mode_ok(x)
  598. #define TELOPT_MODE(x) telopt_mode(x)
  599. #endif /* TELOPT_MACRO */
  600. /* Sub-option qualifiers */
  601. #define TELQUAL_IS 0 /* option is... */
  602. #define TELQUAL_SEND 1 /* send option */
  603. #define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
  604. #define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
  605. #define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
  606. #define TEL_ENV_VAR 0
  607. #define TEL_ENV_VALUE 1
  608. #define TEL_ENV_ESC 2
  609. #define TEL_ENV_USERVAR 3
  610. #define LFLOW_OFF 0 /* Disable remote flow control */
  611. #define LFLOW_ON 1 /* Enable remote flow control */
  612. #define LFLOW_RESTART_ANY 2 /* Restart output on any char */
  613. #define LFLOW_RESTART_XON 3 /* Restart output only on XON */
  614. /*
  615. * LINEMODE suboptions
  616. */
  617. #define LM_MODE 1
  618. #define LM_FORWARDMASK 2
  619. #define LM_SLC 3
  620. #define MODE_EDIT 0x01
  621. #define MODE_TRAPSIG 0x02
  622. #define MODE_ACK 0x04
  623. #define MODE_SOFT_TAB 0x08
  624. #define MODE_LIT_ECHO 0x10
  625. #define MODE_MASK 0x1f
  626. /* Not part of protocol, but needed to simplify things... */
  627. #define MODE_FLOW 0x0100
  628. #define MODE_ECHO 0x0200
  629. #define MODE_INBIN 0x0400
  630. #define MODE_OUTBIN 0x0800
  631. #define MODE_FORCE 0x1000
  632. #define SLC_SYNCH 1
  633. #define SLC_BRK 2
  634. #define SLC_IP 3
  635. #define SLC_AO 4
  636. #define SLC_AYT 5
  637. #define SLC_EOR 6
  638. #define SLC_ABORT 7
  639. #define SLC_EOF 8
  640. #define SLC_SUSP 9
  641. #define SLC_EC 10
  642. #define SLC_EL 11
  643. #define SLC_EW 12
  644. #define SLC_RP 13
  645. #define SLC_LNEXT 14
  646. #define SLC_XON 15
  647. #define SLC_XOFF 16
  648. #define SLC_FORW1 17
  649. #define SLC_FORW2 18
  650. #define SLC_MCL 19
  651. #define SLC_MCR 20
  652. #define SLC_MCWL 21
  653. #define SLC_MCWR 22
  654. #define SLC_MCBOL 23
  655. #define SLC_MCEOL 24
  656. #define SLC_INSRT 25
  657. #define SLC_OVER 26
  658. #define SLC_ECR 27
  659. #define SLC_EWR 28
  660. #define SLC_EBOL 29
  661. #define SLC_EEOL 30
  662. #define NSLC 30
  663. /*
  664. * For backwards compatability, we define SLC_NAMES to be the
  665. * list of names if SLC_NAMES is not defined.
  666. */
  667. #define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
  668. "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
  669. "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \
  670. "MCL", "MCR", "MCWL", "MCWR", "MCBOL", "MCEOL", \
  671. "INSRT", "OVER", "ECR", "EWR", "EBOL", "EEOL", 0
  672. #ifdef SLC_NAMES
  673. char *slc_names[] = {
  674. SLC_NAMELIST
  675. };
  676. #else
  677. extern char *slc_names[];
  678. #define SLC_NAMES SLC_NAMELIST
  679. #endif
  680. #define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
  681. #define SLC_NAME(x) (SLC_NAME_OK(x)?slc_names[x]:"UNKNOWN")
  682. #define SLC_NOSUPPORT 0
  683. #define SLC_CANTCHANGE 1
  684. #define SLC_VARIABLE 2
  685. #define SLC_DEFAULT 3
  686. #define SLC_LEVELBITS 0x03
  687. #define SLC_FUNC 0
  688. #define SLC_FLAGS 1
  689. #define SLC_VALUE 2
  690. #define SLC_ACK 0x80
  691. #define SLC_FLUSHIN 0x40
  692. #define SLC_FLUSHOUT 0x20
  693. #define OLD_ENV_VAR 1
  694. #define OLD_ENV_VALUE 0
  695. #define NEW_ENV_VAR 0
  696. #define NEW_ENV_VALUE 1
  697. #define ENV_ESC 2
  698. #define ENV_USERVAR 3
  699. #define FWDX_SCREEN 0
  700. #define FWDX_OPEN 1
  701. #define FWDX_CLOSE 2
  702. #define FWDX_DATA 3
  703. #define FWDX_OPTIONS 4
  704. #define FWDX_OPT_DATA 5
  705. #define FWDX_XOFF 6
  706. #define FWDX_XON 7
  707. #define FWDX_OPT_NONE 0
  708. #define FWDX_OPT_XAUTH 1
  709. /*
  710. * AUTHENTICATION suboptions
  711. */
  712. /*
  713. * Who is authenticating who ...
  714. */
  715. #define AUTH_CLIENT_TO_SERVER 0 /* Client authenticating server */
  716. #define AUTH_SERVER_TO_CLIENT 1 /* Server authenticating client */
  717. #define AUTH_WHO_MASK 1
  718. /*
  719. * amount of authentication done
  720. */
  721. #define AUTH_HOW_ONE_WAY 0
  722. #define AUTH_HOW_MUTUAL 2
  723. #define AUTH_HOW_MASK 2
  724. /*
  725. * should we be encrypting?
  726. */
  727. #define AUTH_ENCRYPT_OFF 0
  728. #define AUTH_ENCRYPT_USING_TELOPT 4
  729. #define AUTH_ENCRYPT_AFTER_EXCHANGE 16
  730. #define AUTH_ENCRYPT_START_TLS 20
  731. #define AUTH_ENCRYPT_MASK 20
  732. /*
  733. * will we be forwarding?
  734. * if we want to activate the use of this flag then
  735. * #define USE_INI_CRED_FWD
  736. */
  737. #define INI_CRED_FWD_OFF 0
  738. #define INI_CRED_FWD_ON 8
  739. #define INI_CRED_FWD_MASK 8
  740. #define USE_INI_CRED_FWD
  741. #define AUTHTYPE_NULL 0
  742. #define AUTHTYPE_KERBEROS_V4 1
  743. #define AUTHTYPE_KERBEROS_V5 2
  744. #define AUTHTYPE_SPX 3
  745. #define AUTHTYPE_MINK 4
  746. #define AUTHTYPE_SRP 5
  747. #define AUTHTYPE_RSA 6
  748. #define AUTHTYPE_SSL 7
  749. #define AUTHTYPE_LOKI 10
  750. #define AUTHTYPE_SSA 11
  751. #define AUTHTYPE_KEA_SJ 12
  752. #define AUTHTYPE_KEA_INTEG 13
  753. #define AUTHTYPE_DSS 14
  754. #define AUTHTYPE_NTLM 15
  755. #define AUTHTYPE_GSSAPI_KRB5 16 /* Not allocated by IANA */
  756. #ifdef AUTHTYPE_CNT
  757. #undef AUTHTYPE_CNT
  758. #endif /* AUTHTYPE_CNT */
  759. #define AUTHTYPE_CNT 17
  760. /*
  761. * AUTHTYPEs Last updated 21 March 1999
  762. * from http://www.isi.edu/in-notes/iana/assignments/telnet-options
  763. */
  764. #define AUTHTYPE_AUTO 99
  765. #ifdef AUTH_NAMES
  766. char *authtype_names[] = {
  767. "NULL", /* RFC 2941 */
  768. "KERBEROS_V4", /* RFC 2941 / 1411 */
  769. "KERBEROS_V5", /* RFC 2941 */
  770. "SPX", /* RFC 2941 (not Internet Standard) */
  771. "MINK", /* RFC 2941 (not Internet Standard) */
  772. "SRP", /* RFC 2944 */
  773. "RSA", /* RFC 2941 (not Internet Standard) */
  774. "SSL", /* RFC 2941 (not Internet Standard) */
  775. "IANA_8", /* not assigned by IANA */
  776. "IANA_9", /* not assigned by IANA */
  777. "LOKI", /* RFC 2941 (not Internet Standard) */
  778. "SSA", /* Schoch */
  779. "KEA_SJ", /* RFC 2951 */
  780. "KEA_SJ_INTEG", /* RFC 2951 */
  781. "DSS", /* RFC 2943 */
  782. "NTLM", /* Kahn <louisk@microsoft.com> */
  783. "GSSAPI-KRB5", /* experimental - altman */
  784. 0
  785. };
  786. char * authmode_names[] = {
  787. "CLIENT_TO_SERVER|ONE_WAY",
  788. "SERVER_TO_CLIENT|ONE_WAY",
  789. "CLIENT_TO_SERVER|MUTUAL",
  790. "SERVER_TO_CLIENT|MUTUAL",
  791. "CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_USING_TELOPT",
  792. "SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_USING_TELOPT",
  793. "CLIENT_TO_SERVER|MUTUAL|ENCRYPT_USING_TELOPT",
  794. "SERVER_TO_CLIENT|MUTUAL|ENCRYPT_USING_TELOPT",
  795. "CLIENT_TO_SERVER|ONE_WAY|CRED_FWD",
  796. "SERVER_TO_CLIENT|ONE_WAY|CRED_FWD",
  797. "CLIENT_TO_SERVER|MUTUAL|CRED_FWD",
  798. "SERVER_TO_CLIENT|MUTUAL|CRED_FWD",
  799. "CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_USING_TELOPT|CRED_FWD",
  800. "SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_USING_TELOPT|CRED_FWD",
  801. "CLIENT_TO_SERVER|MUTUAL|ENCRYPT_USING_TELOPT|CRED_FWD",
  802. "SERVER_TO_CLIENT|MUTUAL|ENCRYPT_USING_TELOPT|CRED_FWD",
  803. "CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_AFTER_EXCHANGE",
  804. "SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_AFTER_EXCHANGE",
  805. "CLIENT_TO_SERVER|MUTUAL|ENCRYPT_AFTER_EXCHANGE",
  806. "SERVER_TO_CLIENT|MUTUAL|ENCRYPT_AFTER_EXCHANGE",
  807. "CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_START_TLS",
  808. "SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_START_TLS",
  809. "CLIENT_TO_SERVER|MUTUAL|ENCRYPT_START_TLS",
  810. "SERVER_TO_CLIENT|MUTUAL|ENCRYPT_START_TLS",
  811. "CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_AFTER_EXCHANGE|CRED_FWD",
  812. "SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_AFTER_EXCHANGE|CRED_FWD",
  813. "CLIENT_TO_SERVER|MUTUAL|ENCRYPT_AFTER_EXCHANGE|CRED_FWD",
  814. "SERVER_TO_CLIENT|MUTUAL|ENCRYPT_AFTER_EXCHANGE|CRED_FWD",
  815. "CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_START_TLS|CRED_FWD",
  816. "SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_START_TLS|CRED_FWD",
  817. "CLIENT_TO_SERVER|MUTUAL|ENCRYPT_START_TLS|CRED_FWD",
  818. "SERVER_TO_CLIENT|MUTUAL|ENCRYPT_START_TLS|CRED_FWD",
  819. 0
  820. };
  821. #else
  822. extern char *authtype_names[];
  823. extern char *authmode_names[];
  824. #endif
  825. #define AUTHMODE_CNT 32
  826. #define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
  827. #define AUTHTYPE_NAME(x) (AUTHTYPE_NAME_OK(x)?authtype_names[x]:"UNKNOWN")
  828. #define AUTHMODE_NAME_OK(x) ((unsigned int)(x) < AUTHMODE_CNT)
  829. #define AUTHMODE_NAME(x) (AUTHMODE_NAME_OK(x)?authmode_names[x]:"UNKNOWN")
  830. /* Kerberos Authentication Message Identifiers */
  831. #define KRB_AUTH 0 /* Authentication data follows */
  832. #define KRB_REJECT 1 /* Rejected (reason might follow) */
  833. #define KRB_ACCEPT 2 /* Accepted */
  834. #define KRB4_CHALLENGE 3
  835. #define KRB4_RESPONSE 4
  836. #define KRB5_RESPONSE 3 /* Response for mutual auth. */
  837. #define KRB5_FORWARD 4 /* Forwarded credentials follow */
  838. #define KRB5_FORWARD_ACCEPT 5 /* Forwarded credentials accepted */
  839. #define KRB5_FORWARD_REJECT 6 /* Forwarded credentials rejected */
  840. #define KRB5_TLS_VERIFY 7 /* TLS Finished Msg verifier */
  841. /* GSSAPI-KRB5 Authentication Message Identifiers */
  842. #define GSS_AUTH_DATA 0 /* Authentication data follows */
  843. #define GSS_REJECT 1 /* Rejected (reason might follow) */
  844. #define GSS_ACCEPT 2 /* Accepted (username might follow) */
  845. #define GSS_CONTINUE 3
  846. /* Secure Remote Password Authentication Message Identifiers */
  847. #define SRP_AUTH 0 /* Authentication data follows */
  848. #define SRP_REJECT 1 /* Rejected (reason might follow) */
  849. #define SRP_ACCEPT 2 /* Accepted */
  850. #define SRP_CHALLENGE 3
  851. #define SRP_RESPONSE 4
  852. #define SRP_EXP 8 /* */
  853. #define SRP_PARAMS 9 /* */
  854. /* Telnet Auth using KEA and SKIPJACK */
  855. #define KEA_CERTA_RA 1
  856. #define KEA_CERTB_RB_IVB_NONCEB 2
  857. #define KEA_IVA_RESPONSEB_NONCEA 3
  858. #define KEA_RESPONSEA 4
  859. /* Tim Hudson's SSL Authentication Message Identifiers */
  860. #define SSL_START 1
  861. #define SSL_ACCEPT 2
  862. #define SSL_REJECT 3
  863. /* Microsoft NTLM Authentication Message Identifiers */
  864. #define NTLM_AUTH 0
  865. #define NTLM_CHALLENGE 1
  866. #define NTLM_RESPONSE 2
  867. #define NTLM_ACCEPT 3
  868. #define NTLM_REJECT 4
  869. /* Generic Constants */
  870. #define AUTH_SUCCESS 0
  871. #define AUTH_FAILURE 255
  872. /*
  873. * ENCRYPTion suboptions
  874. */
  875. #define ENCRYPT_IS 0 /* I pick encryption type ... */
  876. #define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
  877. #define ENCRYPT_REPLY 2 /* Initial setup response */
  878. #define ENCRYPT_START 3 /* Am starting to send encrypted */
  879. #define ENCRYPT_END 4 /* Am ending encrypted */
  880. #define ENCRYPT_REQSTART 5 /* Request you start encrypting */
  881. #define ENCRYPT_REQEND 6 /* Request you send encrypting */
  882. #define ENCRYPT_ENC_KEYID 7
  883. #define ENCRYPT_DEC_KEYID 8
  884. #define ENCRYPT_CNT 9
  885. #define ENCTYPE_ANY 0
  886. #define ENCTYPE_DES_CFB64 1
  887. #define ENCTYPE_DES_OFB64 2
  888. #define ENCTYPE_DES3_CFB64 3
  889. #define ENCTYPE_DES3_OFB64 4
  890. #define ENCTYPE_CAST5_40_CFB64 8
  891. #define ENCTYPE_CAST5_40_OFB64 9
  892. #define ENCTYPE_CAST128_CFB64 10
  893. #define ENCTYPE_CAST128_OFB64 11
  894. #ifdef ENCTYPE_CNT
  895. #undef ENCTYPE_CNT
  896. #endif
  897. #define ENCTYPE_CNT 12
  898. #ifdef ENCRYPT_NAMES
  899. char *encrypt_names[] = {
  900. "IS", "SUPPORT", "REPLY", "START", "END",
  901. "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
  902. 0
  903. };
  904. char *enctype_names[] = {
  905. "ANY",
  906. "DES_CFB64", /* RFC 2952 */
  907. "DES_OFB64", /* RFC 2953 */
  908. "DES3_CFB64", /* RFC 2947 */
  909. "DES3_OFB64", /* RFC 2948 */
  910. "UNKNOWN-5",
  911. "UNKNOWN-6",
  912. "UNKNOWN-7",
  913. "CAST5_40_CFB64", /* RFC 2950 */
  914. "CAST5_40_OFB64", /* RFC 2949 */
  915. "CAST128_CFB64", /* RFC 2950*/
  916. "CAST128_OFB64", /* RFC 2949 */
  917. 0
  918. };
  919. #else
  920. extern char *encrypt_names[];
  921. extern char *enctype_names[];
  922. #endif
  923. #define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
  924. #define ENCRYPT_NAME(x) (ENCRYPT_NAME_OK(x)?encrypt_names[x]:"UNKNOWN")
  925. #define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
  926. #define ENCTYPE_NAME(x) (ENCTYPE_NAME_OK(x)?enctype_names[x]:"UNKNOWN")
  927. /* For setting the state of validUser */
  928. #define AUTH_REJECT 0 /* Rejected */
  929. #define AUTH_UNKNOWN 1 /* We don't know who he is, but he's okay */
  930. #define AUTH_OTHER 2 /* We know him, but not his name */
  931. #define AUTH_USER 3 /* We know he name */
  932. #define AUTH_VALID 4 /* We know him, and he needs no password */
  933. /* Kermit Option Subnegotiations */
  934. #define KERMIT_START 0
  935. #define KERMIT_STOP 1
  936. #define KERMIT_REQ_START 2
  937. #define KERMIT_REQ_STOP 3
  938. #define KERMIT_SOP 4
  939. #define KERMIT_RESP_START 8
  940. #define KERMIT_RESP_STOP 9
  941. /* For SET TELNET AUTH HOW */
  942. #define TN_AUTH_HOW_ANY 0
  943. #define TN_AUTH_HOW_ONE_WAY 1
  944. #define TN_AUTH_HOW_MUTUAL 2
  945. /* For SET TELNET AUTH ENCRYPT */
  946. #define TN_AUTH_ENC_ANY 0
  947. #define TN_AUTH_ENC_NONE 1
  948. #define TN_AUTH_ENC_TELOPT 2
  949. #define TN_AUTH_ENC_EXCH 3 /* not used in Kermit */
  950. #define TN_AUTH_ENC_TLS 4
  951. /* Telnet protocol functions defined in C-Kermit */
  952. _PROTOTYP( int tn_ini, (void) ); /* Telnet protocol support */
  953. _PROTOTYP( int tn_reset, (void));
  954. _PROTOTYP( int tn_set_modes, (void));
  955. _PROTOTYP( int tn_sopt, (int, int) );
  956. _PROTOTYP( int tn_doop, (CHAR, int, int (*)(int) ) );
  957. _PROTOTYP( int tn_sttyp, (void) );
  958. _PROTOTYP( int tn_snenv, (CHAR *, int) ) ;
  959. _PROTOTYP( int tn_rnenv, (CHAR *, int) ) ;
  960. _PROTOTYP( int tn_wait, (char *) ) ;
  961. _PROTOTYP( int tn_push, (void) ) ;
  962. _PROTOTYP( int tnsndbrk, (void) );
  963. _PROTOTYP( VOID tn_debug, (char *));
  964. _PROTOTYP( int tn_hex, (CHAR *, int, CHAR *, int));
  965. _PROTOTYP( unsigned char * tn_get_display, (void));
  966. #ifdef IKS_OPTION
  967. _PROTOTYP( int tn_siks, (int) );
  968. _PROTOTYP( int iks_wait, (int, int) );
  969. #endif /* IKS_OPTION */
  970. #ifdef CK_NAWS
  971. _PROTOTYP( int tn_snaws, (void) );
  972. #endif /* CK_NAWS */
  973. #ifdef CK_XDISPLOC
  974. _PROTOTYP( int tn_sxdisploc, (void) );
  975. #endif /* CK_XDISPLOC */
  976. #ifdef CK_SNDLOC
  977. _PROTOTYP( int tn_sndloc, (void) );
  978. #endif /* CK_SNDLOC */
  979. #ifdef CK_FORWARD_X
  980. /* From Xauth.h */
  981. typedef struct xauth {
  982. unsigned short family;
  983. unsigned short address_length;
  984. char *address;
  985. unsigned short number_length;
  986. char *number;
  987. unsigned short name_length;
  988. char *name;
  989. unsigned short data_length;
  990. char *data;
  991. } Xauth;
  992. #include <stdio.h>
  993. /* from X.h */
  994. #define FamilyInternet 0
  995. #define FamilyDECnet 1
  996. #define FamilyChaos 2
  997. # define FamilyLocal (256) /* not part of X standard (i.e. X.h) */
  998. # define FamilyWild (65535)
  999. # define FamilyNetname (254) /* not part of X standard */
  1000. # define FamilyKrb5Principal (253) /* Kerberos 5 principal name */
  1001. # define FamilyLocalHost (252) /* for local non-net authentication */
  1002. char *XauFileName();
  1003. Xauth *XauReadAuth(
  1004. FILE* /* auth_file */
  1005. );
  1006. int XauWriteAuth(
  1007. FILE* /* auth_file */,
  1008. Xauth* /* auth */
  1009. );
  1010. Xauth *XauGetAuthByName(
  1011. const char* /* display_name */
  1012. );
  1013. Xauth *XauGetAuthByAddr(
  1014. unsigned int /* family */,
  1015. unsigned int /* address_length */,
  1016. const char* /* address */,
  1017. unsigned int /* number_length */,
  1018. const char* /* number */,
  1019. unsigned int /* name_length */,
  1020. const char* /* name */
  1021. );
  1022. void XauDisposeAuth(
  1023. Xauth* /* auth */
  1024. );
  1025. _PROTOTYP( int fwdx_create_listen_socket,(int));
  1026. _PROTOTYP( int fwdx_open_client_channel,(int));
  1027. _PROTOTYP( int fwdx_open_server_channel,(VOID));
  1028. _PROTOTYP( int fwdx_close_channel,(int));
  1029. _PROTOTYP( int fwdx_write_data_to_channel,(int, char *,int));
  1030. _PROTOTYP( int fwdx_send_data_from_channel,(int, char *,int));
  1031. _PROTOTYP( int fwdx_close_all,(VOID));
  1032. _PROTOTYP( int fwdx_tn_sb,(unsigned char *, int));
  1033. _PROTOTYP( int tn_sndfwdx, (void));
  1034. _PROTOTYP( int fwdx_send_close,(int));
  1035. _PROTOTYP( int fwdx_send_open,(int));
  1036. _PROTOTYP( int fwdx_client_reply_options,(char *, int));
  1037. _PROTOTYP( int fwdx_send_options,(VOID));
  1038. _PROTOTYP( VOID fwdx_check_sockets,(fd_set *));
  1039. _PROTOTYP( int fwdx_init_fd_set,(fd_set *));
  1040. _PROTOTYP( int fwdx_authorize_channel, (int, unsigned char *, int));
  1041. _PROTOTYP( int fwdx_create_fake_xauth, (char *, int, int));
  1042. _PROTOTYP( int fwdx_send_xauth_to_xserver, (int, unsigned char *, int len));
  1043. _PROTOTYP( int fwdx_server_avail, (VOID));
  1044. _PROTOTYP( int fwdx_parse_displayname, (char *, int *, char **, int *, int *, char **));
  1045. #ifdef NT
  1046. _PROTOTYP( VOID fwdx_thread,(VOID *));
  1047. #endif /* NT */
  1048. #endif /* CK_FORWARD_X */
  1049. #ifdef TN_COMPORT
  1050. #define TNC_C2S_SIGNATURE 0
  1051. #define TNC_C2S_SET_BAUDRATE 1
  1052. #define TNC_C2S_SET_DATASIZE 2
  1053. #define TNC_C2S_SET_PARITY 3
  1054. #define TNC_C2S_SET_STOPSIZE 4
  1055. #define TNC_C2S_SET_CONTROL 5
  1056. #define TNC_C2S_NOTIFY_LINESTATE 6
  1057. #define TNC_C2S_NOTIFY_MODEMSTATE 7
  1058. #define TNC_C2S_FLOW_SUSPEND 8
  1059. #define TNC_C2S_FLOW_RESUME 9
  1060. #define TNC_C2S_SET_LS_MASK 10
  1061. #define TNC_C2S_SET_MS_MASK 11
  1062. #define TNC_C2S_PURGE 12
  1063. #define TNC_S2C_SIGNATURE 100
  1064. #define TNC_S2C_SET_BAUDRATE 101
  1065. #define TNC_S2C_SET_DATASIZE 102
  1066. #define TNC_S2C_SET_PARITY 103
  1067. #define TNC_S2C_SET_STOPSIZE 104
  1068. #define TNC_S2C_SET_CONTROL 105
  1069. #define TNC_S2C_SEND_LS 106
  1070. #define TNC_S2C_SEND_MS 107
  1071. #define TNC_S2C_FLOW_SUSPEND 108
  1072. #define TNC_S2C_FLOW_RESUME 109
  1073. #define TNC_S2C_SET_LS_MASK 110
  1074. #define TNC_S2C_SET_MS_MASK 111
  1075. #define TNC_S2C_PURGE 112
  1076. /* The COMPORT values are not defined in RFC 2217 */
  1077. #define TNC_BPS_REQUEST 0
  1078. #define TNC_BPS_300 3
  1079. #define TNC_BPS_600 4
  1080. #define TNC_BPS_1200 5
  1081. #define TNC_BPS_2400 6
  1082. #define TNC_BPS_4800 7
  1083. #define TNC_BPS_9600 8
  1084. #define TNC_BPS_14400 9
  1085. #define TNC_BPS_19200 10
  1086. #define TNC_BPS_28800 11
  1087. #define TNC_BPS_38400 12
  1088. #define TNC_BPS_57600 13
  1089. #define TNC_BPS_115200 14
  1090. #define TNC_BPS_230400 15
  1091. #define TNC_BPS_460800 16
  1092. #define TNC_BPS_1500000 17
  1093. #define TNC_DS_REQUEST 0
  1094. #define TNC_DS_5 5
  1095. #define TNC_DS_6 6
  1096. #define TNC_DS_7 7
  1097. #define TNC_DS_8 8
  1098. #define TNC_PAR_REQUEST 0
  1099. #define TNC_PAR_NONE 1
  1100. #define TNC_PAR_ODD 2
  1101. #define TNC_PAR_EVEN 3
  1102. #define TNC_PAR_MARK 4
  1103. #define TNC_PAR_SPACE 5
  1104. #define TNC_SB_REQUEST 0
  1105. #define TNC_SB_1 1
  1106. #define TNC_SB_1_5 3
  1107. #define TNC_SB_2 2
  1108. #define TNC_CTL_OFLOW_REQUEST 0
  1109. #define TNC_CTL_OFLOW_NONE 1
  1110. #define TNC_CTL_OFLOW_XON_XOFF 2
  1111. #define TNC_CTL_OFLOW_RTS_CTS 3
  1112. #define TNC_CTL_OFLOW_DCD 17
  1113. #define TNC_CTL_OFLOW_DSR 19
  1114. #define TNC_CTL_BREAK_REQUEST 4
  1115. #define TNC_CTL_BREAK_ON 5
  1116. #define TNC_CTL_BREAK_OFF 6
  1117. #define TNC_CTL_DTR_REQUEST 7
  1118. #define TNC_CTL_DTR_ON 8
  1119. #define TNC_CTL_DTR_OFF 9
  1120. #define TNC_CTL_RTS_REQUEST 10
  1121. #define TNC_CTL_RTS_ON 11
  1122. #define TNC_CTL_RTS_OFF 12
  1123. #define TNC_CTL_IFLOW_REQUEST 13
  1124. #define TNC_CTL_IFLOW_NONE 14
  1125. #define TNC_CTL_IFLOW_XON_XOFF 15
  1126. #define TNC_CTL_IFLOW_RTS_CTS 16
  1127. #define TNC_CTL_IFLOW_DTR 18
  1128. #define TNC_MS_DATA_READY 1
  1129. #define TNC_MS_OVERRUN_ERROR 2
  1130. #define TNC_MS_PARITY_ERROR 4
  1131. #define TNC_MS_FRAME_ERROR 8
  1132. #define TNC_MS_BREAK_ERROR 16
  1133. #define TNC_MS_HR_EMPTY 32
  1134. #define TNC_MS_SR_EMPTY 64
  1135. #define TNC_MS_TIMEOUT_ERROR 128
  1136. #define TNC_MS_CTS_DELTA 1
  1137. #define TNC_MS_DSR_DELTA 2
  1138. #define TNC_MS_EDGE_RING 4
  1139. #define TNC_MS_RLSD_DELTA 8
  1140. #define TNC_MS_CTS_SIG 16
  1141. #define TNC_MS_DSR_SIG 32
  1142. #define TNC_MS_RI_SIG 64
  1143. #define TNC_MS_RLSD_SIG 128
  1144. #define TNC_PURGE_RECEIVE 1
  1145. #define TNC_PURGE_TRANSMIT 2
  1146. #define TNC_PURGE_BOTH 3
  1147. #ifdef TNC_NAMES
  1148. char *tnc_names[] = {
  1149. "SIGNATURE", "SET-BAUDRATE", "SET-DATARATE", "SET-PARITY", "SET-STOPSIZE",
  1150. "SET-CONTROL", "NOTIFY-LINESTATE", "NOTIFY-MODEMSTATE",
  1151. "FLOWCONTROL-SUSPEND", "FLOWCONTROL-RESUME", "SET-LINESTATE-MASK",
  1152. "SET-MODEMSTATE-MASK", "PURGE-DATA",
  1153. 0
  1154. };
  1155. #else
  1156. extern char *tnc_names[];
  1157. #endif
  1158. #define TNC_NAME_OK(x) ((x) >= 0 && (x) <= 12 || (x) >= 100 && (x) <= 112)
  1159. #define TNC_NAME(x) \
  1160. (TNC_NAME_OK(x)?tnc_names[(x)>=100?(x)-100:(x)]:"UNKNOWN")
  1161. _PROTOTYP(int tnc_init,(void));
  1162. _PROTOTYP(int tnc_wait,(CHAR *, int));
  1163. _PROTOTYP(int tnc_tn_sb,(CHAR *,int));
  1164. _PROTOTYP(CONST char * tnc_get_signature, (void));
  1165. _PROTOTYP(int tnc_send_signature, (char *));
  1166. _PROTOTYP(int tnc_set_baud,(long));
  1167. _PROTOTYP(int tnc_get_baud,(void));
  1168. _PROTOTYP(int tnc_set_datasize,(int));
  1169. _PROTOTYP(int tnc_get_datasize,(void));
  1170. _PROTOTYP(int tnc_set_parity,(int));
  1171. _PROTOTYP(int tnc_get_parity,(void));
  1172. _PROTOTYP(int tnc_set_stopsize,(int));
  1173. _PROTOTYP(int tnc_get_stopsize,(void));
  1174. _PROTOTYP(int tnc_set_oflow,(int));
  1175. _PROTOTYP(int tnc_get_oflow,(void));
  1176. _PROTOTYP(int tnc_set_iflow,(int));
  1177. _PROTOTYP(int tnc_get_iflow,(void));
  1178. _PROTOTYP(int tnc_set_break_state,(int));
  1179. _PROTOTYP(int tnc_get_break_state,(void));
  1180. _PROTOTYP(int tnc_set_dtr_state,(int));
  1181. _PROTOTYP(int tnc_get_dtr_state,(void));
  1182. _PROTOTYP(int tnc_set_rts_state,(int));
  1183. _PROTOTYP(int tnc_get_rts_state,(void));
  1184. _PROTOTYP(int tnc_set_ls_mask,(int));
  1185. _PROTOTYP(int tnc_get_ls_mask,(void));
  1186. _PROTOTYP(int tnc_get_ls,(void));
  1187. _PROTOTYP(int tnc_set_ms_mask,(int));
  1188. _PROTOTYP(int tnc_get_ms_mask,(void));
  1189. _PROTOTYP(int tnc_get_ms,(void));
  1190. _PROTOTYP(int tnc_send_purge_data,(int));
  1191. _PROTOTYP(int tnc_flow_suspended,(void));
  1192. _PROTOTYP(int tnc_suspend_flow,(void));
  1193. _PROTOTYP(int tnc_resume_flow,(void));
  1194. /* The following methods are to be called by ck?tio.c routines */
  1195. _PROTOTYP(int tnsetflow,(int));
  1196. _PROTOTYP(int tnsettings,(int,int));
  1197. _PROTOTYP(int tngmdm,(void));
  1198. _PROTOTYP(int tnsndb,(long));
  1199. _PROTOTYP(int istncomport,(void));
  1200. _PROTOTYP(int tn_sndcomport,(void));
  1201. #endif /* TN_COMPORT */
  1202. #ifndef CKCTEL_C /* These are declared in ckctel.c */
  1203. extern int tn_init; /* Telnet protocol initialized flag */
  1204. extern char *tn_term; /* Terminal type override */
  1205. extern int sstelnet; /* Server side telnet? */
  1206. extern int tn_deb; /* Telnet option debugging flag */
  1207. extern int tn_auth_krb5_des_bug; /* Telnet BUG */
  1208. #endif /* CKCTEL_C */
  1209. #define TN_MSG_LEN 12292
  1210. #endif /* TNCODE */
  1211. #endif /* CKCTEL_H */