]> git.saurik.com Git - apple/xnu.git/blame - bsd/include/arpa/telnet.h
xnu-201.42.3.tar.gz
[apple/xnu.git] / bsd / include / arpa / telnet.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * Copyright (c) 1983, 1993
24 * The Regents of the University of California. All rights reserved.
25 *
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
28 * are met:
29 * 1. Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in the
33 * documentation and/or other materials provided with the distribution.
34 * 3. All advertising materials mentioning features or use of this software
35 * must display the following acknowledgement:
36 * This product includes software developed by the University of
37 * California, Berkeley and its contributors.
38 * 4. Neither the name of the University nor the names of its contributors
39 * may be used to endorse or promote products derived from this software
40 * without specific prior written permission.
41 *
42 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
43 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
46 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 * SUCH DAMAGE.
53 *
54 * @(#)telnet.h 8.2 (Berkeley) 12/15/93
55 */
56
57#ifndef _TELNET_H_
58#define _TELNET_H_
59
60/*
61 * Definitions for the TELNET protocol.
62 */
63#define IAC 255 /* interpret as command: */
64#define DONT 254 /* you are not to use option */
65#define DO 253 /* please, you use option */
66#define WONT 252 /* I won't use option */
67#define WILL 251 /* I will use option */
68#define SB 250 /* interpret as subnegotiation */
69#define GA 249 /* you may reverse the line */
70#define EL 248 /* erase the current line */
71#define EC 247 /* erase the current character */
72#define AYT 246 /* are you there */
73#define AO 245 /* abort output--but let prog finish */
74#define IP 244 /* interrupt process--permanently */
75#define BREAK 243 /* break */
76#define DM 242 /* data mark--for connect. cleaning */
77#define NOP 241 /* nop */
78#define SE 240 /* end sub negotiation */
79#define EOR 239 /* end of record (transparent mode) */
80#define ABORT 238 /* Abort process */
81#define SUSP 237 /* Suspend process */
82#define xEOF 236 /* End of file: EOF is already used... */
83
84#define SYNCH 242 /* for telfunc calls */
85
86#ifdef TELCMDS
87char *telcmds[] = {
88 "EOF", "SUSP", "ABORT", "EOR",
89 "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
90 "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
91};
92#else
93extern char *telcmds[];
94#endif
95
96#define TELCMD_FIRST xEOF
97#define TELCMD_LAST IAC
98#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
99 (unsigned int)(x) >= TELCMD_FIRST)
100#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
101
102/* telnet options */
103#define TELOPT_BINARY 0 /* 8-bit data path */
104#define TELOPT_ECHO 1 /* echo */
105#define TELOPT_RCP 2 /* prepare to reconnect */
106#define TELOPT_SGA 3 /* suppress go ahead */
107#define TELOPT_NAMS 4 /* approximate message size */
108#define TELOPT_STATUS 5 /* give status */
109#define TELOPT_TM 6 /* timing mark */
110#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
111#define TELOPT_NAOL 8 /* negotiate about output line width */
112#define TELOPT_NAOP 9 /* negotiate about output page size */
113#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
114#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
115#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
116#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
117#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
118#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
119#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
120#define TELOPT_XASCII 17 /* extended ascic character set */
121#define TELOPT_LOGOUT 18 /* force logout */
122#define TELOPT_BM 19 /* byte macro */
123#define TELOPT_DET 20 /* data entry terminal */
124#define TELOPT_SUPDUP 21 /* supdup protocol */
125#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
126#define TELOPT_SNDLOC 23 /* send location */
127#define TELOPT_TTYPE 24 /* terminal type */
128#define TELOPT_EOR 25 /* end or record */
129#define TELOPT_TUID 26 /* TACACS user identification */
130#define TELOPT_OUTMRK 27 /* output marking */
131#define TELOPT_TTYLOC 28 /* terminal location number */
132#define TELOPT_3270REGIME 29 /* 3270 regime */
133#define TELOPT_X3PAD 30 /* X.3 PAD */
134#define TELOPT_NAWS 31 /* window size */
135#define TELOPT_TSPEED 32 /* terminal speed */
136#define TELOPT_LFLOW 33 /* remote flow control */
137#define TELOPT_LINEMODE 34 /* Linemode option */
138#define TELOPT_XDISPLOC 35 /* X Display Location */
139#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
140#define TELOPT_AUTHENTICATION 37/* Authenticate */
141#define TELOPT_ENCRYPT 38 /* Encryption option */
142#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
143#define TELOPT_EXOPL 255 /* extended-options-list */
144
145
146#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
147#ifdef TELOPTS
148char *telopts[NTELOPTS+1] = {
149 "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
150 "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
151 "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
152 "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
153 "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
154 "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
155 "TACACS UID", "OUTPUT MARKING", "TTYLOC",
156 "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
157 "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
158 "ENCRYPT", "NEW-ENVIRON",
159 0,
160};
161#define TELOPT_FIRST TELOPT_BINARY
162#define TELOPT_LAST TELOPT_NEW_ENVIRON
163#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
164#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
165#endif
166
167/* sub-option qualifiers */
168#define TELQUAL_IS 0 /* option is... */
169#define TELQUAL_SEND 1 /* send option */
170#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
171#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
172#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
173
174#define LFLOW_OFF 0 /* Disable remote flow control */
175#define LFLOW_ON 1 /* Enable remote flow control */
176#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
177#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
178
179/*
180 * LINEMODE suboptions
181 */
182
183#define LM_MODE 1
184#define LM_FORWARDMASK 2
185#define LM_SLC 3
186
187#define MODE_EDIT 0x01
188#define MODE_TRAPSIG 0x02
189#define MODE_ACK 0x04
190#define MODE_SOFT_TAB 0x08
191#define MODE_LIT_ECHO 0x10
192
193#define MODE_MASK 0x1f
194
195/* Not part of protocol, but needed to simplify things... */
196#define MODE_FLOW 0x0100
197#define MODE_ECHO 0x0200
198#define MODE_INBIN 0x0400
199#define MODE_OUTBIN 0x0800
200#define MODE_FORCE 0x1000
201
202#define SLC_SYNCH 1
203#define SLC_BRK 2
204#define SLC_IP 3
205#define SLC_AO 4
206#define SLC_AYT 5
207#define SLC_EOR 6
208#define SLC_ABORT 7
209#define SLC_EOF 8
210#define SLC_SUSP 9
211#define SLC_EC 10
212#define SLC_EL 11
213#define SLC_EW 12
214#define SLC_RP 13
215#define SLC_LNEXT 14
216#define SLC_XON 15
217#define SLC_XOFF 16
218#define SLC_FORW1 17
219#define SLC_FORW2 18
220
221#define NSLC 18
222
223/*
224 * For backwards compatability, we define SLC_NAMES to be the
225 * list of names if SLC_NAMES is not defined.
226 */
227#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
228 "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
229 "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
230#ifdef SLC_NAMES
231char *slc_names[] = {
232 SLC_NAMELIST
233};
234#else
235extern char *slc_names[];
236#define SLC_NAMES SLC_NAMELIST
237#endif
238
239#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
240#define SLC_NAME(x) slc_names[x]
241
242#define SLC_NOSUPPORT 0
243#define SLC_CANTCHANGE 1
244#define SLC_VARIABLE 2
245#define SLC_DEFAULT 3
246#define SLC_LEVELBITS 0x03
247
248#define SLC_FUNC 0
249#define SLC_FLAGS 1
250#define SLC_VALUE 2
251
252#define SLC_ACK 0x80
253#define SLC_FLUSHIN 0x40
254#define SLC_FLUSHOUT 0x20
255
256#define OLD_ENV_VAR 1
257#define OLD_ENV_VALUE 0
258#define NEW_ENV_VAR 0
259#define NEW_ENV_VALUE 1
260#define ENV_ESC 2
261#define ENV_USERVAR 3
262
263/*
264 * AUTHENTICATION suboptions
265 */
266
267/*
268 * Who is authenticating who ...
269 */
270#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
271#define AUTH_WHO_SERVER 1 /* Server authenticating client */
272#define AUTH_WHO_MASK 1
273
274/*
275 * amount of authentication done
276 */
277#define AUTH_HOW_ONE_WAY 0
278#define AUTH_HOW_MUTUAL 2
279#define AUTH_HOW_MASK 2
280
281#define AUTHTYPE_NULL 0
282#define AUTHTYPE_KERBEROS_V4 1
283#define AUTHTYPE_KERBEROS_V5 2
284#define AUTHTYPE_SPX 3
285#define AUTHTYPE_MINK 4
286#define AUTHTYPE_CNT 5
287
288#define AUTHTYPE_TEST 99
289
290#ifdef AUTH_NAMES
291char *authtype_names[] = {
292 "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 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 send 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
321char *encrypt_names[] = {
322 "IS", "SUPPORT", "REPLY", "START", "END",
323 "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
324 0,
325};
326char *enctype_names[] = {
327 "ANY", "DES_CFB64", "DES_OFB64", 0,
328};
329#else
330extern char *encrypt_names[];
331extern char *enctype_names[];
332#endif
333
334
335#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
336#define ENCRYPT_NAME(x) encrypt_names[x]
337
338#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
339#define ENCTYPE_NAME(x) enctype_names[x]
340
341#endif /* !_TELNET_H_ */