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