113498266Sopenharmony_ci#ifndef HEADER_CURL_ARPA_TELNET_H
213498266Sopenharmony_ci#define HEADER_CURL_ARPA_TELNET_H
313498266Sopenharmony_ci/***************************************************************************
413498266Sopenharmony_ci *                                  _   _ ____  _
513498266Sopenharmony_ci *  Project                     ___| | | |  _ \| |
613498266Sopenharmony_ci *                             / __| | | | |_) | |
713498266Sopenharmony_ci *                            | (__| |_| |  _ <| |___
813498266Sopenharmony_ci *                             \___|\___/|_| \_\_____|
913498266Sopenharmony_ci *
1013498266Sopenharmony_ci * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
1113498266Sopenharmony_ci *
1213498266Sopenharmony_ci * This software is licensed as described in the file COPYING, which
1313498266Sopenharmony_ci * you should have received as part of this distribution. The terms
1413498266Sopenharmony_ci * are also available at https://curl.se/docs/copyright.html.
1513498266Sopenharmony_ci *
1613498266Sopenharmony_ci * You may opt to use, copy, modify, merge, publish, distribute and/or sell
1713498266Sopenharmony_ci * copies of the Software, and permit persons to whom the Software is
1813498266Sopenharmony_ci * furnished to do so, under the terms of the COPYING file.
1913498266Sopenharmony_ci *
2013498266Sopenharmony_ci * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
2113498266Sopenharmony_ci * KIND, either express or implied.
2213498266Sopenharmony_ci *
2313498266Sopenharmony_ci * SPDX-License-Identifier: curl
2413498266Sopenharmony_ci *
2513498266Sopenharmony_ci ***************************************************************************/
2613498266Sopenharmony_ci#ifndef CURL_DISABLE_TELNET
2713498266Sopenharmony_ci/*
2813498266Sopenharmony_ci * Telnet option defines. Add more here if in need.
2913498266Sopenharmony_ci */
3013498266Sopenharmony_ci#define CURL_TELOPT_BINARY   0  /* binary 8bit data */
3113498266Sopenharmony_ci#define CURL_TELOPT_ECHO     1  /* just echo! */
3213498266Sopenharmony_ci#define CURL_TELOPT_SGA      3  /* Suppress Go Ahead */
3313498266Sopenharmony_ci#define CURL_TELOPT_EXOPL  255  /* EXtended OPtions List */
3413498266Sopenharmony_ci#define CURL_TELOPT_TTYPE   24  /* Terminal TYPE */
3513498266Sopenharmony_ci#define CURL_TELOPT_NAWS    31  /* Negotiate About Window Size */
3613498266Sopenharmony_ci#define CURL_TELOPT_XDISPLOC 35 /* X DISPlay LOCation */
3713498266Sopenharmony_ci
3813498266Sopenharmony_ci#define CURL_TELOPT_NEW_ENVIRON 39  /* NEW ENVIRONment variables */
3913498266Sopenharmony_ci#define CURL_NEW_ENV_VAR   0
4013498266Sopenharmony_ci#define CURL_NEW_ENV_VALUE 1
4113498266Sopenharmony_ci
4213498266Sopenharmony_ci#ifndef CURL_DISABLE_VERBOSE_STRINGS
4313498266Sopenharmony_ci/*
4413498266Sopenharmony_ci * The telnet options represented as strings
4513498266Sopenharmony_ci */
4613498266Sopenharmony_cistatic const char * const telnetoptions[]=
4713498266Sopenharmony_ci{
4813498266Sopenharmony_ci  "BINARY",      "ECHO",           "RCP",           "SUPPRESS GO AHEAD",
4913498266Sopenharmony_ci  "NAME",        "STATUS",         "TIMING MARK",   "RCTE",
5013498266Sopenharmony_ci  "NAOL",        "NAOP",           "NAOCRD",        "NAOHTS",
5113498266Sopenharmony_ci  "NAOHTD",      "NAOFFD",         "NAOVTS",        "NAOVTD",
5213498266Sopenharmony_ci  "NAOLFD",      "EXTEND ASCII",   "LOGOUT",        "BYTE MACRO",
5313498266Sopenharmony_ci  "DE TERMINAL", "SUPDUP",         "SUPDUP OUTPUT", "SEND LOCATION",
5413498266Sopenharmony_ci  "TERM TYPE",   "END OF RECORD",  "TACACS UID",    "OUTPUT MARKING",
5513498266Sopenharmony_ci  "TTYLOC",      "3270 REGIME",    "X3 PAD",        "NAWS",
5613498266Sopenharmony_ci  "TERM SPEED",  "LFLOW",          "LINEMODE",      "XDISPLOC",
5713498266Sopenharmony_ci  "OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT",       "NEW-ENVIRON"
5813498266Sopenharmony_ci};
5913498266Sopenharmony_ci#define CURL_TELOPT(x)    telnetoptions[x]
6013498266Sopenharmony_ci#else
6113498266Sopenharmony_ci#define CURL_TELOPT(x)    ""
6213498266Sopenharmony_ci#endif
6313498266Sopenharmony_ci
6413498266Sopenharmony_ci#define CURL_TELOPT_MAXIMUM CURL_TELOPT_NEW_ENVIRON
6513498266Sopenharmony_ci
6613498266Sopenharmony_ci#define CURL_TELOPT_OK(x) ((x) <= CURL_TELOPT_MAXIMUM)
6713498266Sopenharmony_ci
6813498266Sopenharmony_ci#define CURL_NTELOPTS 40
6913498266Sopenharmony_ci
7013498266Sopenharmony_ci/*
7113498266Sopenharmony_ci * First some defines
7213498266Sopenharmony_ci */
7313498266Sopenharmony_ci#define CURL_xEOF 236 /* End Of File */
7413498266Sopenharmony_ci#define CURL_SE   240 /* Sub negotiation End */
7513498266Sopenharmony_ci#define CURL_NOP  241 /* No OPeration */
7613498266Sopenharmony_ci#define CURL_DM   242 /* Data Mark */
7713498266Sopenharmony_ci#define CURL_GA   249 /* Go Ahead, reverse the line */
7813498266Sopenharmony_ci#define CURL_SB   250 /* SuBnegotiation */
7913498266Sopenharmony_ci#define CURL_WILL 251 /* Our side WILL use this option */
8013498266Sopenharmony_ci#define CURL_WONT 252 /* Our side WON'T use this option */
8113498266Sopenharmony_ci#define CURL_DO   253 /* DO use this option! */
8213498266Sopenharmony_ci#define CURL_DONT 254 /* DON'T use this option! */
8313498266Sopenharmony_ci#define CURL_IAC  255 /* Interpret As Command */
8413498266Sopenharmony_ci
8513498266Sopenharmony_ci#ifndef CURL_DISABLE_VERBOSE_STRINGS
8613498266Sopenharmony_ci/*
8713498266Sopenharmony_ci * Then those numbers represented as strings:
8813498266Sopenharmony_ci */
8913498266Sopenharmony_cistatic const char * const telnetcmds[]=
9013498266Sopenharmony_ci{
9113498266Sopenharmony_ci  "EOF",  "SUSP",  "ABORT", "EOR",  "SE",
9213498266Sopenharmony_ci  "NOP",  "DMARK", "BRK",   "IP",   "AO",
9313498266Sopenharmony_ci  "AYT",  "EC",    "EL",    "GA",   "SB",
9413498266Sopenharmony_ci  "WILL", "WONT",  "DO",    "DONT", "IAC"
9513498266Sopenharmony_ci};
9613498266Sopenharmony_ci#endif
9713498266Sopenharmony_ci
9813498266Sopenharmony_ci#define CURL_TELCMD_MINIMUM CURL_xEOF /* the first one */
9913498266Sopenharmony_ci#define CURL_TELCMD_MAXIMUM CURL_IAC  /* surprise, 255 is the last one! ;-) */
10013498266Sopenharmony_ci
10113498266Sopenharmony_ci#define CURL_TELQUAL_IS   0
10213498266Sopenharmony_ci#define CURL_TELQUAL_SEND 1
10313498266Sopenharmony_ci#define CURL_TELQUAL_INFO 2
10413498266Sopenharmony_ci#define CURL_TELQUAL_NAME 3
10513498266Sopenharmony_ci
10613498266Sopenharmony_ci#define CURL_TELCMD_OK(x) ( ((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \
10713498266Sopenharmony_ci                       ((unsigned int)(x) <= CURL_TELCMD_MAXIMUM) )
10813498266Sopenharmony_ci
10913498266Sopenharmony_ci#ifndef CURL_DISABLE_VERBOSE_STRINGS
11013498266Sopenharmony_ci#define CURL_TELCMD(x)    telnetcmds[(x)-CURL_TELCMD_MINIMUM]
11113498266Sopenharmony_ci#else
11213498266Sopenharmony_ci#define CURL_TELCMD(x)    ""
11313498266Sopenharmony_ci#endif
11413498266Sopenharmony_ci
11513498266Sopenharmony_ci#endif /* CURL_DISABLE_TELNET */
11613498266Sopenharmony_ci
11713498266Sopenharmony_ci#endif /* HEADER_CURL_ARPA_TELNET_H */
118