1 /* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)telnet.h 4.4 (Berkeley) 09/01/89 18 */ 19 20 /* 21 * Definitions for the TELNET protocol. 22 */ 23 #define IAC 255 /* interpret as command: */ 24 #define DONT 254 /* you are not to use option */ 25 #define DO 253 /* please, you use option */ 26 #define WONT 252 /* I won't use option */ 27 #define WILL 251 /* I will use option */ 28 #define SB 250 /* interpret as subnegotiation */ 29 #define GA 249 /* you may reverse the line */ 30 #define EL 248 /* erase the current line */ 31 #define EC 247 /* erase the current character */ 32 #define AYT 246 /* are you there */ 33 #define AO 245 /* abort output--but let prog finish */ 34 #define IP 244 /* interrupt process--permanently */ 35 #define BREAK 243 /* break */ 36 #define DM 242 /* data mark--for connect. cleaning */ 37 #define NOP 241 /* nop */ 38 #define SE 240 /* end sub negotiation */ 39 #define EOR 239 /* end of record (transparent mode) */ 40 #define ABORT 238 /* Abort process */ 41 #define SUSP 237 /* Suspend process */ 42 #define xEOF 236 /* End of file: EOF is already used... */ 43 44 #define SYNCH 242 /* for telfunc calls */ 45 46 #ifdef TELCMDS 47 char *telcmds[] = { 48 "EOF", "SUSP", "ABORT", "EOR", 49 "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", 50 "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 51 }; 52 #define TELCMD_FIRST xEOF 53 #define TELCMD_LAST IAC 54 #define TELCMD_OK(x) ((x) <= TELCMD_LAST && (x) >= TELCMD_FIRST) 55 #define TELCMD(x) telcmds[(x)-TELCMD_FIRST] 56 #endif 57 58 /* telnet options */ 59 #define TELOPT_BINARY 0 /* 8-bit data path */ 60 #define TELOPT_ECHO 1 /* echo */ 61 #define TELOPT_RCP 2 /* prepare to reconnect */ 62 #define TELOPT_SGA 3 /* suppress go ahead */ 63 #define TELOPT_NAMS 4 /* approximate message size */ 64 #define TELOPT_STATUS 5 /* give status */ 65 #define TELOPT_TM 6 /* timing mark */ 66 #define TELOPT_RCTE 7 /* remote controlled transmission and echo */ 67 #define TELOPT_NAOL 8 /* negotiate about output line width */ 68 #define TELOPT_NAOP 9 /* negotiate about output page size */ 69 #define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ 70 #define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ 71 #define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ 72 #define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ 73 #define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ 74 #define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ 75 #define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ 76 #define TELOPT_XASCII 17 /* extended ascic character set */ 77 #define TELOPT_LOGOUT 18 /* force logout */ 78 #define TELOPT_BM 19 /* byte macro */ 79 #define TELOPT_DET 20 /* data entry terminal */ 80 #define TELOPT_SUPDUP 21 /* supdup protocol */ 81 #define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ 82 #define TELOPT_SNDLOC 23 /* send location */ 83 #define TELOPT_TTYPE 24 /* terminal type */ 84 #define TELOPT_EOR 25 /* end or record */ 85 #define TELOPT_TUID 26 /* TACACS user identification */ 86 #define TELOPT_OUTMRK 27 /* output marking */ 87 #define TELOPT_TTYLOC 28 /* terminal location number */ 88 #define TELOPT_3270REGIME 29 /* 3270 regime */ 89 #define TELOPT_X3PAD 30 /* X.3 PAD */ 90 #define TELOPT_NAWS 31 /* window size */ 91 #define TELOPT_TSPEED 32 /* terminal speed */ 92 #define TELOPT_LFLOW 33 /* remote flow control */ 93 #define TELOPT_LINEMODE 34 /* Linemode option */ 94 #define TELOPT_EXOPL 255 /* extended-options-list */ 95 96 #define NTELOPTS (1+TELOPT_LINEMODE) 97 #ifdef TELOPTS 98 char *telopts[NTELOPTS] = { 99 "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", 100 "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", 101 "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", 102 "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", 103 "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", 104 "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", 105 "TACACS UID", "OUTPUT MARKING", "TTYLOC", 106 "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", 107 "LINEMODE", 108 }; 109 #define TELOPT_FIRST TELOPT_BINARY 110 #define TELOPT_LAST TELOPT_LINEMODE 111 #define TELOPT_OK(x) ((x) <= TELOPT_LAST && (x) >= TELOPT_FIRST) 112 #define TELOPT(x) telopts[(x)-TELOPT_FIRST] 113 #endif 114 115 /* sub-option qualifiers */ 116 #define TELQUAL_IS 0 /* option is... */ 117 #define TELQUAL_SEND 1 /* send option */ 118 119 /* 120 * LINEMODE suboptions 121 */ 122 123 #define LM_MODE 1 124 #define LM_FORWARDMASK 2 125 #define LM_SLC 3 126 127 #define MODE_EDIT 0x01 128 #define MODE_TRAPSIG 0x02 129 #define MODE_ACK 0x04 130 131 #define MODE_MASK (MODE_EDIT|MODE_TRAPSIG|MODE_ACK) 132 133 /* Not part of protocol, but needed to simplify things... */ 134 #define MODE_FLOW 0x40 135 #define MODE_ECHO 0x80 136 #define MODE_FORCE 0x20 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