• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *	@(#)telnet.h	8.2 (Berkeley) 12/15/93
30  * $FreeBSD$
31  */
32 
33 #ifndef _ARPA_TELNET_H_
34 #define	_ARPA_TELNET_H_
35 
36 /*
37  * Definitions for the TELNET protocol.
38  */
39 #define	IAC	255		/* interpret as command: */
40 #define	DONT	254		/* you are not to use option */
41 #define	DO	253		/* please, you use option */
42 #define	WONT	252		/* I won't use option */
43 #define	WILL	251		/* I will use option */
44 #define	SB	250		/* interpret as subnegotiation */
45 #define	GA	249		/* you may reverse the line */
46 #define	EL	248		/* erase the current line */
47 #define	EC	247		/* erase the current character */
48 #define	AYT	246		/* are you there */
49 #define	AO	245		/* abort output--but let prog finish */
50 #define	IP	244		/* interrupt process--permanently */
51 #define	BREAK	243		/* break */
52 #define	DM	242		/* data mark--for connect. cleaning */
53 #define	NOP	241		/* nop */
54 #define	SE	240		/* end sub negotiation */
55 #define EOR     239             /* end of record (transparent mode) */
56 #define	ABORT	238		/* Abort process */
57 #define	SUSP	237		/* Suspend process */
58 #define	xEOF	236		/* End of file: EOF is already used... */
59 
60 #define SYNCH	242		/* for telfunc calls */
61 
62 #ifdef TELCMDS
63 const char *telcmds[] = {
64 	"EOF", "SUSP", "ABORT", "EOR",
65 	"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
66 	"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
67 	0
68 };
69 #else
70 extern char *telcmds[];
71 #endif
72 
73 #define	TELCMD_FIRST	xEOF
74 #define	TELCMD_LAST	IAC
75 #define	TELCMD_OK(x)	((unsigned int)(x) <= TELCMD_LAST && \
76 			 (unsigned int)(x) >= TELCMD_FIRST)
77 #define	TELCMD(x)	telcmds[(x)-TELCMD_FIRST]
78 
79 /* telnet options */
80 #define TELOPT_BINARY	0	/* 8-bit data path */
81 #define TELOPT_ECHO	1	/* echo */
82 #define	TELOPT_RCP	2	/* prepare to reconnect */
83 #define	TELOPT_SGA	3	/* suppress go ahead */
84 #define	TELOPT_NAMS	4	/* approximate message size */
85 #define	TELOPT_STATUS	5	/* give status */
86 #define	TELOPT_TM	6	/* timing mark */
87 #define	TELOPT_RCTE	7	/* remote controlled transmission and echo */
88 #define TELOPT_NAOL 	8	/* negotiate about output line width */
89 #define TELOPT_NAOP 	9	/* negotiate about output page size */
90 #define TELOPT_NAOCRD	10	/* negotiate about CR disposition */
91 #define TELOPT_NAOHTS	11	/* negotiate about horizontal tabstops */
92 #define TELOPT_NAOHTD	12	/* negotiate about horizontal tab disposition */
93 #define TELOPT_NAOFFD	13	/* negotiate about formfeed disposition */
94 #define TELOPT_NAOVTS	14	/* negotiate about vertical tab stops */
95 #define TELOPT_NAOVTD	15	/* negotiate about vertical tab disposition */
96 #define TELOPT_NAOLFD	16	/* negotiate about output LF disposition */
97 #define TELOPT_XASCII	17	/* extended ascic character set */
98 #define	TELOPT_LOGOUT	18	/* force logout */
99 #define	TELOPT_BM	19	/* byte macro */
100 #define	TELOPT_DET	20	/* data entry terminal */
101 #define	TELOPT_SUPDUP	21	/* supdup protocol */
102 #define	TELOPT_SUPDUPOUTPUT 22	/* supdup output */
103 #define	TELOPT_SNDLOC	23	/* send location */
104 #define	TELOPT_TTYPE	24	/* terminal type */
105 #define	TELOPT_EOR	25	/* end or record */
106 #define	TELOPT_TUID	26	/* TACACS user identification */
107 #define	TELOPT_OUTMRK	27	/* output marking */
108 #define	TELOPT_TTYLOC	28	/* terminal location number */
109 #define	TELOPT_3270REGIME 29	/* 3270 regime */
110 #define	TELOPT_X3PAD	30	/* X.3 PAD */
111 #define	TELOPT_NAWS	31	/* window size */
112 #define	TELOPT_TSPEED	32	/* terminal speed */
113 #define	TELOPT_LFLOW	33	/* remote flow control */
114 #define TELOPT_LINEMODE	34	/* Linemode option */
115 #define TELOPT_XDISPLOC	35	/* X Display Location */
116 #define TELOPT_OLD_ENVIRON 36	/* Old - Environment variables */
117 #define	TELOPT_AUTHENTICATION 37/* Authenticate */
118 #define	TELOPT_ENCRYPT	38	/* Encryption option */
119 #define TELOPT_NEW_ENVIRON 39	/* New - Environment variables */
120 #define	TELOPT_TN3270E	40	/* RFC2355 - TN3270 Enhancements */
121 #define	TELOPT_CHARSET	42	/* RFC2066 - Charset */
122 #define	TELOPT_COMPORT	44	/* RFC2217 - Com Port Control */
123 #define	TELOPT_KERMIT	47	/* RFC2840 - Kermit */
124 #define	TELOPT_EXOPL	255	/* extended-options-list */
125 
126 
127 #define	NTELOPTS	(1+TELOPT_KERMIT)
128 #ifdef TELOPTS
129 const char *telopts[NTELOPTS+1] = {
130 	"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
131 	"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
132 	"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
133 	"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
134 	"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
135 	"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
136 	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
137 	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
138 	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
139 	"ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET",
140 	"RSP", "COM-PORT", "SLE", "STARTTLS", "KERMIT",
141 	0
142 };
143 #define	TELOPT_FIRST	TELOPT_BINARY
144 #define	TELOPT_LAST	TELOPT_KERMIT
145 #define	TELOPT_OK(x)	((unsigned int)(x) <= TELOPT_LAST)
146 #define	TELOPT(x)	telopts[(x)-TELOPT_FIRST]
147 #endif
148 
149 /* sub-option qualifiers */
150 #define	TELQUAL_IS	0	/* option is... */
151 #define	TELQUAL_SEND	1	/* send option */
152 #define	TELQUAL_INFO	2	/* ENVIRON: informational version of IS */
153 #define	TELQUAL_REPLY	2	/* AUTHENTICATION: client version of IS */
154 #define	TELQUAL_NAME	3	/* AUTHENTICATION: client version of IS */
155 
156 #define	LFLOW_OFF		0	/* Disable remote flow control */
157 #define	LFLOW_ON		1	/* Enable remote flow control */
158 #define	LFLOW_RESTART_ANY	2	/* Restart output on any char */
159 #define	LFLOW_RESTART_XON	3	/* Restart output only on XON */
160 
161 /*
162  * LINEMODE suboptions
163  */
164 
165 #define	LM_MODE		1
166 #define	LM_FORWARDMASK	2
167 #define	LM_SLC		3
168 
169 #define	MODE_EDIT	0x01
170 #define	MODE_TRAPSIG	0x02
171 #define	MODE_ACK	0x04
172 #define MODE_SOFT_TAB	0x08
173 #define MODE_LIT_ECHO	0x10
174 
175 #define	MODE_MASK	0x1f
176 
177 /* Not part of protocol, but needed to simplify things... */
178 #define MODE_FLOW		0x0100
179 #define MODE_ECHO		0x0200
180 #define MODE_INBIN		0x0400
181 #define MODE_OUTBIN		0x0800
182 #define MODE_FORCE		0x1000
183 
184 #define	SLC_SYNCH	1
185 #define	SLC_BRK		2
186 #define	SLC_IP		3
187 #define	SLC_AO		4
188 #define	SLC_AYT		5
189 #define	SLC_EOR		6
190 #define	SLC_ABORT	7
191 #define	SLC_EOF		8
192 #define	SLC_SUSP	9
193 #define	SLC_EC		10
194 #define	SLC_EL		11
195 #define	SLC_EW		12
196 #define	SLC_RP		13
197 #define	SLC_LNEXT	14
198 #define	SLC_XON		15
199 #define	SLC_XOFF	16
200 #define	SLC_FORW1	17
201 #define	SLC_FORW2	18
202 #define SLC_MCL         19
203 #define SLC_MCR         20
204 #define SLC_MCWL        21
205 #define SLC_MCWR        22
206 #define SLC_MCBOL       23
207 #define SLC_MCEOL       24
208 #define SLC_INSRT       25
209 #define SLC_OVER        26
210 #define SLC_ECR         27
211 #define SLC_EWR         28
212 #define SLC_EBOL        29
213 #define SLC_EEOL        30
214 
215 #define	NSLC		30
216 
217 /*
218  * For backwards compatibility, we define SLC_NAMES to be the
219  * list of names if SLC_NAMES is not defined.
220  */
221 #define	SLC_NAMELIST	"0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR",	\
222 			"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP",	\
223 			"LNEXT", "XON", "XOFF", "FORW1", "FORW2",	\
224 			"MCL", "MCR", "MCWL", "MCWR", "MCBOL",		\
225 			"MCEOL", "INSRT", "OVER", "ECR", "EWR",		\
226 			"EBOL", "EEOL",					\
227 			0
228 
229 #ifdef	SLC_NAMES
230 const char *slc_names[] = {
231 	SLC_NAMELIST
232 };
233 #else
234 extern char *slc_names[];
235 #define	SLC_NAMES SLC_NAMELIST
236 #endif
237 
238 #define	SLC_NAME_OK(x)	((unsigned int)(x) <= NSLC)
239 #define SLC_NAME(x)	slc_names[x]
240 
241 #define	SLC_NOSUPPORT	0
242 #define	SLC_CANTCHANGE	1
243 #define	SLC_VARIABLE	2
244 #define	SLC_DEFAULT	3
245 #define	SLC_LEVELBITS	0x03
246 
247 #define	SLC_FUNC	0
248 #define	SLC_FLAGS	1
249 #define	SLC_VALUE	2
250 
251 #define	SLC_ACK		0x80
252 #define	SLC_FLUSHIN	0x40
253 #define	SLC_FLUSHOUT	0x20
254 
255 #define	OLD_ENV_VAR	1
256 #define	OLD_ENV_VALUE	0
257 #define	NEW_ENV_VAR	0
258 #define	NEW_ENV_VALUE	1
259 #define	ENV_ESC		2
260 #define ENV_USERVAR	3
261 
262 /*
263  * AUTHENTICATION suboptions
264  */
265 
266 /*
267  * Who is authenticating who ...
268  */
269 #define	AUTH_WHO_CLIENT		0	/* Client authenticating server */
270 #define	AUTH_WHO_SERVER		1	/* Server authenticating client */
271 #define	AUTH_WHO_MASK		1
272 
273 /*
274  * amount of authentication done
275  */
276 #define	AUTH_HOW_ONE_WAY	0
277 #define	AUTH_HOW_MUTUAL		2
278 #define	AUTH_HOW_MASK		2
279 
280 #define	AUTHTYPE_NULL		0
281 #define	AUTHTYPE_KERBEROS_V4	1
282 #define	AUTHTYPE_KERBEROS_V5	2
283 #define	AUTHTYPE_SPX		3
284 #define	AUTHTYPE_MINK		4
285 #define	AUTHTYPE_SRA		6
286 #define	AUTHTYPE_CNT		7
287 
288 #define	AUTHTYPE_TEST		99
289 
290 #ifdef	AUTH_NAMES
291 const char *authtype_names[] = {
292 	"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", NULL, "SRA",
293 	0
294 };
295 #else
296 extern char *authtype_names[];
297 #endif
298 
299 #define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)
300 #define	AUTHTYPE_NAME(x)	authtype_names[x]
301 
302 /*
303  * ENCRYPTion suboptions
304  */
305 #define	ENCRYPT_IS		0	/* I pick encryption type ... */
306 #define	ENCRYPT_SUPPORT		1	/* I support encryption types ... */
307 #define	ENCRYPT_REPLY		2	/* Initial setup response */
308 #define	ENCRYPT_START		3	/* Am starting to send encrypted */
309 #define	ENCRYPT_END		4	/* Am ending encrypted */
310 #define	ENCRYPT_REQSTART	5	/* Request you start encrypting */
311 #define	ENCRYPT_REQEND		6	/* Request you end encrypting */
312 #define	ENCRYPT_ENC_KEYID	7
313 #define	ENCRYPT_DEC_KEYID	8
314 #define	ENCRYPT_CNT		9
315 
316 #define	ENCTYPE_ANY		0
317 #define	ENCTYPE_DES_CFB64	1
318 #define	ENCTYPE_DES_OFB64	2
319 #define	ENCTYPE_CNT		3
320 
321 #ifdef	ENCRYPT_NAMES
322 const char *encrypt_names[] = {
323 	"IS", "SUPPORT", "REPLY", "START", "END",
324 	"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
325 	0
326 };
327 const char *enctype_names[] = {
328 	"ANY", "DES_CFB64",  "DES_OFB64",
329 	0
330 };
331 #else
332 extern char *encrypt_names[];
333 extern char *enctype_names[];
334 #endif
335 
336 
337 #define	ENCRYPT_NAME_OK(x)	((unsigned int)(x) < ENCRYPT_CNT)
338 #define	ENCRYPT_NAME(x)		encrypt_names[x]
339 
340 #define	ENCTYPE_NAME_OK(x)	((unsigned int)(x) < ENCTYPE_CNT)
341 #define	ENCTYPE_NAME(x)		enctype_names[x]
342 
343 #endif /* !_TELNET_H_ */
344