[NTDLL]
[reactos.git] / reactos / base / applications / network / telnet / src / telnet.h
1 #pragma once
2
3 /*
4 * Copyright (c) 1983 Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms are permitted provided
8 * that: (1) source distributions retain this entire copyright notice and
9 * comment, and (2) distributions including binaries display the following
10 * acknowledgement: ``This product includes software developed by the
11 * University of California, Berkeley and its contributors'' in the
12 * documentation or other materials provided with the distribution and in
13 * all advertising materials mentioning features or use of this software.
14 * Neither the name of the University nor the names of its contributors may
15 * be used to endorse or promote products derived from this software without
16 * specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * @(#)telnet.h 5.12 (Berkeley) 3/5/91
22 */
23
24 // This file modified 5/15/98 by Paul Brannan.
25 // Added (unsigned char) to the #defines.
26 // Formatted for readability.
27
28 /*
29 * Definitions for the TELNET protocol.
30 */
31 #define IAC (unsigned char)255 /* interpret as command: */
32 #define DONT (unsigned char)254 /* you are not to use option */
33 #define DO (unsigned char)253 /* please, you use option */
34 #define WONT (unsigned char)252 /* I won't use option */
35 #define WILL (unsigned char)251 /* I will use option */
36 #define SB (unsigned char)250 /* interpret as subnegotiation */
37 #define GA (unsigned char)249 /* you may reverse the line */
38 #define EL (unsigned char)248 /* erase the current line */
39 #define EC (unsigned char)247 /* erase the current character */
40 #define AYT (unsigned char)246 /* are you there */
41 #define AO (unsigned char)245 /* abort output--but let prog finish */
42 #define IP (unsigned char)244 /* interrupt process--permanently */
43 #define BREAK (unsigned char)243 /* break */
44 #define DM (unsigned char)242 /* data mark--for connect. cleaning */
45 #define NOP (unsigned char)241 /* nop */
46 #define SE (unsigned char)240 /* end sub negotiation */
47 #define EOR (unsigned char)239 /* end of record (transparent mode) */
48 #define ABORT (unsigned char)238 /* Abort process */
49 #define SUSP (unsigned char)237 /* Suspend process */
50 #define xEOF (unsigned char)236 /* End of file: EOF is already used... */
51
52 #define SYNCH (unsigned char)242 /* for telfunc calls */
53
54 #ifdef TELCMDS
55 char *telcmds[] = {
56 "EOF", "SUSP", "ABORT", "EOR",
57 "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
58 "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
59 };
60 #else
61 extern char *telcmds[];
62 #endif
63
64 #define TELCMD_FIRST xEOF
65 #define TELCMD_LAST IAC
66 #define TELCMD_OK(x) ((x) <= TELCMD_LAST && (x) >= TELCMD_FIRST)
67 #define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
68
69 /* telnet options */
70 #define TELOPT_BINARY (unsigned char)0 /* 8-bit data path */
71 #define TELOPT_ECHO (unsigned char)1 /* echo */
72 #define TELOPT_RCP (unsigned char)2 /* prepare to reconnect */
73 #define TELOPT_SGA (unsigned char)3 /* suppress go ahead */
74 #define TELOPT_NAMS (unsigned char)4 /* approximate message size */
75 #define TELOPT_STATUS (unsigned char)5 /* give status */
76 #define TELOPT_TM (unsigned char)6 /* timing mark */
77 #define TELOPT_RCTE (unsigned char)7 /* remote controlled transmission and echo */
78 #define TELOPT_NAOL (unsigned char)8 /* negotiate about output line width */
79 #define TELOPT_NAOP (unsigned char)9 /* negotiate about output page size */
80 #define TELOPT_NAOCRD (unsigned char)10 /* negotiate about CR disposition */
81 #define TELOPT_NAOHTS (unsigned char)11 /* negotiate about horizontal tabstops */
82 #define TELOPT_NAOHTD (unsigned char)12 /* negotiate about horizontal tab disposition */
83 #define TELOPT_NAOFFD (unsigned char)13 /* negotiate about formfeed disposition */
84 #define TELOPT_NAOVTS (unsigned char)14 /* negotiate about vertical tab stops */
85 #define TELOPT_NAOVTD (unsigned char)15 /* negotiate about vertical tab disposition */
86 #define TELOPT_NAOLFD (unsigned char)16 /* negotiate about output LF disposition */
87 #define TELOPT_XASCII (unsigned char)17 /* extended ascic character set */
88 #define TELOPT_LOGOUT (unsigned char)18 /* force logout */
89 #define TELOPT_BM (unsigned char)19 /* byte macro */
90 #define TELOPT_DET (unsigned char)20 /* data entry terminal */
91 #define TELOPT_SUPDUP (unsigned char)21 /* supdup protocol */
92 #define TELOPT_SUPDUPOUTPUT (unsigned char)22 /* supdup output */
93 #define TELOPT_SNDLOC (unsigned char)23 /* send location */
94 #define TELOPT_TTYPE (unsigned char)24 /* terminal type */
95 #define TELOPT_EOR (unsigned char)25 /* end or record */
96 #define TELOPT_TUID (unsigned char)26 /* TACACS user identification */
97 #define TELOPT_OUTMRK (unsigned char)27 /* output marking */
98 #define TELOPT_TTYLOC (unsigned char)28 /* terminal location number */
99 #define TELOPT_3270REGIME (unsigned char)29 /* 3270 regime */
100 #define TELOPT_X3PAD (unsigned char)30 /* X.3 PAD */
101 #define TELOPT_NAWS (unsigned char)31 /* window size */
102 #define TELOPT_TSPEED (unsigned char)32 /* terminal speed */
103 #define TELOPT_LFLOW (unsigned char)33 /* remote flow control */
104 #define TELOPT_LINEMODE (unsigned char)34 /* Linemode option */
105 #define TELOPT_XDISPLOC (unsigned char)35 /* X Display Location */
106 #define TELOPT_ENVIRON (unsigned char)36 /* Environment variables */
107 #define TELOPT_AUTHENTICATION (unsigned char)37 /* Authenticate */
108 #define TELOPT_ENCRYPT (unsigned char)38 /* Encryption option */
109 #define TELOPT_EXOPL (unsigned char)255 /* extended-options-list */
110
111
112 #define NTELOPTS (1+TELOPT_ENCRYPT)
113 #ifdef TELOPTS
114 char *telopts[NTELOPTS+1] = {
115 "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
116 "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
117 "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
118 "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
119 "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
120 "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
121 "TACACS UID", "OUTPUT MARKING", "TTYLOC",
122 "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
123 "LINEMODE", "XDISPLOC", "ENVIRON", "AUTHENTICATION",
124 "ENCRYPT",
125 0,
126 };
127 #define TELOPT_FIRST TELOPT_BINARY
128 #define TELOPT_LAST TELOPT_ENCRYPT
129 #define TELOPT_OK(x) ((x) <= TELOPT_LAST && (x) >= TELOPT_FIRST)
130 #define TELOPT(x) telopts[(x)-TELOPT_FIRST]
131 #endif
132
133 /* sub-option qualifiers */
134 #define TELQUAL_IS (unsigned char)0 /* option is... */
135 #define TELQUAL_SEND (unsigned char)1 /* send option */
136 #define TELQUAL_INFO (unsigned char)2 /* ENVIRON: informational version of IS */
137 #define TELQUAL_REPLY (unsigned char)2 /* AUTHENTICATION: client version of IS */
138 #define TELQUAL_NAME (unsigned char)3 /* AUTHENTICATION: client version of IS */
139
140 /*
141 * LINEMODE suboptions
142 */
143
144 #define LM_MODE 1
145 #define LM_FORWARDMASK 2
146 #define LM_SLC 3
147
148 #define MODE_EDIT 0x01
149 #define MODE_TRAPSIG 0x02
150 #define MODE_ACK 0x04
151 #define MODE_SOFT_TAB 0x08
152 #define MODE_LIT_ECHO 0x10
153
154 #define MODE_MASK 0x1f
155
156 /* Not part of protocol, but needed to simplify things... */
157 #define MODE_FLOW 0x0100
158 #define MODE_ECHO 0x0200
159 #define MODE_INBIN 0x0400
160 #define MODE_OUTBIN 0x0800
161 #define MODE_FORCE 0x1000
162
163 #define SLC_SYNCH 1
164 #define SLC_BRK 2
165 #define SLC_IP 3
166 #define SLC_AO 4
167 #define SLC_AYT 5
168 #define SLC_EOR 6
169 #define SLC_ABORT 7
170 #define SLC_EOF 8
171 #define SLC_SUSP 9
172 #define SLC_EC 10
173 #define SLC_EL 11
174 #define SLC_EW 12
175 #define SLC_RP 13
176 #define SLC_LNEXT 14
177 #define SLC_XON 15
178 #define SLC_XOFF 16
179 #define SLC_FORW1 17
180 #define SLC_FORW2 18
181
182 #define NSLC 18
183
184 /*
185 * For backwards compatability, we define SLC_NAMES to be the
186 * list of names if SLC_NAMES is not defined.
187 */
188 #define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
189 "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
190 "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
191 #ifdef SLC_NAMES
192 //char *slc_names[] = {
193 // SLC_NAMELIST
194 //};
195 #else
196 extern char *slc_names[];
197 #define SLC_NAMES SLC_NAMELIST
198 #endif
199
200 #define SLC_NAME_OK(x) ((x) >= 0 && (x) < NSLC)
201 #define SLC_NAME(x) slc_names[x]
202
203 #define SLC_NOSUPPORT 0
204 #define SLC_CANTCHANGE 1
205 #define SLC_VARIABLE 2
206 #define SLC_DEFAULT 3
207 #define SLC_LEVELBITS 0x03
208
209 #define SLC_FUNC 0
210 #define SLC_FLAGS 1
211 #define SLC_VALUE 2
212
213 #define SLC_ACK 0x80
214 #define SLC_FLUSHIN 0x40
215 #define SLC_FLUSHOUT 0x20
216
217 #define ENV_VALUE 0
218 #define ENV_VAR 1
219 #define ENV_ESC 2
220
221 /*
222 * AUTHENTICATION suboptions
223 */
224
225 /*
226 * Who is authenticating who ...
227 */
228 #define AUTH_WHO_CLIENT 0 /* Client authenticating server */
229 #define AUTH_WHO_SERVER 1 /* Server authenticating client */
230 #define AUTH_WHO_MASK 1
231
232 /*
233 * amount of authentication done
234 */
235 #define AUTH_HOW_ONE_WAY 0
236 #define AUTH_HOW_MUTUAL 2
237 #define AUTH_HOW_MASK 2
238
239 #define AUTHTYPE_NULL 0
240 #define AUTHTYPE_KERBEROS_V4 1
241 #define AUTHTYPE_KERBEROS_V5 2
242 #define AUTHTYPE_SPX 3
243 #define AUTHTYPE_MINK 4
244 #define AUTHTYPE_CNT 5
245
246 #define AUTHTYPE_TEST 99
247
248 #ifdef AUTH_NAMES
249 char *authtype_names[] = {
250 "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
251 };
252 #else
253 extern char *authtype_names[];
254 #endif
255
256 #define AUTHTYPE_NAME_OK(x) ((x) >= 0 && (x) < AUTHTYPE_CNT)
257 #define AUTHTYPE_NAME(x) authtype_names[x]
258
259 /*
260 * ENCRYPTion suboptions
261 */
262 #define ENCRYPT_IS 0 /* I pick encryption type ... */
263 #define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
264 #define ENCRYPT_REPLY 2 /* Initial setup response */
265 #define ENCRYPT_START 3 /* Am starting to send encrypted */
266 #define ENCRYPT_END 4 /* Am ending encrypted */
267 #define ENCRYPT_REQSTART 5 /* Request you start encrypting */
268 #define ENCRYPT_REQEND 6 /* Request you send encrypting */
269 #define ENCRYPT_ENC_KEYID 7
270 #define ENCRYPT_DEC_KEYID 8
271 #define ENCRYPT_CNT 9
272
273 #define ENCTYPE_ANY 0
274 #define ENCTYPE_DES_CFB64 1
275 #define ENCTYPE_DES_OFB64 2
276 #define ENCTYPE_CNT 3
277
278 #ifdef ENCRYPT_NAMES
279 char *encrypt_names[] = {
280 "IS", "SUPPORT", "REPLY", "START", "END",
281 "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
282 0,
283 };
284 char *enctype_names[] = {
285 "ANY", "DES_CFB64", "DES_OFB64", 0,
286 };
287 #else
288 extern char *encrypt_names[];
289 extern char *enctype_names[];
290 #endif
291
292
293 #define ENCRYPT_NAME_OK(x) ((x) >= 0 && (x) < ENCRYPT_CNT)
294 #define ENCRYPT_NAME(x) encrypt_names[x]
295
296 #define ENCTYPE_NAME_OK(x) ((x) >= 0 && (x) < ENCTYPE_CNT)
297 #define ENCTYPE_NAME(x) enctype_names[x]
298 //////////////////////////////////////////////////////
299 //////////////////////////////////////////////////////