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