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