telnet.h revision 87268
11539Srgrimes/*
21539Srgrimes * Copyright (c) 1983, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes *
51539Srgrimes * Redistribution and use in source and binary forms, with or without
61539Srgrimes * modification, are permitted provided that the following conditions
71539Srgrimes * are met:
81539Srgrimes * 1. Redistributions of source code must retain the above copyright
91539Srgrimes *    notice, this list of conditions and the following disclaimer.
101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111539Srgrimes *    notice, this list of conditions and the following disclaimer in the
121539Srgrimes *    documentation and/or other materials provided with the distribution.
131539Srgrimes * 3. All advertising materials mentioning features or use of this software
141539Srgrimes *    must display the following acknowledgement:
151539Srgrimes *	This product includes software developed by the University of
161539Srgrimes *	California, Berkeley and its contributors.
171539Srgrimes * 4. Neither the name of the University nor the names of its contributors
181539Srgrimes *    may be used to endorse or promote products derived from this software
191539Srgrimes *    without specific prior written permission.
201539Srgrimes *
211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311539Srgrimes * SUCH DAMAGE.
321539Srgrimes *
331539Srgrimes *	@(#)telnet.h	8.2 (Berkeley) 12/15/93
3472092Sasmodai * $FreeBSD: head/include/arpa/telnet.h 87268 2001-12-03 12:41:19Z markm $
351539Srgrimes */
361539Srgrimes
372163Spaul#ifndef _ARPA_TELNET_H_
382163Spaul#define	_ARPA_TELNET_H_
391539Srgrimes
401539Srgrimes/*
411539Srgrimes * Definitions for the TELNET protocol.
421539Srgrimes */
431539Srgrimes#define	IAC	255		/* interpret as command: */
441539Srgrimes#define	DONT	254		/* you are not to use option */
451539Srgrimes#define	DO	253		/* please, you use option */
461539Srgrimes#define	WONT	252		/* I won't use option */
471539Srgrimes#define	WILL	251		/* I will use option */
481539Srgrimes#define	SB	250		/* interpret as subnegotiation */
491539Srgrimes#define	GA	249		/* you may reverse the line */
501539Srgrimes#define	EL	248		/* erase the current line */
511539Srgrimes#define	EC	247		/* erase the current character */
521539Srgrimes#define	AYT	246		/* are you there */
531539Srgrimes#define	AO	245		/* abort output--but let prog finish */
541539Srgrimes#define	IP	244		/* interrupt process--permanently */
551539Srgrimes#define	BREAK	243		/* break */
561539Srgrimes#define	DM	242		/* data mark--for connect. cleaning */
571539Srgrimes#define	NOP	241		/* nop */
581539Srgrimes#define	SE	240		/* end sub negotiation */
591539Srgrimes#define EOR     239             /* end of record (transparent mode) */
601539Srgrimes#define	ABORT	238		/* Abort process */
611539Srgrimes#define	SUSP	237		/* Suspend process */
621539Srgrimes#define	xEOF	236		/* End of file: EOF is already used... */
631539Srgrimes
641539Srgrimes#define SYNCH	242		/* for telfunc calls */
651539Srgrimes
661539Srgrimes#ifdef TELCMDS
6787268Smarkmconst char *telcmds[] = {
681539Srgrimes	"EOF", "SUSP", "ABORT", "EOR",
691539Srgrimes	"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
7020003Sphk	"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
7120003Sphk	0
721539Srgrimes};
731539Srgrimes#else
741539Srgrimesextern char *telcmds[];
751539Srgrimes#endif
761539Srgrimes
771539Srgrimes#define	TELCMD_FIRST	xEOF
781539Srgrimes#define	TELCMD_LAST	IAC
791539Srgrimes#define	TELCMD_OK(x)	((unsigned int)(x) <= TELCMD_LAST && \
801539Srgrimes			 (unsigned int)(x) >= TELCMD_FIRST)
811539Srgrimes#define	TELCMD(x)	telcmds[(x)-TELCMD_FIRST]
821539Srgrimes
831539Srgrimes/* telnet options */
841539Srgrimes#define TELOPT_BINARY	0	/* 8-bit data path */
851539Srgrimes#define TELOPT_ECHO	1	/* echo */
861539Srgrimes#define	TELOPT_RCP	2	/* prepare to reconnect */
871539Srgrimes#define	TELOPT_SGA	3	/* suppress go ahead */
881539Srgrimes#define	TELOPT_NAMS	4	/* approximate message size */
891539Srgrimes#define	TELOPT_STATUS	5	/* give status */
901539Srgrimes#define	TELOPT_TM	6	/* timing mark */
911539Srgrimes#define	TELOPT_RCTE	7	/* remote controlled transmission and echo */
921539Srgrimes#define TELOPT_NAOL 	8	/* negotiate about output line width */
931539Srgrimes#define TELOPT_NAOP 	9	/* negotiate about output page size */
941539Srgrimes#define TELOPT_NAOCRD	10	/* negotiate about CR disposition */
951539Srgrimes#define TELOPT_NAOHTS	11	/* negotiate about horizontal tabstops */
961539Srgrimes#define TELOPT_NAOHTD	12	/* negotiate about horizontal tab disposition */
971539Srgrimes#define TELOPT_NAOFFD	13	/* negotiate about formfeed disposition */
981539Srgrimes#define TELOPT_NAOVTS	14	/* negotiate about vertical tab stops */
991539Srgrimes#define TELOPT_NAOVTD	15	/* negotiate about vertical tab disposition */
1001539Srgrimes#define TELOPT_NAOLFD	16	/* negotiate about output LF disposition */
1011539Srgrimes#define TELOPT_XASCII	17	/* extended ascic character set */
1021539Srgrimes#define	TELOPT_LOGOUT	18	/* force logout */
1031539Srgrimes#define	TELOPT_BM	19	/* byte macro */
1041539Srgrimes#define	TELOPT_DET	20	/* data entry terminal */
1051539Srgrimes#define	TELOPT_SUPDUP	21	/* supdup protocol */
1061539Srgrimes#define	TELOPT_SUPDUPOUTPUT 22	/* supdup output */
1071539Srgrimes#define	TELOPT_SNDLOC	23	/* send location */
1081539Srgrimes#define	TELOPT_TTYPE	24	/* terminal type */
1091539Srgrimes#define	TELOPT_EOR	25	/* end or record */
1101539Srgrimes#define	TELOPT_TUID	26	/* TACACS user identification */
1111539Srgrimes#define	TELOPT_OUTMRK	27	/* output marking */
1121539Srgrimes#define	TELOPT_TTYLOC	28	/* terminal location number */
1131539Srgrimes#define	TELOPT_3270REGIME 29	/* 3270 regime */
1141539Srgrimes#define	TELOPT_X3PAD	30	/* X.3 PAD */
1151539Srgrimes#define	TELOPT_NAWS	31	/* window size */
1161539Srgrimes#define	TELOPT_TSPEED	32	/* terminal speed */
1171539Srgrimes#define	TELOPT_LFLOW	33	/* remote flow control */
1181539Srgrimes#define TELOPT_LINEMODE	34	/* Linemode option */
1191539Srgrimes#define TELOPT_XDISPLOC	35	/* X Display Location */
1201539Srgrimes#define TELOPT_OLD_ENVIRON 36	/* Old - Environment variables */
1211539Srgrimes#define	TELOPT_AUTHENTICATION 37/* Authenticate */
1221539Srgrimes#define	TELOPT_ENCRYPT	38	/* Encryption option */
1231539Srgrimes#define TELOPT_NEW_ENVIRON 39	/* New - Environment variables */
1241539Srgrimes#define	TELOPT_EXOPL	255	/* extended-options-list */
1251539Srgrimes
1261539Srgrimes
1271539Srgrimes#define	NTELOPTS	(1+TELOPT_NEW_ENVIRON)
1281539Srgrimes#ifdef TELOPTS
12987268Smarkmconst char *telopts[NTELOPTS+1] = {
1301539Srgrimes	"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
1311539Srgrimes	"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
1321539Srgrimes	"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
1331539Srgrimes	"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
1341539Srgrimes	"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
1351539Srgrimes	"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
1361539Srgrimes	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
1371539Srgrimes	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
1381539Srgrimes	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
1391539Srgrimes	"ENCRYPT", "NEW-ENVIRON",
14020003Sphk	0
1411539Srgrimes};
1421539Srgrimes#define	TELOPT_FIRST	TELOPT_BINARY
1431539Srgrimes#define	TELOPT_LAST	TELOPT_NEW_ENVIRON
1441539Srgrimes#define	TELOPT_OK(x)	((unsigned int)(x) <= TELOPT_LAST)
1451539Srgrimes#define	TELOPT(x)	telopts[(x)-TELOPT_FIRST]
1461539Srgrimes#endif
1471539Srgrimes
1481539Srgrimes/* sub-option qualifiers */
1491539Srgrimes#define	TELQUAL_IS	0	/* option is... */
1501539Srgrimes#define	TELQUAL_SEND	1	/* send option */
1511539Srgrimes#define	TELQUAL_INFO	2	/* ENVIRON: informational version of IS */
1521539Srgrimes#define	TELQUAL_REPLY	2	/* AUTHENTICATION: client version of IS */
1531539Srgrimes#define	TELQUAL_NAME	3	/* AUTHENTICATION: client version of IS */
1541539Srgrimes
1551539Srgrimes#define	LFLOW_OFF		0	/* Disable remote flow control */
1561539Srgrimes#define	LFLOW_ON		1	/* Enable remote flow control */
1571539Srgrimes#define	LFLOW_RESTART_ANY	2	/* Restart output on any char */
1581539Srgrimes#define	LFLOW_RESTART_XON	3	/* Restart output only on XON */
1591539Srgrimes
1601539Srgrimes/*
1611539Srgrimes * LINEMODE suboptions
1621539Srgrimes */
1631539Srgrimes
1641539Srgrimes#define	LM_MODE		1
1651539Srgrimes#define	LM_FORWARDMASK	2
1661539Srgrimes#define	LM_SLC		3
1671539Srgrimes
1681539Srgrimes#define	MODE_EDIT	0x01
1691539Srgrimes#define	MODE_TRAPSIG	0x02
1701539Srgrimes#define	MODE_ACK	0x04
1711539Srgrimes#define MODE_SOFT_TAB	0x08
1721539Srgrimes#define MODE_LIT_ECHO	0x10
1731539Srgrimes
1741539Srgrimes#define	MODE_MASK	0x1f
1751539Srgrimes
1761539Srgrimes/* Not part of protocol, but needed to simplify things... */
1771539Srgrimes#define MODE_FLOW		0x0100
1781539Srgrimes#define MODE_ECHO		0x0200
1791539Srgrimes#define MODE_INBIN		0x0400
1801539Srgrimes#define MODE_OUTBIN		0x0800
1811539Srgrimes#define MODE_FORCE		0x1000
1821539Srgrimes
1831539Srgrimes#define	SLC_SYNCH	1
1841539Srgrimes#define	SLC_BRK		2
1851539Srgrimes#define	SLC_IP		3
1861539Srgrimes#define	SLC_AO		4
1871539Srgrimes#define	SLC_AYT		5
1881539Srgrimes#define	SLC_EOR		6
1891539Srgrimes#define	SLC_ABORT	7
1901539Srgrimes#define	SLC_EOF		8
1911539Srgrimes#define	SLC_SUSP	9
1921539Srgrimes#define	SLC_EC		10
1931539Srgrimes#define	SLC_EL		11
1941539Srgrimes#define	SLC_EW		12
1951539Srgrimes#define	SLC_RP		13
1961539Srgrimes#define	SLC_LNEXT	14
1971539Srgrimes#define	SLC_XON		15
1981539Srgrimes#define	SLC_XOFF	16
1991539Srgrimes#define	SLC_FORW1	17
2001539Srgrimes#define	SLC_FORW2	18
20120003Sphk#define SLC_MCL         19
20220003Sphk#define SLC_MCR         20
20320003Sphk#define SLC_MCWL        21
20420003Sphk#define SLC_MCWR        22
20520003Sphk#define SLC_MCBOL       23
20620003Sphk#define SLC_MCEOL       24
20720003Sphk#define SLC_INSRT       25
20820003Sphk#define SLC_OVER        26
20920003Sphk#define SLC_ECR         27
21020003Sphk#define SLC_EWR         28
21120003Sphk#define SLC_EBOL        29
21220003Sphk#define SLC_EEOL        30
2131539Srgrimes
21420003Sphk#define	NSLC		30
2151539Srgrimes
2161539Srgrimes/*
21772092Sasmodai * For backwards compatibility, we define SLC_NAMES to be the
2181539Srgrimes * list of names if SLC_NAMES is not defined.
2191539Srgrimes */
22020003Sphk#define	SLC_NAMELIST	"0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR",	\
22120003Sphk			"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP",	\
22220003Sphk			"LNEXT", "XON", "XOFF", "FORW1", "FORW2",	\
22320003Sphk			"MCL", "MCR", "MCWL", "MCWR", "MCBOL",		\
22420003Sphk			"MCEOL", "INSRT", "OVER", "ECR", "EWR",		\
22520003Sphk			"EBOL", "EEOL",					\
22620003Sphk			0
22720003Sphk
2281539Srgrimes#ifdef	SLC_NAMES
22987268Smarkmconst char *slc_names[] = {
2301539Srgrimes	SLC_NAMELIST
2311539Srgrimes};
2321539Srgrimes#else
2331539Srgrimesextern char *slc_names[];
2341539Srgrimes#define	SLC_NAMES SLC_NAMELIST
2351539Srgrimes#endif
2361539Srgrimes
2371539Srgrimes#define	SLC_NAME_OK(x)	((unsigned int)(x) <= NSLC)
2381539Srgrimes#define SLC_NAME(x)	slc_names[x]
2391539Srgrimes
2401539Srgrimes#define	SLC_NOSUPPORT	0
2411539Srgrimes#define	SLC_CANTCHANGE	1
2421539Srgrimes#define	SLC_VARIABLE	2
2431539Srgrimes#define	SLC_DEFAULT	3
2441539Srgrimes#define	SLC_LEVELBITS	0x03
2451539Srgrimes
2461539Srgrimes#define	SLC_FUNC	0
2471539Srgrimes#define	SLC_FLAGS	1
2481539Srgrimes#define	SLC_VALUE	2
2491539Srgrimes
2501539Srgrimes#define	SLC_ACK		0x80
2511539Srgrimes#define	SLC_FLUSHIN	0x40
2521539Srgrimes#define	SLC_FLUSHOUT	0x20
2531539Srgrimes
2541539Srgrimes#define	OLD_ENV_VAR	1
2551539Srgrimes#define	OLD_ENV_VALUE	0
2561539Srgrimes#define	NEW_ENV_VAR	0
2571539Srgrimes#define	NEW_ENV_VALUE	1
2581539Srgrimes#define	ENV_ESC		2
2591539Srgrimes#define ENV_USERVAR	3
2601539Srgrimes
2611539Srgrimes/*
2621539Srgrimes * AUTHENTICATION suboptions
2631539Srgrimes */
2641539Srgrimes
2651539Srgrimes/*
2661539Srgrimes * Who is authenticating who ...
2671539Srgrimes */
2681539Srgrimes#define	AUTH_WHO_CLIENT		0	/* Client authenticating server */
2691539Srgrimes#define	AUTH_WHO_SERVER		1	/* Server authenticating client */
2701539Srgrimes#define	AUTH_WHO_MASK		1
2711539Srgrimes
2721539Srgrimes/*
2731539Srgrimes * amount of authentication done
2741539Srgrimes */
2751539Srgrimes#define	AUTH_HOW_ONE_WAY	0
2761539Srgrimes#define	AUTH_HOW_MUTUAL		2
2771539Srgrimes#define	AUTH_HOW_MASK		2
2781539Srgrimes
2791539Srgrimes#define	AUTHTYPE_NULL		0
2801539Srgrimes#define	AUTHTYPE_KERBEROS_V4	1
2811539Srgrimes#define	AUTHTYPE_KERBEROS_V5	2
2821539Srgrimes#define	AUTHTYPE_SPX		3
2831539Srgrimes#define	AUTHTYPE_MINK		4
28485600Smarkm#define	AUTHTYPE_SRA		6
28585600Smarkm#define	AUTHTYPE_CNT		7
2861539Srgrimes
2871539Srgrimes#define	AUTHTYPE_TEST		99
2881539Srgrimes
2891539Srgrimes#ifdef	AUTH_NAMES
29087268Smarkmconst char *authtype_names[] = {
29185600Smarkm	"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", NULL, "SRA",
29220003Sphk	0
2931539Srgrimes};
2941539Srgrimes#else
2951539Srgrimesextern char *authtype_names[];
2961539Srgrimes#endif
2971539Srgrimes
2981539Srgrimes#define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)
2991539Srgrimes#define	AUTHTYPE_NAME(x)	authtype_names[x]
3001539Srgrimes
3011539Srgrimes/*
3021539Srgrimes * ENCRYPTion suboptions
3031539Srgrimes */
3041539Srgrimes#define	ENCRYPT_IS		0	/* I pick encryption type ... */
3051539Srgrimes#define	ENCRYPT_SUPPORT		1	/* I support encryption types ... */
3061539Srgrimes#define	ENCRYPT_REPLY		2	/* Initial setup response */
3071539Srgrimes#define	ENCRYPT_START		3	/* Am starting to send encrypted */
3081539Srgrimes#define	ENCRYPT_END		4	/* Am ending encrypted */
3091539Srgrimes#define	ENCRYPT_REQSTART	5	/* Request you start encrypting */
31028057Sfenner#define	ENCRYPT_REQEND		6	/* Request you end encrypting */
3111539Srgrimes#define	ENCRYPT_ENC_KEYID	7
3121539Srgrimes#define	ENCRYPT_DEC_KEYID	8
3131539Srgrimes#define	ENCRYPT_CNT		9
3141539Srgrimes
3151539Srgrimes#define	ENCTYPE_ANY		0
3161539Srgrimes#define	ENCTYPE_DES_CFB64	1
3171539Srgrimes#define	ENCTYPE_DES_OFB64	2
3181539Srgrimes#define	ENCTYPE_CNT		3
3191539Srgrimes
3201539Srgrimes#ifdef	ENCRYPT_NAMES
32187268Smarkmconst char *encrypt_names[] = {
3221539Srgrimes	"IS", "SUPPORT", "REPLY", "START", "END",
3231539Srgrimes	"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
32420003Sphk	0
3251539Srgrimes};
32687268Smarkmconst char *enctype_names[] = {
32720003Sphk	"ANY", "DES_CFB64",  "DES_OFB64",
32820003Sphk	0
3291539Srgrimes};
3301539Srgrimes#else
3311539Srgrimesextern char *encrypt_names[];
3321539Srgrimesextern char *enctype_names[];
3331539Srgrimes#endif
3341539Srgrimes
3351539Srgrimes
3361539Srgrimes#define	ENCRYPT_NAME_OK(x)	((unsigned int)(x) < ENCRYPT_CNT)
3371539Srgrimes#define	ENCRYPT_NAME(x)		encrypt_names[x]
3381539Srgrimes
3391539Srgrimes#define	ENCTYPE_NAME_OK(x)	((unsigned int)(x) < ENCTYPE_CNT)
3401539Srgrimes#define	ENCTYPE_NAME(x)		enctype_names[x]
3411539Srgrimes
3421539Srgrimes#endif /* !_TELNET_H_ */
343