1 #ifndef TELNET_H__ 2 #define TELNET_H__ 1 3 4 /* 5 * Copyright (c) 1983 Regents of the University of California. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the University of California, Berkeley. The name of the 14 * University may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * 20 * @(#)telnet.h 5.7 (Berkeley) 11/14/89 21 */ 22 23 /* 24 * Definitions for the TELNET protocol. 25 */ 26 #define IAC 255 /* interpret as command: */ 27 #define DONT 254 /* you are not to use option */ 28 #define DO 253 /* please, you use option */ 29 #define WONT 252 /* I won't use option */ 30 #define WILL 251 /* I will use option */ 31 #define SB 250 /* interpret as subnegotiation */ 32 #define GA 249 /* you may reverse the line */ 33 #define EL 248 /* erase the current line */ 34 #define EC 247 /* erase the current character */ 35 #define AYT 246 /* are you there */ 36 #define AO 245 /* abort output--but let prog finish */ 37 #define IP 244 /* interrupt process--permanently */ 38 #define BREAK 243 /* break */ 39 #define DM 242 /* data mark--for connect. cleaning */ 40 #define NOP 241 /* nop */ 41 #define SE 240 /* end sub negotiation */ 42 #define EOR 239 /* end of record (transparent mode) */ 43 #define ABORT 238 /* Abort process */ 44 #define SUSP 237 /* Suspend process */ 45 #define xEOF 236 /* End of file: EOF is already used... */ 46 47 #define SYNCH 242 /* for telfunc calls */ 48 49 #ifdef __DRIVER_SOURCE__ 50 51 #ifdef TELCMDS 52 char *telcmds[] = { 53 "EOF", "SUSP", "ABORT", "EOR", 54 "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", 55 "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 56 }; 57 #define TELCMD_FIRST xEOF 58 #define TELCMD_LAST IAC 59 #define TELCMD_OK(x) ((x) <= TELCMD_LAST && (x) >= TELCMD_FIRST) 60 #define TELCMD(x) telcmds[(x)-TELCMD_FIRST] 61 #endif 62 63 #endif /* __DRIVER_SOURCE__ */ 64 65 /* telnet options */ 66 #define TELOPT_BINARY 0 /* 8-bit data path */ 67 #define TELOPT_ECHO 1 /* echo */ 68 #define TELOPT_RCP 2 /* prepare to reconnect */ 69 #define TELOPT_SGA 3 /* suppress go ahead */ 70 #define TELOPT_NAMS 4 /* approximate message size */ 71 #define TELOPT_STATUS 5 /* give status */ 72 #define TELOPT_TM 6 /* timing mark */ 73 #define TELOPT_RCTE 7 /* remote controlled transmission and echo */ 74 #define TELOPT_NAOL 8 /* negotiate about output line width */ 75 #define TELOPT_NAOP 9 /* negotiate about output page size */ 76 #define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ 77 #define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ 78 #define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ 79 #define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ 80 #define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ 81 #define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ 82 #define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ 83 #define TELOPT_XASCII 17 /* extended ascic character set */ 84 #define TELOPT_LOGOUT 18 /* force logout */ 85 #define TELOPT_BM 19 /* byte macro */ 86 #define TELOPT_DET 20 /* data entry terminal */ 87 #define TELOPT_SUPDUP 21 /* supdup protocol */ 88 #define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ 89 #define TELOPT_SNDLOC 23 /* send location */ 90 #define TELOPT_TTYPE 24 /* terminal type */ 91 #define TELOPT_EOR 25 /* end or record */ 92 #define TELOPT_TUID 26 /* TACACS user identification */ 93 #define TELOPT_OUTMRK 27 /* output marking */ 94 #define TELOPT_TTYLOC 28 /* terminal location number */ 95 #define TELOPT_3270REGIME 29 /* 3270 regime */ 96 #define TELOPT_X3PAD 30 /* X.3 PAD */ 97 #define TELOPT_NAWS 31 /* window size */ 98 #define TELOPT_TSPEED 32 /* terminal speed */ 99 #define TELOPT_LFLOW 33 /* remote flow control */ 100 #define TELOPT_LINEMODE 34 /* Linemode option */ 101 #define TELOPT_XDISPLOC 35 /* X Display Location */ 102 #define TELOPT_ENVIRON 36 /* Environment opt for Port ID */ 103 #define TELOPT_AUTHENTICATION 37 /* authentication */ 104 #define TELOPT_ENCRYPT 38 /* authentication */ 105 #define TELOPT_NEWENV 39 /* Environment opt for Port ID */ 106 #define TELOPT_STARTTLS 46 /* Transport Layer Security */ 107 108 /* Inofficial, mud specific telnet options */ 109 #define TELOPT_MSSP 70 /* Mud Server Status Protocol */ 110 #define TELOPT_COMPRESS 85 /* Mud Compression Protocol, v.1 */ 111 #define TELOPT_COMPRESS2 86 /* Mud Compression Protocol, v.2 */ 112 #define TELOPT_MSP 90 /* Mud Sound Protocol */ 113 #define TELOPT_MXP 91 /* Mud Extension Protocol */ 114 #define TELOPT_ZMP 93 /* Zenith Mud Protocol */ 115 #define TELOPT_MUSHCLIENT 102 /* Mushclient/Aardwolf Protocol */ 116 #define TELOPT_ATCP 200 /* Achaea Telnet Client Protocol */ 117 #define TELOPT_EXOPL 255 /* extended-options-list */ 118 119 #define NTELOPTS 256 /* was: (1+TELOPT_NEWENV) */ 120 121 #ifdef __DRIVER_SOURCE__ 122 123 #ifdef TELOPTS 124 char *telopts[NTELOPTS] 125 = { "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD" 126 , "NAME", "STATUS", "TIMING MARK", "RCTE" 127 , "NAOL", "NAOP", "NAOCRD", "NAOHTS" 128 , "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD" 129 , "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO" 130 , "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", "SEND LOCATION" 131 , "TERMINAL TYPE", "END OF RECORD", "TACACS UID", "OUTPUT MARKING" 132 , "TTYLOC", "3270 REGIME", "X.3 PAD", "NAWS" 133 , "TSPEED", "LFLOW", "LINEMODE", "XDISPLOC" 134 , "ENVIRON", "AUTH", "ENCRYPT", "NEWENV" 135 , "TELOPT 40", "TELOPT 41", "TELOPT 42", "TELOPT 43" 136 , "TELOPT 44", "TELOPT 45", "STARTTLS", "TELOPT 47" 137 , "TELOPT 48", "TELOPT 49", "TELOPT 50", "TELOPT 51" 138 , "TELOPT 52", "TELOPT 53", "TELOPT 54", "TELOPT 55" 139 , "TELOPT 56", "TELOPT 57", "TELOPT 58", "TELOPT 59" 140 , "TELOPT 60", "TELOPT 61", "TELOPT 62", "TELOPT 63" 141 , "TELOPT 64", "TELOPT 65", "TELOPT 66", "TELOPT 67" 142 , "TELOPT 68", "TELOPT 69", "MSSP", "TELOPT 71" 143 , "TELOPT 72", "TELOPT 73", "TELOPT 74", "TELOPT 75" 144 , "TELOPT 76", "TELOPT 77", "TELOPT 78", "TELOPT 79" 145 , "TELOPT 80", "TELOPT 81", "TELOPT 82", "TELOPT 83" 146 , "TELOPT 84", "MUD COMPRESS", "MUD COMPRESS2", "TELOPT 87" 147 , "TELOPT 88", "TELOPT 89", "MUD SOUND", "MUD EXTENSION" 148 , "TELOPT 92", "ZMP", "TELOPT 94", "TELOPT 95" 149 , "TELOPT 96", "TELOPT 97", "TELOPT 98", "TELOPT 99" 150 , "TELOPT 100", "TELOPT 101", "MUSHCLIENT", "TELOPT 103" 151 , "TELOPT 104", "TELOPT 105", "TELOPT 106", "TELOPT 107" 152 , "TELOPT 108", "TELOPT 109", "TELOPT 110", "TELOPT 111" 153 , "TELOPT 112", "TELOPT 113", "TELOPT 114", "TELOPT 115" 154 , "TELOPT 116", "TELOPT 117", "TELOPT 118", "TELOPT 119" 155 , "TELOPT 120", "TELOPT 121", "TELOPT 122", "TELOPT 123" 156 , "TELOPT 124", "TELOPT 125", "TELOPT 126", "TELOPT 127" 157 , "TELOPT 128", "TELOPT 129", "TELOPT 130", "TELOPT 131" 158 , "TELOPT 132", "TELOPT 133", "TELOPT 134", "TELOPT 135" 159 , "TELOPT 136", "TELOPT 137", "TELOPT 138", "TELOPT 139" 160 , "TELOPT 140", "TELOPT 141", "TELOPT 142", "TELOPT 143" 161 , "TELOPT 144", "TELOPT 145", "TELOPT 146", "TELOPT 147" 162 , "TELOPT 148", "TELOPT 149", "TELOPT 150", "TELOPT 151" 163 , "TELOPT 152", "TELOPT 153", "TELOPT 154", "TELOPT 155" 164 , "TELOPT 156", "TELOPT 157", "TELOPT 158", "TELOPT 159" 165 , "TELOPT 160", "TELOPT 161", "TELOPT 162", "TELOPT 163" 166 , "TELOPT 164", "TELOPT 165", "TELOPT 166", "TELOPT 167" 167 , "TELOPT 168", "TELOPT 169", "TELOPT 170", "TELOPT 171" 168 , "TELOPT 172", "TELOPT 173", "TELOPT 174", "TELOPT 175" 169 , "TELOPT 176", "TELOPT 177", "TELOPT 178", "TELOPT 179" 170 , "TELOPT 180", "TELOPT 181", "TELOPT 182", "TELOPT 183" 171 , "TELOPT 184", "TELOPT 185", "TELOPT 186", "TELOPT 187" 172 , "TELOPT 188", "TELOPT 189", "TELOPT 190", "TELOPT 191" 173 , "TELOPT 192", "TELOPT 193", "TELOPT 194", "TELOPT 195" 174 , "TELOPT 196", "TELOPT 197", "TELOPT 198", "TELOPT 199" 175 , "ATCP", "TELOPT 201", "TELOPT 202", "TELOPT 203" 176 , "TELOPT 204", "TELOPT 205", "TELOPT 206", "TELOPT 207" 177 , "TELOPT 208", "TELOPT 209", "TELOPT 210", "TELOPT 211" 178 , "TELOPT 212", "TELOPT 213", "TELOPT 214", "TELOPT 215" 179 , "TELOPT 216", "TELOPT 217", "TELOPT 218", "TELOPT 219" 180 , "TELOPT 220", "TELOPT 221", "TELOPT 222", "TELOPT 223" 181 , "TELOPT 224", "TELOPT 225", "TELOPT 226", "TELOPT 227" 182 , "TELOPT 228", "TELOPT 229", "TELOPT 230", "TELOPT 231" 183 , "TELOPT 232", "TELOPT 233", "TELOPT 234", "TELOPT 235" 184 , "TELOPT 236", "TELOPT 237", "TELOPT 238", "TELOPT 239" 185 , "TELOPT 240", "TELOPT 241", "TELOPT 242", "TELOPT 243" 186 , "TELOPT 244", "TELOPT 245", "TELOPT 246", "TELOPT 247" 187 , "TELOPT 248", "TELOPT 249", "TELOPT 250", "TELOPT 251" 188 , "TELOPT 252", "TELOPT 253", "TELOPT 254", "EXOPL" 189 }; 190 #endif 191 192 #endif /* __DRIVER_SOURCE__ */ 193 194 /* sub-option qualifiers */ 195 #define TELQUAL_IS 0 /* option is... */ 196 #define TELQUAL_SEND 1 /* send option */ 197 198 /* 199 * LINEMODE suboptions 200 */ 201 202 #define LM_MODE 1 203 #define LM_FORWARDMASK 2 204 #define LM_SLC 3 205 206 #define MODE_EDIT 0x01 207 #define MODE_TRAPSIG 0x02 208 #define MODE_ACK 0x04 209 210 #define MODE_MASK (MODE_EDIT|MODE_TRAPSIG|MODE_ACK) 211 212 /* Not part of protocol, but needed to simplify things... */ 213 #define MODE_FLOW 0x0100 214 #define MODE_ECHO 0x0200 215 #define MODE_INBIN 0x0400 216 #define MODE_OUTBIN 0x0800 217 #define MODE_FORCE 0x1000 218 219 #define SLC_SYNCH 1 220 #define SLC_BRK 2 221 #define SLC_IP 3 222 #define SLC_AO 4 223 #define SLC_AYT 5 224 #define SLC_EOR 6 225 #define SLC_ABORT 7 226 #define SLC_EOF 8 227 #define SLC_SUSP 9 228 #define SLC_EC 10 229 #define SLC_EL 11 230 #define SLC_EW 12 231 #define SLC_RP 13 232 #define SLC_LNEXT 14 233 #define SLC_XON 15 234 #define SLC_XOFF 16 235 #define SLC_FORW1 17 236 #define SLC_FORW2 18 237 238 #define NSLC 18 239 240 #define SLC_NAMES "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ 241 "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ 242 "LNEXT", "XON", "XOFF", "FORW1", "FORW2" 243 244 #define SLC_NOSUPPORT 0 245 #define SLC_CANTCHANGE 1 246 #define SLC_VARIABLE 2 247 #define SLC_DEFAULT 3 248 #define SLC_LEVELBITS 0x03 249 250 #define SLC_FUNC 0 251 #define SLC_FLAGS 1 252 #define SLC_VALUE 2 253 254 #define SLC_ACK 0x80 255 #define SLC_FLUSHIN 0x40 256 #define SLC_FLUSHOUT 0x20 257 258 #endif /* TELNET_H__ */ 259