xref: /curl/lib/arpa_telnet.h (revision c074ba64)
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) 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 https://curl.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  * SPDX-License-Identifier: curl
24  *
25  ***************************************************************************/
26 #ifndef CURL_DISABLE_TELNET
27 /*
28  * Telnet option defines. Add more here if in need.
29  */
30 #define CURL_TELOPT_BINARY   0  /* binary 8bit data */
31 #define CURL_TELOPT_ECHO     1  /* just echo! */
32 #define CURL_TELOPT_SGA      3  /* Suppress Go Ahead */
33 #define CURL_TELOPT_EXOPL  255  /* EXtended OPtions List */
34 #define CURL_TELOPT_TTYPE   24  /* Terminal TYPE */
35 #define CURL_TELOPT_NAWS    31  /* Negotiate About Window Size */
36 #define CURL_TELOPT_XDISPLOC 35 /* X DISPlay LOCation */
37 
38 #define CURL_TELOPT_NEW_ENVIRON 39  /* NEW ENVIRONment variables */
39 #define CURL_NEW_ENV_VAR   0
40 #define CURL_NEW_ENV_VALUE 1
41 
42 #ifndef CURL_DISABLE_VERBOSE_STRINGS
43 /*
44  * The telnet options represented as strings
45  */
46 static const char * const telnetoptions[]=
47 {
48   "BINARY",      "ECHO",           "RCP",           "SUPPRESS GO AHEAD",
49   "NAME",        "STATUS",         "TIMING MARK",   "RCTE",
50   "NAOL",        "NAOP",           "NAOCRD",        "NAOHTS",
51   "NAOHTD",      "NAOFFD",         "NAOVTS",        "NAOVTD",
52   "NAOLFD",      "EXTEND ASCII",   "LOGOUT",        "BYTE MACRO",
53   "DE TERMINAL", "SUPDUP",         "SUPDUP OUTPUT", "SEND LOCATION",
54   "TERM TYPE",   "END OF RECORD",  "TACACS UID",    "OUTPUT MARKING",
55   "TTYLOC",      "3270 REGIME",    "X3 PAD",        "NAWS",
56   "TERM SPEED",  "LFLOW",          "LINEMODE",      "XDISPLOC",
57   "OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT",       "NEW-ENVIRON"
58 };
59 #define CURL_TELOPT(x)    telnetoptions[x]
60 #else
61 #define CURL_TELOPT(x)    ""
62 #endif
63 
64 #define CURL_TELOPT_MAXIMUM CURL_TELOPT_NEW_ENVIRON
65 
66 #define CURL_TELOPT_OK(x) ((x) <= CURL_TELOPT_MAXIMUM)
67 
68 #define CURL_NTELOPTS 40
69 
70 /*
71  * First some defines
72  */
73 #define CURL_xEOF 236 /* End Of File */
74 #define CURL_SE   240 /* Sub negotiation End */
75 #define CURL_NOP  241 /* No OPeration */
76 #define CURL_DM   242 /* Data Mark */
77 #define CURL_GA   249 /* Go Ahead, reverse the line */
78 #define CURL_SB   250 /* SuBnegotiation */
79 #define CURL_WILL 251 /* Our side WILL use this option */
80 #define CURL_WONT 252 /* Our side will not use this option */
81 #define CURL_DO   253 /* DO use this option! */
82 #define CURL_DONT 254 /* DON'T use this option! */
83 #define CURL_IAC  255 /* Interpret As Command */
84 
85 #ifndef CURL_DISABLE_VERBOSE_STRINGS
86 /*
87  * Then those numbers represented as strings:
88  */
89 static const char * const telnetcmds[]=
90 {
91   "EOF",  "SUSP",  "ABORT", "EOR",  "SE",
92   "NOP",  "DMARK", "BRK",   "IP",   "AO",
93   "AYT",  "EC",    "EL",    "GA",   "SB",
94   "WILL", "WONT",  "DO",    "DONT", "IAC"
95 };
96 #endif
97 
98 #define CURL_TELCMD_MINIMUM CURL_xEOF /* the first one */
99 #define CURL_TELCMD_MAXIMUM CURL_IAC  /* surprise, 255 is the last one! ;-) */
100 
101 #define CURL_TELQUAL_IS   0
102 #define CURL_TELQUAL_SEND 1
103 #define CURL_TELQUAL_INFO 2
104 #define CURL_TELQUAL_NAME 3
105 
106 #define CURL_TELCMD_OK(x) ( ((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \
107                        ((unsigned int)(x) <= CURL_TELCMD_MAXIMUM) )
108 
109 #ifndef CURL_DISABLE_VERBOSE_STRINGS
110 #define CURL_TELCMD(x)    telnetcmds[(x)-CURL_TELCMD_MINIMUM]
111 #else
112 #define CURL_TELCMD(x)    ""
113 #endif
114 
115 #endif /* CURL_DISABLE_TELNET */
116 
117 #endif /* HEADER_CURL_ARPA_TELNET_H */
118