1170754Sdelphij/*-
2170754Sdelphij * SPDX-License-Identifier: BSD-3-Clause
3170754Sdelphij *
4170754Sdelphij * Copyright (c) 1983, 1993
5170754Sdelphij *	The Regents of the University of California.  All rights reserved.
6170754Sdelphij *
7170754Sdelphij * Redistribution and use in source and binary forms, with or without
8170754Sdelphij * modification, are permitted provided that the following conditions
9170754Sdelphij * are met:
10170754Sdelphij * 1. Redistributions of source code must retain the above copyright
11170754Sdelphij *    notice, this list of conditions and the following disclaimer.
12170754Sdelphij * 2. Redistributions in binary form must reproduce the above copyright
13170754Sdelphij *    notice, this list of conditions and the following disclaimer in the
14170754Sdelphij *    documentation and/or other materials provided with the distribution.
15170754Sdelphij * 3. Neither the name of the University nor the names of its contributors
16170754Sdelphij *    may be used to endorse or promote products derived from this software
17170754Sdelphij *    without specific prior written permission.
18170754Sdelphij *
19170754Sdelphij * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20170754Sdelphij * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21170754Sdelphij * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22170754Sdelphij * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23170754Sdelphij * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24170754Sdelphij * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25170754Sdelphij * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26170754Sdelphij * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27170754Sdelphij * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28170754Sdelphij * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29170754Sdelphij * SUCH DAMAGE.
30170754Sdelphij */
31170754Sdelphij
32170754Sdelphij#ifndef _ARPA_TELNET_H_
33170754Sdelphij#define	_ARPA_TELNET_H_
34170754Sdelphij
35170754Sdelphij/*
36170754Sdelphij * Definitions for the TELNET protocol.
37170754Sdelphij */
38170754Sdelphij#define	IAC	255		/* interpret as command: */
39170754Sdelphij#define	DONT	254		/* you are not to use option */
40170754Sdelphij#define	DO	253		/* please, you use option */
41170754Sdelphij#define	WONT	252		/* I won't use option */
42170754Sdelphij#define	WILL	251		/* I will use option */
43170754Sdelphij#define	SB	250		/* interpret as subnegotiation */
44170754Sdelphij#define	GA	249		/* you may reverse the line */
45170754Sdelphij#define	EL	248		/* erase the current line */
46170754Sdelphij#define	EC	247		/* erase the current character */
47170754Sdelphij#define	AYT	246		/* are you there */
48170754Sdelphij#define	AO	245		/* abort output--but let prog finish */
49170754Sdelphij#define	IP	244		/* interrupt process--permanently */
50170754Sdelphij#define	BREAK	243		/* break */
51170754Sdelphij#define	DM	242		/* data mark--for connect. cleaning */
52170754Sdelphij#define	NOP	241		/* nop */
53170754Sdelphij#define	SE	240		/* end sub negotiation */
54170754Sdelphij#define EOR     239             /* end of record (transparent mode) */
55170754Sdelphij#define	ABORT	238		/* Abort process */
56170754Sdelphij#define	SUSP	237		/* Suspend process */
57170754Sdelphij#define	xEOF	236		/* End of file: EOF is already used... */
58170754Sdelphij
59170754Sdelphij#define SYNCH	242		/* for telfunc calls */
60170754Sdelphij
61170754Sdelphij#ifdef TELCMDS
62170754Sdelphijconst char *telcmds[] = {
63170754Sdelphij	"EOF", "SUSP", "ABORT", "EOR",
64170754Sdelphij	"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
65170754Sdelphij	"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
66170754Sdelphij	0
67170754Sdelphij};
68170754Sdelphij#else
69170754Sdelphijextern char *telcmds[];
70170754Sdelphij#endif
71170754Sdelphij
72170754Sdelphij#define	TELCMD_FIRST	xEOF
73170754Sdelphij#define	TELCMD_LAST	IAC
74170754Sdelphij#define	TELCMD_OK(x)	((unsigned int)(x) <= TELCMD_LAST && \
75170754Sdelphij			 (unsigned int)(x) >= TELCMD_FIRST)
76170754Sdelphij#define	TELCMD(x)	telcmds[(x)-TELCMD_FIRST]
77170754Sdelphij
78170754Sdelphij/* telnet options */
79170754Sdelphij#define TELOPT_BINARY	0	/* 8-bit data path */
80170754Sdelphij#define TELOPT_ECHO	1	/* echo */
81170754Sdelphij#define	TELOPT_RCP	2	/* prepare to reconnect */
82170754Sdelphij#define	TELOPT_SGA	3	/* suppress go ahead */
83170754Sdelphij#define	TELOPT_NAMS	4	/* approximate message size */
84170754Sdelphij#define	TELOPT_STATUS	5	/* give status */
85170754Sdelphij#define	TELOPT_TM	6	/* timing mark */
86170754Sdelphij#define	TELOPT_RCTE	7	/* remote controlled transmission and echo */
87170754Sdelphij#define TELOPT_NAOL 	8	/* negotiate about output line width */
88170754Sdelphij#define TELOPT_NAOP 	9	/* negotiate about output page size */
89170754Sdelphij#define TELOPT_NAOCRD	10	/* negotiate about CR disposition */
90170754Sdelphij#define TELOPT_NAOHTS	11	/* negotiate about horizontal tabstops */
91170754Sdelphij#define TELOPT_NAOHTD	12	/* negotiate about horizontal tab disposition */
92170754Sdelphij#define TELOPT_NAOFFD	13	/* negotiate about formfeed disposition */
93170754Sdelphij#define TELOPT_NAOVTS	14	/* negotiate about vertical tab stops */
94170754Sdelphij#define TELOPT_NAOVTD	15	/* negotiate about vertical tab disposition */
95170754Sdelphij#define TELOPT_NAOLFD	16	/* negotiate about output LF disposition */
96170754Sdelphij#define TELOPT_XASCII	17	/* extended ascic character set */
97170754Sdelphij#define	TELOPT_LOGOUT	18	/* force logout */
98170754Sdelphij#define	TELOPT_BM	19	/* byte macro */
99170754Sdelphij#define	TELOPT_DET	20	/* data entry terminal */
100170754Sdelphij#define	TELOPT_SUPDUP	21	/* supdup protocol */
101170754Sdelphij#define	TELOPT_SUPDUPOUTPUT 22	/* supdup output */
102170754Sdelphij#define	TELOPT_SNDLOC	23	/* send location */
103170754Sdelphij#define	TELOPT_TTYPE	24	/* terminal type */
104170754Sdelphij#define	TELOPT_EOR	25	/* end or record */
105170754Sdelphij#define	TELOPT_TUID	26	/* TACACS user identification */
106170754Sdelphij#define	TELOPT_OUTMRK	27	/* output marking */
107170754Sdelphij#define	TELOPT_TTYLOC	28	/* terminal location number */
108170754Sdelphij#define	TELOPT_3270REGIME 29	/* 3270 regime */
109170754Sdelphij#define	TELOPT_X3PAD	30	/* X.3 PAD */
110170754Sdelphij#define	TELOPT_NAWS	31	/* window size */
111170754Sdelphij#define	TELOPT_TSPEED	32	/* terminal speed */
112170754Sdelphij#define	TELOPT_LFLOW	33	/* remote flow control */
113170754Sdelphij#define TELOPT_LINEMODE	34	/* Linemode option */
114170754Sdelphij#define TELOPT_XDISPLOC	35	/* X Display Location */
115170754Sdelphij#define TELOPT_OLD_ENVIRON 36	/* Old - Environment variables */
116170754Sdelphij#define	TELOPT_AUTHENTICATION 37/* Authenticate */
117170754Sdelphij#define	TELOPT_ENCRYPT	38	/* Encryption option */
118170754Sdelphij#define TELOPT_NEW_ENVIRON 39	/* New - Environment variables */
119170754Sdelphij#define	TELOPT_TN3270E	40	/* RFC2355 - TN3270 Enhancements */
120170754Sdelphij#define	TELOPT_CHARSET	42	/* RFC2066 - Charset */
121170754Sdelphij#define	TELOPT_COMPORT	44	/* RFC2217 - Com Port Control */
122170754Sdelphij#define	TELOPT_KERMIT	47	/* RFC2840 - Kermit */
123170754Sdelphij#define	TELOPT_EXOPL	255	/* extended-options-list */
124170754Sdelphij
125170754Sdelphij
126170754Sdelphij#define	NTELOPTS	(1+TELOPT_KERMIT)
127170754Sdelphij#ifdef TELOPTS
128170754Sdelphijconst char *telopts[NTELOPTS+1] = {
129170754Sdelphij	"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
130170754Sdelphij	"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
131170754Sdelphij	"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
132170754Sdelphij	"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
133	"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
134	"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
135	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
136	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
137	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
138	"ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET",
139	"RSP", "COM-PORT", "SLE", "STARTTLS", "KERMIT",
140	0
141};
142#define	TELOPT_FIRST	TELOPT_BINARY
143#define	TELOPT_LAST	TELOPT_KERMIT
144#define	TELOPT_OK(x)	((unsigned int)(x) <= TELOPT_LAST)
145#define	TELOPT(x)	telopts[(x)-TELOPT_FIRST]
146#endif
147
148/* sub-option qualifiers */
149#define	TELQUAL_IS	0	/* option is... */
150#define	TELQUAL_SEND	1	/* send option */
151#define	TELQUAL_INFO	2	/* ENVIRON: informational version of IS */
152#define	TELQUAL_REPLY	2	/* AUTHENTICATION: client version of IS */
153#define	TELQUAL_NAME	3	/* AUTHENTICATION: client version of IS */
154
155#define	LFLOW_OFF		0	/* Disable remote flow control */
156#define	LFLOW_ON		1	/* Enable remote flow control */
157#define	LFLOW_RESTART_ANY	2	/* Restart output on any char */
158#define	LFLOW_RESTART_XON	3	/* Restart output only on XON */
159
160/*
161 * LINEMODE suboptions
162 */
163
164#define	LM_MODE		1
165#define	LM_FORWARDMASK	2
166#define	LM_SLC		3
167
168#define	MODE_EDIT	0x01
169#define	MODE_TRAPSIG	0x02
170#define	MODE_ACK	0x04
171#define MODE_SOFT_TAB	0x08
172#define MODE_LIT_ECHO	0x10
173
174#define	MODE_MASK	0x1f
175
176/* Not part of protocol, but needed to simplify things... */
177#define MODE_FLOW		0x0100
178#define MODE_ECHO		0x0200
179#define MODE_INBIN		0x0400
180#define MODE_OUTBIN		0x0800
181#define MODE_FORCE		0x1000
182
183#define	SLC_SYNCH	1
184#define	SLC_BRK		2
185#define	SLC_IP		3
186#define	SLC_AO		4
187#define	SLC_AYT		5
188#define	SLC_EOR		6
189#define	SLC_ABORT	7
190#define	SLC_EOF		8
191#define	SLC_SUSP	9
192#define	SLC_EC		10
193#define	SLC_EL		11
194#define	SLC_EW		12
195#define	SLC_RP		13
196#define	SLC_LNEXT	14
197#define	SLC_XON		15
198#define	SLC_XOFF	16
199#define	SLC_FORW1	17
200#define	SLC_FORW2	18
201#define SLC_MCL         19
202#define SLC_MCR         20
203#define SLC_MCWL        21
204#define SLC_MCWR        22
205#define SLC_MCBOL       23
206#define SLC_MCEOL       24
207#define SLC_INSRT       25
208#define SLC_OVER        26
209#define SLC_ECR         27
210#define SLC_EWR         28
211#define SLC_EBOL        29
212#define SLC_EEOL        30
213
214#define	NSLC		30
215
216/*
217 * For backwards compatibility, we define SLC_NAMES to be the
218 * list of names if SLC_NAMES is not defined.
219 */
220#define	SLC_NAMELIST	"0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR",	\
221			"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP",	\
222			"LNEXT", "XON", "XOFF", "FORW1", "FORW2",	\
223			"MCL", "MCR", "MCWL", "MCWR", "MCBOL",		\
224			"MCEOL", "INSRT", "OVER", "ECR", "EWR",		\
225			"EBOL", "EEOL",					\
226			0
227
228#ifdef	SLC_NAMES
229const char *slc_names[] = {
230	SLC_NAMELIST
231};
232#else
233extern char *slc_names[];
234#define	SLC_NAMES SLC_NAMELIST
235#endif
236
237#define	SLC_NAME_OK(x)	((unsigned int)(x) <= NSLC)
238#define SLC_NAME(x)	slc_names[x]
239
240#define	SLC_NOSUPPORT	0
241#define	SLC_CANTCHANGE	1
242#define	SLC_VARIABLE	2
243#define	SLC_DEFAULT	3
244#define	SLC_LEVELBITS	0x03
245
246#define	SLC_FUNC	0
247#define	SLC_FLAGS	1
248#define	SLC_VALUE	2
249
250#define	SLC_ACK		0x80
251#define	SLC_FLUSHIN	0x40
252#define	SLC_FLUSHOUT	0x20
253
254#define	OLD_ENV_VAR	1
255#define	OLD_ENV_VALUE	0
256#define	NEW_ENV_VAR	0
257#define	NEW_ENV_VALUE	1
258#define	ENV_ESC		2
259#define ENV_USERVAR	3
260
261/*
262 * AUTHENTICATION suboptions
263 */
264
265/*
266 * Who is authenticating who ...
267 */
268#define	AUTH_WHO_CLIENT		0	/* Client authenticating server */
269#define	AUTH_WHO_SERVER		1	/* Server authenticating client */
270#define	AUTH_WHO_MASK		1
271
272/*
273 * amount of authentication done
274 */
275#define	AUTH_HOW_ONE_WAY	0
276#define	AUTH_HOW_MUTUAL		2
277#define	AUTH_HOW_MASK		2
278
279#define	AUTHTYPE_NULL		0
280#define	AUTHTYPE_KERBEROS_V4	1
281#define	AUTHTYPE_KERBEROS_V5	2
282#define	AUTHTYPE_SPX		3
283#define	AUTHTYPE_MINK		4
284#define	AUTHTYPE_SRA		6
285#define	AUTHTYPE_CNT		7
286
287#define	AUTHTYPE_TEST		99
288
289#ifdef	AUTH_NAMES
290const char *authtype_names[] = {
291	"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", NULL, "SRA",
292	0
293};
294#else
295extern char *authtype_names[];
296#endif
297
298#define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)
299#define	AUTHTYPE_NAME(x)	authtype_names[x]
300
301/*
302 * ENCRYPTion suboptions
303 */
304#define	ENCRYPT_IS		0	/* I pick encryption type ... */
305#define	ENCRYPT_SUPPORT		1	/* I support encryption types ... */
306#define	ENCRYPT_REPLY		2	/* Initial setup response */
307#define	ENCRYPT_START		3	/* Am starting to send encrypted */
308#define	ENCRYPT_END		4	/* Am ending encrypted */
309#define	ENCRYPT_REQSTART	5	/* Request you start encrypting */
310#define	ENCRYPT_REQEND		6	/* Request you end encrypting */
311#define	ENCRYPT_ENC_KEYID	7
312#define	ENCRYPT_DEC_KEYID	8
313#define	ENCRYPT_CNT		9
314
315#define	ENCTYPE_ANY		0
316#define	ENCTYPE_DES_CFB64	1
317#define	ENCTYPE_DES_OFB64	2
318#define	ENCTYPE_CNT		3
319
320#ifdef	ENCRYPT_NAMES
321const char *encrypt_names[] = {
322	"IS", "SUPPORT", "REPLY", "START", "END",
323	"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
324	0
325};
326const char *enctype_names[] = {
327	"ANY", "DES_CFB64",  "DES_OFB64",
328	0
329};
330#else
331extern char *encrypt_names[];
332extern char *enctype_names[];
333#endif
334
335
336#define	ENCRYPT_NAME_OK(x)	((unsigned int)(x) < ENCRYPT_CNT)
337#define	ENCRYPT_NAME(x)		encrypt_names[x]
338
339#define	ENCTYPE_NAME_OK(x)	((unsigned int)(x) < ENCTYPE_CNT)
340#define	ENCTYPE_NAME(x)		enctype_names[x]
341
342#endif /* !_TELNET_H_ */
343