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