1 #ifndef HEADER_CURL_ARPA_TELNET_H
2 #define HEADER_CURL_ARPA_TELNET_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
11  *
12  * This software is licensed as described in the file COPYING, which
13  * you should have received as part of this distribution. The terms
14  * are also available at http://curl.haxx.se/docs/copyright.html.
15  *
16  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17  * copies of the Software, and permit persons to whom the Software is
18  * furnished to do so, under the terms of the COPYING file.
19  *
20  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21  * KIND, either express or implied.
22  *
23  ***************************************************************************/
24 #ifndef CURL_DISABLE_TELNET
25 /*
26  * Telnet option defines. Add more here if in need.
27  */
28 #define CURL_TELOPT_BINARY   0  /* binary 8bit data */
29 #define CURL_TELOPT_ECHO     1  /* just echo! */
30 #define CURL_TELOPT_SGA      3  /* Suppress Go Ahead */
31 #define CURL_TELOPT_EXOPL  255  /* EXtended OPtions List */
32 #define CURL_TELOPT_TTYPE   24  /* Terminal TYPE */
33 #define CURL_TELOPT_NAWS    31  /* Negotiate About Window Size */
34 #define CURL_TELOPT_XDISPLOC 35 /* X DISPlay LOCation */
35 
36 #define CURL_TELOPT_NEW_ENVIRON 39  /* NEW ENVIRONment variables */
37 #define CURL_NEW_ENV_VAR   0
38 #define CURL_NEW_ENV_VALUE 1
39 
40 /*
41  * The telnet options represented as strings
42  */
43 static const char * const telnetoptions[]=
44 {
45   "BINARY",      "ECHO",           "RCP",           "SUPPRESS GO AHEAD",
46   "NAME",        "STATUS",         "TIMING MARK",   "RCTE",
47   "NAOL",        "NAOP",           "NAOCRD",        "NAOHTS",
48   "NAOHTD",      "NAOFFD",         "NAOVTS",        "NAOVTD",
49   "NAOLFD",      "EXTEND ASCII",   "LOGOUT",        "BYTE MACRO",
50   "DE TERMINAL", "SUPDUP",         "SUPDUP OUTPUT", "SEND LOCATION",
51   "TERM TYPE",   "END OF RECORD",  "TACACS UID",    "OUTPUT MARKING",
52   "TTYLOC",      "3270 REGIME",    "X3 PAD",        "NAWS",
53   "TERM SPEED",  "LFLOW",          "LINEMODE",      "XDISPLOC",
54   "OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT",       "NEW-ENVIRON"
55 };
56 
57 #define CURL_TELOPT_MAXIMUM CURL_TELOPT_NEW_ENVIRON
58 
59 #define CURL_TELOPT_OK(x) ((x) <= CURL_TELOPT_MAXIMUM)
60 #define CURL_TELOPT(x)    telnetoptions[x]
61 
62 #define CURL_NTELOPTS 40
63 
64 /*
65  * First some defines
66  */
67 #define CURL_xEOF 236 /* End Of File */
68 #define CURL_SE   240 /* Sub negotiation End */
69 #define CURL_NOP  241 /* No OPeration */
70 #define CURL_DM   242 /* Data Mark */
71 #define CURL_GA   249 /* Go Ahead, reverse the line */
72 #define CURL_SB   250 /* SuBnegotiation */
73 #define CURL_WILL 251 /* Our side WILL use this option */
74 #define CURL_WONT 252 /* Our side WON'T use this option */
75 #define CURL_DO   253 /* DO use this option! */
76 #define CURL_DONT 254 /* DON'T use this option! */
77 #define CURL_IAC  255 /* Interpret As Command */
78 
79 /*
80  * Then those numbers represented as strings:
81  */
82 static const char * const telnetcmds[]=
83 {
84   "EOF",  "SUSP",  "ABORT", "EOR",  "SE",
85   "NOP",  "DMARK", "BRK",   "IP",   "AO",
86   "AYT",  "EC",    "EL",    "GA",   "SB",
87   "WILL", "WONT",  "DO",    "DONT", "IAC"
88 };
89 
90 #define CURL_TELCMD_MINIMUM CURL_xEOF /* the first one */
91 #define CURL_TELCMD_MAXIMUM CURL_IAC  /* surprise, 255 is the last one! ;-) */
92 
93 #define CURL_TELQUAL_IS   0
94 #define CURL_TELQUAL_SEND 1
95 #define CURL_TELQUAL_INFO 2
96 #define CURL_TELQUAL_NAME 3
97 
98 #define CURL_TELCMD_OK(x) ( ((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \
99                        ((unsigned int)(x) <= CURL_TELCMD_MAXIMUM) )
100 #define CURL_TELCMD(x)    telnetcmds[(x)-CURL_TELCMD_MINIMUM]
101 
102 #endif /* CURL_DISABLE_TELNET */
103 
104 #endif /* HEADER_CURL_ARPA_TELNET_H */
105