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