telnet.h revision 20003
1154603Smjacob/*
2154603Smjacob * Copyright (c) 1983, 1993
3154603Smjacob *	The Regents of the University of California.  All rights reserved.
4154603Smjacob *
5154603Smjacob * Redistribution and use in source and binary forms, with or without
6154603Smjacob * modification, are permitted provided that the following conditions
7154603Smjacob * are met:
8154603Smjacob * 1. Redistributions of source code must retain the above copyright
9154603Smjacob *    notice, this list of conditions and the following disclaimer.
10154603Smjacob * 2. Redistributions in binary form must reproduce the above copyright
11154603Smjacob *    notice, this list of conditions and the following disclaimer in the
12154603Smjacob *    documentation and/or other materials provided with the distribution.
13154603Smjacob * 3. All advertising materials mentioning features or use of this software
14154603Smjacob *    must display the following acknowledgement:
15154603Smjacob *	This product includes software developed by the University of
16154603Smjacob *	California, Berkeley and its contributors.
17154603Smjacob * 4. Neither the name of the University nor the names of its contributors
18154603Smjacob *    may be used to endorse or promote products derived from this software
19154603Smjacob *    without specific prior written permission.
20154603Smjacob *
21154603Smjacob * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22154603Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23154603Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24154603Smjacob * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25154603Smjacob * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26154603Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27154603Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28154603Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29154603Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30154603Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31154603Smjacob * SUCH DAMAGE.
32154603Smjacob *
33154603Smjacob *	@(#)telnet.h	8.2 (Berkeley) 12/15/93
34154603Smjacob */
35154603Smjacob
36170251Sscottl#ifndef _ARPA_TELNET_H_
37154603Smjacob#define	_ARPA_TELNET_H_
38154603Smjacob
39154603Smjacob/*
40154603Smjacob * Definitions for the TELNET protocol.
41154603Smjacob */
42154603Smjacob#define	IAC	255		/* interpret as command: */
43154603Smjacob#define	DONT	254		/* you are not to use option */
44156000Smjacob#define	DO	253		/* please, you use option */
45156000Smjacob#define	WONT	252		/* I won't use option */
46156000Smjacob#define	WILL	251		/* I will use option */
47170251Sscottl#define	SB	250		/* interpret as subnegotiation */
48170251Sscottl#define	GA	249		/* you may reverse the line */
49170251Sscottl#define	EL	248		/* erase the current line */
50170251Sscottl#define	EC	247		/* erase the current character */
51170251Sscottl#define	AYT	246		/* are you there */
52170251Sscottl#define	AO	245		/* abort output--but let prog finish */
53154603Smjacob#define	IP	244		/* interrupt process--permanently */
54154603Smjacob#define	BREAK	243		/* break */
55154603Smjacob#define	DM	242		/* data mark--for connect. cleaning */
56154603Smjacob#define	NOP	241		/* nop */
57154603Smjacob#define	SE	240		/* end sub negotiation */
58154603Smjacob#define EOR     239             /* end of record (transparent mode) */
59154603Smjacob#define	ABORT	238		/* Abort process */
60154603Smjacob#define	SUSP	237		/* Suspend process */
61154603Smjacob#define	xEOF	236		/* End of file: EOF is already used... */
62154603Smjacob
63154603Smjacob#define SYNCH	242		/* for telfunc calls */
64154603Smjacob
65154603Smjacob#ifdef TELCMDS
66154603Smjacobchar *telcmds[] = {
67154603Smjacob	"EOF", "SUSP", "ABORT", "EOR",
68154603Smjacob	"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
69154603Smjacob	"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
70154603Smjacob	0
71154603Smjacob};
72154603Smjacob#else
73154603Smjacobextern char *telcmds[];
74154603Smjacob#endif
75154603Smjacob
76154603Smjacob#define	TELCMD_FIRST	xEOF
77154603Smjacob#define	TELCMD_LAST	IAC
78154603Smjacob#define	TELCMD_OK(x)	((unsigned int)(x) <= TELCMD_LAST && \
79154603Smjacob			 (unsigned int)(x) >= TELCMD_FIRST)
80154603Smjacob#define	TELCMD(x)	telcmds[(x)-TELCMD_FIRST]
81154603Smjacob
82154603Smjacob/* telnet options */
83154603Smjacob#define TELOPT_BINARY	0	/* 8-bit data path */
84154603Smjacob#define TELOPT_ECHO	1	/* echo */
85154603Smjacob#define	TELOPT_RCP	2	/* prepare to reconnect */
86154603Smjacob#define	TELOPT_SGA	3	/* suppress go ahead */
87154603Smjacob#define	TELOPT_NAMS	4	/* approximate message size */
88154603Smjacob#define	TELOPT_STATUS	5	/* give status */
89154603Smjacob#define	TELOPT_TM	6	/* timing mark */
90156000Smjacob#define	TELOPT_RCTE	7	/* remote controlled transmission and echo */
91154603Smjacob#define TELOPT_NAOL 	8	/* negotiate about output line width */
92154603Smjacob#define TELOPT_NAOP 	9	/* negotiate about output page size */
93154603Smjacob#define TELOPT_NAOCRD	10	/* negotiate about CR disposition */
94154603Smjacob#define TELOPT_NAOHTS	11	/* negotiate about horizontal tabstops */
95154603Smjacob#define TELOPT_NAOHTD	12	/* negotiate about horizontal tab disposition */
96154603Smjacob#define TELOPT_NAOFFD	13	/* negotiate about formfeed disposition */
97154603Smjacob#define TELOPT_NAOVTS	14	/* negotiate about vertical tab stops */
98154603Smjacob#define TELOPT_NAOVTD	15	/* negotiate about vertical tab disposition */
99154603Smjacob#define TELOPT_NAOLFD	16	/* negotiate about output LF disposition */
100154603Smjacob#define TELOPT_XASCII	17	/* extended ascic character set */
101154603Smjacob#define	TELOPT_LOGOUT	18	/* force logout */
102154603Smjacob#define	TELOPT_BM	19	/* byte macro */
103154603Smjacob#define	TELOPT_DET	20	/* data entry terminal */
104154603Smjacob#define	TELOPT_SUPDUP	21	/* supdup protocol */
105154603Smjacob#define	TELOPT_SUPDUPOUTPUT 22	/* supdup output */
106154603Smjacob#define	TELOPT_SNDLOC	23	/* send location */
107154603Smjacob#define	TELOPT_TTYPE	24	/* terminal type */
108154603Smjacob#define	TELOPT_EOR	25	/* end or record */
109154603Smjacob#define	TELOPT_TUID	26	/* TACACS user identification */
110154603Smjacob#define	TELOPT_OUTMRK	27	/* output marking */
111154603Smjacob#define	TELOPT_TTYLOC	28	/* terminal location number */
112154603Smjacob#define	TELOPT_3270REGIME 29	/* 3270 regime */
113154603Smjacob#define	TELOPT_X3PAD	30	/* X.3 PAD */
114154603Smjacob#define	TELOPT_NAWS	31	/* window size */
115154603Smjacob#define	TELOPT_TSPEED	32	/* terminal speed */
116154603Smjacob#define	TELOPT_LFLOW	33	/* remote flow control */
117154603Smjacob#define TELOPT_LINEMODE	34	/* Linemode option */
118154603Smjacob#define TELOPT_XDISPLOC	35	/* X Display Location */
119154603Smjacob#define TELOPT_OLD_ENVIRON 36	/* Old - Environment variables */
120154603Smjacob#define	TELOPT_AUTHENTICATION 37/* Authenticate */
121154603Smjacob#define	TELOPT_ENCRYPT	38	/* Encryption option */
122154603Smjacob#define TELOPT_NEW_ENVIRON 39	/* New - Environment variables */
123154603Smjacob#define	TELOPT_EXOPL	255	/* extended-options-list */
124154603Smjacob
125154603Smjacob
126154603Smjacob#define	NTELOPTS	(1+TELOPT_NEW_ENVIRON)
127154603Smjacob#ifdef TELOPTS
128154603Smjacobchar *telopts[NTELOPTS+1] = {
129154603Smjacob	"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
130154603Smjacob	"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
131154603Smjacob	"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
132154603Smjacob	"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
133154603Smjacob	"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
134154603Smjacob	"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
135154603Smjacob	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
136154603Smjacob	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
137154603Smjacob	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
138154603Smjacob	"ENCRYPT", "NEW-ENVIRON",
139154603Smjacob	0
140154603Smjacob};
141154603Smjacob#define	TELOPT_FIRST	TELOPT_BINARY
142154603Smjacob#define	TELOPT_LAST	TELOPT_NEW_ENVIRON
143154603Smjacob#define	TELOPT_OK(x)	((unsigned int)(x) <= TELOPT_LAST)
144154603Smjacob#define	TELOPT(x)	telopts[(x)-TELOPT_FIRST]
145154603Smjacob#endif
146154603Smjacob
147154603Smjacob/* sub-option qualifiers */
148154603Smjacob#define	TELQUAL_IS	0	/* option is... */
149154603Smjacob#define	TELQUAL_SEND	1	/* send option */
150154603Smjacob#define	TELQUAL_INFO	2	/* ENVIRON: informational version of IS */
151154603Smjacob#define	TELQUAL_REPLY	2	/* AUTHENTICATION: client version of IS */
152154603Smjacob#define	TELQUAL_NAME	3	/* AUTHENTICATION: client version of IS */
153154603Smjacob
154154603Smjacob#define	LFLOW_OFF		0	/* Disable remote flow control */
155154603Smjacob#define	LFLOW_ON		1	/* Enable remote flow control */
156154603Smjacob#define	LFLOW_RESTART_ANY	2	/* Restart output on any char */
157154603Smjacob#define	LFLOW_RESTART_XON	3	/* Restart output only on XON */
158154603Smjacob
159154603Smjacob/*
160154603Smjacob * LINEMODE suboptions
161154603Smjacob */
162154603Smjacob
163154603Smjacob#define	LM_MODE		1
164154603Smjacob#define	LM_FORWARDMASK	2
165154603Smjacob#define	LM_SLC		3
166154603Smjacob
167154603Smjacob#define	MODE_EDIT	0x01
168154603Smjacob#define	MODE_TRAPSIG	0x02
169154603Smjacob#define	MODE_ACK	0x04
170154603Smjacob#define MODE_SOFT_TAB	0x08
171154603Smjacob#define MODE_LIT_ECHO	0x10
172154603Smjacob
173154603Smjacob#define	MODE_MASK	0x1f
174154603Smjacob
175154603Smjacob/* Not part of protocol, but needed to simplify things... */
176154603Smjacob#define MODE_FLOW		0x0100
177154603Smjacob#define MODE_ECHO		0x0200
178154603Smjacob#define MODE_INBIN		0x0400
179154603Smjacob#define MODE_OUTBIN		0x0800
180154603Smjacob#define MODE_FORCE		0x1000
181154603Smjacob
182154603Smjacob#define	SLC_SYNCH	1
183154603Smjacob#define	SLC_BRK		2
184154603Smjacob#define	SLC_IP		3
185154603Smjacob#define	SLC_AO		4
186154603Smjacob#define	SLC_AYT		5
187154603Smjacob#define	SLC_EOR		6
188154603Smjacob#define	SLC_ABORT	7
189154603Smjacob#define	SLC_EOF		8
190154603Smjacob#define	SLC_SUSP	9
191154603Smjacob#define	SLC_EC		10
192154603Smjacob#define	SLC_EL		11
193154603Smjacob#define	SLC_EW		12
194154603Smjacob#define	SLC_RP		13
195154603Smjacob#define	SLC_LNEXT	14
196154603Smjacob#define	SLC_XON		15
197154603Smjacob#define	SLC_XOFF	16
198154603Smjacob#define	SLC_FORW1	17
199154603Smjacob#define	SLC_FORW2	18
200154603Smjacob#define SLC_MCL         19
201154603Smjacob#define SLC_MCR         20
202154603Smjacob#define SLC_MCWL        21
203154603Smjacob#define SLC_MCWR        22
204154603Smjacob#define SLC_MCBOL       23
205154603Smjacob#define SLC_MCEOL       24
206154603Smjacob#define SLC_INSRT       25
207154603Smjacob#define SLC_OVER        26
208154603Smjacob#define SLC_ECR         27
209154603Smjacob#define SLC_EWR         28
210154603Smjacob#define SLC_EBOL        29
211154603Smjacob#define SLC_EEOL        30
212154603Smjacob
213154603Smjacob#define	NSLC		30
214154603Smjacob
215154603Smjacob/*
216154603Smjacob * For backwards compatability, we define SLC_NAMES to be the
217154603Smjacob * list of names if SLC_NAMES is not defined.
218154603Smjacob */
219154603Smjacob#define	SLC_NAMELIST	"0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR",	\
220154603Smjacob			"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP",	\
221154603Smjacob			"LNEXT", "XON", "XOFF", "FORW1", "FORW2",	\
222154603Smjacob			"MCL", "MCR", "MCWL", "MCWR", "MCBOL",		\
223154603Smjacob			"MCEOL", "INSRT", "OVER", "ECR", "EWR",		\
224154603Smjacob			"EBOL", "EEOL",					\
225154603Smjacob			0
226154603Smjacob
227154603Smjacob#ifdef	SLC_NAMES
228154603Smjacobchar *slc_names[] = {
229154603Smjacob	SLC_NAMELIST
230154603Smjacob};
231154603Smjacob#else
232154603Smjacobextern char *slc_names[];
233154603Smjacob#define	SLC_NAMES SLC_NAMELIST
234154603Smjacob#endif
235154603Smjacob
236154603Smjacob#define	SLC_NAME_OK(x)	((unsigned int)(x) <= NSLC)
237154603Smjacob#define SLC_NAME(x)	slc_names[x]
238154603Smjacob
239154603Smjacob#define	SLC_NOSUPPORT	0
240154603Smjacob#define	SLC_CANTCHANGE	1
241154603Smjacob#define	SLC_VARIABLE	2
242154603Smjacob#define	SLC_DEFAULT	3
243154603Smjacob#define	SLC_LEVELBITS	0x03
244154603Smjacob
245170251Sscottl#define	SLC_FUNC	0
246154603Smjacob#define	SLC_FLAGS	1
247154603Smjacob#define	SLC_VALUE	2
248154603Smjacob
249154603Smjacob#define	SLC_ACK		0x80
250154603Smjacob#define	SLC_FLUSHIN	0x40
251154603Smjacob#define	SLC_FLUSHOUT	0x20
252156000Smjacob
253156000Smjacob#define	OLD_ENV_VAR	1
254154603Smjacob#define	OLD_ENV_VALUE	0
255156000Smjacob#define	NEW_ENV_VAR	0
256154603Smjacob#define	NEW_ENV_VALUE	1
257154603Smjacob#define	ENV_ESC		2
258154603Smjacob#define ENV_USERVAR	3
259154603Smjacob
260170251Sscottl/*
261170251Sscottl * AUTHENTICATION suboptions
262170251Sscottl */
263170251Sscottl
264170251Sscottl/*
265170251Sscottl * Who is authenticating who ...
266156000Smjacob */
267170251Sscottl#define	AUTH_WHO_CLIENT		0	/* Client authenticating server */
268170251Sscottl#define	AUTH_WHO_SERVER		1	/* Server authenticating client */
269170251Sscottl#define	AUTH_WHO_MASK		1
270170251Sscottl
271154603Smjacob/*
272156000Smjacob * amount of authentication done
273156000Smjacob */
274156000Smjacob#define	AUTH_HOW_ONE_WAY	0
275156000Smjacob#define	AUTH_HOW_MUTUAL		2
276154603Smjacob#define	AUTH_HOW_MASK		2
277156000Smjacob
278154603Smjacob#define	AUTHTYPE_NULL		0
279154603Smjacob#define	AUTHTYPE_KERBEROS_V4	1
280154603Smjacob#define	AUTHTYPE_KERBEROS_V5	2
281154603Smjacob#define	AUTHTYPE_SPX		3
282154603Smjacob#define	AUTHTYPE_MINK		4
283154603Smjacob#define	AUTHTYPE_CNT		5
284154603Smjacob
285170251Sscottl#define	AUTHTYPE_TEST		99
286154603Smjacob
287154603Smjacob#ifdef	AUTH_NAMES
288154603Smjacobchar *authtype_names[] = {
289154603Smjacob	"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK",
290154603Smjacob	0
291154603Smjacob};
292154603Smjacob#else
293154603Smjacobextern char *authtype_names[];
294154603Smjacob#endif
295154603Smjacob
296156000Smjacob#define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)
297156000Smjacob#define	AUTHTYPE_NAME(x)	authtype_names[x]
298
299/*
300 * ENCRYPTion suboptions
301 */
302#define	ENCRYPT_IS		0	/* I pick encryption type ... */
303#define	ENCRYPT_SUPPORT		1	/* I support encryption types ... */
304#define	ENCRYPT_REPLY		2	/* Initial setup response */
305#define	ENCRYPT_START		3	/* Am starting to send encrypted */
306#define	ENCRYPT_END		4	/* Am ending encrypted */
307#define	ENCRYPT_REQSTART	5	/* Request you start encrypting */
308#define	ENCRYPT_REQEND		6	/* Request you send encrypting */
309#define	ENCRYPT_ENC_KEYID	7
310#define	ENCRYPT_DEC_KEYID	8
311#define	ENCRYPT_CNT		9
312
313#define	ENCTYPE_ANY		0
314#define	ENCTYPE_DES_CFB64	1
315#define	ENCTYPE_DES_OFB64	2
316#define	ENCTYPE_CNT		3
317
318#ifdef	ENCRYPT_NAMES
319char *encrypt_names[] = {
320	"IS", "SUPPORT", "REPLY", "START", "END",
321	"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
322	0
323};
324char *enctype_names[] = {
325	"ANY", "DES_CFB64",  "DES_OFB64",
326	0
327};
328#else
329extern char *encrypt_names[];
330extern char *enctype_names[];
331#endif
332
333
334#define	ENCRYPT_NAME_OK(x)	((unsigned int)(x) < ENCRYPT_CNT)
335#define	ENCRYPT_NAME(x)		encrypt_names[x]
336
337#define	ENCTYPE_NAME_OK(x)	((unsigned int)(x) < ENCTYPE_CNT)
338#define	ENCTYPE_NAME(x)		enctype_names[x]
339
340#endif /* !_TELNET_H_ */
341