telnet.h revision 183004
1103739Stjr/*
2103739Stjr * Copyright (c) 1983, 1993
3103739Stjr *	The Regents of the University of California.  All rights reserved.
4103739Stjr *
5103739Stjr * Redistribution and use in source and binary forms, with or without
6103739Stjr * modification, are permitted provided that the following conditions
7103739Stjr * are met:
8103739Stjr * 1. Redistributions of source code must retain the above copyright
9103739Stjr *    notice, this list of conditions and the following disclaimer.
10103739Stjr * 2. Redistributions in binary form must reproduce the above copyright
11103739Stjr *    notice, this list of conditions and the following disclaimer in the
12103739Stjr *    documentation and/or other materials provided with the distribution.
13103739Stjr * 3. All advertising materials mentioning features or use of this software
14103739Stjr *    must display the following acknowledgement:
15103739Stjr *	This product includes software developed by the University of
16103739Stjr *	California, Berkeley and its contributors.
17103739Stjr * 4. Neither the name of the University nor the names of its contributors
18103739Stjr *    may be used to endorse or promote products derived from this software
19103739Stjr *    without specific prior written permission.
20103739Stjr *
21103739Stjr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22103739Stjr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23103739Stjr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24103739Stjr * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25103739Stjr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26103739Stjr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27103739Stjr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28103739Stjr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29103739Stjr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30103739Stjr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31103739Stjr * SUCH DAMAGE.
32103739Stjr *
33103739Stjr *	@(#)telnet.h	8.2 (Berkeley) 12/15/93
34103739Stjr * $FreeBSD: head/include/arpa/telnet.h 183004 2008-09-13 17:46:50Z antoine $
35103739Stjr */
36103739Stjr
37103739Stjr#ifndef _ARPA_TELNET_H_
38128843Sobrien#define	_ARPA_TELNET_H_
39103739Stjr
40103739Stjr/*
41103739Stjr * Definitions for the TELNET protocol.
42103739Stjr */
43103739Stjr#define	IAC	255		/* interpret as command: */
44103739Stjr#define	DONT	254		/* you are not to use option */
45103739Stjr#define	DO	253		/* please, you use option */
46103739Stjr#define	WONT	252		/* I won't use option */
47103739Stjr#define	WILL	251		/* I will use option */
48103739Stjr#define	SB	250		/* interpret as subnegotiation */
49103739Stjr#define	GA	249		/* you may reverse the line */
50103739Stjr#define	EL	248		/* erase the current line */
51103739Stjr#define	EC	247		/* erase the current character */
52103739Stjr#define	AYT	246		/* are you there */
53103739Stjr#define	AO	245		/* abort output--but let prog finish */
54103739Stjr#define	IP	244		/* interrupt process--permanently */
55103739Stjr#define	BREAK	243		/* break */
56103739Stjr#define	DM	242		/* data mark--for connect. cleaning */
57103739Stjr#define	NOP	241		/* nop */
58103739Stjr#define	SE	240		/* end sub negotiation */
59103739Stjr#define EOR     239             /* end of record (transparent mode) */
60103739Stjr#define	ABORT	238		/* Abort process */
61103739Stjr#define	SUSP	237		/* Suspend process */
62103739Stjr#define	xEOF	236		/* End of file: EOF is already used... */
63103739Stjr
64103739Stjr#define SYNCH	242		/* for telfunc calls */
65103739Stjr
66103739Stjr#ifdef TELCMDS
67180104Sdasconst char *telcmds[] = {
68103739Stjr	"EOF", "SUSP", "ABORT", "EOR",
69103739Stjr	"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
70122547Stjr	"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
71124887Sdas	0
72113199Stjr};
73124887Sdas#else
74113199Stjrextern char *telcmds[];
75103739Stjr#endif
76103739Stjr
77103739Stjr#define	TELCMD_FIRST	xEOF
78103739Stjr#define	TELCMD_LAST	IAC
79103739Stjr#define	TELCMD_OK(x)	((unsigned int)(x) <= TELCMD_LAST && \
80103739Stjr			 (unsigned int)(x) >= TELCMD_FIRST)
81103739Stjr#define	TELCMD(x)	telcmds[(x)-TELCMD_FIRST]
82103739Stjr
83103739Stjr/* telnet options */
84103739Stjr#define TELOPT_BINARY	0	/* 8-bit data path */
85103739Stjr#define TELOPT_ECHO	1	/* echo */
86103739Stjr#define	TELOPT_RCP	2	/* prepare to reconnect */
87103739Stjr#define	TELOPT_SGA	3	/* suppress go ahead */
88103739Stjr#define	TELOPT_NAMS	4	/* approximate message size */
89103739Stjr#define	TELOPT_STATUS	5	/* give status */
90103739Stjr#define	TELOPT_TM	6	/* timing mark */
91103739Stjr#define	TELOPT_RCTE	7	/* remote controlled transmission and echo */
92103739Stjr#define TELOPT_NAOL 	8	/* negotiate about output line width */
93103739Stjr#define TELOPT_NAOP 	9	/* negotiate about output page size */
94178287Sjhb#define TELOPT_NAOCRD	10	/* negotiate about CR disposition */
95178287Sjhb#define TELOPT_NAOHTS	11	/* negotiate about horizontal tabstops */
96103739Stjr#define TELOPT_NAOHTD	12	/* negotiate about horizontal tab disposition */
97103739Stjr#define TELOPT_NAOFFD	13	/* negotiate about formfeed disposition */
98103739Stjr#define TELOPT_NAOVTS	14	/* negotiate about vertical tab stops */
99103739Stjr#define TELOPT_NAOVTD	15	/* negotiate about vertical tab disposition */
100103739Stjr#define TELOPT_NAOLFD	16	/* negotiate about output LF disposition */
101103739Stjr#define TELOPT_XASCII	17	/* extended ascic character set */
102103739Stjr#define	TELOPT_LOGOUT	18	/* force logout */
103103739Stjr#define	TELOPT_BM	19	/* byte macro */
104103739Stjr#define	TELOPT_DET	20	/* data entry terminal */
105103739Stjr#define	TELOPT_SUPDUP	21	/* supdup protocol */
106103739Stjr#define	TELOPT_SUPDUPOUTPUT 22	/* supdup output */
107103739Stjr#define	TELOPT_SNDLOC	23	/* send location */
108103739Stjr#define	TELOPT_TTYPE	24	/* terminal type */
109103739Stjr#define	TELOPT_EOR	25	/* end or record */
110103739Stjr#define	TELOPT_TUID	26	/* TACACS user identification */
111103739Stjr#define	TELOPT_OUTMRK	27	/* output marking */
112122547Stjr#define	TELOPT_TTYLOC	28	/* terminal location number */
113122547Stjr#define	TELOPT_3270REGIME 29	/* 3270 regime */
114122547Stjr#define	TELOPT_X3PAD	30	/* X.3 PAD */
115122547Stjr#define	TELOPT_NAWS	31	/* window size */
116122547Stjr#define	TELOPT_TSPEED	32	/* terminal speed */
117122547Stjr#define	TELOPT_LFLOW	33	/* remote flow control */
118128002Stjr#define TELOPT_LINEMODE	34	/* Linemode option */
119128002Stjr#define TELOPT_XDISPLOC	35	/* X Display Location */
120122547Stjr#define TELOPT_OLD_ENVIRON 36	/* Old - Environment variables */
121122547Stjr#define	TELOPT_AUTHENTICATION 37/* Authenticate */
122122547Stjr#define	TELOPT_ENCRYPT	38	/* Encryption option */
123124174Snectar#define TELOPT_NEW_ENVIRON 39	/* New - Environment variables */
124122547Stjr#define	TELOPT_TN3270E	40	/* RFC2355 - TN3270 Enhancements */
125122547Stjr#define	TELOPT_CHARSET	42	/* RFC2066 - Charset */
126122547Stjr#define	TELOPT_COMPORT	44	/* RFC2217 - Com Port Control */
127122547Stjr#define	TELOPT_KERMIT	47	/* RFC2840 - Kermit */
128128002Stjr#define	TELOPT_EXOPL	255	/* extended-options-list */
129128002Stjr
130122547Stjr
131122547Stjr#define	NTELOPTS	(1+TELOPT_KERMIT)
132122547Stjr#ifdef TELOPTS
133122547Stjrconst char *telopts[NTELOPTS+1] = {
134122547Stjr	"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
135122547Stjr	"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
136122547Stjr	"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
137122547Stjr	"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
138122547Stjr	"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
139122547Stjr	"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
140122547Stjr	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
141122547Stjr	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
142103739Stjr	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
143103739Stjr	"ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET",
144103739Stjr	"RSP", "COM-PORT", "SLE", "STARTTLS", "KERMIT",
145103739Stjr	0
146103739Stjr};
147103739Stjr#define	TELOPT_FIRST	TELOPT_BINARY
148124887Sdas#define	TELOPT_LAST	TELOPT_KERMIT
149103739Stjr#define	TELOPT_OK(x)	((unsigned int)(x) <= TELOPT_LAST)
150103739Stjr#define	TELOPT(x)	telopts[(x)-TELOPT_FIRST]
151103739Stjr#endif
152103739Stjr
153103739Stjr/* sub-option qualifiers */
154103739Stjr#define	TELQUAL_IS	0	/* option is... */
155103739Stjr#define	TELQUAL_SEND	1	/* send option */
156103739Stjr#define	TELQUAL_INFO	2	/* ENVIRON: informational version of IS */
157103739Stjr#define	TELQUAL_REPLY	2	/* AUTHENTICATION: client version of IS */
158103739Stjr#define	TELQUAL_NAME	3	/* AUTHENTICATION: client version of IS */
159103739Stjr
160103739Stjr#define	LFLOW_OFF		0	/* Disable remote flow control */
161103739Stjr#define	LFLOW_ON		1	/* Enable remote flow control */
162103739Stjr#define	LFLOW_RESTART_ANY	2	/* Restart output on any char */
163103739Stjr#define	LFLOW_RESTART_XON	3	/* Restart output only on XON */
164103739Stjr
165103739Stjr/*
166103739Stjr * LINEMODE suboptions
167103739Stjr */
168103739Stjr
169103739Stjr#define	LM_MODE		1
170103739Stjr#define	LM_FORWARDMASK	2
171103739Stjr#define	LM_SLC		3
172103739Stjr
173103739Stjr#define	MODE_EDIT	0x01
174103739Stjr#define	MODE_TRAPSIG	0x02
175103739Stjr#define	MODE_ACK	0x04
176103739Stjr#define MODE_SOFT_TAB	0x08
177103739Stjr#define MODE_LIT_ECHO	0x10
178103739Stjr
179103739Stjr#define	MODE_MASK	0x1f
180103739Stjr
181103739Stjr/* Not part of protocol, but needed to simplify things... */
182103739Stjr#define MODE_FLOW		0x0100
183103739Stjr#define MODE_ECHO		0x0200
184103739Stjr#define MODE_INBIN		0x0400
185103739Stjr#define MODE_OUTBIN		0x0800
186103739Stjr#define MODE_FORCE		0x1000
187103739Stjr
188103739Stjr#define	SLC_SYNCH	1
189103739Stjr#define	SLC_BRK		2
190103739Stjr#define	SLC_IP		3
191103739Stjr#define	SLC_AO		4
192103739Stjr#define	SLC_AYT		5
193103739Stjr#define	SLC_EOR		6
194103739Stjr#define	SLC_ABORT	7
195103739Stjr#define	SLC_EOF		8
196103739Stjr#define	SLC_SUSP	9
197103739Stjr#define	SLC_EC		10
198103739Stjr#define	SLC_EL		11
199103739Stjr#define	SLC_EW		12
200103739Stjr#define	SLC_RP		13
201103739Stjr#define	SLC_LNEXT	14
202103739Stjr#define	SLC_XON		15
203103739Stjr#define	SLC_XOFF	16
204103739Stjr#define	SLC_FORW1	17
205103739Stjr#define	SLC_FORW2	18
206103739Stjr#define SLC_MCL         19
207103739Stjr#define SLC_MCR         20
208103739Stjr#define SLC_MCWL        21
209103739Stjr#define SLC_MCWR        22
210103739Stjr#define SLC_MCBOL       23
211103739Stjr#define SLC_MCEOL       24
212103739Stjr#define SLC_INSRT       25
213103739Stjr#define SLC_OVER        26
214103739Stjr#define SLC_ECR         27
215103739Stjr#define SLC_EWR         28
216103739Stjr#define SLC_EBOL        29
217103739Stjr#define SLC_EEOL        30
218103739Stjr
219103739Stjr#define	NSLC		30
220103739Stjr
221103739Stjr/*
222103739Stjr * For backwards compatibility, we define SLC_NAMES to be the
223103739Stjr * list of names if SLC_NAMES is not defined.
224103739Stjr */
225113199Stjr#define	SLC_NAMELIST	"0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR",	\
226124887Sdas			"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP",	\
227103739Stjr			"LNEXT", "XON", "XOFF", "FORW1", "FORW2",	\
228103739Stjr			"MCL", "MCR", "MCWL", "MCWR", "MCBOL",		\
229103739Stjr			"MCEOL", "INSRT", "OVER", "ECR", "EWR",		\
230103739Stjr			"EBOL", "EEOL",					\
231103739Stjr			0
232103739Stjr
233103739Stjr#ifdef	SLC_NAMES
234103739Stjrconst char *slc_names[] = {
235103739Stjr	SLC_NAMELIST
236103739Stjr};
237103739Stjr#else
238103739Stjrextern char *slc_names[];
239103739Stjr#define	SLC_NAMES SLC_NAMELIST
240103739Stjr#endif
241103739Stjr
242103739Stjr#define	SLC_NAME_OK(x)	((unsigned int)(x) <= NSLC)
243103739Stjr#define SLC_NAME(x)	slc_names[x]
244103739Stjr
245103739Stjr#define	SLC_NOSUPPORT	0
246103739Stjr#define	SLC_CANTCHANGE	1
247103739Stjr#define	SLC_VARIABLE	2
248103739Stjr#define	SLC_DEFAULT	3
249103739Stjr#define	SLC_LEVELBITS	0x03
250103739Stjr
251103739Stjr#define	SLC_FUNC	0
252103739Stjr#define	SLC_FLAGS	1
253103739Stjr#define	SLC_VALUE	2
254103739Stjr
255103739Stjr#define	SLC_ACK		0x80
256103739Stjr#define	SLC_FLUSHIN	0x40
257103739Stjr#define	SLC_FLUSHOUT	0x20
258103739Stjr
259103739Stjr#define	OLD_ENV_VAR	1
260103739Stjr#define	OLD_ENV_VALUE	0
261103739Stjr#define	NEW_ENV_VAR	0
262103739Stjr#define	NEW_ENV_VALUE	1
263103739Stjr#define	ENV_ESC		2
264103739Stjr#define ENV_USERVAR	3
265103739Stjr
266103739Stjr/*
267103739Stjr * AUTHENTICATION suboptions
268103739Stjr */
269103739Stjr
270103739Stjr/*
271103739Stjr * Who is authenticating who ...
272103739Stjr */
273103739Stjr#define	AUTH_WHO_CLIENT		0	/* Client authenticating server */
274103739Stjr#define	AUTH_WHO_SERVER		1	/* Server authenticating client */
275103739Stjr#define	AUTH_WHO_MASK		1
276103739Stjr
277103739Stjr/*
278103739Stjr * amount of authentication done
279103739Stjr */
280103739Stjr#define	AUTH_HOW_ONE_WAY	0
281103739Stjr#define	AUTH_HOW_MUTUAL		2
282103739Stjr#define	AUTH_HOW_MASK		2
283103739Stjr
284103739Stjr#define	AUTHTYPE_NULL		0
285103739Stjr#define	AUTHTYPE_KERBEROS_V4	1
286103739Stjr#define	AUTHTYPE_KERBEROS_V5	2
287103739Stjr#define	AUTHTYPE_SPX		3
288103739Stjr#define	AUTHTYPE_MINK		4
289103739Stjr#define	AUTHTYPE_SRA		6
290103739Stjr#define	AUTHTYPE_CNT		7
291103739Stjr
292103739Stjr#define	AUTHTYPE_TEST		99
293103739Stjr
294103739Stjr#ifdef	AUTH_NAMES
295103739Stjrconst char *authtype_names[] = {
296103739Stjr	"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", NULL, "SRA",
297103739Stjr	0
298103739Stjr};
299103739Stjr#else
300103739Stjrextern char *authtype_names[];
301103739Stjr#endif
302103739Stjr
303103739Stjr#define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)
304128002Stjr#define	AUTHTYPE_NAME(x)	authtype_names[x]
305128002Stjr
306103739Stjr/*
307103739Stjr * ENCRYPTion suboptions
308103739Stjr */
309103739Stjr#define	ENCRYPT_IS		0	/* I pick encryption type ... */
310113199Stjr#define	ENCRYPT_SUPPORT		1	/* I support encryption types ... */
311113199Stjr#define	ENCRYPT_REPLY		2	/* Initial setup response */
312113199Stjr#define	ENCRYPT_START		3	/* Am starting to send encrypted */
313103739Stjr#define	ENCRYPT_END		4	/* Am ending encrypted */
314103739Stjr#define	ENCRYPT_REQSTART	5	/* Request you start encrypting */
315103739Stjr#define	ENCRYPT_REQEND		6	/* Request you end encrypting */
316103739Stjr#define	ENCRYPT_ENC_KEYID	7
317103739Stjr#define	ENCRYPT_DEC_KEYID	8
318103739Stjr#define	ENCRYPT_CNT		9
319103739Stjr
320103739Stjr#define	ENCTYPE_ANY		0
321103739Stjr#define	ENCTYPE_DES_CFB64	1
322103739Stjr#define	ENCTYPE_DES_OFB64	2
323103739Stjr#define	ENCTYPE_CNT		3
324128002Stjr
325103739Stjr#ifdef	ENCRYPT_NAMES
326128002Stjrconst char *encrypt_names[] = {
327103739Stjr	"IS", "SUPPORT", "REPLY", "START", "END",
328103739Stjr	"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
329103739Stjr	0
330103739Stjr};
331103739Stjrconst char *enctype_names[] = {
332103739Stjr	"ANY", "DES_CFB64",  "DES_OFB64",
333103739Stjr	0
334103739Stjr};
335103739Stjr#else
336103739Stjrextern char *encrypt_names[];
337103739Stjrextern char *enctype_names[];
338103739Stjr#endif
339103739Stjr
340103739Stjr
341103739Stjr#define	ENCRYPT_NAME_OK(x)	((unsigned int)(x) < ENCRYPT_CNT)
342103739Stjr#define	ENCRYPT_NAME(x)		encrypt_names[x]
343103739Stjr
344103739Stjr#define	ENCTYPE_NAME_OK(x)	((unsigned int)(x) < ENCTYPE_CNT)
345103739Stjr#define	ENCTYPE_NAME(x)		enctype_names[x]
346103739Stjr
347103739Stjr#endif /* !_TELNET_H_ */
348103739Stjr