xref: /titanic_51/usr/src/head/arpa/telnet.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
32*7c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of California.
33*7c478bd9Sstevel@tonic-gate  */
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #ifndef	_ARPA_TELNET_H
36*7c478bd9Sstevel@tonic-gate #define	_ARPA_TELNET_H
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
41*7c478bd9Sstevel@tonic-gate extern "C" {
42*7c478bd9Sstevel@tonic-gate #endif
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate /*
45*7c478bd9Sstevel@tonic-gate  * Definitions for the TELNET protocol.
46*7c478bd9Sstevel@tonic-gate  */
47*7c478bd9Sstevel@tonic-gate #define	IAC	255		/* interpret as command: */
48*7c478bd9Sstevel@tonic-gate #define	DONT	254		/* you are not to use option */
49*7c478bd9Sstevel@tonic-gate #define	DO	253		/* please, you use option */
50*7c478bd9Sstevel@tonic-gate #define	WONT	252		/* I won't use option */
51*7c478bd9Sstevel@tonic-gate #define	WILL	251		/* I will use option */
52*7c478bd9Sstevel@tonic-gate #define	SB	250		/* interpret as subnegotiation */
53*7c478bd9Sstevel@tonic-gate #define	GA	249		/* you may reverse the line */
54*7c478bd9Sstevel@tonic-gate #define	EL	248		/* erase the current line */
55*7c478bd9Sstevel@tonic-gate #define	EC	247		/* erase the current character */
56*7c478bd9Sstevel@tonic-gate #define	AYT	246		/* are you there */
57*7c478bd9Sstevel@tonic-gate #define	AO	245		/* abort output--but let prog finish */
58*7c478bd9Sstevel@tonic-gate #define	IP	244		/* interrupt process--permanently */
59*7c478bd9Sstevel@tonic-gate #define	BREAK	243		/* break */
60*7c478bd9Sstevel@tonic-gate #define	DM	242		/* data mark--for connect. cleaning */
61*7c478bd9Sstevel@tonic-gate #define	NOP	241		/* nop */
62*7c478bd9Sstevel@tonic-gate #define	SE	240		/* end sub negotiation */
63*7c478bd9Sstevel@tonic-gate #define	EOR	239		/* end of record (transparent mode) */
64*7c478bd9Sstevel@tonic-gate #define	ABORT	238		/* Abort process */
65*7c478bd9Sstevel@tonic-gate #define	SUSP	237		/* Suspend process */
66*7c478bd9Sstevel@tonic-gate #define	xEOF	236		/* End of file: EOF is already used... */
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate #define	SYNCH	242		/* for telfunc calls */
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate #ifdef TELCMDS
71*7c478bd9Sstevel@tonic-gate char *telcmds[] = {
72*7c478bd9Sstevel@tonic-gate 	"EOF", "SUSP", "ABORT", "EOR",
73*7c478bd9Sstevel@tonic-gate 	"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
74*7c478bd9Sstevel@tonic-gate 	"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0
75*7c478bd9Sstevel@tonic-gate };
76*7c478bd9Sstevel@tonic-gate #endif
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate #define	TELCMD_FIRST	xEOF
79*7c478bd9Sstevel@tonic-gate #define	TELCMD_LAST	IAC
80*7c478bd9Sstevel@tonic-gate #define	TELCMD_OK(x)	((unsigned int)(x) <= TELCMD_LAST && \
81*7c478bd9Sstevel@tonic-gate 			    (unsigned int)(x) >= TELCMD_FIRST)
82*7c478bd9Sstevel@tonic-gate #define	TELCMD(x)	telcmds[(x)-TELCMD_FIRST]
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate /* telnet options */
85*7c478bd9Sstevel@tonic-gate #define	TELOPT_BINARY	0	/* 8-bit data path */
86*7c478bd9Sstevel@tonic-gate #define	TELOPT_ECHO	1	/* echo */
87*7c478bd9Sstevel@tonic-gate #define	TELOPT_RCP	2	/* prepare to reconnect */
88*7c478bd9Sstevel@tonic-gate #define	TELOPT_SGA	3	/* suppress go ahead */
89*7c478bd9Sstevel@tonic-gate #define	TELOPT_NAMS	4	/* approximate message size */
90*7c478bd9Sstevel@tonic-gate #define	TELOPT_STATUS	5	/* give status */
91*7c478bd9Sstevel@tonic-gate #define	TELOPT_TM	6	/* timing mark */
92*7c478bd9Sstevel@tonic-gate #define	TELOPT_RCTE	7	/* remote controlled transmission and echo */
93*7c478bd9Sstevel@tonic-gate #define	TELOPT_NAOL 	8	/* negotiate about output line width */
94*7c478bd9Sstevel@tonic-gate #define	TELOPT_NAOP 	9	/* negotiate about output page size */
95*7c478bd9Sstevel@tonic-gate #define	TELOPT_NAOCRD	10	/* negotiate about CR disposition */
96*7c478bd9Sstevel@tonic-gate #define	TELOPT_NAOHTS	11	/* negotiate about horizontal tabstops */
97*7c478bd9Sstevel@tonic-gate #define	TELOPT_NAOHTD	12	/* negotiate about horizontal tab disposition */
98*7c478bd9Sstevel@tonic-gate #define	TELOPT_NAOFFD	13	/* negotiate about formfeed disposition */
99*7c478bd9Sstevel@tonic-gate #define	TELOPT_NAOVTS	14	/* negotiate about vertical tab stops */
100*7c478bd9Sstevel@tonic-gate #define	TELOPT_NAOVTD	15	/* negotiate about vertical tab disposition */
101*7c478bd9Sstevel@tonic-gate #define	TELOPT_NAOLFD	16	/* negotiate about output LF disposition */
102*7c478bd9Sstevel@tonic-gate #define	TELOPT_XASCII	17	/* extended ascic character set */
103*7c478bd9Sstevel@tonic-gate #define	TELOPT_LOGOUT	18	/* force logout */
104*7c478bd9Sstevel@tonic-gate #define	TELOPT_BM	19	/* byte macro */
105*7c478bd9Sstevel@tonic-gate #define	TELOPT_DET	20	/* data entry terminal */
106*7c478bd9Sstevel@tonic-gate #define	TELOPT_SUPDUP	21	/* supdup protocol */
107*7c478bd9Sstevel@tonic-gate #define	TELOPT_SUPDUPOUTPUT 22	/* supdup output */
108*7c478bd9Sstevel@tonic-gate #define	TELOPT_SNDLOC	23	/* send location */
109*7c478bd9Sstevel@tonic-gate #define	TELOPT_TTYPE	24	/* terminal type */
110*7c478bd9Sstevel@tonic-gate #define	TELOPT_EOR	25	/* end or record */
111*7c478bd9Sstevel@tonic-gate #define	TELOPT_TUID	26	/* TACACS user identification */
112*7c478bd9Sstevel@tonic-gate #define	TELOPT_OUTMRK	27	/* output marking */
113*7c478bd9Sstevel@tonic-gate #define	TELOPT_TTYLOC	28	/* terminal location number */
114*7c478bd9Sstevel@tonic-gate #define	TELOPT_3270REGIME 29	/* 3270 regime */
115*7c478bd9Sstevel@tonic-gate #define	TELOPT_X3PAD	30	/* X.3 PAD */
116*7c478bd9Sstevel@tonic-gate #define	TELOPT_NAWS	31	/* window size */
117*7c478bd9Sstevel@tonic-gate #define	TELOPT_TSPEED	32	/* terminal speed */
118*7c478bd9Sstevel@tonic-gate #define	TELOPT_LFLOW	33	/* remote flow control */
119*7c478bd9Sstevel@tonic-gate #define	TELOPT_LINEMODE	34	/* Linemode option */
120*7c478bd9Sstevel@tonic-gate #define	TELOPT_XDISPLOC	35	/* X Display Location */
121*7c478bd9Sstevel@tonic-gate #define	TELOPT_OLD_ENVIRON 36	/* Old - Environment variables */
122*7c478bd9Sstevel@tonic-gate #define	TELOPT_AUTHENTICATION 37 /* Authenticate */
123*7c478bd9Sstevel@tonic-gate #define	TELOPT_ENCRYPT	38	/* Encryption option */
124*7c478bd9Sstevel@tonic-gate #define	TELOPT_NEW_ENVIRON 39	/* New - Environment variables */
125*7c478bd9Sstevel@tonic-gate #define	TELOPT_EXOPL	255	/* extended-options-list */
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate #ifdef TELOPTS
128*7c478bd9Sstevel@tonic-gate #define	NTELOPTS	(1+TELOPT_NEW_ENVIRON)
129*7c478bd9Sstevel@tonic-gate char *telopts[NTELOPTS+1] = {
130*7c478bd9Sstevel@tonic-gate 	"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
131*7c478bd9Sstevel@tonic-gate 	"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
132*7c478bd9Sstevel@tonic-gate 	"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
133*7c478bd9Sstevel@tonic-gate 	"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
134*7c478bd9Sstevel@tonic-gate 	"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
135*7c478bd9Sstevel@tonic-gate 	"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
136*7c478bd9Sstevel@tonic-gate 	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
137*7c478bd9Sstevel@tonic-gate 	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
138*7c478bd9Sstevel@tonic-gate 	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
139*7c478bd9Sstevel@tonic-gate 	"ENCRYPT", "NEW-ENVIRON",
140*7c478bd9Sstevel@tonic-gate 	0,
141*7c478bd9Sstevel@tonic-gate };
142*7c478bd9Sstevel@tonic-gate #endif /* TELOPTS */
143*7c478bd9Sstevel@tonic-gate #define	TELOPT_FIRST	TELOPT_BINARY
144*7c478bd9Sstevel@tonic-gate #define	TELOPT_LAST	TELOPT_NEW_ENVIRON
145*7c478bd9Sstevel@tonic-gate #define	TELOPT_OK(x)	((unsigned int)(x) <= TELOPT_LAST)
146*7c478bd9Sstevel@tonic-gate #define	TELOPT(x)	telopts[(x)-TELOPT_FIRST]
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate /* sub-option qualifiers */
149*7c478bd9Sstevel@tonic-gate #define	TELQUAL_IS	0	/* option is... */
150*7c478bd9Sstevel@tonic-gate #define	TELQUAL_SEND	1	/* send option */
151*7c478bd9Sstevel@tonic-gate #define	TELQUAL_INFO	2	/* ENVIRON: informational version of IS */
152*7c478bd9Sstevel@tonic-gate #define	TELQUAL_REPLY	2	/* AUTHENTICATION: client version of IS */
153*7c478bd9Sstevel@tonic-gate #define	TELQUAL_NAME	3	/* AUTHENTICATION: client version of IS */
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate #define	LFLOW_OFF		0	/* Disable remote flow control */
156*7c478bd9Sstevel@tonic-gate #define	LFLOW_ON		1	/* Enable remote flow control */
157*7c478bd9Sstevel@tonic-gate #define	LFLOW_RESTART_ANY	2	/* Restart output on any char */
158*7c478bd9Sstevel@tonic-gate #define	LFLOW_RESTART_XON	3	/* Restart output only on XON */
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate /*
161*7c478bd9Sstevel@tonic-gate  * LINEMODE suboptions
162*7c478bd9Sstevel@tonic-gate  */
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate #define	LM_MODE		1
165*7c478bd9Sstevel@tonic-gate #define	LM_FORWARDMASK	2
166*7c478bd9Sstevel@tonic-gate #define	LM_SLC		3
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate #define	MODE_EDIT	0x01
169*7c478bd9Sstevel@tonic-gate #define	MODE_TRAPSIG	0x02
170*7c478bd9Sstevel@tonic-gate #define	MODE_ACK	0x04
171*7c478bd9Sstevel@tonic-gate #define	MODE_SOFT_TAB	0x08
172*7c478bd9Sstevel@tonic-gate #define	MODE_LIT_ECHO	0x10
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate #define	MODE_MASK	0x1f
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate /* Not part of protocol, but needed to simplify things... */
177*7c478bd9Sstevel@tonic-gate #define	MODE_FLOW		0x0100
178*7c478bd9Sstevel@tonic-gate #define	MODE_ECHO		0x0200
179*7c478bd9Sstevel@tonic-gate #define	MODE_INBIN		0x0400
180*7c478bd9Sstevel@tonic-gate #define	MODE_OUTBIN		0x0800
181*7c478bd9Sstevel@tonic-gate #define	MODE_FORCE		0x1000
182*7c478bd9Sstevel@tonic-gate 
183*7c478bd9Sstevel@tonic-gate #define	SLC_SYNCH	1
184*7c478bd9Sstevel@tonic-gate #define	SLC_BRK		2
185*7c478bd9Sstevel@tonic-gate #define	SLC_IP		3
186*7c478bd9Sstevel@tonic-gate #define	SLC_AO		4
187*7c478bd9Sstevel@tonic-gate #define	SLC_AYT		5
188*7c478bd9Sstevel@tonic-gate #define	SLC_EOR		6
189*7c478bd9Sstevel@tonic-gate #define	SLC_ABORT	7
190*7c478bd9Sstevel@tonic-gate #define	SLC_EOF		8
191*7c478bd9Sstevel@tonic-gate #define	SLC_SUSP	9
192*7c478bd9Sstevel@tonic-gate #define	SLC_EC		10
193*7c478bd9Sstevel@tonic-gate #define	SLC_EL		11
194*7c478bd9Sstevel@tonic-gate #define	SLC_EW		12
195*7c478bd9Sstevel@tonic-gate #define	SLC_RP		13
196*7c478bd9Sstevel@tonic-gate #define	SLC_LNEXT	14
197*7c478bd9Sstevel@tonic-gate #define	SLC_XON		15
198*7c478bd9Sstevel@tonic-gate #define	SLC_XOFF	16
199*7c478bd9Sstevel@tonic-gate #define	SLC_FORW1	17
200*7c478bd9Sstevel@tonic-gate #define	SLC_FORW2	18
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate #define	NSLC		18
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate /*
205*7c478bd9Sstevel@tonic-gate  * For backwards compatability, we define SLC_NAMES to be the
206*7c478bd9Sstevel@tonic-gate  * list of names if SLC_NAMES is not defined.
207*7c478bd9Sstevel@tonic-gate  */
208*7c478bd9Sstevel@tonic-gate #define	SLC_NAMELIST	"0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
209*7c478bd9Sstevel@tonic-gate 			"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
210*7c478bd9Sstevel@tonic-gate 			"LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
211*7c478bd9Sstevel@tonic-gate #ifdef	SLC_NAMES
212*7c478bd9Sstevel@tonic-gate char *slc_names[] = {
213*7c478bd9Sstevel@tonic-gate 	SLC_NAMELIST
214*7c478bd9Sstevel@tonic-gate };
215*7c478bd9Sstevel@tonic-gate #else
216*7c478bd9Sstevel@tonic-gate extern char *slc_names[];
217*7c478bd9Sstevel@tonic-gate #define	SLC_NAMES SLC_NAMELIST
218*7c478bd9Sstevel@tonic-gate #endif
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate #define	SLC_NAME_OK(x)	((unsigned int)(x) <= NSLC)
221*7c478bd9Sstevel@tonic-gate #define	SLC_NAME(x)	slc_names[x]
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate #define	SLC_NOSUPPORT	0
224*7c478bd9Sstevel@tonic-gate #define	SLC_CANTCHANGE	1
225*7c478bd9Sstevel@tonic-gate #define	SLC_VARIABLE	2
226*7c478bd9Sstevel@tonic-gate #define	SLC_DEFAULT	3
227*7c478bd9Sstevel@tonic-gate #define	SLC_LEVELBITS	0x03
228*7c478bd9Sstevel@tonic-gate 
229*7c478bd9Sstevel@tonic-gate #define	SLC_FUNC	0
230*7c478bd9Sstevel@tonic-gate #define	SLC_FLAGS	1
231*7c478bd9Sstevel@tonic-gate #define	SLC_VALUE	2
232*7c478bd9Sstevel@tonic-gate 
233*7c478bd9Sstevel@tonic-gate #define	SLC_ACK		0x80
234*7c478bd9Sstevel@tonic-gate #define	SLC_FLUSHIN	0x40
235*7c478bd9Sstevel@tonic-gate #define	SLC_FLUSHOUT	0x20
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate #define	OLD_ENV_VAR	1
238*7c478bd9Sstevel@tonic-gate #define	OLD_ENV_VALUE	0
239*7c478bd9Sstevel@tonic-gate #define	NEW_ENV_VAR	0
240*7c478bd9Sstevel@tonic-gate #define	NEW_ENV_VALUE	1
241*7c478bd9Sstevel@tonic-gate #define	ENV_ESC		2
242*7c478bd9Sstevel@tonic-gate #define	ENV_USERVAR	3
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate /*
245*7c478bd9Sstevel@tonic-gate  * AUTHENTICATION suboptions
246*7c478bd9Sstevel@tonic-gate  */
247*7c478bd9Sstevel@tonic-gate #define	AUTH_REJECT	0	/* Rejected */
248*7c478bd9Sstevel@tonic-gate #define	AUTH_UNKNOWN	1	/* We don't know who he is, but he's okay */
249*7c478bd9Sstevel@tonic-gate #define	AUTH_OTHER	2	/* We know him, but not his name */
250*7c478bd9Sstevel@tonic-gate #define	AUTH_USER	3	/* We know his name */
251*7c478bd9Sstevel@tonic-gate #define	AUTH_VALID	4	/* We know him, and he needs no password */
252*7c478bd9Sstevel@tonic-gate 
253*7c478bd9Sstevel@tonic-gate /*
254*7c478bd9Sstevel@tonic-gate  * Who is authenticating who ...
255*7c478bd9Sstevel@tonic-gate  */
256*7c478bd9Sstevel@tonic-gate #define	AUTH_WHO_CLIENT		0	/* Client authenticating server */
257*7c478bd9Sstevel@tonic-gate #define	AUTH_WHO_SERVER		1	/* Server authenticating client */
258*7c478bd9Sstevel@tonic-gate #define	AUTH_WHO_MASK		1
259*7c478bd9Sstevel@tonic-gate 
260*7c478bd9Sstevel@tonic-gate #ifdef	AUTHWHO_STR
261*7c478bd9Sstevel@tonic-gate char *authwho_str[] = {
262*7c478bd9Sstevel@tonic-gate 	"CLIENT", "SERVER" };
263*7c478bd9Sstevel@tonic-gate #define	AUTHWHO_NAME(x)	authwho_str[x]
264*7c478bd9Sstevel@tonic-gate #endif /* AUTHWHO_STR */
265*7c478bd9Sstevel@tonic-gate 
266*7c478bd9Sstevel@tonic-gate /*
267*7c478bd9Sstevel@tonic-gate  * amount of authentication done
268*7c478bd9Sstevel@tonic-gate  */
269*7c478bd9Sstevel@tonic-gate #define	AUTH_HOW_ONE_WAY	0
270*7c478bd9Sstevel@tonic-gate #define	AUTH_HOW_MUTUAL		2
271*7c478bd9Sstevel@tonic-gate #define	AUTH_HOW_MASK		2
272*7c478bd9Sstevel@tonic-gate 
273*7c478bd9Sstevel@tonic-gate /*
274*7c478bd9Sstevel@tonic-gate  * should we be encrypting? (not yet formally standardized)
275*7c478bd9Sstevel@tonic-gate  */
276*7c478bd9Sstevel@tonic-gate #define	AUTH_ENCRYPT_OFF	0
277*7c478bd9Sstevel@tonic-gate #define	AUTH_ENCRYPT_ON		4
278*7c478bd9Sstevel@tonic-gate #define	AUTH_ENCRYPT_MASK	4
279*7c478bd9Sstevel@tonic-gate 
280*7c478bd9Sstevel@tonic-gate #define	AUTHTYPE_NULL		0
281*7c478bd9Sstevel@tonic-gate #define	AUTHTYPE_KERBEROS_V4	1	/* not supported */
282*7c478bd9Sstevel@tonic-gate #define	AUTHTYPE_KERBEROS_V5	2
283*7c478bd9Sstevel@tonic-gate #define	AUTHTYPE_CNT		3
284*7c478bd9Sstevel@tonic-gate 
285*7c478bd9Sstevel@tonic-gate #define	OPTS_FORWARD_CREDS		0x00000002
286*7c478bd9Sstevel@tonic-gate #define	OPTS_FORWARDABLE_CREDS		0x00000001
287*7c478bd9Sstevel@tonic-gate 
288*7c478bd9Sstevel@tonic-gate #ifdef AUTHTYPE_NAMES
289*7c478bd9Sstevel@tonic-gate char *authtype_names[] = {
290*7c478bd9Sstevel@tonic-gate 	"NULL", "KERBEROS_V4", "KERBEROS_V5", 0,
291*7c478bd9Sstevel@tonic-gate };
292*7c478bd9Sstevel@tonic-gate #else
293*7c478bd9Sstevel@tonic-gate extern char *authtype_names[];
294*7c478bd9Sstevel@tonic-gate #endif /* AUTHTYPE_NAMES */
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate #define	AUTHTYPE_NAME(x)	authtype_names[x]
297*7c478bd9Sstevel@tonic-gate #define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)
298*7c478bd9Sstevel@tonic-gate 
299*7c478bd9Sstevel@tonic-gate #ifdef AUTHHOW_NAMES
300*7c478bd9Sstevel@tonic-gate char *authhow_names[] = {
301*7c478bd9Sstevel@tonic-gate 	"ONE-WAY", "[undefined]", "MUTUAL" };
302*7c478bd9Sstevel@tonic-gate #endif /* AUTHHOW_NAMES */
303*7c478bd9Sstevel@tonic-gate 
304*7c478bd9Sstevel@tonic-gate #define	AUTHHOW_NAME(x)		authhow_names[x]
305*7c478bd9Sstevel@tonic-gate 
306*7c478bd9Sstevel@tonic-gate #define	KRB_AUTH		0	/* Authentication data follows */
307*7c478bd9Sstevel@tonic-gate #define	KRB_REJECT		1	/* Rejected (reason might follow) */
308*7c478bd9Sstevel@tonic-gate #define	KRB_ACCEPT		2	/* Accepted */
309*7c478bd9Sstevel@tonic-gate #define	KRB_RESPONSE		3	/* Response for mutual auth. */
310*7c478bd9Sstevel@tonic-gate #define	KRB_FORWARD		4	/* Forwarded credentials follow */
311*7c478bd9Sstevel@tonic-gate #define	KRB_FORWARD_ACCEPT	5	/* Forwarded credentials accepted */
312*7c478bd9Sstevel@tonic-gate #define	KRB_FORWARD_REJECT	6	/* Forwarded credentials rejected */
313*7c478bd9Sstevel@tonic-gate 
314*7c478bd9Sstevel@tonic-gate #ifdef AUTHRSP_NAMES
315*7c478bd9Sstevel@tonic-gate char *authrsp_names[] = {
316*7c478bd9Sstevel@tonic-gate 	"AUTH", "REJECT", "ACCEPT", "RESPONSE", "FORWARD",
317*7c478bd9Sstevel@tonic-gate 	"FORWARD_ACCEPT", "FORWARD_REJECT" };
318*7c478bd9Sstevel@tonic-gate #define	AUTHRSP_NAME(x)		authrsp_names[x]
319*7c478bd9Sstevel@tonic-gate #endif /* AUTHRSP_NAMES */
320*7c478bd9Sstevel@tonic-gate 
321*7c478bd9Sstevel@tonic-gate #define	AUTH_MODE_REQUIRE	0
322*7c478bd9Sstevel@tonic-gate #define	AUTH_MODE_PROMPT	1
323*7c478bd9Sstevel@tonic-gate #define	AUTH_MODE_WARN		2
324*7c478bd9Sstevel@tonic-gate #define	AUTH_MODE_REJECT	3
325*7c478bd9Sstevel@tonic-gate 
326*7c478bd9Sstevel@tonic-gate 
327*7c478bd9Sstevel@tonic-gate /*
328*7c478bd9Sstevel@tonic-gate  * Encryption suboptions. See RFC 2946.
329*7c478bd9Sstevel@tonic-gate  */
330*7c478bd9Sstevel@tonic-gate #define	ENCRYPT_IS		0	/* I pick encryption type ... */
331*7c478bd9Sstevel@tonic-gate #define	ENCRYPT_SUPPORT		1	/* I support encryption types ... */
332*7c478bd9Sstevel@tonic-gate #define	ENCRYPT_REPLY		2	/* Initial setup response */
333*7c478bd9Sstevel@tonic-gate #define	ENCRYPT_START		3	/* Starting encrypting output */
334*7c478bd9Sstevel@tonic-gate #define	ENCRYPT_END		4	/* End encrypting output */
335*7c478bd9Sstevel@tonic-gate #define	ENCRYPT_REQSTART	5	/* Request to start encrypting output */
336*7c478bd9Sstevel@tonic-gate #define	ENCRYPT_REQEND		6	/* Request to stop encrypting output */
337*7c478bd9Sstevel@tonic-gate #define	ENCRYPT_ENC_KEYID	7	/* Negotiate encryption key */
338*7c478bd9Sstevel@tonic-gate #define	ENCRYPT_DEC_KEYID	8	/* Negotiate decryption key */
339*7c478bd9Sstevel@tonic-gate #define	ENCRYPT_CNT		9	/* marks the maximum ENCRYPT value */
340*7c478bd9Sstevel@tonic-gate 
341*7c478bd9Sstevel@tonic-gate #define	TELOPT_ENCTYPE_NULL		0
342*7c478bd9Sstevel@tonic-gate #define	TELOPT_ENCTYPE_DES_CFB64	1 /* 64-bit Cipher Feedback Mode */
343*7c478bd9Sstevel@tonic-gate #define	TELOPT_ENCTYPE_CNT		2
344*7c478bd9Sstevel@tonic-gate 
345*7c478bd9Sstevel@tonic-gate #define	CFB64_IV	1
346*7c478bd9Sstevel@tonic-gate #define	CFB64_IV_OK	2
347*7c478bd9Sstevel@tonic-gate #define	CFB64_IV_BAD	3
348*7c478bd9Sstevel@tonic-gate 
349*7c478bd9Sstevel@tonic-gate #define	FB64_IV		CFB64_IV
350*7c478bd9Sstevel@tonic-gate #define	FB64_IV_OK	CFB64_IV_OK
351*7c478bd9Sstevel@tonic-gate #define	FB64_IV_BAD	CFB64_IV_BAD
352*7c478bd9Sstevel@tonic-gate 
353*7c478bd9Sstevel@tonic-gate #ifdef ENCRYPT_NAMES
354*7c478bd9Sstevel@tonic-gate char *encrypt_names[] = {
355*7c478bd9Sstevel@tonic-gate 	"IS", "SUPPORT", "REPLY", "START", "END",
356*7c478bd9Sstevel@tonic-gate 	"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
357*7c478bd9Sstevel@tonic-gate 	0,
358*7c478bd9Sstevel@tonic-gate };
359*7c478bd9Sstevel@tonic-gate 
360*7c478bd9Sstevel@tonic-gate char *enctype_names[] = {
361*7c478bd9Sstevel@tonic-gate 	"ANY", "DES_CFB64", 0,
362*7c478bd9Sstevel@tonic-gate };
363*7c478bd9Sstevel@tonic-gate #else
364*7c478bd9Sstevel@tonic-gate extern char *encrypt_names[];
365*7c478bd9Sstevel@tonic-gate extern char *enctype_names[];
366*7c478bd9Sstevel@tonic-gate #endif /* ENCRYPT_NAMES */
367*7c478bd9Sstevel@tonic-gate 
368*7c478bd9Sstevel@tonic-gate #define	ENCRYPT_NAME(x)		encrypt_names[x]
369*7c478bd9Sstevel@tonic-gate #define	ENCTYPE_NAME(x)		enctype_names[x]
370*7c478bd9Sstevel@tonic-gate 
371*7c478bd9Sstevel@tonic-gate #define	ENCRYPT_NAME_OK(x)	((unsigned int)(x) < ENCRYPT_CNT)
372*7c478bd9Sstevel@tonic-gate #define	ENCTYPE_NAME_OK(x)	((unsigned int)(x) < TELOPT_ENCTYPE_CNT)
373*7c478bd9Sstevel@tonic-gate 
374*7c478bd9Sstevel@tonic-gate #define	SK_DES	1 /* Matched Kerberos v5 ENCTYPE_DES */
375*7c478bd9Sstevel@tonic-gate 
376*7c478bd9Sstevel@tonic-gate #ifndef	DES_BLOCKSIZE
377*7c478bd9Sstevel@tonic-gate #define	DES_BLOCKSIZE  8
378*7c478bd9Sstevel@tonic-gate #endif	/* DES_BLOCKSIZE */
379*7c478bd9Sstevel@tonic-gate 
380*7c478bd9Sstevel@tonic-gate #define	TELNET_MAXNUMKEYS	64
381*7c478bd9Sstevel@tonic-gate #define	TELNET_MAXKEYIDLEN	16
382*7c478bd9Sstevel@tonic-gate 
383*7c478bd9Sstevel@tonic-gate #define	CFB 0
384*7c478bd9Sstevel@tonic-gate 
385*7c478bd9Sstevel@tonic-gate #define	ENCR_STATE_FAILED	-1
386*7c478bd9Sstevel@tonic-gate #define	ENCR_STATE_OK		0x00
387*7c478bd9Sstevel@tonic-gate #define	ENCR_STATE_NO_SEND_IV	0x01
388*7c478bd9Sstevel@tonic-gate #define	ENCR_STATE_NO_RECV_IV	0x02
389*7c478bd9Sstevel@tonic-gate #define	ENCR_STATE_NO_KEYID	0x04
390*7c478bd9Sstevel@tonic-gate #define	ENCR_STATE_NOT_READY	0x08
391*7c478bd9Sstevel@tonic-gate #define	ENCR_STATE_IN_PROGRESS \
392*7c478bd9Sstevel@tonic-gate 	(ENCR_STATE_NO_SEND_IV|ENCR_STATE_NO_RECV_IV|ENCR_STATE_NO_KEYID)
393*7c478bd9Sstevel@tonic-gate #define	TELNET_DIR_ENCRYPT	0
394*7c478bd9Sstevel@tonic-gate #define	TELNET_DIR_DECRYPT	1
395*7c478bd9Sstevel@tonic-gate 
396*7c478bd9Sstevel@tonic-gate typedef unsigned char Block[DES_BLOCKSIZE];
397*7c478bd9Sstevel@tonic-gate typedef unsigned char *BlockT;
398*7c478bd9Sstevel@tonic-gate typedef struct { Block _; } Schedule[16];
399*7c478bd9Sstevel@tonic-gate 
400*7c478bd9Sstevel@tonic-gate typedef struct {
401*7c478bd9Sstevel@tonic-gate 	short		type;
402*7c478bd9Sstevel@tonic-gate 	int		length;
403*7c478bd9Sstevel@tonic-gate 	unsigned char	*data;
404*7c478bd9Sstevel@tonic-gate } Session_Key;
405*7c478bd9Sstevel@tonic-gate 
406*7c478bd9Sstevel@tonic-gate typedef struct {
407*7c478bd9Sstevel@tonic-gate 	unsigned char	need_start;
408*7c478bd9Sstevel@tonic-gate 	unsigned char	autoflag;	/* automatically start operation */
409*7c478bd9Sstevel@tonic-gate 	unsigned char	setup;
410*7c478bd9Sstevel@tonic-gate 	unsigned char	type;
411*7c478bd9Sstevel@tonic-gate 	unsigned int	state;
412*7c478bd9Sstevel@tonic-gate 	unsigned char	keyid[TELNET_MAXNUMKEYS];
413*7c478bd9Sstevel@tonic-gate 	int		keyidlen;
414*7c478bd9Sstevel@tonic-gate 	Block		ivec;
415*7c478bd9Sstevel@tonic-gate 	Block		krbdes_key;
416*7c478bd9Sstevel@tonic-gate } cipher_info_t;
417*7c478bd9Sstevel@tonic-gate 
418*7c478bd9Sstevel@tonic-gate typedef struct {
419*7c478bd9Sstevel@tonic-gate 	cipher_info_t encrypt;
420*7c478bd9Sstevel@tonic-gate 	cipher_info_t decrypt;
421*7c478bd9Sstevel@tonic-gate } telnet_enc_data_t;
422*7c478bd9Sstevel@tonic-gate 
423*7c478bd9Sstevel@tonic-gate /* A valid key has no "0" bytes */
424*7c478bd9Sstevel@tonic-gate #define	VALIDKEY(key)	(key[0] | key[1] | key[2] | key[3] | \
425*7c478bd9Sstevel@tonic-gate 		key[4] | key[5] | key[6] | key[7])
426*7c478bd9Sstevel@tonic-gate 
427*7c478bd9Sstevel@tonic-gate 
428*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
429*7c478bd9Sstevel@tonic-gate }
430*7c478bd9Sstevel@tonic-gate #endif
431*7c478bd9Sstevel@tonic-gate 
432*7c478bd9Sstevel@tonic-gate #endif	/* _ARPA_TELNET_H */
433