home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / cku200.zip / ckctel.h < prev    next >
C/C++ Source or Header  |  2001-06-07  |  43KB  |  1,255 lines

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