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