File indexing completed on 2025-01-17 09:55:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 #ifndef LIBSSH2_H
0043 #define LIBSSH2_H 1
0044
0045 #define LIBSSH2_COPYRIGHT "The libssh2 project and its contributors."
0046
0047
0048
0049
0050
0051 #define LIBSSH2_VERSION "1.11.1"
0052
0053
0054
0055 #define LIBSSH2_VERSION_MAJOR 1
0056 #define LIBSSH2_VERSION_MINOR 11
0057 #define LIBSSH2_VERSION_PATCH 1
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 #define LIBSSH2_VERSION_NUM 0x010b01
0075
0076
0077
0078
0079
0080
0081
0082
0083
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
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
0112 # else
0113 # define LIBSSH2_API
0114 # endif
0115 # else
0116 # define LIBSSH2_API
0117 # endif
0118 #endif
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
0148 typedef int libssh2_socket_t;
0149 #define LIBSSH2_INVALID_SOCKET -1
0150 #define LIBSSH2_SOCKET_CLOSE(s) close(s)
0151 #endif
0152
0153
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
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
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
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
0237
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
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
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
0263 #define LIBSSH2_SOCKET_POLL_UDELAY 250000
0264
0265 #define LIBSSH2_SOCKET_POLL_MAXLOOPS 120
0266
0267
0268
0269 #define LIBSSH2_PACKET_MAXCOMP 32000
0270
0271
0272
0273 #define LIBSSH2_PACKET_MAXDECOMP 40000
0274
0275
0276
0277 #define LIBSSH2_PACKET_MAXPAYLOAD 40000
0278
0279
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;
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
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
0313
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
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
0330 #define LIBSSH2_SK_PRESENCE_REQUIRED 0x01
0331 #define LIBSSH2_SK_VERIFICATION_REQUIRED 0x04
0332
0333
0334
0335
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
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
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
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
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
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;
0451
0452 union {
0453 libssh2_socket_t socket;
0454
0455 LIBSSH2_CHANNEL *channel;
0456 LIBSSH2_LISTENER *listener;
0457
0458 } fd;
0459
0460 unsigned long events;
0461 unsigned long revents;
0462 } LIBSSH2_POLLFD;
0463
0464
0465 #define LIBSSH2_POLLFD_SOCKET 1
0466 #define LIBSSH2_POLLFD_CHANNEL 2
0467 #define LIBSSH2_POLLFD_LISTENER 3
0468
0469
0470
0471
0472 #define LIBSSH2_POLLFD_POLLIN 0x0001
0473
0474
0475 #define LIBSSH2_POLLFD_POLLPRI 0x0002
0476
0477 #define LIBSSH2_POLLFD_POLLEXT 0x0002
0478
0479 #define LIBSSH2_POLLFD_POLLOUT 0x0004
0480
0481
0482 #define LIBSSH2_POLLFD_POLLERR 0x0008
0483 #define LIBSSH2_POLLFD_POLLHUP 0x0010
0484 #define LIBSSH2_POLLFD_SESSION_CLOSED 0x0010
0485 #define LIBSSH2_POLLFD_POLLNVAL 0x0020
0486
0487 #define LIBSSH2_POLLFD_POLLEX 0x0040
0488
0489 #define LIBSSH2_POLLFD_CHANNEL_CLOSED 0x0080
0490 #define LIBSSH2_POLLFD_LISTENER_CLOSED 0x0080
0491
0492 #define HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION
0493
0494 #define LIBSSH2_SESSION_BLOCK_INBOUND 0x0001
0495 #define LIBSSH2_SESSION_BLOCK_OUTBOUND 0x0002
0496
0497
0498 #define LIBSSH2_HOSTKEY_HASH_MD5 1
0499 #define LIBSSH2_HOSTKEY_HASH_SHA1 2
0500 #define LIBSSH2_HOSTKEY_HASH_SHA256 3
0501
0502
0503 #define LIBSSH2_HOSTKEY_TYPE_UNKNOWN 0
0504 #define LIBSSH2_HOSTKEY_TYPE_RSA 1
0505 #define LIBSSH2_HOSTKEY_TYPE_DSS 2
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
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
0529 #define LIBSSH2_ERROR_NONE 0
0530
0531
0532
0533
0534
0535
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
0595 #define LIBSSH2_ERROR_BANNER_NONE LIBSSH2_ERROR_BANNER_RECV
0596
0597
0598 #define LIBSSH2_INIT_NO_CRYPTO 0x0001
0599
0600
0601
0602
0603
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614 LIBSSH2_API int libssh2_init(int flags);
0615
0616
0617
0618
0619
0620
0621 LIBSSH2_API void libssh2_exit(void);
0622
0623
0624
0625
0626
0627
0628 LIBSSH2_API void libssh2_free(LIBSSH2_SESSION *session, void *ptr);
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638
0639
0640 LIBSSH2_API int libssh2_session_supported_algs(LIBSSH2_SESSION* session,
0641 int method_type,
0642 const char ***algs);
0643
0644
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
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
0790
0791
0792
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
0824 #define LIBSSH2_CHANNEL_WINDOW_DEFAULT (2*1024*1024)
0825 #define LIBSSH2_CHANNEL_PACKET_DEFAULT 32768
0826 #define LIBSSH2_CHANNEL_MINADJUST 1024
0827
0828
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
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
1013
1014
1015
1016
1017
1018
1019
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
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
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
1091 #define HAVE_LIBSSH2_VERSION_API 0x010100
1092 #define HAVE_LIBSSH2_CRYPTOENGINE_API 0x011100
1093
1094
1095 struct libssh2_knownhost {
1096 unsigned int magic;
1097 void *node;
1098 char *name;
1099 char *key;
1100 int typemask;
1101 };
1102
1103
1104
1105
1106
1107
1108
1109 LIBSSH2_API LIBSSH2_KNOWNHOSTS *
1110 libssh2_knownhost_init(LIBSSH2_SESSION *session);
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135 #define LIBSSH2_KNOWNHOST_TYPE_MASK 0xffff
1136 #define LIBSSH2_KNOWNHOST_TYPE_PLAIN 1
1137 #define LIBSSH2_KNOWNHOST_TYPE_SHA1 2
1138 #define LIBSSH2_KNOWNHOST_TYPE_CUSTOM 3
1139
1140
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
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)
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
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
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
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
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
1230
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
1240
1241
1242
1243
1244
1245 LIBSSH2_API int
1246 libssh2_knownhost_del(LIBSSH2_KNOWNHOSTS *hosts,
1247 struct libssh2_knownhost *entry);
1248
1249
1250
1251
1252
1253
1254
1255 LIBSSH2_API void
1256 libssh2_knownhost_free(LIBSSH2_KNOWNHOSTS *hosts);
1257
1258
1259
1260
1261
1262
1263
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
1272
1273
1274
1275
1276
1277
1278
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
1289
1290
1291
1292
1293
1294
1295
1296
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,
1304 int type);
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315 LIBSSH2_API int
1316 libssh2_knownhost_writefile(LIBSSH2_KNOWNHOSTS *hosts,
1317 const char *filename, int type);
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
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
1337
1338 struct libssh2_agent_publickey {
1339 unsigned int magic;
1340 void *node;
1341 unsigned char *blob;
1342 size_t blob_len;
1343 char *comment;
1344 };
1345
1346
1347
1348
1349
1350
1351
1352 LIBSSH2_API LIBSSH2_AGENT *
1353 libssh2_agent_init(LIBSSH2_SESSION *session);
1354
1355
1356
1357
1358
1359
1360
1361
1362 LIBSSH2_API int
1363 libssh2_agent_connect(LIBSSH2_AGENT *agent);
1364
1365
1366
1367
1368
1369
1370
1371
1372 LIBSSH2_API int
1373 libssh2_agent_list_identities(LIBSSH2_AGENT *agent);
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
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
1394
1395
1396
1397
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
1406
1407
1408
1409
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
1423
1424
1425
1426
1427
1428 LIBSSH2_API int
1429 libssh2_agent_disconnect(LIBSSH2_AGENT *agent);
1430
1431
1432
1433
1434
1435
1436
1437 LIBSSH2_API void
1438 libssh2_agent_free(LIBSSH2_AGENT *agent);
1439
1440
1441
1442
1443
1444
1445
1446 LIBSSH2_API void
1447 libssh2_agent_set_identity_path(LIBSSH2_AGENT *agent,
1448 const char *path);
1449
1450
1451
1452
1453
1454
1455
1456 LIBSSH2_API const char *
1457 libssh2_agent_get_identity_path(LIBSSH2_AGENT *agent);
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472 LIBSSH2_API void libssh2_keepalive_config(LIBSSH2_SESSION *session,
1473 int want_reply,
1474 unsigned int interval);
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484 LIBSSH2_API int libssh2_keepalive_send(LIBSSH2_SESSION *session,
1485 int *seconds_to_next);
1486
1487
1488
1489
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 }
1512 #endif
1513
1514 #endif
1515
1516 #endif