blob: 94a2b141219a187460eb663c88687fe8d06defa1 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001#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
52char *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#define TELOPT_KERMIT 47 /* Telnet KERMIT */
108#define TELOPT_SEND_URL 48 /* Send URL */
109#define TELOPT_EXOPL 255 /* extended-options-list */
110
111/* Inofficial, mud specific telnet options */
112#define TELOPT_MSSP 70 /* Mud Server Status Protocol */
113#define TELOPT_COMPRESS 85 /* Mud Compression Protocol, v.1 */
114#define TELOPT_COMPRESS2 86 /* Mud Compression Protocol, v.2 */
115#define TELOPT_MSP 90 /* Mud Sound Protocol */
116#define TELOPT_MXP 91 /* Mud Extension Protocol */
117#define TELOPT_ZMP 93 /* Zenith Mud Protocol */
118#define TELOPT_MUSHCLIENT 102 /* Mushclient/Aardwolf Protocol */
119#define TELOPT_ATCP 200 /* Achaea Telnet Client Protocol */
120#define TELOPT_GMCP 201 /* General Mud Communication Protocol*/
121
122#define NTELOPTS 256 /* was: (1+TELOPT_NEWENV) */
123
124#ifdef __DRIVER_SOURCE__
125
126#ifdef TELOPTS
127char *telopts[NTELOPTS]
128 = { "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD"
129 , "NAME", "STATUS", "TIMING MARK", "RCTE"
130 , "NAOL", "NAOP", "NAOCRD", "NAOHTS"
131 , "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD"
132 , "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO"
133 , "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", "SEND LOCATION"
134 , "TERMINAL TYPE", "END OF RECORD", "TACACS UID", "OUTPUT MARKING"
135 , "TTYLOC", "3270 REGIME", "X.3 PAD", "NAWS"
136 , "TSPEED", "LFLOW", "LINEMODE", "XDISPLOC"
137 , "ENVIRON", "AUTH", "ENCRYPT", "NEWENV"
138 , "TELOPT 40", "TELOPT 41", "TELOPT 42", "TELOPT 43"
139 , "TELOPT 44", "TELOPT 45", "STARTTLS", "KERMIT"
140 , "SEND_URL", "TELOPT 49", "TELOPT 50", "TELOPT 51"
141 , "TELOPT 52", "TELOPT 53", "TELOPT 54", "TELOPT 55"
142 , "TELOPT 56", "TELOPT 57", "TELOPT 58", "TELOPT 59"
143 , "TELOPT 60", "TELOPT 61", "TELOPT 62", "TELOPT 63"
144 , "TELOPT 64", "TELOPT 65", "TELOPT 66", "TELOPT 67"
145 , "TELOPT 68", "TELOPT 69", "MSSP", "TELOPT 71"
146 , "TELOPT 72", "TELOPT 73", "TELOPT 74", "TELOPT 75"
147 , "TELOPT 76", "TELOPT 77", "TELOPT 78", "TELOPT 79"
148 , "TELOPT 80", "TELOPT 81", "TELOPT 82", "TELOPT 83"
149 , "TELOPT 84", "MUD COMPRESS", "MUD COMPRESS2", "TELOPT 87"
150 , "TELOPT 88", "TELOPT 89", "MUD SOUND", "MUD EXTENSION"
151 , "TELOPT 92", "ZMP", "TELOPT 94", "TELOPT 95"
152 , "TELOPT 96", "TELOPT 97", "TELOPT 98", "TELOPT 99"
153 , "TELOPT 100", "TELOPT 101", "MUSHCLIENT", "TELOPT 103"
154 , "TELOPT 104", "TELOPT 105", "TELOPT 106", "TELOPT 107"
155 , "TELOPT 108", "TELOPT 109", "TELOPT 110", "TELOPT 111"
156 , "TELOPT 112", "TELOPT 113", "TELOPT 114", "TELOPT 115"
157 , "TELOPT 116", "TELOPT 117", "TELOPT 118", "TELOPT 119"
158 , "TELOPT 120", "TELOPT 121", "TELOPT 122", "TELOPT 123"
159 , "TELOPT 124", "TELOPT 125", "TELOPT 126", "TELOPT 127"
160 , "TELOPT 128", "TELOPT 129", "TELOPT 130", "TELOPT 131"
161 , "TELOPT 132", "TELOPT 133", "TELOPT 134", "TELOPT 135"
162 , "TELOPT 136", "TELOPT 137", "TELOPT 138", "TELOPT 139"
163 , "TELOPT 140", "TELOPT 141", "TELOPT 142", "TELOPT 143"
164 , "TELOPT 144", "TELOPT 145", "TELOPT 146", "TELOPT 147"
165 , "TELOPT 148", "TELOPT 149", "TELOPT 150", "TELOPT 151"
166 , "TELOPT 152", "TELOPT 153", "TELOPT 154", "TELOPT 155"
167 , "TELOPT 156", "TELOPT 157", "TELOPT 158", "TELOPT 159"
168 , "TELOPT 160", "TELOPT 161", "TELOPT 162", "TELOPT 163"
169 , "TELOPT 164", "TELOPT 165", "TELOPT 166", "TELOPT 167"
170 , "TELOPT 168", "TELOPT 169", "TELOPT 170", "TELOPT 171"
171 , "TELOPT 172", "TELOPT 173", "TELOPT 174", "TELOPT 175"
172 , "TELOPT 176", "TELOPT 177", "TELOPT 178", "TELOPT 179"
173 , "TELOPT 180", "TELOPT 181", "TELOPT 182", "TELOPT 183"
174 , "TELOPT 184", "TELOPT 185", "TELOPT 186", "TELOPT 187"
175 , "TELOPT 188", "TELOPT 189", "TELOPT 190", "TELOPT 191"
176 , "TELOPT 192", "TELOPT 193", "TELOPT 194", "TELOPT 195"
177 , "TELOPT 196", "TELOPT 197", "TELOPT 198", "TELOPT 199"
178 , "ATCP", "TELOPT 201", "TELOPT 202", "TELOPT 203"
179 , "TELOPT 204", "TELOPT 205", "TELOPT 206", "TELOPT 207"
180 , "TELOPT 208", "TELOPT 209", "TELOPT 210", "TELOPT 211"
181 , "TELOPT 212", "TELOPT 213", "TELOPT 214", "TELOPT 215"
182 , "TELOPT 216", "TELOPT 217", "TELOPT 218", "TELOPT 219"
183 , "TELOPT 220", "TELOPT 221", "TELOPT 222", "TELOPT 223"
184 , "TELOPT 224", "TELOPT 225", "TELOPT 226", "TELOPT 227"
185 , "TELOPT 228", "TELOPT 229", "TELOPT 230", "TELOPT 231"
186 , "TELOPT 232", "TELOPT 233", "TELOPT 234", "TELOPT 235"
187 , "TELOPT 236", "TELOPT 237", "TELOPT 238", "TELOPT 239"
188 , "TELOPT 240", "TELOPT 241", "TELOPT 242", "TELOPT 243"
189 , "TELOPT 244", "TELOPT 245", "TELOPT 246", "TELOPT 247"
190 , "TELOPT 248", "TELOPT 249", "TELOPT 250", "TELOPT 251"
191 , "TELOPT 252", "TELOPT 253", "TELOPT 254", "EXOPL"
192};
193#endif
194
195#endif /* __DRIVER_SOURCE__ */
196
197/* sub-option qualifiers */
198#define TELQUAL_IS 0 /* option is... */
199#define TELQUAL_SEND 1 /* send option */
200
201/*
202 * LINEMODE suboptions
203 */
204
205#define LM_MODE 1
206#define LM_FORWARDMASK 2
207#define LM_SLC 3
208
209#define MODE_EDIT 0x01
210#define MODE_TRAPSIG 0x02
211#define MODE_ACK 0x04
212
213#define MODE_MASK (MODE_EDIT|MODE_TRAPSIG|MODE_ACK)
214
215/* Not part of protocol, but needed to simplify things... */
216#define MODE_FLOW 0x0100
217#define MODE_ECHO 0x0200
218#define MODE_INBIN 0x0400
219#define MODE_OUTBIN 0x0800
220#define MODE_FORCE 0x1000
221
222#define SLC_SYNCH 1
223#define SLC_BRK 2
224#define SLC_IP 3
225#define SLC_AO 4
226#define SLC_AYT 5
227#define SLC_EOR 6
228#define SLC_ABORT 7
229#define SLC_EOF 8
230#define SLC_SUSP 9
231#define SLC_EC 10
232#define SLC_EL 11
233#define SLC_EW 12
234#define SLC_RP 13
235#define SLC_LNEXT 14
236#define SLC_XON 15
237#define SLC_XOFF 16
238#define SLC_FORW1 17
239#define SLC_FORW2 18
240
241#define NSLC 18
242
243#define SLC_NAMES "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
244 "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
245 "LNEXT", "XON", "XOFF", "FORW1", "FORW2"
246
247#define SLC_NOSUPPORT 0
248#define SLC_CANTCHANGE 1
249#define SLC_VARIABLE 2
250#define SLC_DEFAULT 3
251#define SLC_LEVELBITS 0x03
252
253#define SLC_FUNC 0
254#define SLC_FLAGS 1
255#define SLC_VALUE 2
256
257#define SLC_ACK 0x80
258#define SLC_FLUSHIN 0x40
259#define SLC_FLUSHOUT 0x20
260
261#endif /* TELNET_H__ */