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