arpa_telnet.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. #define CURL_TELOPT_NEW_ENVIRON 39 /* NEW ENVIRONment variables */
  38. #define CURL_NEW_ENV_VAR 0
  39. #define CURL_NEW_ENV_VALUE 1
  40. #ifndef CURL_DISABLE_VERBOSE_STRINGS
  41. /*
  42. * The telnet options represented as strings
  43. */
  44. static const char * const telnetoptions[]=
  45. {
  46. "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD",
  47. "NAME", "STATUS", "TIMING MARK", "RCTE",
  48. "NAOL", "NAOP", "NAOCRD", "NAOHTS",
  49. "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD",
  50. "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
  51. "DE TERMINAL", "SUPDUP", "SUPDUP OUTPUT", "SEND LOCATION",
  52. "TERM TYPE", "END OF RECORD", "TACACS UID", "OUTPUT MARKING",
  53. "TTYLOC", "3270 REGIME", "X3 PAD", "NAWS",
  54. "TERM SPEED", "LFLOW", "LINEMODE", "XDISPLOC",
  55. "OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT", "NEW-ENVIRON"
  56. };
  57. #define CURL_TELOPT(x) telnetoptions[x]
  58. #else
  59. #define CURL_TELOPT(x) ""
  60. #endif
  61. #define CURL_TELOPT_MAXIMUM CURL_TELOPT_NEW_ENVIRON
  62. #define CURL_TELOPT_OK(x) ((x) <= CURL_TELOPT_MAXIMUM)
  63. #define CURL_NTELOPTS 40
  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. #ifndef CURL_DISABLE_VERBOSE_STRINGS
  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. #endif
  90. #define CURL_TELCMD_MINIMUM CURL_xEOF /* the first one */
  91. #define CURL_TELCMD_MAXIMUM CURL_IAC /* surprise, 255 is the last one! ;-) */
  92. #define CURL_TELQUAL_IS 0
  93. #define CURL_TELQUAL_SEND 1
  94. #define CURL_TELQUAL_INFO 2
  95. #define CURL_TELQUAL_NAME 3
  96. #define CURL_TELCMD_OK(x) ( ((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \
  97. ((unsigned int)(x) <= CURL_TELCMD_MAXIMUM) )
  98. #ifndef CURL_DISABLE_VERBOSE_STRINGS
  99. #define CURL_TELCMD(x) telnetcmds[(x)-CURL_TELCMD_MINIMUM]
  100. #else
  101. #define CURL_TELCMD(x) ""
  102. #endif
  103. #endif /* CURL_DISABLE_TELNET */
  104. #endif /* HEADER_CURL_ARPA_TELNET_H */