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

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