xref: /illumos-gate/usr/src/head/arpa/telnet.h (revision a141dbd6230b88bf7da3b673ca0f9b46918d5684)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
2548bbca81SDaniel Hoffman  * Copyright (c) 2016 by Delphix. All rights reserved.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
297c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
337c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of California.
347c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifndef	_ARPA_TELNET_H
377c478bd9Sstevel@tonic-gate #define	_ARPA_TELNET_H
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
407c478bd9Sstevel@tonic-gate extern "C" {
417c478bd9Sstevel@tonic-gate #endif
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /*
447c478bd9Sstevel@tonic-gate  * Definitions for the TELNET protocol.
457c478bd9Sstevel@tonic-gate  */
467c478bd9Sstevel@tonic-gate #define	IAC	255		/* interpret as command: */
477c478bd9Sstevel@tonic-gate #define	DONT	254		/* you are not to use option */
487c478bd9Sstevel@tonic-gate #define	DO	253		/* please, you use option */
497c478bd9Sstevel@tonic-gate #define	WONT	252		/* I won't use option */
507c478bd9Sstevel@tonic-gate #define	WILL	251		/* I will use option */
517c478bd9Sstevel@tonic-gate #define	SB	250		/* interpret as subnegotiation */
527c478bd9Sstevel@tonic-gate #define	GA	249		/* you may reverse the line */
537c478bd9Sstevel@tonic-gate #define	EL	248		/* erase the current line */
547c478bd9Sstevel@tonic-gate #define	EC	247		/* erase the current character */
557c478bd9Sstevel@tonic-gate #define	AYT	246		/* are you there */
567c478bd9Sstevel@tonic-gate #define	AO	245		/* abort output--but let prog finish */
577c478bd9Sstevel@tonic-gate #define	IP	244		/* interrupt process--permanently */
587c478bd9Sstevel@tonic-gate #define	BREAK	243		/* break */
597c478bd9Sstevel@tonic-gate #define	DM	242		/* data mark--for connect. cleaning */
607c478bd9Sstevel@tonic-gate #define	NOP	241		/* nop */
617c478bd9Sstevel@tonic-gate #define	SE	240		/* end sub negotiation */
627c478bd9Sstevel@tonic-gate #define	EOR	239		/* end of record (transparent mode) */
637c478bd9Sstevel@tonic-gate #define	ABORT	238		/* Abort process */
647c478bd9Sstevel@tonic-gate #define	SUSP	237		/* Suspend process */
657c478bd9Sstevel@tonic-gate #define	xEOF	236		/* End of file: EOF is already used... */
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #define	SYNCH	242		/* for telfunc calls */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate #ifdef TELCMDS
707c478bd9Sstevel@tonic-gate char *telcmds[] = {
717c478bd9Sstevel@tonic-gate 	"EOF", "SUSP", "ABORT", "EOR",
727c478bd9Sstevel@tonic-gate 	"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
737c478bd9Sstevel@tonic-gate 	"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0
747c478bd9Sstevel@tonic-gate };
757c478bd9Sstevel@tonic-gate #endif
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate #define	TELCMD_FIRST	xEOF
787c478bd9Sstevel@tonic-gate #define	TELCMD_LAST	IAC
797c478bd9Sstevel@tonic-gate #define	TELCMD_OK(x)	((unsigned int)(x) <= TELCMD_LAST && \
807c478bd9Sstevel@tonic-gate 			    (unsigned int)(x) >= TELCMD_FIRST)
817c478bd9Sstevel@tonic-gate #define	TELCMD(x)	telcmds[(x)-TELCMD_FIRST]
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /* telnet options */
847c478bd9Sstevel@tonic-gate #define	TELOPT_BINARY	0	/* 8-bit data path */
857c478bd9Sstevel@tonic-gate #define	TELOPT_ECHO	1	/* echo */
867c478bd9Sstevel@tonic-gate #define	TELOPT_RCP	2	/* prepare to reconnect */
877c478bd9Sstevel@tonic-gate #define	TELOPT_SGA	3	/* suppress go ahead */
887c478bd9Sstevel@tonic-gate #define	TELOPT_NAMS	4	/* approximate message size */
897c478bd9Sstevel@tonic-gate #define	TELOPT_STATUS	5	/* give status */
907c478bd9Sstevel@tonic-gate #define	TELOPT_TM	6	/* timing mark */
917c478bd9Sstevel@tonic-gate #define	TELOPT_RCTE	7	/* remote controlled transmission and echo */
927c478bd9Sstevel@tonic-gate #define	TELOPT_NAOL	8	/* negotiate about output line width */
937c478bd9Sstevel@tonic-gate #define	TELOPT_NAOP	9	/* negotiate about output page size */
947c478bd9Sstevel@tonic-gate #define	TELOPT_NAOCRD	10	/* negotiate about CR disposition */
957c478bd9Sstevel@tonic-gate #define	TELOPT_NAOHTS	11	/* negotiate about horizontal tabstops */
967c478bd9Sstevel@tonic-gate #define	TELOPT_NAOHTD	12	/* negotiate about horizontal tab disposition */
977c478bd9Sstevel@tonic-gate #define	TELOPT_NAOFFD	13	/* negotiate about formfeed disposition */
987c478bd9Sstevel@tonic-gate #define	TELOPT_NAOVTS	14	/* negotiate about vertical tab stops */
997c478bd9Sstevel@tonic-gate #define	TELOPT_NAOVTD	15	/* negotiate about vertical tab disposition */
1007c478bd9Sstevel@tonic-gate #define	TELOPT_NAOLFD	16	/* negotiate about output LF disposition */
1017c478bd9Sstevel@tonic-gate #define	TELOPT_XASCII	17	/* extended ascic character set */
1027c478bd9Sstevel@tonic-gate #define	TELOPT_LOGOUT	18	/* force logout */
1037c478bd9Sstevel@tonic-gate #define	TELOPT_BM	19	/* byte macro */
1047c478bd9Sstevel@tonic-gate #define	TELOPT_DET	20	/* data entry terminal */
1057c478bd9Sstevel@tonic-gate #define	TELOPT_SUPDUP	21	/* supdup protocol */
1067c478bd9Sstevel@tonic-gate #define	TELOPT_SUPDUPOUTPUT 22	/* supdup output */
1077c478bd9Sstevel@tonic-gate #define	TELOPT_SNDLOC	23	/* send location */
1087c478bd9Sstevel@tonic-gate #define	TELOPT_TTYPE	24	/* terminal type */
1097c478bd9Sstevel@tonic-gate #define	TELOPT_EOR	25	/* end or record */
1107c478bd9Sstevel@tonic-gate #define	TELOPT_TUID	26	/* TACACS user identification */
1117c478bd9Sstevel@tonic-gate #define	TELOPT_OUTMRK	27	/* output marking */
1127c478bd9Sstevel@tonic-gate #define	TELOPT_TTYLOC	28	/* terminal location number */
1137c478bd9Sstevel@tonic-gate #define	TELOPT_3270REGIME 29	/* 3270 regime */
1147c478bd9Sstevel@tonic-gate #define	TELOPT_X3PAD	30	/* X.3 PAD */
1157c478bd9Sstevel@tonic-gate #define	TELOPT_NAWS	31	/* window size */
1167c478bd9Sstevel@tonic-gate #define	TELOPT_TSPEED	32	/* terminal speed */
1177c478bd9Sstevel@tonic-gate #define	TELOPT_LFLOW	33	/* remote flow control */
1187c478bd9Sstevel@tonic-gate #define	TELOPT_LINEMODE	34	/* Linemode option */
1197c478bd9Sstevel@tonic-gate #define	TELOPT_XDISPLOC	35	/* X Display Location */
1207c478bd9Sstevel@tonic-gate #define	TELOPT_OLD_ENVIRON 36	/* Old - Environment variables */
1217c478bd9Sstevel@tonic-gate #define	TELOPT_AUTHENTICATION 37 /* Authenticate */
1227c478bd9Sstevel@tonic-gate #define	TELOPT_ENCRYPT	38	/* Encryption option */
1237c478bd9Sstevel@tonic-gate #define	TELOPT_NEW_ENVIRON 39	/* New - Environment variables */
1247c478bd9Sstevel@tonic-gate #define	TELOPT_EXOPL	255	/* extended-options-list */
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate #ifdef TELOPTS
1277c478bd9Sstevel@tonic-gate #define	NTELOPTS	(1+TELOPT_NEW_ENVIRON)
1287c478bd9Sstevel@tonic-gate char *telopts[NTELOPTS+1] = {
1297c478bd9Sstevel@tonic-gate 	"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
1307c478bd9Sstevel@tonic-gate 	"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
1317c478bd9Sstevel@tonic-gate 	"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
1327c478bd9Sstevel@tonic-gate 	"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
1337c478bd9Sstevel@tonic-gate 	"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
1347c478bd9Sstevel@tonic-gate 	"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
1357c478bd9Sstevel@tonic-gate 	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
1367c478bd9Sstevel@tonic-gate 	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
1377c478bd9Sstevel@tonic-gate 	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
1387c478bd9Sstevel@tonic-gate 	"ENCRYPT", "NEW-ENVIRON",
1397c478bd9Sstevel@tonic-gate 	0,
1407c478bd9Sstevel@tonic-gate };
1417c478bd9Sstevel@tonic-gate #endif /* TELOPTS */
1427c478bd9Sstevel@tonic-gate #define	TELOPT_FIRST	TELOPT_BINARY
1437c478bd9Sstevel@tonic-gate #define	TELOPT_LAST	TELOPT_NEW_ENVIRON
1447c478bd9Sstevel@tonic-gate #define	TELOPT_OK(x)	((unsigned int)(x) <= TELOPT_LAST)
1457c478bd9Sstevel@tonic-gate #define	TELOPT(x)	telopts[(x)-TELOPT_FIRST]
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate /* sub-option qualifiers */
1487c478bd9Sstevel@tonic-gate #define	TELQUAL_IS	0	/* option is... */
1497c478bd9Sstevel@tonic-gate #define	TELQUAL_SEND	1	/* send option */
1507c478bd9Sstevel@tonic-gate #define	TELQUAL_INFO	2	/* ENVIRON: informational version of IS */
1517c478bd9Sstevel@tonic-gate #define	TELQUAL_REPLY	2	/* AUTHENTICATION: client version of IS */
1527c478bd9Sstevel@tonic-gate #define	TELQUAL_NAME	3	/* AUTHENTICATION: client version of IS */
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate #define	LFLOW_OFF		0	/* Disable remote flow control */
1557c478bd9Sstevel@tonic-gate #define	LFLOW_ON		1	/* Enable remote flow control */
1567c478bd9Sstevel@tonic-gate #define	LFLOW_RESTART_ANY	2	/* Restart output on any char */
1577c478bd9Sstevel@tonic-gate #define	LFLOW_RESTART_XON	3	/* Restart output only on XON */
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate /*
1607c478bd9Sstevel@tonic-gate  * LINEMODE suboptions
1617c478bd9Sstevel@tonic-gate  */
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate #define	LM_MODE		1
1647c478bd9Sstevel@tonic-gate #define	LM_FORWARDMASK	2
1657c478bd9Sstevel@tonic-gate #define	LM_SLC		3
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate #define	MODE_EDIT	0x01
1687c478bd9Sstevel@tonic-gate #define	MODE_TRAPSIG	0x02
1697c478bd9Sstevel@tonic-gate #define	MODE_ACK	0x04
1707c478bd9Sstevel@tonic-gate #define	MODE_SOFT_TAB	0x08
1717c478bd9Sstevel@tonic-gate #define	MODE_LIT_ECHO	0x10
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate #define	MODE_MASK	0x1f
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate /* Not part of protocol, but needed to simplify things... */
1767c478bd9Sstevel@tonic-gate #define	MODE_FLOW		0x0100
1777c478bd9Sstevel@tonic-gate #define	MODE_ECHO		0x0200
1787c478bd9Sstevel@tonic-gate #define	MODE_INBIN		0x0400
1797c478bd9Sstevel@tonic-gate #define	MODE_OUTBIN		0x0800
1807c478bd9Sstevel@tonic-gate #define	MODE_FORCE		0x1000
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate #define	SLC_SYNCH	1
1837c478bd9Sstevel@tonic-gate #define	SLC_BRK		2
1847c478bd9Sstevel@tonic-gate #define	SLC_IP		3
1857c478bd9Sstevel@tonic-gate #define	SLC_AO		4
1867c478bd9Sstevel@tonic-gate #define	SLC_AYT		5
1877c478bd9Sstevel@tonic-gate #define	SLC_EOR		6
1887c478bd9Sstevel@tonic-gate #define	SLC_ABORT	7
1897c478bd9Sstevel@tonic-gate #define	SLC_EOF		8
1907c478bd9Sstevel@tonic-gate #define	SLC_SUSP	9
1917c478bd9Sstevel@tonic-gate #define	SLC_EC		10
1927c478bd9Sstevel@tonic-gate #define	SLC_EL		11
1937c478bd9Sstevel@tonic-gate #define	SLC_EW		12
1947c478bd9Sstevel@tonic-gate #define	SLC_RP		13
1957c478bd9Sstevel@tonic-gate #define	SLC_LNEXT	14
1967c478bd9Sstevel@tonic-gate #define	SLC_XON		15
1977c478bd9Sstevel@tonic-gate #define	SLC_XOFF	16
1987c478bd9Sstevel@tonic-gate #define	SLC_FORW1	17
1997c478bd9Sstevel@tonic-gate #define	SLC_FORW2	18
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate #define	NSLC		18
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate /*
2047c478bd9Sstevel@tonic-gate  * For backwards compatability, we define SLC_NAMES to be the
2057c478bd9Sstevel@tonic-gate  * list of names if SLC_NAMES is not defined.
2067c478bd9Sstevel@tonic-gate  */
2077c478bd9Sstevel@tonic-gate #define	SLC_NAMELIST	"0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
2087c478bd9Sstevel@tonic-gate 			"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
2097c478bd9Sstevel@tonic-gate 			"LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
2107c478bd9Sstevel@tonic-gate #ifdef	SLC_NAMES
2117c478bd9Sstevel@tonic-gate char *slc_names[] = {
2127c478bd9Sstevel@tonic-gate 	SLC_NAMELIST
2137c478bd9Sstevel@tonic-gate };
2147c478bd9Sstevel@tonic-gate #else
2157c478bd9Sstevel@tonic-gate extern char *slc_names[];
2167c478bd9Sstevel@tonic-gate #define	SLC_NAMES SLC_NAMELIST
2177c478bd9Sstevel@tonic-gate #endif
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate #define	SLC_NAME_OK(x)	((unsigned int)(x) <= NSLC)
2207c478bd9Sstevel@tonic-gate #define	SLC_NAME(x)	slc_names[x]
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate #define	SLC_NOSUPPORT	0
2237c478bd9Sstevel@tonic-gate #define	SLC_CANTCHANGE	1
2247c478bd9Sstevel@tonic-gate #define	SLC_VARIABLE	2
2257c478bd9Sstevel@tonic-gate #define	SLC_DEFAULT	3
2267c478bd9Sstevel@tonic-gate #define	SLC_LEVELBITS	0x03
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate #define	SLC_FUNC	0
2297c478bd9Sstevel@tonic-gate #define	SLC_FLAGS	1
2307c478bd9Sstevel@tonic-gate #define	SLC_VALUE	2
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate #define	SLC_ACK		0x80
2337c478bd9Sstevel@tonic-gate #define	SLC_FLUSHIN	0x40
2347c478bd9Sstevel@tonic-gate #define	SLC_FLUSHOUT	0x20
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate #define	OLD_ENV_VAR	1
2377c478bd9Sstevel@tonic-gate #define	OLD_ENV_VALUE	0
2387c478bd9Sstevel@tonic-gate #define	NEW_ENV_VAR	0
2397c478bd9Sstevel@tonic-gate #define	NEW_ENV_VALUE	1
2407c478bd9Sstevel@tonic-gate #define	ENV_ESC		2
2417c478bd9Sstevel@tonic-gate #define	ENV_USERVAR	3
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate /*
2447c478bd9Sstevel@tonic-gate  * AUTHENTICATION suboptions
2457c478bd9Sstevel@tonic-gate  */
2467c478bd9Sstevel@tonic-gate #define	AUTH_REJECT	0	/* Rejected */
24748bbca81SDaniel Hoffman #define	AUTH_UNKNOWN	1	/* We don't know who it is, but it's okay */
248*a141dbd6SAlison C #define	AUTH_OTHER	2	/* We know it, but not its name */
249*a141dbd6SAlison C #define	AUTH_USER	3	/* We know its name */
25048bbca81SDaniel Hoffman #define	AUTH_VALID	4	/* We know it, and it needs no password */
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate /*
2537c478bd9Sstevel@tonic-gate  * Who is authenticating who ...
2547c478bd9Sstevel@tonic-gate  */
2557c478bd9Sstevel@tonic-gate #define	AUTH_WHO_CLIENT		0	/* Client authenticating server */
2567c478bd9Sstevel@tonic-gate #define	AUTH_WHO_SERVER		1	/* Server authenticating client */
2577c478bd9Sstevel@tonic-gate #define	AUTH_WHO_MASK		1
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate #ifdef	AUTHWHO_STR
2607c478bd9Sstevel@tonic-gate char *authwho_str[] = {
2617c478bd9Sstevel@tonic-gate 	"CLIENT", "SERVER" };
2627c478bd9Sstevel@tonic-gate #define	AUTHWHO_NAME(x)	authwho_str[x]
2637c478bd9Sstevel@tonic-gate #endif /* AUTHWHO_STR */
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate /*
2667c478bd9Sstevel@tonic-gate  * amount of authentication done
2677c478bd9Sstevel@tonic-gate  */
2687c478bd9Sstevel@tonic-gate #define	AUTH_HOW_ONE_WAY	0
2697c478bd9Sstevel@tonic-gate #define	AUTH_HOW_MUTUAL		2
2707c478bd9Sstevel@tonic-gate #define	AUTH_HOW_MASK		2
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate /*
2737c478bd9Sstevel@tonic-gate  * should we be encrypting? (not yet formally standardized)
2747c478bd9Sstevel@tonic-gate  */
2757c478bd9Sstevel@tonic-gate #define	AUTH_ENCRYPT_OFF	0
2767c478bd9Sstevel@tonic-gate #define	AUTH_ENCRYPT_ON		4
2777c478bd9Sstevel@tonic-gate #define	AUTH_ENCRYPT_MASK	4
2787c478bd9Sstevel@tonic-gate 
2797c478bd9Sstevel@tonic-gate #define	AUTHTYPE_NULL		0
2807c478bd9Sstevel@tonic-gate #define	AUTHTYPE_KERBEROS_V4	1	/* not supported */
2817c478bd9Sstevel@tonic-gate #define	AUTHTYPE_KERBEROS_V5	2
2827c478bd9Sstevel@tonic-gate #define	AUTHTYPE_CNT		3
2837c478bd9Sstevel@tonic-gate 
2847c478bd9Sstevel@tonic-gate #define	OPTS_FORWARD_CREDS		0x00000002
2857c478bd9Sstevel@tonic-gate #define	OPTS_FORWARDABLE_CREDS		0x00000001
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate #ifdef AUTHTYPE_NAMES
2887c478bd9Sstevel@tonic-gate char *authtype_names[] = {
2897c478bd9Sstevel@tonic-gate 	"NULL", "KERBEROS_V4", "KERBEROS_V5", 0,
2907c478bd9Sstevel@tonic-gate };
2917c478bd9Sstevel@tonic-gate #else
2927c478bd9Sstevel@tonic-gate extern char *authtype_names[];
2937c478bd9Sstevel@tonic-gate #endif /* AUTHTYPE_NAMES */
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate #define	AUTHTYPE_NAME(x)	authtype_names[x]
2967c478bd9Sstevel@tonic-gate #define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)
2977c478bd9Sstevel@tonic-gate 
2987c478bd9Sstevel@tonic-gate #ifdef AUTHHOW_NAMES
2997c478bd9Sstevel@tonic-gate char *authhow_names[] = {
3007c478bd9Sstevel@tonic-gate 	"ONE-WAY", "[undefined]", "MUTUAL" };
3017c478bd9Sstevel@tonic-gate #endif /* AUTHHOW_NAMES */
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate #define	AUTHHOW_NAME(x)		authhow_names[x]
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate #define	KRB_AUTH		0	/* Authentication data follows */
3067c478bd9Sstevel@tonic-gate #define	KRB_REJECT		1	/* Rejected (reason might follow) */
3077c478bd9Sstevel@tonic-gate #define	KRB_ACCEPT		2	/* Accepted */
3087c478bd9Sstevel@tonic-gate #define	KRB_RESPONSE		3	/* Response for mutual auth. */
3097c478bd9Sstevel@tonic-gate #define	KRB_FORWARD		4	/* Forwarded credentials follow */
3107c478bd9Sstevel@tonic-gate #define	KRB_FORWARD_ACCEPT	5	/* Forwarded credentials accepted */
3117c478bd9Sstevel@tonic-gate #define	KRB_FORWARD_REJECT	6	/* Forwarded credentials rejected */
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate #ifdef AUTHRSP_NAMES
3147c478bd9Sstevel@tonic-gate char *authrsp_names[] = {
3157c478bd9Sstevel@tonic-gate 	"AUTH", "REJECT", "ACCEPT", "RESPONSE", "FORWARD",
3167c478bd9Sstevel@tonic-gate 	"FORWARD_ACCEPT", "FORWARD_REJECT" };
3177c478bd9Sstevel@tonic-gate #define	AUTHRSP_NAME(x)		authrsp_names[x]
3187c478bd9Sstevel@tonic-gate #endif /* AUTHRSP_NAMES */
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate #define	AUTH_MODE_REQUIRE	0
3217c478bd9Sstevel@tonic-gate #define	AUTH_MODE_PROMPT	1
3227c478bd9Sstevel@tonic-gate #define	AUTH_MODE_WARN		2
3237c478bd9Sstevel@tonic-gate #define	AUTH_MODE_REJECT	3
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate /*
3277c478bd9Sstevel@tonic-gate  * Encryption suboptions. See RFC 2946.
3287c478bd9Sstevel@tonic-gate  */
3297c478bd9Sstevel@tonic-gate #define	ENCRYPT_IS		0	/* I pick encryption type ... */
3307c478bd9Sstevel@tonic-gate #define	ENCRYPT_SUPPORT		1	/* I support encryption types ... */
3317c478bd9Sstevel@tonic-gate #define	ENCRYPT_REPLY		2	/* Initial setup response */
3327c478bd9Sstevel@tonic-gate #define	ENCRYPT_START		3	/* Starting encrypting output */
3337c478bd9Sstevel@tonic-gate #define	ENCRYPT_END		4	/* End encrypting output */
3347c478bd9Sstevel@tonic-gate #define	ENCRYPT_REQSTART	5	/* Request to start encrypting output */
3357c478bd9Sstevel@tonic-gate #define	ENCRYPT_REQEND		6	/* Request to stop encrypting output */
3367c478bd9Sstevel@tonic-gate #define	ENCRYPT_ENC_KEYID	7	/* Negotiate encryption key */
3377c478bd9Sstevel@tonic-gate #define	ENCRYPT_DEC_KEYID	8	/* Negotiate decryption key */
3387c478bd9Sstevel@tonic-gate #define	ENCRYPT_CNT		9	/* marks the maximum ENCRYPT value */
3397c478bd9Sstevel@tonic-gate 
3407c478bd9Sstevel@tonic-gate #define	TELOPT_ENCTYPE_NULL		0
3417c478bd9Sstevel@tonic-gate #define	TELOPT_ENCTYPE_DES_CFB64	1 /* 64-bit Cipher Feedback Mode */
3427c478bd9Sstevel@tonic-gate #define	TELOPT_ENCTYPE_CNT		2
3437c478bd9Sstevel@tonic-gate 
3447c478bd9Sstevel@tonic-gate #define	CFB64_IV	1
3457c478bd9Sstevel@tonic-gate #define	CFB64_IV_OK	2
3467c478bd9Sstevel@tonic-gate #define	CFB64_IV_BAD	3
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate #define	FB64_IV		CFB64_IV
3497c478bd9Sstevel@tonic-gate #define	FB64_IV_OK	CFB64_IV_OK
3507c478bd9Sstevel@tonic-gate #define	FB64_IV_BAD	CFB64_IV_BAD
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate #ifdef ENCRYPT_NAMES
3537c478bd9Sstevel@tonic-gate char *encrypt_names[] = {
3547c478bd9Sstevel@tonic-gate 	"IS", "SUPPORT", "REPLY", "START", "END",
3557c478bd9Sstevel@tonic-gate 	"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
3567c478bd9Sstevel@tonic-gate 	0,
3577c478bd9Sstevel@tonic-gate };
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate char *enctype_names[] = {
3607c478bd9Sstevel@tonic-gate 	"ANY", "DES_CFB64", 0,
3617c478bd9Sstevel@tonic-gate };
3627c478bd9Sstevel@tonic-gate #else
3637c478bd9Sstevel@tonic-gate extern char *encrypt_names[];
3647c478bd9Sstevel@tonic-gate extern char *enctype_names[];
3657c478bd9Sstevel@tonic-gate #endif /* ENCRYPT_NAMES */
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate #define	ENCRYPT_NAME(x)		encrypt_names[x]
3687c478bd9Sstevel@tonic-gate #define	ENCTYPE_NAME(x)		enctype_names[x]
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate #define	ENCRYPT_NAME_OK(x)	((unsigned int)(x) < ENCRYPT_CNT)
3717c478bd9Sstevel@tonic-gate #define	ENCTYPE_NAME_OK(x)	((unsigned int)(x) < TELOPT_ENCTYPE_CNT)
3727c478bd9Sstevel@tonic-gate 
3737c478bd9Sstevel@tonic-gate #define	SK_DES	1 /* Matched Kerberos v5 ENCTYPE_DES */
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate #ifndef	DES_BLOCKSIZE
3767c478bd9Sstevel@tonic-gate #define	DES_BLOCKSIZE  8
3777c478bd9Sstevel@tonic-gate #endif	/* DES_BLOCKSIZE */
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate #define	TELNET_MAXNUMKEYS	64
3807c478bd9Sstevel@tonic-gate #define	TELNET_MAXKEYIDLEN	16
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate #define	CFB 0
3837c478bd9Sstevel@tonic-gate 
3847c478bd9Sstevel@tonic-gate #define	ENCR_STATE_FAILED	-1
3857c478bd9Sstevel@tonic-gate #define	ENCR_STATE_OK		0x00
3867c478bd9Sstevel@tonic-gate #define	ENCR_STATE_NO_SEND_IV	0x01
3877c478bd9Sstevel@tonic-gate #define	ENCR_STATE_NO_RECV_IV	0x02
3887c478bd9Sstevel@tonic-gate #define	ENCR_STATE_NO_KEYID	0x04
3897c478bd9Sstevel@tonic-gate #define	ENCR_STATE_NOT_READY	0x08
3907c478bd9Sstevel@tonic-gate #define	ENCR_STATE_IN_PROGRESS \
3917c478bd9Sstevel@tonic-gate 	(ENCR_STATE_NO_SEND_IV|ENCR_STATE_NO_RECV_IV|ENCR_STATE_NO_KEYID)
3927c478bd9Sstevel@tonic-gate #define	TELNET_DIR_ENCRYPT	0
3937c478bd9Sstevel@tonic-gate #define	TELNET_DIR_DECRYPT	1
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate typedef unsigned char Block[DES_BLOCKSIZE];
3967c478bd9Sstevel@tonic-gate typedef unsigned char *BlockT;
3977c478bd9Sstevel@tonic-gate typedef struct { Block _; } Schedule[16];
3987c478bd9Sstevel@tonic-gate 
3997c478bd9Sstevel@tonic-gate typedef struct {
4007c478bd9Sstevel@tonic-gate 	short		type;
4017c478bd9Sstevel@tonic-gate 	int		length;
4027c478bd9Sstevel@tonic-gate 	unsigned char	*data;
4037c478bd9Sstevel@tonic-gate } Session_Key;
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate typedef struct {
4067c478bd9Sstevel@tonic-gate 	unsigned char	need_start;
4077c478bd9Sstevel@tonic-gate 	unsigned char	autoflag;	/* automatically start operation */
4087c478bd9Sstevel@tonic-gate 	unsigned char	setup;
4097c478bd9Sstevel@tonic-gate 	unsigned char	type;
4107c478bd9Sstevel@tonic-gate 	unsigned int	state;
4117c478bd9Sstevel@tonic-gate 	unsigned char	keyid[TELNET_MAXNUMKEYS];
4127c478bd9Sstevel@tonic-gate 	int		keyidlen;
4137c478bd9Sstevel@tonic-gate 	Block		ivec;
4147c478bd9Sstevel@tonic-gate 	Block		krbdes_key;
4157c478bd9Sstevel@tonic-gate } cipher_info_t;
4167c478bd9Sstevel@tonic-gate 
4177c478bd9Sstevel@tonic-gate typedef struct {
4187c478bd9Sstevel@tonic-gate 	cipher_info_t encrypt;
4197c478bd9Sstevel@tonic-gate 	cipher_info_t decrypt;
4207c478bd9Sstevel@tonic-gate } telnet_enc_data_t;
4217c478bd9Sstevel@tonic-gate 
4227c478bd9Sstevel@tonic-gate /* A valid key has no "0" bytes */
4237c478bd9Sstevel@tonic-gate #define	VALIDKEY(key)	(key[0] | key[1] | key[2] | key[3] | \
4247c478bd9Sstevel@tonic-gate 		key[4] | key[5] | key[6] | key[7])
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate 
4277c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4287c478bd9Sstevel@tonic-gate }
4297c478bd9Sstevel@tonic-gate #endif
4307c478bd9Sstevel@tonic-gate 
4317c478bd9Sstevel@tonic-gate #endif	/* _ARPA_TELNET_H */
432