1 /* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)telnet.h 5.10 (Berkeley) 06/28/90 8 */ 9 10 /* 11 * Definitions for the TELNET protocol. 12 */ 13 #define IAC 255 /* interpret as command: */ 14 #define DONT 254 /* you are not to use option */ 15 #define DO 253 /* please, you use option */ 16 #define WONT 252 /* I won't use option */ 17 #define WILL 251 /* I will use option */ 18 #define SB 250 /* interpret as subnegotiation */ 19 #define GA 249 /* you may reverse the line */ 20 #define EL 248 /* erase the current line */ 21 #define EC 247 /* erase the current character */ 22 #define AYT 246 /* are you there */ 23 #define AO 245 /* abort output--but let prog finish */ 24 #define IP 244 /* interrupt process--permanently */ 25 #define BREAK 243 /* break */ 26 #define DM 242 /* data mark--for connect. cleaning */ 27 #define NOP 241 /* nop */ 28 #define SE 240 /* end sub negotiation */ 29 #define EOR 239 /* end of record (transparent mode) */ 30 #define ABORT 238 /* Abort process */ 31 #define SUSP 237 /* Suspend process */ 32 #define xEOF 236 /* End of file: EOF is already used... */ 33 34 #define SYNCH 242 /* for telfunc calls */ 35 36 #ifdef TELCMDS 37 char *telcmds[] = { 38 "EOF", "SUSP", "ABORT", "EOR", 39 "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", 40 "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 41 }; 42 #define TELCMD_FIRST xEOF 43 #define TELCMD_LAST IAC 44 #define TELCMD_OK(x) ((x) <= TELCMD_LAST && (x) >= TELCMD_FIRST) 45 #define TELCMD(x) telcmds[(x)-TELCMD_FIRST] 46 #endif 47 48 /* telnet options */ 49 #define TELOPT_BINARY 0 /* 8-bit data path */ 50 #define TELOPT_ECHO 1 /* echo */ 51 #define TELOPT_RCP 2 /* prepare to reconnect */ 52 #define TELOPT_SGA 3 /* suppress go ahead */ 53 #define TELOPT_NAMS 4 /* approximate message size */ 54 #define TELOPT_STATUS 5 /* give status */ 55 #define TELOPT_TM 6 /* timing mark */ 56 #define TELOPT_RCTE 7 /* remote controlled transmission and echo */ 57 #define TELOPT_NAOL 8 /* negotiate about output line width */ 58 #define TELOPT_NAOP 9 /* negotiate about output page size */ 59 #define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ 60 #define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ 61 #define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ 62 #define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ 63 #define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ 64 #define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ 65 #define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ 66 #define TELOPT_XASCII 17 /* extended ascic character set */ 67 #define TELOPT_LOGOUT 18 /* force logout */ 68 #define TELOPT_BM 19 /* byte macro */ 69 #define TELOPT_DET 20 /* data entry terminal */ 70 #define TELOPT_SUPDUP 21 /* supdup protocol */ 71 #define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ 72 #define TELOPT_SNDLOC 23 /* send location */ 73 #define TELOPT_TTYPE 24 /* terminal type */ 74 #define TELOPT_EOR 25 /* end or record */ 75 #define TELOPT_TUID 26 /* TACACS user identification */ 76 #define TELOPT_OUTMRK 27 /* output marking */ 77 #define TELOPT_TTYLOC 28 /* terminal location number */ 78 #define TELOPT_3270REGIME 29 /* 3270 regime */ 79 #define TELOPT_X3PAD 30 /* X.3 PAD */ 80 #define TELOPT_NAWS 31 /* window size */ 81 #define TELOPT_TSPEED 32 /* terminal speed */ 82 #define TELOPT_LFLOW 33 /* remote flow control */ 83 #define TELOPT_LINEMODE 34 /* Linemode option */ 84 #define TELOPT_XDISPLOC 35 /* X Display Location */ 85 #define TELOPT_ENVIRON 36 /* Environment variables */ 86 #define TELOPT_AUTHENTICATION 45 /* XXX Auto Authenticate */ 87 #define TELOPT_EXOPL 255 /* extended-options-list */ 88 89 #define NTELOPTS (1+TELOPT_AUTHENTICATION) 90 #ifdef TELOPTS 91 char *telopts[NTELOPTS] = { 92 "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", 93 "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", 94 "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", 95 "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", 96 "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", 97 "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", 98 "TACACS UID", "OUTPUT MARKING", "TTYLOC", 99 "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", 100 "LINEMODE", "XDISPLOC", "ENVIRON", 101 "UNKNOWN 37", "UNKNOWN 38", "UNKNOWN 39", "UNKNOWN 40", "UNKNOWN 41", 102 "UNKNOWN 42", "UNKNOWN 43", "UNKNOWN 44", "AUTHENTICATION", 103 }; 104 #define TELOPT_FIRST TELOPT_BINARY 105 #define TELOPT_LAST TELOPT_AUTHENTICATION 106 #define TELOPT_OK(x) ((x) <= TELOPT_LAST && (x) >= TELOPT_FIRST) 107 #define TELOPT(x) telopts[(x)-TELOPT_FIRST] 108 #endif 109 110 /* sub-option qualifiers */ 111 #define TELQUAL_IS 0 /* option is... */ 112 #define TELQUAL_SEND 1 /* send option */ 113 #define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */ 114 115 /* 116 * LINEMODE suboptions 117 */ 118 119 #define LM_MODE 1 120 #define LM_FORWARDMASK 2 121 #define LM_SLC 3 122 123 #define MODE_EDIT 0x01 124 #define MODE_TRAPSIG 0x02 125 #define MODE_ACK 0x04 126 #define MODE_SOFT_TAB 0x08 127 #define MODE_LIT_ECHO 0x10 128 129 #define MODE_MASK 0x1f 130 131 /* Not part of protocol, but needed to simplify things... */ 132 #define MODE_FLOW 0x0100 133 #define MODE_ECHO 0x0200 134 #define MODE_INBIN 0x0400 135 #define MODE_OUTBIN 0x0800 136 #define MODE_FORCE 0x1000 137 138 #define SLC_SYNCH 1 139 #define SLC_BRK 2 140 #define SLC_IP 3 141 #define SLC_AO 4 142 #define SLC_AYT 5 143 #define SLC_EOR 6 144 #define SLC_ABORT 7 145 #define SLC_EOF 8 146 #define SLC_SUSP 9 147 #define SLC_EC 10 148 #define SLC_EL 11 149 #define SLC_EW 12 150 #define SLC_RP 13 151 #define SLC_LNEXT 14 152 #define SLC_XON 15 153 #define SLC_XOFF 16 154 #define SLC_FORW1 17 155 #define SLC_FORW2 18 156 157 #define NSLC 18 158 159 #define SLC_NAMES "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ 160 "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ 161 "LNEXT", "XON", "XOFF", "FORW1", "FORW2" 162 163 #define SLC_NOSUPPORT 0 164 #define SLC_CANTCHANGE 1 165 #define SLC_VARIABLE 2 166 #define SLC_DEFAULT 3 167 #define SLC_LEVELBITS 0x03 168 169 #define SLC_FUNC 0 170 #define SLC_FLAGS 1 171 #define SLC_VALUE 2 172 173 #define SLC_ACK 0x80 174 #define SLC_FLUSHIN 0x40 175 #define SLC_FLUSHOUT 0x20 176 177 #define ENV_VALUE 0 178 #define ENV_VAR 1 179 #define ENV_ESC 2 180 181 /* 182 * AUTHENTICATION suboptions 183 */ 184 185 #define TELQUAL_AUTHTYPE_NONE 0 186 #define TELQUAL_AUTHTYPE_PRIVATE 1 187 #define TELQUAL_AUTHTYPE_KERBEROS 2 188 189 /* Kerberos-specific */ 190 191 #define TELQUAL_AUTHTYPE_KERBEROS_V4 4 192 #define TELQUAL_AUTHTYPE_KERBEROS_V5 5 193 #define TELQUAL_AUTHTYPE_KERBEROS_USERNAME 1 194