home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / cku209.tar / ckctel.h < prev    next >
C/C++ Source or Header  |  2002-04-27  |  43KB  |  1,257 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.           unsigned char wait_for_ms;
  505.       } comport;
  506. #endif /* TN_COMPORT */
  507.     /* additional options such as New Environment or Send Location */
  508.   } sb;
  509. };
  510. typedef struct _telopt_state telopt_state, *p_telopt_state;
  511.  
  512. /* telopt_states[] is the array of structs which the state of each telnet */
  513. /* option is stored.  We allocate one more than we need in case we are    */
  514. /* sent telnet options that we do not recognize.  If by some chance the   */
  515. /* TELOPT_OK() check is skipped, TELOPT_INDEX() will force the option to  */
  516. /* use the extra cell.                                                    */
  517.  
  518. #ifdef TELOPT_STATES
  519. telopt_state telopt_states[NTELOPTS+1];
  520. #else /* TELOPT_STATES */
  521. extern telopt_state telopt_states[];
  522. #endif /* TELOPT_STATES */
  523.  
  524. #define TELOPT_ME(x) (telopt_states[TELOPT_INDEX(x)].me)
  525. #define TELOPT_U(x)  (telopt_states[TELOPT_INDEX(x)].u)
  526. #define TELOPT_ME_MODE(x) \
  527.         (telopt_states[TELOPT_INDEX(x)].me_mode)
  528. #define TELOPT_U_MODE(x)  \
  529.         (telopt_states[TELOPT_INDEX(x)].u_mode)
  530. #define TELOPT_UNANSWERED_WILL(x) \
  531.         (telopt_states[TELOPT_INDEX(x)].unanswered_will)
  532. #define TELOPT_UNANSWERED_DO(x)   \
  533.         (telopt_states[TELOPT_INDEX(x)].unanswered_do)
  534. #define TELOPT_UNANSWERED_WONT(x) \
  535.         (telopt_states[TELOPT_INDEX(x)].unanswered_wont)
  536. #define TELOPT_UNANSWERED_DONT(x)   \
  537.         (telopt_states[TELOPT_INDEX(x)].unanswered_dont)
  538. #define TELOPT_UNANSWERED_SB(x)   \
  539.         (telopt_states[TELOPT_INDEX(x)].unanswered_sb)
  540. #define TELOPT_SB(x) \
  541.         (telopt_states[TELOPT_INDEX(x)].sb)
  542. #define TELOPT_DEF_S_ME_MODE(x) \
  543.         (telopt_states[TELOPT_INDEX(x)].def_server_me_mode)
  544. #define TELOPT_DEF_S_U_MODE(x)  \
  545.         (telopt_states[TELOPT_INDEX(x)].def_server_u_mode)
  546. #define TELOPT_DEF_C_ME_MODE(x) \
  547.         (telopt_states[TELOPT_INDEX(x)].def_client_me_mode)
  548. #define TELOPT_DEF_C_U_MODE(x)  \
  549.         (telopt_states[TELOPT_INDEX(x)].def_client_u_mode)
  550.  
  551. #ifdef TELOPT_MODES
  552. char * telopt_modes[4] = {
  553.     "REFUSED", "ACCEPTED", "REQUESTED", "REQUIRED"
  554. };
  555. #else /* TELOPT_MODES */
  556. extern char * telopt_modes[];
  557. #endif /* TELOPT_MODES */
  558.  
  559. #ifdef TELOPT_MACRO
  560. #define TELOPT_MODE_OK(x) ((unsigned int)(x) <= TN_NG_MU)
  561. #define TELOPT_MODE(x) (TELOPT_MODE_OK(x)?telopt_modes[(x)-TN_NG_RF]:"UNKNOWN")
  562. #else /* TELOPT_MACRO */
  563. _PROTOTYP(int telopt_mode_ok,(int));
  564. _PROTOTYP(CHAR * telopt_mode,(int));
  565.  
  566. #define TELOPT_MODE_OK(x) telopt_mode_ok(x)
  567. #define TELOPT_MODE(x)    telopt_mode(x)
  568. #endif /* TELOPT_MACRO */
  569.  
  570. /* Sub-option qualifiers */
  571. #define TELQUAL_IS      0       /* option is... */
  572. #define TELQUAL_SEND    1       /* send option */
  573. #define TELQUAL_INFO    2       /* ENVIRON: informational version of IS */
  574. #define TELQUAL_REPLY   2       /* AUTHENTICATION: client version of IS */
  575. #define TELQUAL_NAME    3       /* AUTHENTICATION: client version of IS */
  576.  
  577. #define TEL_ENV_VAR     0
  578. #define TEL_ENV_VALUE   1
  579. #define TEL_ENV_ESC     2
  580. #define TEL_ENV_USERVAR 3
  581.  
  582. #define LFLOW_OFF               0       /* Disable remote flow control */
  583. #define LFLOW_ON                1       /* Enable remote flow control */
  584. #define LFLOW_RESTART_ANY       2       /* Restart output on any char */
  585. #define LFLOW_RESTART_XON       3       /* Restart output only on XON */
  586.  
  587. /*
  588.  * LINEMODE suboptions
  589.  */
  590.  
  591. #define LM_MODE         1
  592. #define LM_FORWARDMASK  2
  593. #define LM_SLC          3
  594.  
  595. #define MODE_EDIT       0x01
  596. #define MODE_TRAPSIG    0x02
  597. #define MODE_ACK        0x04
  598. #define MODE_SOFT_TAB   0x08
  599. #define MODE_LIT_ECHO   0x10
  600.  
  601. #define MODE_MASK       0x1f
  602.  
  603. /* Not part of protocol, but needed to simplify things... */
  604. #define MODE_FLOW               0x0100
  605. #define MODE_ECHO               0x0200
  606. #define MODE_INBIN              0x0400
  607. #define MODE_OUTBIN             0x0800
  608. #define MODE_FORCE              0x1000
  609.  
  610. #define SLC_SYNCH       1
  611. #define SLC_BRK         2
  612. #define SLC_IP          3
  613. #define SLC_AO          4
  614. #define SLC_AYT         5
  615. #define SLC_EOR         6
  616. #define SLC_ABORT       7
  617. #define SLC_EOF         8
  618. #define SLC_SUSP        9
  619. #define SLC_EC          10
  620. #define SLC_EL          11
  621. #define SLC_EW          12
  622. #define SLC_RP          13
  623. #define SLC_LNEXT       14
  624. #define SLC_XON         15
  625. #define SLC_XOFF        16
  626. #define SLC_FORW1       17
  627. #define SLC_FORW2       18
  628. #define SLC_MCL         19
  629. #define SLC_MCR         20
  630. #define SLC_MCWL        21
  631. #define SLC_MCWR        22
  632. #define SLC_MCBOL       23
  633. #define SLC_MCEOL       24
  634. #define SLC_INSRT       25
  635. #define SLC_OVER        26
  636. #define SLC_ECR         27
  637. #define SLC_EWR         28
  638. #define SLC_EBOL        29
  639. #define SLC_EEOL        30
  640.  
  641. #define NSLC            30
  642.  
  643. /*
  644.  * For backwards compatability, we define SLC_NAMES to be the
  645.  * list of names if SLC_NAMES is not defined.
  646.  */
  647. #define SLC_NAMELIST    "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
  648.                         "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
  649.                         "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \
  650.                         "MCL", "MCR", "MCWL", "MCWR", "MCBOL", "MCEOL", \
  651.                         "INSRT", "OVER", "ECR", "EWR", "EBOL", "EEOL", 0
  652. #ifdef  SLC_NAMES
  653. char *slc_names[] = {
  654.         SLC_NAMELIST
  655. };
  656. #else
  657. extern char *slc_names[];
  658. #define SLC_NAMES SLC_NAMELIST
  659. #endif
  660.  
  661. #define SLC_NAME_OK(x)  ((unsigned int)(x) <= NSLC)
  662. #define SLC_NAME(x)     (SLC_NAME_OK(x)?slc_names[x]:"UNKNOWN")
  663.  
  664. #define SLC_NOSUPPORT       0
  665. #define SLC_CANTCHANGE      1
  666. #define SLC_VARIABLE        2
  667. #define SLC_DEFAULT         3
  668. #define SLC_LEVELBITS       0x03
  669.  
  670. #define SLC_FUNC            0
  671. #define SLC_FLAGS           1
  672. #define SLC_VALUE           2
  673.  
  674. #define SLC_ACK             0x80
  675. #define SLC_FLUSHIN         0x40
  676. #define SLC_FLUSHOUT        0x20
  677.  
  678. #define OLD_ENV_VAR         1
  679. #define OLD_ENV_VALUE       0
  680. #define NEW_ENV_VAR         0
  681. #define NEW_ENV_VALUE       1
  682. #define ENV_ESC             2
  683. #define ENV_USERVAR         3
  684.  
  685. #define FWDX_SCREEN         0
  686. #define FWDX_OPEN           1
  687. #define FWDX_CLOSE          2
  688. #define FWDX_DATA           3
  689. #define FWDX_OPTIONS        4
  690. #define FWDX_OPT_DATA       5
  691. #define FWDX_XOFF           6
  692. #define FWDX_XON            7
  693.  
  694. #define FWDX_OPT_NONE       0
  695. #define FWDX_OPT_XAUTH      1
  696.  
  697. /*
  698.  * AUTHENTICATION suboptions
  699.  */
  700.  
  701. /*
  702.  * Who is authenticating who ...
  703.  */
  704. #define AUTH_CLIENT_TO_SERVER   0       /* Client authenticating server */
  705. #define AUTH_SERVER_TO_CLIENT   1       /* Server authenticating client */
  706. #define AUTH_WHO_MASK           1
  707.  
  708. /*
  709.  * amount of authentication done
  710.  */
  711. #define AUTH_HOW_ONE_WAY        0
  712. #define AUTH_HOW_MUTUAL         2
  713. #define AUTH_HOW_MASK           2
  714.  
  715. /*
  716.  * should we be encrypting?
  717.  */
  718. #define AUTH_ENCRYPT_OFF             0
  719. #define AUTH_ENCRYPT_USING_TELOPT    4
  720. #define AUTH_ENCRYPT_AFTER_EXCHANGE 16
  721. #define AUTH_ENCRYPT_START_TLS      20
  722. #define AUTH_ENCRYPT_MASK           20
  723.  
  724. /*
  725.  * will we be forwarding?
  726.  * if we want to activate the use of this flag then
  727.  *   #define USE_INI_CRED_FWD
  728.  */
  729. #define INI_CRED_FWD_OFF        0
  730. #define INI_CRED_FWD_ON         8
  731. #define INI_CRED_FWD_MASK       8
  732. #define USE_INI_CRED_FWD
  733.  
  734. #define AUTHTYPE_NULL           0
  735. #define AUTHTYPE_KERBEROS_V4    1
  736. #define AUTHTYPE_KERBEROS_V5    2
  737. #define AUTHTYPE_SPX            3
  738. #define AUTHTYPE_MINK           4
  739. #define AUTHTYPE_SRP            5
  740. #define AUTHTYPE_RSA            6
  741. #define AUTHTYPE_SSL            7
  742. #define AUTHTYPE_LOKI          10
  743. #define AUTHTYPE_SSA           11
  744. #define AUTHTYPE_KEA_SJ        12
  745. #define AUTHTYPE_KEA_INTEG     13
  746. #define AUTHTYPE_DSS           14
  747. #define AUTHTYPE_NTLM          15
  748. #define AUTHTYPE_GSSAPI_KRB5   16               /* Not allocated by IANA */
  749. #ifdef AUTHTYPE_CNT
  750. #undef AUTHTYPE_CNT
  751. #endif /* AUTHTYPE_CNT */
  752. #define AUTHTYPE_CNT           17
  753.  
  754. /*
  755.  * AUTHTYPEs Last updated 21 March 1999
  756.  * from http://www.isi.edu/in-notes/iana/assignments/telnet-options
  757.  */
  758.  
  759. #define AUTHTYPE_AUTO           99
  760.  
  761. #ifdef  AUTH_NAMES
  762. char *authtype_names[] = {
  763.     "NULL",                     /* RFC 2941 */
  764.     "KERBEROS_V4",              /* RFC 2941 / 1411 */
  765.     "KERBEROS_V5",              /* RFC 2941 */
  766.     "SPX",                      /* RFC 2941 (not Internet Standard) */
  767.     "MINK",                     /* RFC 2941 (not Internet Standard) */
  768.     "SRP",                      /* RFC 2944 */
  769.     "RSA",                      /* RFC 2941 (not Internet Standard) */
  770.     "SSL",                      /* RFC 2941 (not Internet Standard) */
  771.     "IANA_8",                   /* not assigned by IANA */
  772.     "IANA_9",                   /* not assigned by IANA */
  773.     "LOKI",                     /* RFC 2941 (not Internet Standard) */
  774.     "SSA",                      /* Schoch */
  775.     "KEA_SJ",                   /* RFC 2951 */
  776.     "KEA_SJ_INTEG",             /* RFC 2951 */
  777.     "DSS",                      /* RFC 2943 */
  778.     "NTLM",                     /* Kahn <louisk@microsoft.com> */
  779.     "GSSAPI-KRB5",              /* experimental - altman */
  780.     0
  781. };
  782. char * authmode_names[] = {
  783.     "CLIENT_TO_SERVER|ONE_WAY",
  784.     "SERVER_TO_CLIENT|ONE_WAY",
  785.     "CLIENT_TO_SERVER|MUTUAL",
  786.     "SERVER_TO_CLIENT|MUTUAL",
  787.     "CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_USING_TELOPT",
  788.     "SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_USING_TELOPT",
  789.     "CLIENT_TO_SERVER|MUTUAL|ENCRYPT_USING_TELOPT",
  790.     "SERVER_TO_CLIENT|MUTUAL|ENCRYPT_USING_TELOPT",
  791.     "CLIENT_TO_SERVER|ONE_WAY|CRED_FWD",
  792.     "SERVER_TO_CLIENT|ONE_WAY|CRED_FWD",
  793.     "CLIENT_TO_SERVER|MUTUAL|CRED_FWD",
  794.     "SERVER_TO_CLIENT|MUTUAL|CRED_FWD",
  795.     "CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_USING_TELOPT|CRED_FWD",
  796.     "SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_USING_TELOPT|CRED_FWD",
  797.     "CLIENT_TO_SERVER|MUTUAL|ENCRYPT_USING_TELOPT|CRED_FWD",
  798.     "SERVER_TO_CLIENT|MUTUAL|ENCRYPT_USING_TELOPT|CRED_FWD",
  799.     "CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_AFTER_EXCHANGE",
  800.     "SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_AFTER_EXCHANGE",
  801.     "CLIENT_TO_SERVER|MUTUAL|ENCRYPT_AFTER_EXCHANGE",
  802.     "SERVER_TO_CLIENT|MUTUAL|ENCRYPT_AFTER_EXCHANGE",
  803.     "CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_START_TLS",
  804.     "SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_START_TLS",
  805.     "CLIENT_TO_SERVER|MUTUAL|ENCRYPT_START_TLS",
  806.     "SERVER_TO_CLIENT|MUTUAL|ENCRYPT_START_TLS",
  807.     "CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_AFTER_EXCHANGE|CRED_FWD",
  808.     "SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_AFTER_EXCHANGE|CRED_FWD",
  809.     "CLIENT_TO_SERVER|MUTUAL|ENCRYPT_AFTER_EXCHANGE|CRED_FWD",
  810.     "SERVER_TO_CLIENT|MUTUAL|ENCRYPT_AFTER_EXCHANGE|CRED_FWD",
  811.     "CLIENT_TO_SERVER|ONE_WAY|ENCRYPT_START_TLS|CRED_FWD",
  812.     "SERVER_TO_CLIENT|ONE_WAY|ENCRYPT_START_TLS|CRED_FWD",
  813.     "CLIENT_TO_SERVER|MUTUAL|ENCRYPT_START_TLS|CRED_FWD",
  814.     "SERVER_TO_CLIENT|MUTUAL|ENCRYPT_START_TLS|CRED_FWD",
  815.     0
  816. };
  817. #else
  818. extern char *authtype_names[];
  819. extern char *authmode_names[];
  820. #endif
  821. #define AUTHMODE_CNT  32
  822.  
  823. #define AUTHTYPE_NAME_OK(x)     ((unsigned int)(x) < AUTHTYPE_CNT)
  824. #define AUTHTYPE_NAME(x)      (AUTHTYPE_NAME_OK(x)?authtype_names[x]:"UNKNOWN")
  825.  
  826. #define AUTHMODE_NAME_OK(x)     ((unsigned int)(x) < AUTHMODE_CNT)
  827. #define AUTHMODE_NAME(x)      (AUTHMODE_NAME_OK(x)?authmode_names[x]:"UNKNOWN")
  828.  
  829. /* Kerberos Authentication Message Identifiers */
  830. #define KRB_AUTH                0       /* Authentication data follows */
  831. #define KRB_REJECT              1       /* Rejected (reason might follow) */
  832. #define KRB_ACCEPT              2       /* Accepted */
  833. #define KRB4_CHALLENGE          3
  834. #define KRB4_RESPONSE           4
  835. #define KRB5_RESPONSE           3       /* Response for mutual auth. */
  836. #define KRB5_FORWARD            4       /* Forwarded credentials follow */
  837. #define KRB5_FORWARD_ACCEPT     5       /* Forwarded credentials accepted */
  838. #define KRB5_FORWARD_REJECT     6       /* Forwarded credentials rejected */
  839. #define KRB5_TLS_VERIFY         7       /* TLS Finished Msg verifier */
  840.  
  841. /* GSSAPI-KRB5 Authentication Message Identifiers */
  842. #define GSS_AUTH_DATA           0       /* Authentication data follows */
  843. #define GSS_REJECT              1       /* Rejected (reason might follow) */
  844. #define GSS_ACCEPT              2       /* Accepted (username might follow) */
  845. #define GSS_CONTINUE            3
  846.  
  847. /* Secure Remote Password Authentication Message Identifiers */
  848. #define SRP_AUTH                0       /* Authentication data follows */
  849. #define SRP_REJECT              1       /* Rejected (reason might follow) */
  850. #define SRP_ACCEPT              2       /* Accepted */
  851. #define SRP_CHALLENGE           3
  852. #define SRP_RESPONSE            4
  853. #define SRP_EXP                 8       /* */
  854. #define SRP_PARAMS              9       /* */
  855.  
  856. /* Telnet Auth using KEA and SKIPJACK */
  857.  
  858. #define KEA_CERTA_RA              1
  859. #define KEA_CERTB_RB_IVB_NONCEB   2
  860. #define KEA_IVA_RESPONSEB_NONCEA  3
  861. #define KEA_RESPONSEA             4
  862.  
  863. /* Tim Hudson's SSL Authentication Message Identifiers */
  864. #define SSL_START     1
  865. #define SSL_ACCEPT    2
  866. #define SSL_REJECT    3
  867.  
  868. /* Microsoft NTLM Authentication Message Identifiers */
  869. #define NTLM_AUTH   0
  870. #define NTLM_CHALLENGE 1
  871. #define NTLM_RESPONSE  2
  872. #define NTLM_ACCEPT 3
  873. #define NTLM_REJECT 4
  874.  
  875. /* Generic Constants */
  876. #define AUTH_SUCCESS    0
  877. #define AUTH_FAILURE    255
  878.  
  879. /*
  880.  * ENCRYPTion suboptions
  881.  */
  882. #define ENCRYPT_IS              0       /* I pick encryption type ... */
  883. #define ENCRYPT_SUPPORT         1       /* I support encryption types ... */
  884. #define ENCRYPT_REPLY           2       /* Initial setup response */
  885. #define ENCRYPT_START           3       /* Am starting to send encrypted */
  886. #define ENCRYPT_END             4       /* Am ending encrypted */
  887. #define ENCRYPT_REQSTART        5       /* Request you start encrypting */
  888. #define ENCRYPT_REQEND          6       /* Request you send encrypting */
  889. #define ENCRYPT_ENC_KEYID       7
  890. #define ENCRYPT_DEC_KEYID       8
  891. #define ENCRYPT_CNT             9
  892.  
  893. #define ENCTYPE_ANY             0
  894. #define ENCTYPE_DES_CFB64       1
  895. #define ENCTYPE_DES_OFB64       2
  896. #define ENCTYPE_DES3_CFB64      3
  897. #define ENCTYPE_DES3_OFB64      4
  898. #define ENCTYPE_CAST5_40_CFB64  8
  899. #define ENCTYPE_CAST5_40_OFB64  9
  900. #define ENCTYPE_CAST128_CFB64   10
  901. #define ENCTYPE_CAST128_OFB64   11
  902. #ifdef ENCTYPE_CNT
  903. #undef ENCTYPE_CNT
  904. #endif
  905. #define ENCTYPE_CNT             12
  906.  
  907. #ifdef  ENCRYPT_NAMES
  908. char *encrypt_names[] = {
  909.         "IS", "SUPPORT", "REPLY", "START", "END",
  910.         "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
  911.         0
  912. };
  913. char *enctype_names[] = {
  914.     "ANY",
  915.     "DES_CFB64",                /* RFC 2952 */
  916.     "DES_OFB64",                /* RFC 2953 */
  917.     "DES3_CFB64",               /* RFC 2947 */
  918.     "DES3_OFB64",               /* RFC 2948 */
  919.     "UNKNOWN-5",
  920.     "UNKNOWN-6",
  921.     "UNKNOWN-7",
  922.     "CAST5_40_CFB64",           /* RFC 2950 */
  923.     "CAST5_40_OFB64",           /* RFC 2949 */
  924.     "CAST128_CFB64",            /* RFC 2950*/
  925.     "CAST128_OFB64",            /* RFC 2949 */
  926.     0
  927. };
  928. #else
  929. extern char *encrypt_names[];
  930. extern char *enctype_names[];
  931. #endif
  932.  
  933. #define ENCRYPT_NAME_OK(x)      ((unsigned int)(x) < ENCRYPT_CNT)
  934. #define ENCRYPT_NAME(x)      (ENCRYPT_NAME_OK(x)?encrypt_names[x]:"UNKNOWN")
  935.  
  936. #define ENCTYPE_NAME_OK(x)      ((unsigned int)(x) < ENCTYPE_CNT)
  937. #define ENCTYPE_NAME(x)      (ENCTYPE_NAME_OK(x)?enctype_names[x]:"UNKNOWN")
  938.  
  939. /* For setting the state of validUser */
  940.  
  941. #define AUTH_REJECT     0       /* Rejected */
  942. #define AUTH_UNKNOWN    1       /* We don't know who he is, but he's okay */
  943. #define AUTH_OTHER      2       /* We know him, but not his name */
  944. #define AUTH_USER       3       /* We know he name */
  945. #define AUTH_VALID      4       /* We know him, and he needs no password */
  946.  
  947. /* Kermit Option Subnegotiations */
  948.  
  949. #define KERMIT_START      0
  950. #define KERMIT_STOP       1
  951. #define KERMIT_REQ_START  2
  952. #define KERMIT_REQ_STOP   3
  953. #define KERMIT_SOP        4
  954. #define KERMIT_RESP_START 8
  955. #define KERMIT_RESP_STOP  9
  956.  
  957. /* For SET TELNET AUTH HOW  */
  958. #define TN_AUTH_HOW_ANY     0
  959. #define TN_AUTH_HOW_ONE_WAY 1
  960. #define TN_AUTH_HOW_MUTUAL  2
  961.  
  962. /* For SET TELNET AUTH ENCRYPT */
  963. #define TN_AUTH_ENC_ANY     0
  964. #define TN_AUTH_ENC_NONE    1
  965. #define TN_AUTH_ENC_TELOPT  2
  966. #define TN_AUTH_ENC_EXCH    3  /* not used in Kermit */
  967. #define TN_AUTH_ENC_TLS     4
  968.  
  969. /* Telnet protocol functions defined in C-Kermit */
  970.  
  971. _PROTOTYP( int tn_ini, (void) );        /* Telnet protocol support */
  972. _PROTOTYP( int tn_reset, (void));
  973. _PROTOTYP( int tn_set_modes, (void));
  974. _PROTOTYP( int tn_sopt, (int, int) );
  975. _PROTOTYP( int tn_doop, (CHAR, int, int (*)(int) ) );
  976. _PROTOTYP( int tn_sttyp, (void) );
  977. _PROTOTYP( int tn_snenv, (CHAR *, int) ) ;
  978. _PROTOTYP( int tn_rnenv, (CHAR *, int) ) ;
  979. _PROTOTYP( int tn_wait, (char *) ) ;
  980. _PROTOTYP( int tn_push, (void) ) ;
  981. _PROTOTYP( int tnsndbrk, (void) );
  982. _PROTOTYP( VOID tn_debug, (char *));
  983. _PROTOTYP( int tn_hex, (CHAR *, int, CHAR *, int));
  984. _PROTOTYP( unsigned char * tn_get_display, (void));
  985. #ifdef IKS_OPTION
  986. _PROTOTYP( int tn_siks, (int) );
  987. _PROTOTYP( int iks_wait, (int, int) );
  988. #endif /* IKS_OPTION */
  989. #ifdef CK_NAWS
  990. _PROTOTYP( int tn_snaws, (void) );
  991. #endif /* CK_NAWS */
  992. #ifdef CK_XDISPLOC
  993. _PROTOTYP( int tn_sxdisploc, (void) );
  994. #endif /* CK_XDISPLOC */
  995. #ifdef CK_SNDLOC
  996. _PROTOTYP( int tn_sndloc, (void) );
  997. #endif /* CK_SNDLOC */
  998. #ifdef CK_FORWARD_X
  999. /* From Xauth.h */
  1000. typedef struct xauth {
  1001.     unsigned short   family;
  1002.     unsigned short   address_length;
  1003.     char            *address;
  1004.     unsigned short   number_length;
  1005.     char            *number;
  1006.     unsigned short   name_length;
  1007.     char            *name;
  1008.     unsigned short   data_length;
  1009.     char            *data;
  1010. } Xauth;
  1011.  
  1012. #include   <stdio.h>
  1013.  
  1014. /* from X.h */
  1015. #define FamilyInternet          0
  1016. #define FamilyDECnet            1
  1017. #define FamilyChaos             2
  1018.  
  1019. # define FamilyLocal (256)      /* not part of X standard (i.e. X.h) */
  1020. # define FamilyWild  (65535)
  1021. # define FamilyNetname    (254)   /* not part of X standard */
  1022. # define FamilyKrb5Principal (253) /* Kerberos 5 principal name */
  1023. # define FamilyLocalHost (252)  /* for local non-net authentication */
  1024. char *XauFileName();
  1025.  
  1026. Xauth *XauReadAuth(
  1027. FILE*   /* auth_file */
  1028. );
  1029.  
  1030. int XauWriteAuth(
  1031. FILE*           /* auth_file */,
  1032. Xauth*          /* auth */
  1033. );
  1034.  
  1035. Xauth *XauGetAuthByName(
  1036. const char*     /* display_name */
  1037. );
  1038.  
  1039. Xauth *XauGetAuthByAddr(
  1040. unsigned int    /* family */,
  1041. unsigned int    /* address_length */,
  1042. const char*     /* address */,
  1043. unsigned int    /* number_length */,
  1044. const char*     /* number */,
  1045. unsigned int    /* name_length */,
  1046. const char*     /* name */
  1047. );
  1048.  
  1049. void XauDisposeAuth(
  1050. Xauth*          /* auth */
  1051. );
  1052.  
  1053.  
  1054. _PROTOTYP( int fwdx_create_listen_socket,(int));
  1055. _PROTOTYP( int fwdx_open_client_channel,(int));
  1056. _PROTOTYP( int fwdx_open_server_channel,(VOID));
  1057. _PROTOTYP( int fwdx_close_channel,(int));
  1058. _PROTOTYP( int fwdx_write_data_to_channel,(int, char *,int));
  1059. _PROTOTYP( int fwdx_send_data_from_channel,(int, char *,int));
  1060. _PROTOTYP( int fwdx_close_all,(VOID));
  1061. _PROTOTYP( int fwdx_tn_sb,(unsigned char *, int));
  1062. _PROTOTYP( int tn_sndfwdx, (void));
  1063. _PROTOTYP( int fwdx_send_close,(int));
  1064. _PROTOTYP( int fwdx_send_open,(int));
  1065. _PROTOTYP( int fwdx_client_reply_options,(char *, int));
  1066. _PROTOTYP( int fwdx_send_options,(VOID));
  1067. _PROTOTYP( VOID fwdx_check_sockets,(fd_set *));
  1068. _PROTOTYP( int fwdx_init_fd_set,(fd_set *));
  1069. _PROTOTYP( int fwdx_authorize_channel, (int, unsigned char *, int));
  1070. _PROTOTYP( int fwdx_create_fake_xauth, (char *, int, int));
  1071. _PROTOTYP( int fwdx_send_xauth, (VOID));
  1072. _PROTOTYP( int fwdx_server_avail, (VOID));
  1073. #ifdef NT
  1074. _PROTOTYP( VOID fwdx_thread,(VOID *));
  1075. #endif /* NT */
  1076. #endif /* CK_FORWARD_X */
  1077.  
  1078. #ifdef TN_COMPORT
  1079. #define TNC_C2S_SIGNATURE                 0
  1080. #define TNC_C2S_SET_BAUDRATE              1
  1081. #define TNC_C2S_SET_DATASIZE              2
  1082. #define TNC_C2S_SET_PARITY                3
  1083. #define TNC_C2S_SET_STOPSIZE              4
  1084. #define TNC_C2S_SET_CONTROL               5
  1085. #define TNC_C2S_NOTIFY_LINESTATE          6
  1086. #define TNC_C2S_NOTIFY_MODEMSTATE         7
  1087. #define TNC_C2S_FLOW_SUSPEND              8
  1088. #define TNC_C2S_FLOW_RESUME               9
  1089. #define TNC_C2S_SET_LS_MASK              10
  1090. #define TNC_C2S_SET_MS_MASK              11
  1091. #define TNC_C2S_PURGE                    12
  1092. #define TNC_S2C_SIGNATURE               100
  1093. #define TNC_S2C_SET_BAUDRATE            101
  1094. #define TNC_S2C_SET_DATASIZE            102
  1095. #define TNC_S2C_SET_PARITY              103
  1096. #define TNC_S2C_SET_STOPSIZE            104
  1097. #define TNC_S2C_SET_CONTROL             105
  1098. #define TNC_S2C_SEND_LS                 106
  1099. #define TNC_S2C_SEND_MS                 107
  1100. #define TNC_S2C_FLOW_SUSPEND            108
  1101. #define TNC_S2C_FLOW_RESUME             109
  1102. #define TNC_S2C_SET_LS_MASK             110
  1103. #define TNC_S2C_SET_MS_MASK             111
  1104. #define TNC_S2C_PURGE                   112
  1105.  
  1106. /* The COMPORT values are not defined in RFC 2217 */
  1107. #define TNC_BPS_REQUEST                  0
  1108. #define TNC_BPS_300                      3
  1109. #define TNC_BPS_600                      4
  1110. #define TNC_BPS_1200                     5
  1111. #define TNC_BPS_2400                     6
  1112. #define TNC_BPS_4800                     7
  1113. #define TNC_BPS_9600                     8
  1114. #define TNC_BPS_14400                    9
  1115. #define TNC_BPS_19200                   10
  1116. #define TNC_BPS_28800                   11
  1117. #define TNC_BPS_38400                   12
  1118. #define TNC_BPS_57600                   13
  1119. #define TNC_BPS_115200                  14
  1120. #define TNC_BPS_230400                  15
  1121. #define TNC_BPS_460800                  16
  1122.  
  1123. #define TNC_DS_REQUEST                   0
  1124. #define TNC_DS_5                         5
  1125. #define TNC_DS_6                         6
  1126. #define TNC_DS_7                         7
  1127. #define TNC_DS_8                         8
  1128.  
  1129. #define TNC_PAR_REQUEST                  0
  1130. #define TNC_PAR_NONE                     1
  1131. #define TNC_PAR_ODD                      2
  1132. #define TNC_PAR_EVEN                     3
  1133. #define TNC_PAR_MARK                     4
  1134. #define TNC_PAR_SPACE                    5
  1135.  
  1136. #define TNC_SB_REQUEST                   0
  1137. #define TNC_SB_1                         1
  1138. #define TNC_SB_1_5                       3
  1139. #define TNC_SB_2                         2
  1140.  
  1141. #define TNC_CTL_OFLOW_REQUEST            0
  1142. #define TNC_CTL_OFLOW_NONE               1
  1143. #define TNC_CTL_OFLOW_XON_XOFF           2
  1144. #define TNC_CTL_OFLOW_RTS_CTS            3
  1145. #define TNC_CTL_OFLOW_DCD               17
  1146. #define TNC_CTL_OFLOW_DSR               19
  1147.  
  1148. #define TNC_CTL_BREAK_REQUEST            4
  1149. #define TNC_CTL_BREAK_ON                 5
  1150. #define TNC_CTL_BREAK_OFF                6
  1151.  
  1152. #define TNC_CTL_DTR_REQUEST              7
  1153. #define TNC_CTL_DTR_ON                   8
  1154. #define TNC_CTL_DTR_OFF                  9
  1155.  
  1156. #define TNC_CTL_RTS_REQUEST             10
  1157. #define TNC_CTL_RTS_ON                  11
  1158. #define TNC_CTL_RTS_OFF                 12
  1159.  
  1160. #define TNC_CTL_IFLOW_REQUEST           13
  1161. #define TNC_CTL_IFLOW_NONE              14
  1162. #define TNC_CTL_IFLOW_XON_XOFF          15
  1163. #define TNC_CTL_IFLOW_RTS_CTS           16
  1164. #define TNC_CTL_IFLOW_DTR               18
  1165.  
  1166. #define TNC_MS_DATA_READY                1
  1167. #define TNC_MS_OVERRUN_ERROR             2
  1168. #define TNC_MS_PARITY_ERROR              4
  1169. #define TNC_MS_FRAME_ERROR               8
  1170. #define TNC_MS_BREAK_ERROR              16
  1171. #define TNC_MS_HR_EMPTY                 32
  1172. #define TNC_MS_SR_EMPTY                 64
  1173. #define TNC_MS_TIMEOUT_ERROR           128
  1174.  
  1175. #define TNC_MS_CTS_DELTA                 1
  1176. #define TNC_MS_DSR_DELTA                 2
  1177. #define TNC_MS_EDGE_RING                 4
  1178. #define TNC_MS_RLSD_DELTA                8
  1179. #define TNC_MS_CTS_SIG                  16
  1180. #define TNC_MS_DSR_SIG                  32
  1181. #define TNC_MS_RI_SIG                   64
  1182. #define TNC_MS_RLSD_SIG                128
  1183.  
  1184. #define TNC_PURGE_RECEIVE                1
  1185. #define TNC_PURGE_TRANSMIT               2
  1186. #define TNC_PURGE_BOTH                   3
  1187.  
  1188. #ifdef  TNC_NAMES
  1189. char *tnc_names[] = {
  1190.     "SIGNATURE", "SET-BAUDRATE", "SET-DATARATE", "SET-PARITY", "SET-STOPSIZE",
  1191.     "SET-CONTROL", "NOTIFY-LINESTATE", "NOTIFY-MODEMSTATE",
  1192.     "FLOWCONTROL-SUSPEND", "FLOWCONTROL-RESUME", "SET-LINESTATE-MASK",
  1193.     "SET-MODEMSTATE-MASK", "PURGE-DATA",
  1194.     0
  1195. };
  1196. #else
  1197. extern char *tnc_names[];
  1198. #endif
  1199.  
  1200. #define TNC_NAME_OK(x)  ((x) >= 0 && (x) <= 12 || (x) >= 100 && (x) <= 112)
  1201. #define TNC_NAME(x) \
  1202.              (TNC_NAME_OK(x)?tnc_names[(x)>=100?(x)-100:(x)]:"UNKNOWN")
  1203.  
  1204. _PROTOTYP(int tnc_init,(void));
  1205. _PROTOTYP(int tnc_wait,(CHAR *, int));
  1206. _PROTOTYP(int tnc_tn_sb,(CHAR *,int));
  1207. _PROTOTYP(CONST char * tnc_get_signature, (void));
  1208. _PROTOTYP(int tnc_send_signature, (char *));
  1209. _PROTOTYP(int tnc_set_baud,(long));
  1210. _PROTOTYP(int tnc_get_baud,(void));
  1211. _PROTOTYP(int tnc_set_datasize,(int));
  1212. _PROTOTYP(int tnc_get_datasize,(void));
  1213. _PROTOTYP(int tnc_set_parity,(int));
  1214. _PROTOTYP(int tnc_get_parity,(void));
  1215. _PROTOTYP(int tnc_set_stopsize,(int));
  1216. _PROTOTYP(int tnc_get_stopsize,(void));
  1217. _PROTOTYP(int tnc_set_oflow,(int));
  1218. _PROTOTYP(int tnc_get_oflow,(void));
  1219. _PROTOTYP(int tnc_set_iflow,(int));
  1220. _PROTOTYP(int tnc_get_iflow,(void));
  1221. _PROTOTYP(int tnc_set_break_state,(int));
  1222. _PROTOTYP(int tnc_get_break_state,(void));
  1223. _PROTOTYP(int tnc_set_dtr_state,(int));
  1224. _PROTOTYP(int tnc_get_dtr_state,(void));
  1225. _PROTOTYP(int tnc_set_rts_state,(int));
  1226. _PROTOTYP(int tnc_get_rts_state,(void));
  1227. _PROTOTYP(int tnc_set_ls_mask,(int));
  1228. _PROTOTYP(int tnc_get_ls_mask,(void));
  1229. _PROTOTYP(int tnc_get_ls,(void));
  1230. _PROTOTYP(int tnc_set_ms_mask,(int));
  1231. _PROTOTYP(int tnc_get_ms_mask,(void));
  1232. _PROTOTYP(int tnc_get_ms,(void));
  1233. _PROTOTYP(int tnc_send_purge_data,(int));
  1234. _PROTOTYP(int tnc_flow_suspended,(void));
  1235. _PROTOTYP(int tnc_suspend_flow,(void));
  1236. _PROTOTYP(int tnc_resume_flow,(void));
  1237.  
  1238. /* The following methods are to be called by ck?tio.c routines */
  1239. _PROTOTYP(int tnsetflow,(int));
  1240. _PROTOTYP(int tnsettings,(int,int));
  1241. _PROTOTYP(int tngmdm,(void));
  1242. _PROTOTYP(int tnsndb,(long));
  1243. _PROTOTYP(int istncomport,(void));
  1244. _PROTOTYP(int tn_sndcomport,(void));
  1245. #endif /* TN_COMPORT */
  1246.  
  1247. #ifndef CKCTEL_C                        /* These are declared in ckctel.c */
  1248. extern int tn_init;                     /* Telnet protocol initialized flag */
  1249. extern char *tn_term;                   /* Terminal type override */
  1250. extern int sstelnet;                    /* Server side telnet? */
  1251. extern int tn_deb;                      /* Telnet option debugging flag */
  1252. #endif /* CKCTEL_C */
  1253.  
  1254. #define TN_MSG_LEN 12292
  1255. #endif /* TNCODE */
  1256. #endif /* CKCTEL_H */
  1257.