home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / c-kermit / ckctel.h < prev    next >
C/C++ Source or Header  |  2020-01-01  |  45KB  |  1,337 lines

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