1331722Seadler/*
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.
13203965Simp * 3. Neither the name of the University nor the names of its contributors
141539Srgrimes *    may be used to endorse or promote products derived from this software
151539Srgrimes *    without specific prior written permission.
161539Srgrimes *
171539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271539Srgrimes * SUCH DAMAGE.
281539Srgrimes *
291539Srgrimes *	@(#)telnet.h	8.2 (Berkeley) 12/15/93
3072092Sasmodai * $FreeBSD$
311539Srgrimes */
321539Srgrimes
332163Spaul#ifndef _ARPA_TELNET_H_
342163Spaul#define	_ARPA_TELNET_H_
351539Srgrimes
361539Srgrimes/*
371539Srgrimes * Definitions for the TELNET protocol.
381539Srgrimes */
391539Srgrimes#define	IAC	255		/* interpret as command: */
401539Srgrimes#define	DONT	254		/* you are not to use option */
411539Srgrimes#define	DO	253		/* please, you use option */
421539Srgrimes#define	WONT	252		/* I won't use option */
431539Srgrimes#define	WILL	251		/* I will use option */
441539Srgrimes#define	SB	250		/* interpret as subnegotiation */
451539Srgrimes#define	GA	249		/* you may reverse the line */
461539Srgrimes#define	EL	248		/* erase the current line */
471539Srgrimes#define	EC	247		/* erase the current character */
481539Srgrimes#define	AYT	246		/* are you there */
491539Srgrimes#define	AO	245		/* abort output--but let prog finish */
501539Srgrimes#define	IP	244		/* interrupt process--permanently */
511539Srgrimes#define	BREAK	243		/* break */
521539Srgrimes#define	DM	242		/* data mark--for connect. cleaning */
531539Srgrimes#define	NOP	241		/* nop */
541539Srgrimes#define	SE	240		/* end sub negotiation */
551539Srgrimes#define EOR     239             /* end of record (transparent mode) */
561539Srgrimes#define	ABORT	238		/* Abort process */
571539Srgrimes#define	SUSP	237		/* Suspend process */
581539Srgrimes#define	xEOF	236		/* End of file: EOF is already used... */
591539Srgrimes
601539Srgrimes#define SYNCH	242		/* for telfunc calls */
611539Srgrimes
621539Srgrimes#ifdef TELCMDS
6387268Smarkmconst char *telcmds[] = {
641539Srgrimes	"EOF", "SUSP", "ABORT", "EOR",
651539Srgrimes	"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
6620003Sphk	"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
6720003Sphk	0
681539Srgrimes};
691539Srgrimes#else
701539Srgrimesextern char *telcmds[];
711539Srgrimes#endif
721539Srgrimes
731539Srgrimes#define	TELCMD_FIRST	xEOF
741539Srgrimes#define	TELCMD_LAST	IAC
751539Srgrimes#define	TELCMD_OK(x)	((unsigned int)(x) <= TELCMD_LAST && \
761539Srgrimes			 (unsigned int)(x) >= TELCMD_FIRST)
771539Srgrimes#define	TELCMD(x)	telcmds[(x)-TELCMD_FIRST]
781539Srgrimes
791539Srgrimes/* telnet options */
801539Srgrimes#define TELOPT_BINARY	0	/* 8-bit data path */
811539Srgrimes#define TELOPT_ECHO	1	/* echo */
821539Srgrimes#define	TELOPT_RCP	2	/* prepare to reconnect */
831539Srgrimes#define	TELOPT_SGA	3	/* suppress go ahead */
841539Srgrimes#define	TELOPT_NAMS	4	/* approximate message size */
851539Srgrimes#define	TELOPT_STATUS	5	/* give status */
861539Srgrimes#define	TELOPT_TM	6	/* timing mark */
871539Srgrimes#define	TELOPT_RCTE	7	/* remote controlled transmission and echo */
881539Srgrimes#define TELOPT_NAOL 	8	/* negotiate about output line width */
891539Srgrimes#define TELOPT_NAOP 	9	/* negotiate about output page size */
901539Srgrimes#define TELOPT_NAOCRD	10	/* negotiate about CR disposition */
911539Srgrimes#define TELOPT_NAOHTS	11	/* negotiate about horizontal tabstops */
921539Srgrimes#define TELOPT_NAOHTD	12	/* negotiate about horizontal tab disposition */
931539Srgrimes#define TELOPT_NAOFFD	13	/* negotiate about formfeed disposition */
941539Srgrimes#define TELOPT_NAOVTS	14	/* negotiate about vertical tab stops */
951539Srgrimes#define TELOPT_NAOVTD	15	/* negotiate about vertical tab disposition */
961539Srgrimes#define TELOPT_NAOLFD	16	/* negotiate about output LF disposition */
971539Srgrimes#define TELOPT_XASCII	17	/* extended ascic character set */
981539Srgrimes#define	TELOPT_LOGOUT	18	/* force logout */
991539Srgrimes#define	TELOPT_BM	19	/* byte macro */
1001539Srgrimes#define	TELOPT_DET	20	/* data entry terminal */
1011539Srgrimes#define	TELOPT_SUPDUP	21	/* supdup protocol */
1021539Srgrimes#define	TELOPT_SUPDUPOUTPUT 22	/* supdup output */
1031539Srgrimes#define	TELOPT_SNDLOC	23	/* send location */
1041539Srgrimes#define	TELOPT_TTYPE	24	/* terminal type */
1051539Srgrimes#define	TELOPT_EOR	25	/* end or record */
1061539Srgrimes#define	TELOPT_TUID	26	/* TACACS user identification */
1071539Srgrimes#define	TELOPT_OUTMRK	27	/* output marking */
1081539Srgrimes#define	TELOPT_TTYLOC	28	/* terminal location number */
1091539Srgrimes#define	TELOPT_3270REGIME 29	/* 3270 regime */
1101539Srgrimes#define	TELOPT_X3PAD	30	/* X.3 PAD */
1111539Srgrimes#define	TELOPT_NAWS	31	/* window size */
1121539Srgrimes#define	TELOPT_TSPEED	32	/* terminal speed */
1131539Srgrimes#define	TELOPT_LFLOW	33	/* remote flow control */
1141539Srgrimes#define TELOPT_LINEMODE	34	/* Linemode option */
1151539Srgrimes#define TELOPT_XDISPLOC	35	/* X Display Location */
1161539Srgrimes#define TELOPT_OLD_ENVIRON 36	/* Old - Environment variables */
1171539Srgrimes#define	TELOPT_AUTHENTICATION 37/* Authenticate */
1181539Srgrimes#define	TELOPT_ENCRYPT	38	/* Encryption option */
1191539Srgrimes#define TELOPT_NEW_ENVIRON 39	/* New - Environment variables */
120109467Sbillf#define	TELOPT_TN3270E	40	/* RFC2355 - TN3270 Enhancements */
121109467Sbillf#define	TELOPT_CHARSET	42	/* RFC2066 - Charset */
122109467Sbillf#define	TELOPT_COMPORT	44	/* RFC2217 - Com Port Control */
123109467Sbillf#define	TELOPT_KERMIT	47	/* RFC2840 - Kermit */
1241539Srgrimes#define	TELOPT_EXOPL	255	/* extended-options-list */
1251539Srgrimes
1261539Srgrimes
127109467Sbillf#define	NTELOPTS	(1+TELOPT_KERMIT)
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",
139183004Santoine	"ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET",
140183004Santoine	"RSP", "COM-PORT", "SLE", "STARTTLS", "KERMIT",
14120003Sphk	0
1421539Srgrimes};
1431539Srgrimes#define	TELOPT_FIRST	TELOPT_BINARY
144109467Sbillf#define	TELOPT_LAST	TELOPT_KERMIT
1451539Srgrimes#define	TELOPT_OK(x)	((unsigned int)(x) <= TELOPT_LAST)
1461539Srgrimes#define	TELOPT(x)	telopts[(x)-TELOPT_FIRST]
1471539Srgrimes#endif
1481539Srgrimes
1491539Srgrimes/* sub-option qualifiers */
1501539Srgrimes#define	TELQUAL_IS	0	/* option is... */
1511539Srgrimes#define	TELQUAL_SEND	1	/* send option */
1521539Srgrimes#define	TELQUAL_INFO	2	/* ENVIRON: informational version of IS */
1531539Srgrimes#define	TELQUAL_REPLY	2	/* AUTHENTICATION: client version of IS */
1541539Srgrimes#define	TELQUAL_NAME	3	/* AUTHENTICATION: client version of IS */
1551539Srgrimes
1561539Srgrimes#define	LFLOW_OFF		0	/* Disable remote flow control */
1571539Srgrimes#define	LFLOW_ON		1	/* Enable remote flow control */
1581539Srgrimes#define	LFLOW_RESTART_ANY	2	/* Restart output on any char */
1591539Srgrimes#define	LFLOW_RESTART_XON	3	/* Restart output only on XON */
1601539Srgrimes
1611539Srgrimes/*
1621539Srgrimes * LINEMODE suboptions
1631539Srgrimes */
1641539Srgrimes
1651539Srgrimes#define	LM_MODE		1
1661539Srgrimes#define	LM_FORWARDMASK	2
1671539Srgrimes#define	LM_SLC		3
1681539Srgrimes
1691539Srgrimes#define	MODE_EDIT	0x01
1701539Srgrimes#define	MODE_TRAPSIG	0x02
1711539Srgrimes#define	MODE_ACK	0x04
1721539Srgrimes#define MODE_SOFT_TAB	0x08
1731539Srgrimes#define MODE_LIT_ECHO	0x10
1741539Srgrimes
1751539Srgrimes#define	MODE_MASK	0x1f
1761539Srgrimes
1771539Srgrimes/* Not part of protocol, but needed to simplify things... */
1781539Srgrimes#define MODE_FLOW		0x0100
1791539Srgrimes#define MODE_ECHO		0x0200
1801539Srgrimes#define MODE_INBIN		0x0400
1811539Srgrimes#define MODE_OUTBIN		0x0800
1821539Srgrimes#define MODE_FORCE		0x1000
1831539Srgrimes
1841539Srgrimes#define	SLC_SYNCH	1
1851539Srgrimes#define	SLC_BRK		2
1861539Srgrimes#define	SLC_IP		3
1871539Srgrimes#define	SLC_AO		4
1881539Srgrimes#define	SLC_AYT		5
1891539Srgrimes#define	SLC_EOR		6
1901539Srgrimes#define	SLC_ABORT	7
1911539Srgrimes#define	SLC_EOF		8
1921539Srgrimes#define	SLC_SUSP	9
1931539Srgrimes#define	SLC_EC		10
1941539Srgrimes#define	SLC_EL		11
1951539Srgrimes#define	SLC_EW		12
1961539Srgrimes#define	SLC_RP		13
1971539Srgrimes#define	SLC_LNEXT	14
1981539Srgrimes#define	SLC_XON		15
1991539Srgrimes#define	SLC_XOFF	16
2001539Srgrimes#define	SLC_FORW1	17
2011539Srgrimes#define	SLC_FORW2	18
20220003Sphk#define SLC_MCL         19
20320003Sphk#define SLC_MCR         20
20420003Sphk#define SLC_MCWL        21
20520003Sphk#define SLC_MCWR        22
20620003Sphk#define SLC_MCBOL       23
20720003Sphk#define SLC_MCEOL       24
20820003Sphk#define SLC_INSRT       25
20920003Sphk#define SLC_OVER        26
21020003Sphk#define SLC_ECR         27
21120003Sphk#define SLC_EWR         28
21220003Sphk#define SLC_EBOL        29
21320003Sphk#define SLC_EEOL        30
2141539Srgrimes
21520003Sphk#define	NSLC		30
2161539Srgrimes
2171539Srgrimes/*
21872092Sasmodai * For backwards compatibility, we define SLC_NAMES to be the
2191539Srgrimes * list of names if SLC_NAMES is not defined.
2201539Srgrimes */
22120003Sphk#define	SLC_NAMELIST	"0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR",	\
22220003Sphk			"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP",	\
22320003Sphk			"LNEXT", "XON", "XOFF", "FORW1", "FORW2",	\
22420003Sphk			"MCL", "MCR", "MCWL", "MCWR", "MCBOL",		\
22520003Sphk			"MCEOL", "INSRT", "OVER", "ECR", "EWR",		\
22620003Sphk			"EBOL", "EEOL",					\
22720003Sphk			0
22820003Sphk
2291539Srgrimes#ifdef	SLC_NAMES
23087268Smarkmconst char *slc_names[] = {
2311539Srgrimes	SLC_NAMELIST
2321539Srgrimes};
2331539Srgrimes#else
2341539Srgrimesextern char *slc_names[];
2351539Srgrimes#define	SLC_NAMES SLC_NAMELIST
2361539Srgrimes#endif
2371539Srgrimes
2381539Srgrimes#define	SLC_NAME_OK(x)	((unsigned int)(x) <= NSLC)
2391539Srgrimes#define SLC_NAME(x)	slc_names[x]
2401539Srgrimes
2411539Srgrimes#define	SLC_NOSUPPORT	0
2421539Srgrimes#define	SLC_CANTCHANGE	1
2431539Srgrimes#define	SLC_VARIABLE	2
2441539Srgrimes#define	SLC_DEFAULT	3
2451539Srgrimes#define	SLC_LEVELBITS	0x03
2461539Srgrimes
2471539Srgrimes#define	SLC_FUNC	0
2481539Srgrimes#define	SLC_FLAGS	1
2491539Srgrimes#define	SLC_VALUE	2
2501539Srgrimes
2511539Srgrimes#define	SLC_ACK		0x80
2521539Srgrimes#define	SLC_FLUSHIN	0x40
2531539Srgrimes#define	SLC_FLUSHOUT	0x20
2541539Srgrimes
2551539Srgrimes#define	OLD_ENV_VAR	1
2561539Srgrimes#define	OLD_ENV_VALUE	0
2571539Srgrimes#define	NEW_ENV_VAR	0
2581539Srgrimes#define	NEW_ENV_VALUE	1
2591539Srgrimes#define	ENV_ESC		2
2601539Srgrimes#define ENV_USERVAR	3
2611539Srgrimes
2621539Srgrimes/*
2631539Srgrimes * AUTHENTICATION suboptions
2641539Srgrimes */
2651539Srgrimes
2661539Srgrimes/*
2671539Srgrimes * Who is authenticating who ...
2681539Srgrimes */
2691539Srgrimes#define	AUTH_WHO_CLIENT		0	/* Client authenticating server */
2701539Srgrimes#define	AUTH_WHO_SERVER		1	/* Server authenticating client */
2711539Srgrimes#define	AUTH_WHO_MASK		1
2721539Srgrimes
2731539Srgrimes/*
2741539Srgrimes * amount of authentication done
2751539Srgrimes */
2761539Srgrimes#define	AUTH_HOW_ONE_WAY	0
2771539Srgrimes#define	AUTH_HOW_MUTUAL		2
2781539Srgrimes#define	AUTH_HOW_MASK		2
2791539Srgrimes
2801539Srgrimes#define	AUTHTYPE_NULL		0
2811539Srgrimes#define	AUTHTYPE_KERBEROS_V4	1
2821539Srgrimes#define	AUTHTYPE_KERBEROS_V5	2
2831539Srgrimes#define	AUTHTYPE_SPX		3
2841539Srgrimes#define	AUTHTYPE_MINK		4
28585600Smarkm#define	AUTHTYPE_SRA		6
28685600Smarkm#define	AUTHTYPE_CNT		7
2871539Srgrimes
2881539Srgrimes#define	AUTHTYPE_TEST		99
2891539Srgrimes
2901539Srgrimes#ifdef	AUTH_NAMES
29187268Smarkmconst char *authtype_names[] = {
29285600Smarkm	"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", NULL, "SRA",
29320003Sphk	0
2941539Srgrimes};
2951539Srgrimes#else
2961539Srgrimesextern char *authtype_names[];
2971539Srgrimes#endif
2981539Srgrimes
2991539Srgrimes#define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)
3001539Srgrimes#define	AUTHTYPE_NAME(x)	authtype_names[x]
3011539Srgrimes
3021539Srgrimes/*
3031539Srgrimes * ENCRYPTion suboptions
3041539Srgrimes */
3051539Srgrimes#define	ENCRYPT_IS		0	/* I pick encryption type ... */
3061539Srgrimes#define	ENCRYPT_SUPPORT		1	/* I support encryption types ... */
3071539Srgrimes#define	ENCRYPT_REPLY		2	/* Initial setup response */
3081539Srgrimes#define	ENCRYPT_START		3	/* Am starting to send encrypted */
3091539Srgrimes#define	ENCRYPT_END		4	/* Am ending encrypted */
3101539Srgrimes#define	ENCRYPT_REQSTART	5	/* Request you start encrypting */
31128057Sfenner#define	ENCRYPT_REQEND		6	/* Request you end encrypting */
3121539Srgrimes#define	ENCRYPT_ENC_KEYID	7
3131539Srgrimes#define	ENCRYPT_DEC_KEYID	8
3141539Srgrimes#define	ENCRYPT_CNT		9
3151539Srgrimes
3161539Srgrimes#define	ENCTYPE_ANY		0
3171539Srgrimes#define	ENCTYPE_DES_CFB64	1
3181539Srgrimes#define	ENCTYPE_DES_OFB64	2
3191539Srgrimes#define	ENCTYPE_CNT		3
3201539Srgrimes
3211539Srgrimes#ifdef	ENCRYPT_NAMES
32287268Smarkmconst char *encrypt_names[] = {
3231539Srgrimes	"IS", "SUPPORT", "REPLY", "START", "END",
3241539Srgrimes	"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
32520003Sphk	0
3261539Srgrimes};
32787268Smarkmconst char *enctype_names[] = {
32820003Sphk	"ANY", "DES_CFB64",  "DES_OFB64",
32920003Sphk	0
3301539Srgrimes};
3311539Srgrimes#else
3321539Srgrimesextern char *encrypt_names[];
3331539Srgrimesextern char *enctype_names[];
3341539Srgrimes#endif
3351539Srgrimes
3361539Srgrimes
3371539Srgrimes#define	ENCRYPT_NAME_OK(x)	((unsigned int)(x) < ENCRYPT_CNT)
3381539Srgrimes#define	ENCRYPT_NAME(x)		encrypt_names[x]
3391539Srgrimes
3401539Srgrimes#define	ENCTYPE_NAME_OK(x)	((unsigned int)(x) < ENCTYPE_CNT)
3411539Srgrimes#define	ENCTYPE_NAME(x)		enctype_names[x]
3421539Srgrimes
3431539Srgrimes#endif /* !_TELNET_H_ */
344