Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:55:47

0001 /* Copyright (C) Sara Golemon <sarag@libssh2.org>
0002  * Copyright (C) Daniel Stenberg
0003  * Copyright (C) Simon Josefsson <simon@josefsson.org>
0004  * All rights reserved.
0005  *
0006  * Redistribution and use in source and binary forms,
0007  * with or without modification, are permitted provided
0008  * that the following conditions are met:
0009  *
0010  *   Redistributions of source code must retain the above
0011  *   copyright notice, this list of conditions and the
0012  *   following disclaimer.
0013  *
0014  *   Redistributions in binary form must reproduce the above
0015  *   copyright notice, this list of conditions and the following
0016  *   disclaimer in the documentation and/or other materials
0017  *   provided with the distribution.
0018  *
0019  *   Neither the name of the copyright holder nor the names
0020  *   of any other contributors may be used to endorse or
0021  *   promote products derived from this software without
0022  *   specific prior written permission.
0023  *
0024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
0025  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
0026  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0027  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0028  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
0029  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0030  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
0031  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
0032  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
0034  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0035  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
0036  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
0037  * OF SUCH DAMAGE.
0038  *
0039  * SPDX-License-Identifier: BSD-3-Clause
0040  */
0041 
0042 #ifndef LIBSSH2_H
0043 #define LIBSSH2_H 1
0044 
0045 #define LIBSSH2_COPYRIGHT "The libssh2 project and its contributors."
0046 
0047 /* We use underscore instead of dash when appending DEV in dev versions just
0048    to make the BANNER define (used by src/session.c) be a valid SSH
0049    banner. Release versions have no appended strings and may of course not
0050    have dashes either. */
0051 #define LIBSSH2_VERSION "1.11.1"
0052 
0053 /* The numeric version number is also available "in parts" by using these
0054    defines: */
0055 #define LIBSSH2_VERSION_MAJOR 1
0056 #define LIBSSH2_VERSION_MINOR 11
0057 #define LIBSSH2_VERSION_PATCH 1
0058 
0059 /* This is the numeric version of the libssh2 version number, meant for easier
0060    parsing and comparisons by programs. The LIBSSH2_VERSION_NUM define will
0061    always follow this syntax:
0062 
0063          0xXXYYZZ
0064 
0065    Where XX, YY and ZZ are the main version, release and patch numbers in
0066    hexadecimal (using 8 bits each). All three numbers are always represented
0067    using two digits.  1.2 would appear as "0x010200" while version 9.11.7
0068    appears as "0x090b07".
0069 
0070    This 6-digit (24 bits) hexadecimal number does not show pre-release number,
0071    and it is always a greater number in a more recent release. It makes
0072    comparisons with greater than and less than work.
0073 */
0074 #define LIBSSH2_VERSION_NUM 0x010b01
0075 
0076 /*
0077  * This is the date and time when the full source package was created. The
0078  * timestamp is not stored in the source code repo, as the timestamp is
0079  * properly set in the tarballs by the maketgz script.
0080  *
0081  * The format of the date should follow this template:
0082  *
0083  * "Mon Feb 12 11:35:33 UTC 2007"
0084  */
0085 #define LIBSSH2_TIMESTAMP "Wed Oct 16 08:03:21 UTC 2024"
0086 
0087 #ifndef RC_INVOKED
0088 
0089 #ifdef __cplusplus
0090 extern "C" {
0091 #endif
0092 
0093 #ifdef _WIN32
0094 # include <basetsd.h>
0095 # include <winsock2.h>
0096 #endif
0097 
0098 #include <stddef.h>
0099 #include <string.h>
0100 #include <sys/stat.h>
0101 #include <sys/types.h>
0102 
0103 /* Allow alternate API prefix from CFLAGS or calling app */
0104 #ifndef LIBSSH2_API
0105 # ifdef _WIN32
0106 #  if defined(LIBSSH2_EXPORTS) || defined(_WINDLL)
0107 #   ifdef LIBSSH2_LIBRARY
0108 #    define LIBSSH2_API __declspec(dllexport)
0109 #   else
0110 #    define LIBSSH2_API __declspec(dllimport)
0111 #   endif /* LIBSSH2_LIBRARY */
0112 #  else
0113 #   define LIBSSH2_API
0114 #  endif
0115 # else /* !_WIN32 */
0116 #  define LIBSSH2_API
0117 # endif /* _WIN32 */
0118 #endif /* LIBSSH2_API */
0119 
0120 #ifdef HAVE_SYS_UIO_H
0121 # include <sys/uio.h>
0122 #endif
0123 
0124 #ifdef _MSC_VER
0125 typedef unsigned char uint8_t;
0126 typedef unsigned short int uint16_t;
0127 typedef unsigned int uint32_t;
0128 typedef __int32 int32_t;
0129 typedef __int64 int64_t;
0130 typedef unsigned __int64 uint64_t;
0131 typedef unsigned __int64 libssh2_uint64_t;
0132 typedef __int64 libssh2_int64_t;
0133 #if (!defined(HAVE_SSIZE_T) && !defined(ssize_t))
0134 typedef SSIZE_T ssize_t;
0135 #define HAVE_SSIZE_T
0136 #endif
0137 #else
0138 #include <stdint.h>
0139 typedef unsigned long long libssh2_uint64_t;
0140 typedef long long libssh2_int64_t;
0141 #endif
0142 
0143 #ifdef _WIN32
0144 typedef SOCKET libssh2_socket_t;
0145 #define LIBSSH2_INVALID_SOCKET INVALID_SOCKET
0146 #define LIBSSH2_SOCKET_CLOSE(s) closesocket(s)
0147 #else /* !_WIN32 */
0148 typedef int libssh2_socket_t;
0149 #define LIBSSH2_INVALID_SOCKET -1
0150 #define LIBSSH2_SOCKET_CLOSE(s) close(s)
0151 #endif /* _WIN32 */
0152 
0153 /* Compile-time deprecation macros */
0154 #if !defined(LIBSSH2_DISABLE_DEPRECATION) && !defined(LIBSSH2_LIBRARY)
0155 #  if defined(_MSC_VER)
0156 #    if _MSC_VER >= 1400
0157 #      define LIBSSH2_DEPRECATED(version, message) \
0158          __declspec(deprecated("since libssh2 " # version ". " message))
0159 #    elif _MSC_VER >= 1310
0160 #      define LIBSSH2_DEPRECATED(version, message) \
0161          __declspec(deprecated)
0162 #   endif
0163 #  elif defined(__GNUC__) && !defined(__INTEL_COMPILER)
0164 #    if (defined(__clang__) && __clang_major__ >= 3) || \
0165         (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
0166 #      define LIBSSH2_DEPRECATED(version, message) \
0167          __attribute__((deprecated("since libssh2 " # version ". " message)))
0168 #    elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)
0169 #      define LIBSSH2_DEPRECATED(version, message) \
0170          __attribute__((deprecated))
0171 #    endif
0172 #  elif defined(__SUNPRO_C) && __SUNPRO_C >= 0x5130
0173 #    define LIBSSH2_DEPRECATED(version, message) \
0174        __attribute__((deprecated))
0175 #  endif
0176 #endif
0177 
0178 #ifndef LIBSSH2_DEPRECATED
0179 #define LIBSSH2_DEPRECATED(version, message)
0180 #endif
0181 
0182 /*
0183  * Determine whether there is small or large file support on windows.
0184  */
0185 
0186 #if defined(_MSC_VER) && !defined(_WIN32_WCE)
0187 #  if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
0188 #    define LIBSSH2_USE_WIN32_LARGE_FILES
0189 #  else
0190 #    define LIBSSH2_USE_WIN32_SMALL_FILES
0191 #  endif
0192 #endif
0193 
0194 #if defined(__MINGW32__) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES)
0195 #  define LIBSSH2_USE_WIN32_LARGE_FILES
0196 #endif
0197 
0198 #if defined(__WATCOMC__) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES)
0199 #  define LIBSSH2_USE_WIN32_LARGE_FILES
0200 #endif
0201 
0202 #if defined(__POCC__)
0203 #  undef LIBSSH2_USE_WIN32_LARGE_FILES
0204 #endif
0205 
0206 #if defined(_WIN32) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES) && \
0207     !defined(LIBSSH2_USE_WIN32_SMALL_FILES)
0208 #  define LIBSSH2_USE_WIN32_SMALL_FILES
0209 #endif
0210 
0211 /*
0212  * Large file (>2Gb) support using WIN32 functions.
0213  */
0214 
0215 #ifdef LIBSSH2_USE_WIN32_LARGE_FILES
0216 #  include <io.h>
0217 #  define LIBSSH2_STRUCT_STAT_SIZE_FORMAT    "%I64d"
0218 typedef struct _stati64 libssh2_struct_stat;
0219 typedef __int64 libssh2_struct_stat_size;
0220 #endif
0221 
0222 /*
0223  * Small file (<2Gb) support using WIN32 functions.
0224  */
0225 
0226 #ifdef LIBSSH2_USE_WIN32_SMALL_FILES
0227 #  ifndef _WIN32_WCE
0228 #    define LIBSSH2_STRUCT_STAT_SIZE_FORMAT    "%d"
0229 typedef struct _stat libssh2_struct_stat;
0230 typedef off_t libssh2_struct_stat_size;
0231 #  endif
0232 #endif
0233 
0234 #ifndef LIBSSH2_STRUCT_STAT_SIZE_FORMAT
0235 #  ifdef __VMS
0236 /* We have to roll our own format here because %z is a C99-ism we don't
0237    have. */
0238 #    if __USE_OFF64_T || __USING_STD_STAT
0239 #      define LIBSSH2_STRUCT_STAT_SIZE_FORMAT      "%Ld"
0240 #    else
0241 #      define LIBSSH2_STRUCT_STAT_SIZE_FORMAT      "%d"
0242 #    endif
0243 #  else
0244 #    define LIBSSH2_STRUCT_STAT_SIZE_FORMAT      "%zd"
0245 #  endif
0246 typedef struct stat libssh2_struct_stat;
0247 typedef off_t libssh2_struct_stat_size;
0248 #endif
0249 
0250 /* Part of every banner, user specified or not */
0251 #define LIBSSH2_SSH_BANNER                  "SSH-2.0-libssh2_" LIBSSH2_VERSION
0252 
0253 #define LIBSSH2_SSH_DEFAULT_BANNER            LIBSSH2_SSH_BANNER
0254 #define LIBSSH2_SSH_DEFAULT_BANNER_WITH_CRLF  LIBSSH2_SSH_DEFAULT_BANNER "\r\n"
0255 
0256 /* Defaults for pty requests */
0257 #define LIBSSH2_TERM_WIDTH      80
0258 #define LIBSSH2_TERM_HEIGHT     24
0259 #define LIBSSH2_TERM_WIDTH_PX   0
0260 #define LIBSSH2_TERM_HEIGHT_PX  0
0261 
0262 /* 1/4 second */
0263 #define LIBSSH2_SOCKET_POLL_UDELAY      250000
0264 /* 0.25 * 120 == 30 seconds */
0265 #define LIBSSH2_SOCKET_POLL_MAXLOOPS    120
0266 
0267 /* Maximum size to allow a payload to compress to, plays it safe by falling
0268    short of spec limits */
0269 #define LIBSSH2_PACKET_MAXCOMP      32000
0270 
0271 /* Maximum size to allow a payload to deccompress to, plays it safe by
0272    allowing more than spec requires */
0273 #define LIBSSH2_PACKET_MAXDECOMP    40000
0274 
0275 /* Maximum size for an inbound compressed payload, plays it safe by
0276    overshooting spec limits */
0277 #define LIBSSH2_PACKET_MAXPAYLOAD   40000
0278 
0279 /* Malloc callbacks */
0280 #define LIBSSH2_ALLOC_FUNC(name)   void *name(size_t count, void **abstract)
0281 #define LIBSSH2_REALLOC_FUNC(name) void *name(void *ptr, size_t count, \
0282                                               void **abstract)
0283 #define LIBSSH2_FREE_FUNC(name)    void name(void *ptr, void **abstract)
0284 
0285 typedef struct _LIBSSH2_USERAUTH_KBDINT_PROMPT
0286 {
0287     unsigned char *text;
0288     size_t length;
0289     unsigned char echo;
0290 } LIBSSH2_USERAUTH_KBDINT_PROMPT;
0291 
0292 typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE
0293 {
0294     char *text;
0295     unsigned int length;  /* FIXME: change type to size_t */
0296 } LIBSSH2_USERAUTH_KBDINT_RESPONSE;
0297 
0298 typedef struct _LIBSSH2_SK_SIG_INFO {
0299     uint8_t flags;
0300     uint32_t counter;
0301     unsigned char *sig_r;
0302     size_t sig_r_len;
0303     unsigned char *sig_s;
0304     size_t sig_s_len;
0305 } LIBSSH2_SK_SIG_INFO;
0306 
0307 /* 'publickey' authentication callback */
0308 #define LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC(name) \
0309     int name(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len, \
0310              const unsigned char *data, size_t data_len, void **abstract)
0311 
0312 /* 'keyboard-interactive' authentication callback */
0313 /* FIXME: name_len, instruction_len -> size_t, num_prompts -> unsigned int? */
0314 #define LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(name_) \
0315     void name_(const char *name, int name_len, const char *instruction, \
0316                int instruction_len, int num_prompts, \
0317                const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts, \
0318                LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses, void **abstract)
0319 
0320 /* SK authentication callback */
0321 #define LIBSSH2_USERAUTH_SK_SIGN_FUNC(name) \
0322     int name(LIBSSH2_SESSION *session, LIBSSH2_SK_SIG_INFO *sig_info, \
0323              const unsigned char *data, size_t data_len, \
0324              int algorithm, uint8_t flags, \
0325              const char *application, const unsigned char *key_handle, \
0326              size_t handle_len, \
0327              void **abstract)
0328 
0329 /* Flags for SK authentication */
0330 #define LIBSSH2_SK_PRESENCE_REQUIRED     0x01
0331 #define LIBSSH2_SK_VERIFICATION_REQUIRED 0x04
0332 
0333 /* FIXME: update lengths to size_t (or ssize_t): */
0334 
0335 /* Callbacks for special SSH packets */
0336 #define LIBSSH2_IGNORE_FUNC(name) \
0337     void name(LIBSSH2_SESSION *session, const char *message, int message_len, \
0338               void **abstract)
0339 
0340 #define LIBSSH2_DEBUG_FUNC(name) \
0341     void name(LIBSSH2_SESSION *session, int always_display, \
0342               const char *message, int message_len, \
0343               const char *language, int language_len, \
0344               void **abstract)
0345 
0346 #define LIBSSH2_DISCONNECT_FUNC(name) \
0347     void name(LIBSSH2_SESSION *session, int reason, \
0348               const char *message, int message_len, \
0349               const char *language, int language_len, \
0350               void **abstract)
0351 
0352 #define LIBSSH2_PASSWD_CHANGEREQ_FUNC(name) \
0353     void name(LIBSSH2_SESSION *session, char **newpw, int *newpw_len, \
0354               void **abstract)
0355 
0356 #define LIBSSH2_MACERROR_FUNC(name) \
0357     int name(LIBSSH2_SESSION *session, const char *packet, int packet_len, \
0358              void **abstract)
0359 
0360 #define LIBSSH2_X11_OPEN_FUNC(name) \
0361     void name(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel, \
0362               const char *shost, int sport, void **abstract)
0363 
0364 #define LIBSSH2_AUTHAGENT_FUNC(name) \
0365     void name(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel, \
0366               void **abstract)
0367 
0368 #define LIBSSH2_ADD_IDENTITIES_FUNC(name) \
0369     void name(LIBSSH2_SESSION *session, void *buffer, \
0370               const char *agent_path, void **abstract)
0371 
0372 #define LIBSSH2_AUTHAGENT_SIGN_FUNC(name) \
0373     int name(LIBSSH2_SESSION* session, \
0374              unsigned char *blob, unsigned int blen, \
0375              const unsigned char *data, unsigned int dlen, \
0376              unsigned char **signature, unsigned int *sigLen, \
0377              const char *agentPath, \
0378              void **abstract)
0379 
0380 #define LIBSSH2_CHANNEL_CLOSE_FUNC(name) \
0381     void name(LIBSSH2_SESSION *session, void **session_abstract, \
0382               LIBSSH2_CHANNEL *channel, void **channel_abstract)
0383 
0384 /* I/O callbacks */
0385 #define LIBSSH2_RECV_FUNC(name)                                         \
0386     ssize_t name(libssh2_socket_t socket,                               \
0387                  void *buffer, size_t length,                           \
0388                  int flags, void **abstract)
0389 #define LIBSSH2_SEND_FUNC(name)                                         \
0390     ssize_t name(libssh2_socket_t socket,                               \
0391                  const void *buffer, size_t length,                     \
0392                  int flags, void **abstract)
0393 
0394 /* libssh2_session_callback_set() constants */
0395 #define LIBSSH2_CALLBACK_IGNORE               0
0396 #define LIBSSH2_CALLBACK_DEBUG                1
0397 #define LIBSSH2_CALLBACK_DISCONNECT           2
0398 #define LIBSSH2_CALLBACK_MACERROR             3
0399 #define LIBSSH2_CALLBACK_X11                  4
0400 #define LIBSSH2_CALLBACK_SEND                 5
0401 #define LIBSSH2_CALLBACK_RECV                 6
0402 #define LIBSSH2_CALLBACK_AUTHAGENT            7
0403 #define LIBSSH2_CALLBACK_AUTHAGENT_IDENTITIES 8
0404 #define LIBSSH2_CALLBACK_AUTHAGENT_SIGN       9
0405 
0406 /* libssh2_session_method_pref() constants */
0407 #define LIBSSH2_METHOD_KEX          0
0408 #define LIBSSH2_METHOD_HOSTKEY      1
0409 #define LIBSSH2_METHOD_CRYPT_CS     2
0410 #define LIBSSH2_METHOD_CRYPT_SC     3
0411 #define LIBSSH2_METHOD_MAC_CS       4
0412 #define LIBSSH2_METHOD_MAC_SC       5
0413 #define LIBSSH2_METHOD_COMP_CS      6
0414 #define LIBSSH2_METHOD_COMP_SC      7
0415 #define LIBSSH2_METHOD_LANG_CS      8
0416 #define LIBSSH2_METHOD_LANG_SC      9
0417 #define LIBSSH2_METHOD_SIGN_ALGO    10
0418 
0419 /* flags */
0420 #define LIBSSH2_FLAG_SIGPIPE        1
0421 #define LIBSSH2_FLAG_COMPRESS       2
0422 #define LIBSSH2_FLAG_QUOTE_PATHS    3
0423 
0424 typedef struct _LIBSSH2_SESSION                     LIBSSH2_SESSION;
0425 typedef struct _LIBSSH2_CHANNEL                     LIBSSH2_CHANNEL;
0426 typedef struct _LIBSSH2_LISTENER                    LIBSSH2_LISTENER;
0427 typedef struct _LIBSSH2_KNOWNHOSTS                  LIBSSH2_KNOWNHOSTS;
0428 typedef struct _LIBSSH2_AGENT                       LIBSSH2_AGENT;
0429 
0430 /* SK signature callback */
0431 typedef struct _LIBSSH2_PRIVKEY_SK {
0432     int algorithm;
0433     uint8_t flags;
0434     const char *application;
0435     const unsigned char *key_handle;
0436     size_t handle_len;
0437     LIBSSH2_USERAUTH_SK_SIGN_FUNC((*sign_callback));
0438     void **orig_abstract;
0439 } LIBSSH2_PRIVKEY_SK;
0440 
0441 int
0442 libssh2_sign_sk(LIBSSH2_SESSION *session,
0443                 unsigned char **sig,
0444                 size_t *sig_len,
0445                 const unsigned char *data,
0446                 size_t data_len,
0447                 void **abstract);
0448 
0449 typedef struct _LIBSSH2_POLLFD {
0450     unsigned char type; /* LIBSSH2_POLLFD_* below */
0451 
0452     union {
0453         libssh2_socket_t socket; /* File descriptors -- examined with
0454                                     system select() call */
0455         LIBSSH2_CHANNEL *channel; /* Examined by checking internal state */
0456         LIBSSH2_LISTENER *listener; /* Read polls only -- are inbound
0457                                        connections waiting to be accepted? */
0458     } fd;
0459 
0460     unsigned long events; /* Requested Events */
0461     unsigned long revents; /* Returned Events */
0462 } LIBSSH2_POLLFD;
0463 
0464 /* Poll FD Descriptor Types */
0465 #define LIBSSH2_POLLFD_SOCKET       1
0466 #define LIBSSH2_POLLFD_CHANNEL      2
0467 #define LIBSSH2_POLLFD_LISTENER     3
0468 
0469 /* Note: Win32 Doesn't actually have a poll() implementation, so some of these
0470    values are faked with select() data */
0471 /* Poll FD events/revents -- Match sys/poll.h where possible */
0472 #define LIBSSH2_POLLFD_POLLIN           0x0001 /* Data available to be read or
0473                                                   connection available --
0474                                                   All */
0475 #define LIBSSH2_POLLFD_POLLPRI          0x0002 /* Priority data available to
0476                                                   be read -- Socket only */
0477 #define LIBSSH2_POLLFD_POLLEXT          0x0002 /* Extended data available to
0478                                                   be read -- Channel only */
0479 #define LIBSSH2_POLLFD_POLLOUT          0x0004 /* Can may be written --
0480                                                   Socket/Channel */
0481 /* revents only */
0482 #define LIBSSH2_POLLFD_POLLERR          0x0008 /* Error Condition -- Socket */
0483 #define LIBSSH2_POLLFD_POLLHUP          0x0010 /* HangUp/EOF -- Socket */
0484 #define LIBSSH2_POLLFD_SESSION_CLOSED   0x0010 /* Session Disconnect */
0485 #define LIBSSH2_POLLFD_POLLNVAL         0x0020 /* Invalid request -- Socket
0486                                                   Only */
0487 #define LIBSSH2_POLLFD_POLLEX           0x0040 /* Exception Condition --
0488                                                   Socket/Win32 */
0489 #define LIBSSH2_POLLFD_CHANNEL_CLOSED   0x0080 /* Channel Disconnect */
0490 #define LIBSSH2_POLLFD_LISTENER_CLOSED  0x0080 /* Listener Disconnect */
0491 
0492 #define HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION
0493 /* Block Direction Types */
0494 #define LIBSSH2_SESSION_BLOCK_INBOUND                  0x0001
0495 #define LIBSSH2_SESSION_BLOCK_OUTBOUND                 0x0002
0496 
0497 /* Hash Types */
0498 #define LIBSSH2_HOSTKEY_HASH_MD5                            1
0499 #define LIBSSH2_HOSTKEY_HASH_SHA1                           2
0500 #define LIBSSH2_HOSTKEY_HASH_SHA256                         3
0501 
0502 /* Hostkey Types */
0503 #define LIBSSH2_HOSTKEY_TYPE_UNKNOWN            0
0504 #define LIBSSH2_HOSTKEY_TYPE_RSA                1
0505 #define LIBSSH2_HOSTKEY_TYPE_DSS                2  /* deprecated */
0506 #define LIBSSH2_HOSTKEY_TYPE_ECDSA_256          3
0507 #define LIBSSH2_HOSTKEY_TYPE_ECDSA_384          4
0508 #define LIBSSH2_HOSTKEY_TYPE_ECDSA_521          5
0509 #define LIBSSH2_HOSTKEY_TYPE_ED25519            6
0510 
0511 /* Disconnect Codes (defined by SSH protocol) */
0512 #define SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT          1
0513 #define SSH_DISCONNECT_PROTOCOL_ERROR                       2
0514 #define SSH_DISCONNECT_KEY_EXCHANGE_FAILED                  3
0515 #define SSH_DISCONNECT_RESERVED                             4
0516 #define SSH_DISCONNECT_MAC_ERROR                            5
0517 #define SSH_DISCONNECT_COMPRESSION_ERROR                    6
0518 #define SSH_DISCONNECT_SERVICE_NOT_AVAILABLE                7
0519 #define SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED       8
0520 #define SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE              9
0521 #define SSH_DISCONNECT_CONNECTION_LOST                      10
0522 #define SSH_DISCONNECT_BY_APPLICATION                       11
0523 #define SSH_DISCONNECT_TOO_MANY_CONNECTIONS                 12
0524 #define SSH_DISCONNECT_AUTH_CANCELLED_BY_USER               13
0525 #define SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE       14
0526 #define SSH_DISCONNECT_ILLEGAL_USER_NAME                    15
0527 
0528 /* Error Codes (defined by libssh2) */
0529 #define LIBSSH2_ERROR_NONE                      0
0530 
0531 /* The library once used -1 as a generic error return value on numerous places
0532    through the code, which subsequently was converted to
0533    LIBSSH2_ERROR_SOCKET_NONE uses over time. As this is a generic error code,
0534    the goal is to never ever return this code but instead make sure that a
0535    more accurate and descriptive error code is used. */
0536 #define LIBSSH2_ERROR_SOCKET_NONE               -1
0537 
0538 #define LIBSSH2_ERROR_BANNER_RECV               -2
0539 #define LIBSSH2_ERROR_BANNER_SEND               -3
0540 #define LIBSSH2_ERROR_INVALID_MAC               -4
0541 #define LIBSSH2_ERROR_KEX_FAILURE               -5
0542 #define LIBSSH2_ERROR_ALLOC                     -6
0543 #define LIBSSH2_ERROR_SOCKET_SEND               -7
0544 #define LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE      -8
0545 #define LIBSSH2_ERROR_TIMEOUT                   -9
0546 #define LIBSSH2_ERROR_HOSTKEY_INIT              -10
0547 #define LIBSSH2_ERROR_HOSTKEY_SIGN              -11
0548 #define LIBSSH2_ERROR_DECRYPT                   -12
0549 #define LIBSSH2_ERROR_SOCKET_DISCONNECT         -13
0550 #define LIBSSH2_ERROR_PROTO                     -14
0551 #define LIBSSH2_ERROR_PASSWORD_EXPIRED          -15
0552 #define LIBSSH2_ERROR_FILE                      -16
0553 #define LIBSSH2_ERROR_METHOD_NONE               -17
0554 #define LIBSSH2_ERROR_AUTHENTICATION_FAILED     -18
0555 #define LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED    \
0556     LIBSSH2_ERROR_AUTHENTICATION_FAILED
0557 #define LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED      -19
0558 #define LIBSSH2_ERROR_CHANNEL_OUTOFORDER        -20
0559 #define LIBSSH2_ERROR_CHANNEL_FAILURE           -21
0560 #define LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED    -22
0561 #define LIBSSH2_ERROR_CHANNEL_UNKNOWN           -23
0562 #define LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED   -24
0563 #define LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED   -25
0564 #define LIBSSH2_ERROR_CHANNEL_CLOSED            -26
0565 #define LIBSSH2_ERROR_CHANNEL_EOF_SENT          -27
0566 #define LIBSSH2_ERROR_SCP_PROTOCOL              -28
0567 #define LIBSSH2_ERROR_ZLIB                      -29
0568 #define LIBSSH2_ERROR_SOCKET_TIMEOUT            -30
0569 #define LIBSSH2_ERROR_SFTP_PROTOCOL             -31
0570 #define LIBSSH2_ERROR_REQUEST_DENIED            -32
0571 #define LIBSSH2_ERROR_METHOD_NOT_SUPPORTED      -33
0572 #define LIBSSH2_ERROR_INVAL                     -34
0573 #define LIBSSH2_ERROR_INVALID_POLL_TYPE         -35
0574 #define LIBSSH2_ERROR_PUBLICKEY_PROTOCOL        -36
0575 #define LIBSSH2_ERROR_EAGAIN                    -37
0576 #define LIBSSH2_ERROR_BUFFER_TOO_SMALL          -38
0577 #define LIBSSH2_ERROR_BAD_USE                   -39
0578 #define LIBSSH2_ERROR_COMPRESS                  -40
0579 #define LIBSSH2_ERROR_OUT_OF_BOUNDARY           -41
0580 #define LIBSSH2_ERROR_AGENT_PROTOCOL            -42
0581 #define LIBSSH2_ERROR_SOCKET_RECV               -43
0582 #define LIBSSH2_ERROR_ENCRYPT                   -44
0583 #define LIBSSH2_ERROR_BAD_SOCKET                -45
0584 #define LIBSSH2_ERROR_KNOWN_HOSTS               -46
0585 #define LIBSSH2_ERROR_CHANNEL_WINDOW_FULL       -47
0586 #define LIBSSH2_ERROR_KEYFILE_AUTH_FAILED       -48
0587 #define LIBSSH2_ERROR_RANDGEN                   -49
0588 #define LIBSSH2_ERROR_MISSING_USERAUTH_BANNER   -50
0589 #define LIBSSH2_ERROR_ALGO_UNSUPPORTED          -51
0590 #define LIBSSH2_ERROR_MAC_FAILURE               -52
0591 #define LIBSSH2_ERROR_HASH_INIT                 -53
0592 #define LIBSSH2_ERROR_HASH_CALC                 -54
0593 
0594 /* this is a define to provide the old (<= 1.2.7) name */
0595 #define LIBSSH2_ERROR_BANNER_NONE LIBSSH2_ERROR_BANNER_RECV
0596 
0597 /* Global API */
0598 #define LIBSSH2_INIT_NO_CRYPTO        0x0001
0599 
0600 /*
0601  * libssh2_init()
0602  *
0603  * Initialize the libssh2 functions.  This typically initialize the
0604  * crypto library.  It uses a global state, and is not thread safe --
0605  * you must make sure this function is not called concurrently.
0606  *
0607  * Flags can be:
0608  * 0:                              Normal initialize
0609  * LIBSSH2_INIT_NO_CRYPTO:         Do not initialize the crypto library (ie.
0610  *                                 OPENSSL_add_cipher_algoritms() for OpenSSL
0611  *
0612  * Returns 0 if succeeded, or a negative value for error.
0613  */
0614 LIBSSH2_API int libssh2_init(int flags);
0615 
0616 /*
0617  * libssh2_exit()
0618  *
0619  * Exit the libssh2 functions and free's all memory used internal.
0620  */
0621 LIBSSH2_API void libssh2_exit(void);
0622 
0623 /*
0624  * libssh2_free()
0625  *
0626  * Deallocate memory allocated by earlier call to libssh2 functions.
0627  */
0628 LIBSSH2_API void libssh2_free(LIBSSH2_SESSION *session, void *ptr);
0629 
0630 /*
0631  * libssh2_session_supported_algs()
0632  *
0633  * Fills algs with a list of supported acryptographic algorithms. Returns a
0634  * non-negative number (number of supported algorithms) on success or a
0635  * negative number (an error code) on failure.
0636  *
0637  * NOTE: on success, algs must be deallocated (by calling libssh2_free) when
0638  * not needed anymore
0639  */
0640 LIBSSH2_API int libssh2_session_supported_algs(LIBSSH2_SESSION* session,
0641                                                int method_type,
0642                                                const char ***algs);
0643 
0644 /* Session API */
0645 LIBSSH2_API LIBSSH2_SESSION *
0646 libssh2_session_init_ex(LIBSSH2_ALLOC_FUNC((*my_alloc)),
0647                         LIBSSH2_FREE_FUNC((*my_free)),
0648                         LIBSSH2_REALLOC_FUNC((*my_realloc)), void *abstract);
0649 #define libssh2_session_init() libssh2_session_init_ex(NULL, NULL, NULL, NULL)
0650 
0651 LIBSSH2_API void **libssh2_session_abstract(LIBSSH2_SESSION *session);
0652 
0653 typedef void (libssh2_cb_generic)(void);
0654 
0655 LIBSSH2_API libssh2_cb_generic *
0656 libssh2_session_callback_set2(LIBSSH2_SESSION *session, int cbtype,
0657                               libssh2_cb_generic *callback);
0658 
0659 LIBSSH2_DEPRECATED(1.11.1, "Use libssh2_session_callback_set2()")
0660 LIBSSH2_API void *libssh2_session_callback_set(LIBSSH2_SESSION *session,
0661                                                int cbtype, void *callback);
0662 LIBSSH2_API int libssh2_session_banner_set(LIBSSH2_SESSION *session,
0663                                            const char *banner);
0664 #ifndef LIBSSH2_NO_DEPRECATED
0665 LIBSSH2_DEPRECATED(1.4.0, "Use libssh2_session_banner_set()")
0666 LIBSSH2_API int libssh2_banner_set(LIBSSH2_SESSION *session,
0667                                    const char *banner);
0668 
0669 LIBSSH2_DEPRECATED(1.2.8, "Use libssh2_session_handshake()")
0670 LIBSSH2_API int libssh2_session_startup(LIBSSH2_SESSION *session, int sock);
0671 #endif
0672 LIBSSH2_API int libssh2_session_handshake(LIBSSH2_SESSION *session,
0673                                           libssh2_socket_t sock);
0674 LIBSSH2_API int libssh2_session_disconnect_ex(LIBSSH2_SESSION *session,
0675                                               int reason,
0676                                               const char *description,
0677                                               const char *lang);
0678 #define libssh2_session_disconnect(session, description) \
0679     libssh2_session_disconnect_ex((session), SSH_DISCONNECT_BY_APPLICATION, \
0680                                   (description), "")
0681 
0682 LIBSSH2_API int libssh2_session_free(LIBSSH2_SESSION *session);
0683 
0684 LIBSSH2_API const char *libssh2_hostkey_hash(LIBSSH2_SESSION *session,
0685                                              int hash_type);
0686 
0687 LIBSSH2_API const char *libssh2_session_hostkey(LIBSSH2_SESSION *session,
0688                                                 size_t *len, int *type);
0689 
0690 LIBSSH2_API int libssh2_session_method_pref(LIBSSH2_SESSION *session,
0691                                             int method_type,
0692                                             const char *prefs);
0693 LIBSSH2_API const char *libssh2_session_methods(LIBSSH2_SESSION *session,
0694                                                 int method_type);
0695 LIBSSH2_API int libssh2_session_last_error(LIBSSH2_SESSION *session,
0696                                            char **errmsg,
0697                                            int *errmsg_len, int want_buf);
0698 LIBSSH2_API int libssh2_session_last_errno(LIBSSH2_SESSION *session);
0699 LIBSSH2_API int libssh2_session_set_last_error(LIBSSH2_SESSION* session,
0700                                                int errcode,
0701                                                const char *errmsg);
0702 LIBSSH2_API int libssh2_session_block_directions(LIBSSH2_SESSION *session);
0703 
0704 LIBSSH2_API int libssh2_session_flag(LIBSSH2_SESSION *session, int flag,
0705                                      int value);
0706 LIBSSH2_API const char *libssh2_session_banner_get(LIBSSH2_SESSION *session);
0707 
0708 /* Userauth API */
0709 LIBSSH2_API char *libssh2_userauth_list(LIBSSH2_SESSION *session,
0710                                         const char *username,
0711                                         unsigned int username_len);
0712 LIBSSH2_API int libssh2_userauth_banner(LIBSSH2_SESSION *session,
0713                                         char **banner);
0714 LIBSSH2_API int libssh2_userauth_authenticated(LIBSSH2_SESSION *session);
0715 
0716 LIBSSH2_API int
0717 libssh2_userauth_password_ex(LIBSSH2_SESSION *session,
0718                              const char *username,
0719                              unsigned int username_len,
0720                              const char *password,
0721                              unsigned int password_len,
0722                              LIBSSH2_PASSWD_CHANGEREQ_FUNC
0723                                  ((*passwd_change_cb)));
0724 
0725 #define libssh2_userauth_password(session, username, password) \
0726     libssh2_userauth_password_ex((session), (username), \
0727                                  (unsigned int)strlen(username), \
0728                                  (password), (unsigned int)strlen(password), \
0729                                  NULL)
0730 
0731 LIBSSH2_API int
0732 libssh2_userauth_publickey_fromfile_ex(LIBSSH2_SESSION *session,
0733                                        const char *username,
0734                                        unsigned int username_len,
0735                                        const char *publickey,
0736                                        const char *privatekey,
0737                                        const char *passphrase);
0738 
0739 #define libssh2_userauth_publickey_fromfile(session, username, publickey,  \
0740                                             privatekey, passphrase)        \
0741     libssh2_userauth_publickey_fromfile_ex((session), (username),          \
0742                                            (unsigned int)strlen(username), \
0743                                            (publickey),                    \
0744                                            (privatekey), (passphrase))
0745 
0746 LIBSSH2_API int
0747 libssh2_userauth_publickey(LIBSSH2_SESSION *session,
0748                            const char *username,
0749                            const unsigned char *pubkeydata,
0750                            size_t pubkeydata_len,
0751                            LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC
0752                                ((*sign_callback)),
0753                            void **abstract);
0754 
0755 LIBSSH2_API int
0756 libssh2_userauth_hostbased_fromfile_ex(LIBSSH2_SESSION *session,
0757                                        const char *username,
0758                                        unsigned int username_len,
0759                                        const char *publickey,
0760                                        const char *privatekey,
0761                                        const char *passphrase,
0762                                        const char *hostname,
0763                                        unsigned int hostname_len,
0764                                        const char *local_username,
0765                                        unsigned int local_username_len);
0766 
0767 #define libssh2_userauth_hostbased_fromfile(session, username, publickey,     \
0768                                             privatekey, passphrase, hostname) \
0769     libssh2_userauth_hostbased_fromfile_ex((session), (username),             \
0770                                            (unsigned int)strlen(username),    \
0771                                            (publickey),                       \
0772                                            (privatekey), (passphrase),        \
0773                                            (hostname),                        \
0774                                            (unsigned int)strlen(hostname),    \
0775                                            (username),                        \
0776                                            (unsigned int)strlen(username))
0777 
0778 LIBSSH2_API int
0779 libssh2_userauth_publickey_frommemory(LIBSSH2_SESSION *session,
0780                                       const char *username,
0781                                       size_t username_len,
0782                                       const char *publickeyfiledata,
0783                                       size_t publickeyfiledata_len,
0784                                       const char *privatekeyfiledata,
0785                                       size_t privatekeyfiledata_len,
0786                                       const char *passphrase);
0787 
0788 /*
0789  * response_callback is provided with filled by library prompts array,
0790  * but client must allocate and fill individual responses. Responses
0791  * array is already allocated. Responses data will be freed by libssh2
0792  * after callback return, but before subsequent callback invocation.
0793  */
0794 LIBSSH2_API int
0795 libssh2_userauth_keyboard_interactive_ex(LIBSSH2_SESSION* session,
0796                                          const char *username,
0797                                          unsigned int username_len,
0798                                          LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC
0799                                              ((*response_callback)));
0800 
0801 #define libssh2_userauth_keyboard_interactive(session, username,             \
0802                                               response_callback)             \
0803     libssh2_userauth_keyboard_interactive_ex((session), (username),          \
0804                                              (unsigned int)strlen(username), \
0805                                              (response_callback))
0806 
0807 LIBSSH2_API int
0808 libssh2_userauth_publickey_sk(LIBSSH2_SESSION *session,
0809                               const char *username,
0810                               size_t username_len,
0811                               const unsigned char *pubkeydata,
0812                               size_t pubkeydata_len,
0813                               const char *privatekeydata,
0814                               size_t privatekeydata_len,
0815                               const char *passphrase,
0816                               LIBSSH2_USERAUTH_SK_SIGN_FUNC
0817                                   ((*sign_callback)),
0818                               void **abstract);
0819 
0820 LIBSSH2_API int libssh2_poll(LIBSSH2_POLLFD *fds, unsigned int nfds,
0821                              long timeout);
0822 
0823 /* Channel API */
0824 #define LIBSSH2_CHANNEL_WINDOW_DEFAULT  (2*1024*1024)
0825 #define LIBSSH2_CHANNEL_PACKET_DEFAULT  32768
0826 #define LIBSSH2_CHANNEL_MINADJUST       1024
0827 
0828 /* Extended Data Handling */
0829 #define LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL        0
0830 #define LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE        1
0831 #define LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE         2
0832 
0833 #define SSH_EXTENDED_DATA_STDERR 1
0834 
0835 /* Returned by any function that would block during a read/write operation */
0836 #define LIBSSH2CHANNEL_EAGAIN LIBSSH2_ERROR_EAGAIN
0837 
0838 LIBSSH2_API LIBSSH2_CHANNEL *
0839 libssh2_channel_open_ex(LIBSSH2_SESSION *session, const char *channel_type,
0840                         unsigned int channel_type_len,
0841                         unsigned int window_size, unsigned int packet_size,
0842                         const char *message, unsigned int message_len);
0843 
0844 #define libssh2_channel_open_session(session) \
0845     libssh2_channel_open_ex((session), "session", sizeof("session") - 1, \
0846                             LIBSSH2_CHANNEL_WINDOW_DEFAULT, \
0847                             LIBSSH2_CHANNEL_PACKET_DEFAULT, NULL, 0)
0848 
0849 LIBSSH2_API LIBSSH2_CHANNEL *
0850 libssh2_channel_direct_tcpip_ex(LIBSSH2_SESSION *session, const char *host,
0851                                 int port, const char *shost, int sport);
0852 #define libssh2_channel_direct_tcpip(session, host, port) \
0853     libssh2_channel_direct_tcpip_ex((session), (host), (port), "127.0.0.1", 22)
0854 
0855 LIBSSH2_API LIBSSH2_CHANNEL *
0856 libssh2_channel_direct_streamlocal_ex(LIBSSH2_SESSION * session,
0857                                       const char *socket_path,
0858                                       const char *shost, int sport);
0859 
0860 LIBSSH2_API LIBSSH2_LISTENER *
0861 libssh2_channel_forward_listen_ex(LIBSSH2_SESSION *session, const char *host,
0862                                   int port, int *bound_port,
0863                                   int queue_maxsize);
0864 #define libssh2_channel_forward_listen(session, port) \
0865     libssh2_channel_forward_listen_ex((session), NULL, (port), NULL, 16)
0866 
0867 LIBSSH2_API int libssh2_channel_forward_cancel(LIBSSH2_LISTENER *listener);
0868 
0869 LIBSSH2_API LIBSSH2_CHANNEL *
0870 libssh2_channel_forward_accept(LIBSSH2_LISTENER *listener);
0871 
0872 LIBSSH2_API int libssh2_channel_setenv_ex(LIBSSH2_CHANNEL *channel,
0873                                           const char *varname,
0874                                           unsigned int varname_len,
0875                                           const char *value,
0876                                           unsigned int value_len);
0877 
0878 #define libssh2_channel_setenv(channel, varname, value)                 \
0879     libssh2_channel_setenv_ex((channel), (varname),                     \
0880                               (unsigned int)strlen(varname), (value),   \
0881                               (unsigned int)strlen(value))
0882 
0883 LIBSSH2_API int libssh2_channel_request_auth_agent(LIBSSH2_CHANNEL *channel);
0884 
0885 LIBSSH2_API int libssh2_channel_request_pty_ex(LIBSSH2_CHANNEL *channel,
0886                                                const char *term,
0887                                                unsigned int term_len,
0888                                                const char *modes,
0889                                                unsigned int modes_len,
0890                                                int width, int height,
0891                                                int width_px, int height_px);
0892 #define libssh2_channel_request_pty(channel, term)                      \
0893     libssh2_channel_request_pty_ex((channel), (term),                   \
0894                                    (unsigned int)strlen(term),          \
0895                                    NULL, 0,                             \
0896                                    LIBSSH2_TERM_WIDTH,                  \
0897                                    LIBSSH2_TERM_HEIGHT,                 \
0898                                    LIBSSH2_TERM_WIDTH_PX,               \
0899                                    LIBSSH2_TERM_HEIGHT_PX)
0900 
0901 LIBSSH2_API int libssh2_channel_request_pty_size_ex(LIBSSH2_CHANNEL *channel,
0902                                                     int width, int height,
0903                                                     int width_px,
0904                                                     int height_px);
0905 #define libssh2_channel_request_pty_size(channel, width, height) \
0906     libssh2_channel_request_pty_size_ex((channel), (width), (height), 0, 0)
0907 
0908 LIBSSH2_API int libssh2_channel_x11_req_ex(LIBSSH2_CHANNEL *channel,
0909                                            int single_connection,
0910                                            const char *auth_proto,
0911                                            const char *auth_cookie,
0912                                            int screen_number);
0913 #define libssh2_channel_x11_req(channel, screen_number) \
0914     libssh2_channel_x11_req_ex((channel), 0, NULL, NULL, (screen_number))
0915 
0916 LIBSSH2_API int libssh2_channel_signal_ex(LIBSSH2_CHANNEL *channel,
0917                                           const char *signame,
0918                                           size_t signame_len);
0919 #define libssh2_channel_signal(channel, signame) \
0920     libssh2_channel_signal_ex((channel), signame, strlen(signame))
0921 
0922 LIBSSH2_API int libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
0923                                                 const char *request,
0924                                                 unsigned int request_len,
0925                                                 const char *message,
0926                                                 unsigned int message_len);
0927 #define libssh2_channel_shell(channel) \
0928     libssh2_channel_process_startup((channel), "shell", sizeof("shell") - 1, \
0929                                     NULL, 0)
0930 #define libssh2_channel_exec(channel, command) \
0931     libssh2_channel_process_startup((channel), "exec", sizeof("exec") - 1, \
0932                                     (command), (unsigned int)strlen(command))
0933 #define libssh2_channel_subsystem(channel, subsystem) \
0934     libssh2_channel_process_startup((channel), "subsystem", \
0935                                     sizeof("subsystem") - 1, (subsystem), \
0936                                     (unsigned int)strlen(subsystem))
0937 
0938 LIBSSH2_API ssize_t libssh2_channel_read_ex(LIBSSH2_CHANNEL *channel,
0939                                             int stream_id, char *buf,
0940                                             size_t buflen);
0941 #define libssh2_channel_read(channel, buf, buflen) \
0942     libssh2_channel_read_ex((channel), 0, \
0943                             (buf), (buflen))
0944 #define libssh2_channel_read_stderr(channel, buf, buflen) \
0945     libssh2_channel_read_ex((channel), SSH_EXTENDED_DATA_STDERR, \
0946                             (buf), (buflen))
0947 
0948 LIBSSH2_API int libssh2_poll_channel_read(LIBSSH2_CHANNEL *channel,
0949                                           int extended);
0950 
0951 LIBSSH2_API unsigned long
0952 libssh2_channel_window_read_ex(LIBSSH2_CHANNEL *channel,
0953                                unsigned long *read_avail,
0954                                unsigned long *window_size_initial);
0955 #define libssh2_channel_window_read(channel) \
0956     libssh2_channel_window_read_ex((channel), NULL, NULL)
0957 
0958 #ifndef LIBSSH2_NO_DEPRECATED
0959 LIBSSH2_DEPRECATED(1.1.0, "Use libssh2_channel_receive_window_adjust2()")
0960 LIBSSH2_API unsigned long
0961 libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL *channel,
0962                                       unsigned long adjustment,
0963                                       unsigned char force);
0964 #endif
0965 LIBSSH2_API int
0966 libssh2_channel_receive_window_adjust2(LIBSSH2_CHANNEL *channel,
0967                                        unsigned long adjustment,
0968                                        unsigned char force,
0969                                        unsigned int *storewindow);
0970 
0971 LIBSSH2_API ssize_t libssh2_channel_write_ex(LIBSSH2_CHANNEL *channel,
0972                                              int stream_id, const char *buf,
0973                                              size_t buflen);
0974 
0975 #define libssh2_channel_write(channel, buf, buflen) \
0976     libssh2_channel_write_ex((channel), 0, \
0977                              (buf), (buflen))
0978 #define libssh2_channel_write_stderr(channel, buf, buflen) \
0979     libssh2_channel_write_ex((channel), SSH_EXTENDED_DATA_STDERR, \
0980                              (buf), (buflen))
0981 
0982 LIBSSH2_API unsigned long
0983 libssh2_channel_window_write_ex(LIBSSH2_CHANNEL *channel,
0984                                 unsigned long *window_size_initial);
0985 #define libssh2_channel_window_write(channel) \
0986     libssh2_channel_window_write_ex((channel), NULL)
0987 
0988 LIBSSH2_API void libssh2_session_set_blocking(LIBSSH2_SESSION* session,
0989                                               int blocking);
0990 LIBSSH2_API int libssh2_session_get_blocking(LIBSSH2_SESSION* session);
0991 
0992 LIBSSH2_API void libssh2_channel_set_blocking(LIBSSH2_CHANNEL *channel,
0993                                               int blocking);
0994 
0995 LIBSSH2_API void libssh2_session_set_timeout(LIBSSH2_SESSION* session,
0996                                              long timeout);
0997 LIBSSH2_API long libssh2_session_get_timeout(LIBSSH2_SESSION* session);
0998 
0999 LIBSSH2_API void libssh2_session_set_read_timeout(LIBSSH2_SESSION* session,
1000                                                   long timeout);
1001 LIBSSH2_API long libssh2_session_get_read_timeout(LIBSSH2_SESSION* session);
1002 
1003 #ifndef LIBSSH2_NO_DEPRECATED
1004 LIBSSH2_DEPRECATED(1.1.0, "libssh2_channel_handle_extended_data2()")
1005 LIBSSH2_API void libssh2_channel_handle_extended_data(LIBSSH2_CHANNEL *channel,
1006                                                       int ignore_mode);
1007 #endif
1008 LIBSSH2_API int libssh2_channel_handle_extended_data2(LIBSSH2_CHANNEL *channel,
1009                                                       int ignore_mode);
1010 
1011 #ifndef LIBSSH2_NO_DEPRECATED
1012 /* libssh2_channel_ignore_extended_data() is defined below for BC with version
1013  * 0.1
1014  *
1015  * Future uses should use libssh2_channel_handle_extended_data() directly if
1016  * LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE is passed, extended data will be read
1017  * (FIFO) from the standard data channel
1018  */
1019 /* DEPRECATED since 0.3.0. Use libssh2_channel_handle_extended_data2(). */
1020 #define libssh2_channel_ignore_extended_data(channel, ignore)                 \
1021     libssh2_channel_handle_extended_data((channel), (ignore) ?                \
1022                                        LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE : \
1023                                        LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL)
1024 #endif
1025 
1026 #define LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA     -1
1027 #define LIBSSH2_CHANNEL_FLUSH_ALL               -2
1028 LIBSSH2_API int libssh2_channel_flush_ex(LIBSSH2_CHANNEL *channel,
1029                                          int streamid);
1030 #define libssh2_channel_flush(channel) libssh2_channel_flush_ex((channel), 0)
1031 #define libssh2_channel_flush_stderr(channel) \
1032     libssh2_channel_flush_ex((channel), SSH_EXTENDED_DATA_STDERR)
1033 
1034 LIBSSH2_API int libssh2_channel_get_exit_status(LIBSSH2_CHANNEL* channel);
1035 LIBSSH2_API int libssh2_channel_get_exit_signal(LIBSSH2_CHANNEL* channel,
1036                                                 char **exitsignal,
1037                                                 size_t *exitsignal_len,
1038                                                 char **errmsg,
1039                                                 size_t *errmsg_len,
1040                                                 char **langtag,
1041                                                 size_t *langtag_len);
1042 LIBSSH2_API int libssh2_channel_send_eof(LIBSSH2_CHANNEL *channel);
1043 LIBSSH2_API int libssh2_channel_eof(LIBSSH2_CHANNEL *channel);
1044 LIBSSH2_API int libssh2_channel_wait_eof(LIBSSH2_CHANNEL *channel);
1045 LIBSSH2_API int libssh2_channel_close(LIBSSH2_CHANNEL *channel);
1046 LIBSSH2_API int libssh2_channel_wait_closed(LIBSSH2_CHANNEL *channel);
1047 LIBSSH2_API int libssh2_channel_free(LIBSSH2_CHANNEL *channel);
1048 
1049 #ifndef LIBSSH2_NO_DEPRECATED
1050 LIBSSH2_DEPRECATED(1.7.0, "Use libssh2_scp_recv2()")
1051 LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session,
1052                                               const char *path,
1053                                               struct stat *sb);
1054 #endif
1055 /* Use libssh2_scp_recv2() for large (> 2GB) file support on windows */
1056 LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv2(LIBSSH2_SESSION *session,
1057                                                const char *path,
1058                                                libssh2_struct_stat *sb);
1059 LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_send_ex(LIBSSH2_SESSION *session,
1060                                                  const char *path, int mode,
1061                                                  size_t size, long mtime,
1062                                                  long atime);
1063 LIBSSH2_API LIBSSH2_CHANNEL *
1064 libssh2_scp_send64(LIBSSH2_SESSION *session, const char *path, int mode,
1065                    libssh2_int64_t size, time_t mtime, time_t atime);
1066 
1067 #define libssh2_scp_send(session, path, mode, size) \
1068     libssh2_scp_send_ex((session), (path), (mode), (size), 0, 0)
1069 
1070 /* DEPRECATED */
1071 LIBSSH2_API int libssh2_base64_decode(LIBSSH2_SESSION *session, char **dest,
1072                                       unsigned int *dest_len,
1073                                       const char *src, unsigned int src_len);
1074 
1075 LIBSSH2_API
1076 const char *libssh2_version(int req_version_num);
1077 
1078 typedef enum {
1079     libssh2_no_crypto = 0,
1080     libssh2_openssl,
1081     libssh2_gcrypt,
1082     libssh2_mbedtls,
1083     libssh2_wincng,
1084     libssh2_os400qc3
1085 } libssh2_crypto_engine_t;
1086 
1087 LIBSSH2_API
1088 libssh2_crypto_engine_t libssh2_crypto_engine(void);
1089 
1090 #define HAVE_LIBSSH2_KNOWNHOST_API 0x010101 /* since 1.1.1 */
1091 #define HAVE_LIBSSH2_VERSION_API   0x010100 /* libssh2_version since 1.1 */
1092 #define HAVE_LIBSSH2_CRYPTOENGINE_API 0x011100 /* libssh2_crypto_engine
1093                                                   since 1.11 */
1094 
1095 struct libssh2_knownhost {
1096     unsigned int magic;  /* magic stored by the library */
1097     void *node; /* handle to the internal representation of this host */
1098     char *name; /* this is NULL if no plain text host name exists */
1099     char *key;  /* key in base64/printable format */
1100     int typemask;
1101 };
1102 
1103 /*
1104  * libssh2_knownhost_init()
1105  *
1106  * Init a collection of known hosts. Returns the pointer to a collection.
1107  *
1108  */
1109 LIBSSH2_API LIBSSH2_KNOWNHOSTS *
1110 libssh2_knownhost_init(LIBSSH2_SESSION *session);
1111 
1112 /*
1113  * libssh2_knownhost_add()
1114  *
1115  * Add a host and its associated key to the collection of known hosts.
1116  *
1117  * The 'type' argument specifies on what format the given host and keys are:
1118  *
1119  * plain  - ascii "hostname.domain.tld"
1120  * sha1   - SHA1(<salt> <host>) base64-encoded!
1121  * custom - another hash
1122  *
1123  * If 'sha1' is selected as type, the salt must be provided to the salt
1124  * argument. This too base64 encoded.
1125  *
1126  * The SHA-1 hash is what OpenSSH can be told to use in known_hosts files.  If
1127  * a custom type is used, salt is ignored and you must provide the host
1128  * pre-hashed when checking for it in the libssh2_knownhost_check() function.
1129  *
1130  * The keylen parameter may be omitted (zero) if the key is provided as a
1131  * NULL-terminated base64-encoded string.
1132  */
1133 
1134 /* host format (2 bits) */
1135 #define LIBSSH2_KNOWNHOST_TYPE_MASK    0xffff
1136 #define LIBSSH2_KNOWNHOST_TYPE_PLAIN   1
1137 #define LIBSSH2_KNOWNHOST_TYPE_SHA1    2 /* always base64 encoded */
1138 #define LIBSSH2_KNOWNHOST_TYPE_CUSTOM  3
1139 
1140 /* key format (2 bits) */
1141 #define LIBSSH2_KNOWNHOST_KEYENC_MASK     (3<<16)
1142 #define LIBSSH2_KNOWNHOST_KEYENC_RAW      (1<<16)
1143 #define LIBSSH2_KNOWNHOST_KEYENC_BASE64   (2<<16)
1144 
1145 /* type of key (4 bits) */
1146 #define LIBSSH2_KNOWNHOST_KEY_MASK         (15<<18)
1147 #define LIBSSH2_KNOWNHOST_KEY_SHIFT        18
1148 #define LIBSSH2_KNOWNHOST_KEY_RSA1         (1<<18)
1149 #define LIBSSH2_KNOWNHOST_KEY_SSHRSA       (2<<18)
1150 #define LIBSSH2_KNOWNHOST_KEY_SSHDSS       (3<<18)  /* deprecated */
1151 #define LIBSSH2_KNOWNHOST_KEY_ECDSA_256    (4<<18)
1152 #define LIBSSH2_KNOWNHOST_KEY_ECDSA_384    (5<<18)
1153 #define LIBSSH2_KNOWNHOST_KEY_ECDSA_521    (6<<18)
1154 #define LIBSSH2_KNOWNHOST_KEY_ED25519      (7<<18)
1155 #define LIBSSH2_KNOWNHOST_KEY_UNKNOWN      (15<<18)
1156 
1157 LIBSSH2_API int
1158 libssh2_knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
1159                       const char *host,
1160                       const char *salt,
1161                       const char *key, size_t keylen, int typemask,
1162                       struct libssh2_knownhost **store);
1163 
1164 /*
1165  * libssh2_knownhost_addc()
1166  *
1167  * Add a host and its associated key to the collection of known hosts.
1168  *
1169  * Takes a comment argument that may be NULL.  A NULL comment indicates
1170  * there is no comment and the entry will end directly after the key
1171  * when written out to a file.  An empty string "" comment will indicate an
1172  * empty comment which will cause a single space to be written after the key.
1173  *
1174  * The 'type' argument specifies on what format the given host and keys are:
1175  *
1176  * plain  - ascii "hostname.domain.tld"
1177  * sha1   - SHA1(<salt> <host>) base64-encoded!
1178  * custom - another hash
1179  *
1180  * If 'sha1' is selected as type, the salt must be provided to the salt
1181  * argument. This too base64 encoded.
1182  *
1183  * The SHA-1 hash is what OpenSSH can be told to use in known_hosts files.
1184  * If a custom type is used, salt is ignored and you must provide the host
1185  * pre-hashed when checking for it in the libssh2_knownhost_check() function.
1186  *
1187  * The keylen parameter may be omitted (zero) if the key is provided as a
1188  * NULL-terminated base64-encoded string.
1189  */
1190 
1191 LIBSSH2_API int
1192 libssh2_knownhost_addc(LIBSSH2_KNOWNHOSTS *hosts,
1193                        const char *host,
1194                        const char *salt,
1195                        const char *key, size_t keylen,
1196                        const char *comment, size_t commentlen, int typemask,
1197                        struct libssh2_knownhost **store);
1198 
1199 /*
1200  * libssh2_knownhost_check()
1201  *
1202  * Check a host and its associated key against the collection of known hosts.
1203  *
1204  * The type is the type/format of the given host name.
1205  *
1206  * plain  - ascii "hostname.domain.tld"
1207  * custom - prehashed base64 encoded. Note that this cannot use any salts.
1208  *
1209  *
1210  * 'knownhost' may be set to NULL if you don't care about that info.
1211  *
1212  * Returns:
1213  *
1214  * LIBSSH2_KNOWNHOST_CHECK_* values, see below
1215  *
1216  */
1217 
1218 #define LIBSSH2_KNOWNHOST_CHECK_MATCH    0
1219 #define LIBSSH2_KNOWNHOST_CHECK_MISMATCH 1
1220 #define LIBSSH2_KNOWNHOST_CHECK_NOTFOUND 2
1221 #define LIBSSH2_KNOWNHOST_CHECK_FAILURE  3
1222 
1223 LIBSSH2_API int
1224 libssh2_knownhost_check(LIBSSH2_KNOWNHOSTS *hosts,
1225                         const char *host, const char *key, size_t keylen,
1226                         int typemask,
1227                         struct libssh2_knownhost **knownhost);
1228 
1229 /* this function is identital to the above one, but also takes a port
1230    argument that allows libssh2 to do a better check */
1231 LIBSSH2_API int
1232 libssh2_knownhost_checkp(LIBSSH2_KNOWNHOSTS *hosts,
1233                          const char *host, int port,
1234                          const char *key, size_t keylen,
1235                          int typemask,
1236                          struct libssh2_knownhost **knownhost);
1237 
1238 /*
1239  * libssh2_knownhost_del()
1240  *
1241  * Remove a host from the collection of known hosts. The 'entry' struct is
1242  * retrieved by a call to libssh2_knownhost_check().
1243  *
1244  */
1245 LIBSSH2_API int
1246 libssh2_knownhost_del(LIBSSH2_KNOWNHOSTS *hosts,
1247                       struct libssh2_knownhost *entry);
1248 
1249 /*
1250  * libssh2_knownhost_free()
1251  *
1252  * Free an entire collection of known hosts.
1253  *
1254  */
1255 LIBSSH2_API void
1256 libssh2_knownhost_free(LIBSSH2_KNOWNHOSTS *hosts);
1257 
1258 /*
1259  * libssh2_knownhost_readline()
1260  *
1261  * Pass in a line of a file of 'type'. It makes libssh2 read this line.
1262  *
1263  * LIBSSH2_KNOWNHOST_FILE_OPENSSH is the only supported type.
1264  *
1265  */
1266 LIBSSH2_API int
1267 libssh2_knownhost_readline(LIBSSH2_KNOWNHOSTS *hosts,
1268                            const char *line, size_t len, int type);
1269 
1270 /*
1271  * libssh2_knownhost_readfile()
1272  *
1273  * Add hosts+key pairs from a given file.
1274  *
1275  * Returns a negative value for error or number of successfully added hosts.
1276  *
1277  * This implementation currently only knows one 'type' (openssh), all others
1278  * are reserved for future use.
1279  */
1280 
1281 #define LIBSSH2_KNOWNHOST_FILE_OPENSSH 1
1282 
1283 LIBSSH2_API int
1284 libssh2_knownhost_readfile(LIBSSH2_KNOWNHOSTS *hosts,
1285                            const char *filename, int type);
1286 
1287 /*
1288  * libssh2_knownhost_writeline()
1289  *
1290  * Ask libssh2 to convert a known host to an output line for storage.
1291  *
1292  * Note that this function returns LIBSSH2_ERROR_BUFFER_TOO_SMALL if the given
1293  * output buffer is too small to hold the desired output.
1294  *
1295  * This implementation currently only knows one 'type' (openssh), all others
1296  * are reserved for future use.
1297  *
1298  */
1299 LIBSSH2_API int
1300 libssh2_knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts,
1301                             struct libssh2_knownhost *known,
1302                             char *buffer, size_t buflen,
1303                             size_t *outlen, /* the amount of written data */
1304                             int type);
1305 
1306 /*
1307  * libssh2_knownhost_writefile()
1308  *
1309  * Write hosts+key pairs to a given file.
1310  *
1311  * This implementation currently only knows one 'type' (openssh), all others
1312  * are reserved for future use.
1313  */
1314 
1315 LIBSSH2_API int
1316 libssh2_knownhost_writefile(LIBSSH2_KNOWNHOSTS *hosts,
1317                             const char *filename, int type);
1318 
1319 /*
1320  * libssh2_knownhost_get()
1321  *
1322  * Traverse the internal list of known hosts. Pass NULL to 'prev' to get
1323  * the first one. Or pass a pointer to the previously returned one to get the
1324  * next.
1325  *
1326  * Returns:
1327  * 0 if a fine host was stored in 'store'
1328  * 1 if end of hosts
1329  * [negative] on errors
1330  */
1331 LIBSSH2_API int
1332 libssh2_knownhost_get(LIBSSH2_KNOWNHOSTS *hosts,
1333                       struct libssh2_knownhost **store,
1334                       struct libssh2_knownhost *prev);
1335 
1336 #define HAVE_LIBSSH2_AGENT_API 0x010202 /* since 1.2.2 */
1337 
1338 struct libssh2_agent_publickey {
1339     unsigned int magic;              /* magic stored by the library */
1340     void *node;     /* handle to the internal representation of key */
1341     unsigned char *blob;           /* public key blob */
1342     size_t blob_len;               /* length of the public key blob */
1343     char *comment;                 /* comment in printable format */
1344 };
1345 
1346 /*
1347  * libssh2_agent_init()
1348  *
1349  * Init an ssh-agent handle. Returns the pointer to the handle.
1350  *
1351  */
1352 LIBSSH2_API LIBSSH2_AGENT *
1353 libssh2_agent_init(LIBSSH2_SESSION *session);
1354 
1355 /*
1356  * libssh2_agent_connect()
1357  *
1358  * Connect to an ssh-agent.
1359  *
1360  * Returns 0 if succeeded, or a negative value for error.
1361  */
1362 LIBSSH2_API int
1363 libssh2_agent_connect(LIBSSH2_AGENT *agent);
1364 
1365 /*
1366  * libssh2_agent_list_identities()
1367  *
1368  * Request an ssh-agent to list identities.
1369  *
1370  * Returns 0 if succeeded, or a negative value for error.
1371  */
1372 LIBSSH2_API int
1373 libssh2_agent_list_identities(LIBSSH2_AGENT *agent);
1374 
1375 /*
1376  * libssh2_agent_get_identity()
1377  *
1378  * Traverse the internal list of public keys. Pass NULL to 'prev' to get
1379  * the first one. Or pass a pointer to the previously returned one to get the
1380  * next.
1381  *
1382  * Returns:
1383  * 0 if a fine public key was stored in 'store'
1384  * 1 if end of public keys
1385  * [negative] on errors
1386  */
1387 LIBSSH2_API int
1388 libssh2_agent_get_identity(LIBSSH2_AGENT *agent,
1389                            struct libssh2_agent_publickey **store,
1390                            struct libssh2_agent_publickey *prev);
1391 
1392 /*
1393  * libssh2_agent_userauth()
1394  *
1395  * Do publickey user authentication with the help of ssh-agent.
1396  *
1397  * Returns 0 if succeeded, or a negative value for error.
1398  */
1399 LIBSSH2_API int
1400 libssh2_agent_userauth(LIBSSH2_AGENT *agent,
1401                        const char *username,
1402                        struct libssh2_agent_publickey *identity);
1403 
1404 /*
1405  * libssh2_agent_sign()
1406  *
1407  * Sign a payload using a system-installed ssh-agent.
1408  *
1409  * Returns 0 if succeeded, or a negative value for error.
1410  */
1411 LIBSSH2_API int
1412 libssh2_agent_sign(LIBSSH2_AGENT *agent,
1413                    struct libssh2_agent_publickey *identity,
1414                    unsigned char **sig,
1415                    size_t *s_len,
1416                    const unsigned char *data,
1417                    size_t d_len,
1418                    const char *method,
1419                    unsigned int method_len);
1420 
1421 /*
1422  * libssh2_agent_disconnect()
1423  *
1424  * Close a connection to an ssh-agent.
1425  *
1426  * Returns 0 if succeeded, or a negative value for error.
1427  */
1428 LIBSSH2_API int
1429 libssh2_agent_disconnect(LIBSSH2_AGENT *agent);
1430 
1431 /*
1432  * libssh2_agent_free()
1433  *
1434  * Free an ssh-agent handle.  This function also frees the internal
1435  * collection of public keys.
1436  */
1437 LIBSSH2_API void
1438 libssh2_agent_free(LIBSSH2_AGENT *agent);
1439 
1440 /*
1441  * libssh2_agent_set_identity_path()
1442  *
1443  * Allows a custom agent identity socket path beyond SSH_AUTH_SOCK env
1444  *
1445  */
1446 LIBSSH2_API void
1447 libssh2_agent_set_identity_path(LIBSSH2_AGENT *agent,
1448                                 const char *path);
1449 
1450 /*
1451  * libssh2_agent_get_identity_path()
1452  *
1453  * Returns the custom agent identity socket path if set
1454  *
1455  */
1456 LIBSSH2_API const char *
1457 libssh2_agent_get_identity_path(LIBSSH2_AGENT *agent);
1458 
1459 /*
1460  * libssh2_keepalive_config()
1461  *
1462  * Set how often keepalive messages should be sent.  WANT_REPLY
1463  * indicates whether the keepalive messages should request a response
1464  * from the server.  INTERVAL is number of seconds that can pass
1465  * without any I/O, use 0 (the default) to disable keepalives.  To
1466  * avoid some busy-loop corner-cases, if you specify an interval of 1
1467  * it will be treated as 2.
1468  *
1469  * Note that non-blocking applications are responsible for sending the
1470  * keepalive messages using libssh2_keepalive_send().
1471  */
1472 LIBSSH2_API void libssh2_keepalive_config(LIBSSH2_SESSION *session,
1473                                           int want_reply,
1474                                           unsigned int interval);
1475 
1476 /*
1477  * libssh2_keepalive_send()
1478  *
1479  * Send a keepalive message if needed.  SECONDS_TO_NEXT indicates how
1480  * many seconds you can sleep after this call before you need to call
1481  * it again.  Returns 0 on success, or LIBSSH2_ERROR_SOCKET_SEND on
1482  * I/O errors.
1483  */
1484 LIBSSH2_API int libssh2_keepalive_send(LIBSSH2_SESSION *session,
1485                                        int *seconds_to_next);
1486 
1487 /* NOTE NOTE NOTE
1488    libssh2_trace() has no function in builds that aren't built with debug
1489    enabled
1490  */
1491 LIBSSH2_API int libssh2_trace(LIBSSH2_SESSION *session, int bitmask);
1492 #define LIBSSH2_TRACE_TRANS      (1<<1)
1493 #define LIBSSH2_TRACE_KEX        (1<<2)
1494 #define LIBSSH2_TRACE_AUTH       (1<<3)
1495 #define LIBSSH2_TRACE_CONN       (1<<4)
1496 #define LIBSSH2_TRACE_SCP        (1<<5)
1497 #define LIBSSH2_TRACE_SFTP       (1<<6)
1498 #define LIBSSH2_TRACE_ERROR      (1<<7)
1499 #define LIBSSH2_TRACE_PUBLICKEY  (1<<8)
1500 #define LIBSSH2_TRACE_SOCKET     (1<<9)
1501 
1502 typedef void (*libssh2_trace_handler_func)(LIBSSH2_SESSION*,
1503                                            void *,
1504                                            const char *,
1505                                            size_t);
1506 LIBSSH2_API int libssh2_trace_sethandler(LIBSSH2_SESSION *session,
1507                                          void *context,
1508                                          libssh2_trace_handler_func callback);
1509 
1510 #ifdef __cplusplus
1511 } /* extern "C" */
1512 #endif
1513 
1514 #endif /* !RC_INVOKED */
1515 
1516 #endif /* LIBSSH2_H */