2010-03-19 09:14:21 +01:00
|
|
|
/* Copyright (c) 2004-2008, 2010, Sara Golemon <sarag@libssh2.org>
|
2011-05-31 23:35:49 +02:00
|
|
|
* Copyright (c) 2009-2011 by Daniel Stenberg
|
2010-01-28 14:30:25 +01:00
|
|
|
* Copyright (c) 2010 Simon Josefsson
|
2004-12-07 21:17:20 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms,
|
|
|
|
* with or without modification, are permitted provided
|
|
|
|
* that the following conditions are met:
|
|
|
|
*
|
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
* following disclaimer.
|
|
|
|
*
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials
|
|
|
|
* provided with the distribution.
|
|
|
|
*
|
|
|
|
* Neither the name of the copyright holder nor the names
|
|
|
|
* of any other contributors may be used to endorse or
|
|
|
|
* promote products derived from this software without
|
|
|
|
* specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
|
|
|
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
|
|
|
* OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIBSSH2_PRIV_H
|
|
|
|
#define LIBSSH2_PRIV_H 1
|
|
|
|
|
2005-01-01 23:38:34 +00:00
|
|
|
#define LIBSSH2_LIBRARY
|
2004-12-07 21:17:20 +00:00
|
|
|
#include "libssh2_config.h"
|
2007-04-05 09:31:38 +00:00
|
|
|
|
2008-11-10 16:48:41 +00:00
|
|
|
#ifdef HAVE_WINDOWS_H
|
2011-11-01 22:45:49 +01:00
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#endif
|
2008-11-10 16:48:41 +00:00
|
|
|
#include <windows.h>
|
2011-11-01 22:45:49 +01:00
|
|
|
#undef WIN32_LEAN_AND_MEAN
|
2008-11-10 16:48:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_WS2TCPIP_H
|
|
|
|
#include <ws2tcpip.h>
|
|
|
|
#endif
|
|
|
|
|
2008-11-20 10:29:01 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2007-04-05 09:31:38 +00:00
|
|
|
/* The following CPP block should really only be in session.c and
|
|
|
|
packet.c. However, AIX have #define's for 'events' and 'revents'
|
|
|
|
and we are using those names in libssh2.h, so we need to include
|
|
|
|
the AIX headers first, to make sure all code is compiled with
|
|
|
|
consistent names of these fields. While arguable the best would to
|
|
|
|
change libssh2.h to use other names, that would break backwards
|
|
|
|
compatibility. For more information, see:
|
|
|
|
http://www.mail-archive.com/libssh2-devel%40lists.sourceforge.net/msg00003.html
|
|
|
|
http://www.mail-archive.com/libssh2-devel%40lists.sourceforge.net/msg00224.html
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_POLL
|
|
|
|
# include <sys/poll.h>
|
|
|
|
#else
|
2008-09-29 14:16:19 +00:00
|
|
|
# if defined(HAVE_SELECT) && !defined(WIN32)
|
2007-04-05 09:31:38 +00:00
|
|
|
# ifdef HAVE_SYS_SELECT_H
|
|
|
|
# include <sys/select.h>
|
|
|
|
# else
|
|
|
|
# include <sys/time.h>
|
|
|
|
# include <sys/types.h>
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2010-04-17 13:18:15 +02:00
|
|
|
/* Needed for struct iovec on some platforms */
|
|
|
|
#ifdef HAVE_SYS_UIO_H
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
|
|
# include <sys/socket.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
|
|
|
# include <sys/ioctl.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_INTTYPES_H
|
|
|
|
#include <inttypes.h>
|
|
|
|
#endif
|
|
|
|
|
2004-12-07 21:17:20 +00:00
|
|
|
#include "libssh2.h"
|
2007-06-06 12:34:06 +00:00
|
|
|
#include "libssh2_publickey.h"
|
|
|
|
#include "libssh2_sftp.h"
|
2009-08-19 13:58:15 +02:00
|
|
|
#include "misc.h" /* for the linked list stuff */
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2009-03-15 22:29:23 +00:00
|
|
|
#ifndef FALSE
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE 1
|
|
|
|
#endif
|
|
|
|
|
2014-05-17 23:47:20 +02:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
/* "inline" keyword is valid only with C++ engine! */
|
|
|
|
#define inline __inline
|
|
|
|
#endif
|
|
|
|
|
2008-11-10 16:48:41 +00:00
|
|
|
/* Provide iovec / writev on WIN32 platform. */
|
|
|
|
#ifdef WIN32
|
|
|
|
|
|
|
|
struct iovec {
|
2009-08-24 14:07:05 +02:00
|
|
|
size_t iov_len;
|
|
|
|
void * iov_base;
|
2008-11-10 16:48:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline int writev(int sock, struct iovec *iov, int nvecs)
|
|
|
|
{
|
2009-03-19 12:45:59 +00:00
|
|
|
DWORD ret;
|
|
|
|
if (WSASend(sock, (LPWSABUF)iov, nvecs, &ret, 0, NULL, NULL) == 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
return -1;
|
2008-11-10 16:48:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* WIN32 */
|
|
|
|
|
2010-12-19 00:00:50 +01:00
|
|
|
#include "crypto.h"
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2008-09-30 21:54:20 +00:00
|
|
|
#ifdef HAVE_WINSOCK2_H
|
|
|
|
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <ws2tcpip.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-02-02 16:21:20 +00:00
|
|
|
/* RFC4253 section 6.1 Maximum Packet Length says:
|
|
|
|
*
|
|
|
|
* "All implementations MUST be able to process packets with
|
|
|
|
* uncompressed payload length of 32768 bytes or less and
|
|
|
|
* total packet size of 35000 bytes or less (including length,
|
|
|
|
* padding length, payload, padding, and MAC.)."
|
|
|
|
*/
|
|
|
|
#define MAX_SSH_PACKET_LEN 35000
|
|
|
|
|
2009-03-17 13:48:35 +00:00
|
|
|
#define LIBSSH2_ALLOC(session, count) \
|
|
|
|
session->alloc((count), &(session)->abstract)
|
|
|
|
#define LIBSSH2_REALLOC(session, ptr, count) \
|
|
|
|
((ptr) ? session->realloc((ptr), (count), &(session)->abstract) : \
|
|
|
|
session->alloc((count), &(session)->abstract))
|
|
|
|
#define LIBSSH2_FREE(session, ptr) \
|
|
|
|
session->free((ptr), &(session)->abstract)
|
|
|
|
#define LIBSSH2_IGNORE(session, data, datalen) \
|
|
|
|
session->ssh_msg_ignore((session), (data), (datalen), &(session)->abstract)
|
|
|
|
#define LIBSSH2_DEBUG(session, always_display, message, message_len, \
|
|
|
|
language, language_len) \
|
2010-06-16 00:04:25 +02:00
|
|
|
session->ssh_msg_debug((session), (always_display), (message), \
|
|
|
|
(message_len), (language), (language_len), \
|
|
|
|
&(session)->abstract)
|
2011-08-25 22:41:17 +02:00
|
|
|
#define LIBSSH2_DISCONNECT(session, reason, message, message_len, \
|
|
|
|
language, language_len) \
|
|
|
|
session->ssh_msg_disconnect((session), (reason), (message), \
|
|
|
|
(message_len), (language), (language_len), \
|
|
|
|
&(session)->abstract)
|
|
|
|
|
|
|
|
#define LIBSSH2_MACERROR(session, data, datalen) \
|
|
|
|
session->macerror((session), (data), (datalen), &(session)->abstract)
|
|
|
|
#define LIBSSH2_X11_OPEN(channel, shost, sport) \
|
|
|
|
channel->session->x11(((channel)->session), (channel), \
|
|
|
|
(shost), (sport), (&(channel)->session->abstract))
|
|
|
|
|
|
|
|
#define LIBSSH2_CHANNEL_CLOSE(session, channel) \
|
|
|
|
channel->close_cb((session), &(session)->abstract, \
|
|
|
|
(channel), &(channel)->abstract)
|
|
|
|
|
|
|
|
#define LIBSSH2_SEND_FD(session, fd, buffer, length, flags) \
|
|
|
|
session->send(fd, buffer, length, flags, &session->abstract)
|
|
|
|
#define LIBSSH2_RECV_FD(session, fd, buffer, length, flags) \
|
|
|
|
session->recv(fd, buffer, length, flags, &session->abstract)
|
|
|
|
|
|
|
|
#define LIBSSH2_SEND(session, buffer, length, flags) \
|
|
|
|
LIBSSH2_SEND_FD(session, session->socket_fd, buffer, length, flags)
|
|
|
|
#define LIBSSH2_RECV(session, buffer, length, flags) \
|
|
|
|
LIBSSH2_RECV_FD(session, session->socket_fd, buffer, length, flags)
|
2011-08-11 22:26:56 +02:00
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
typedef struct _LIBSSH2_KEX_METHOD LIBSSH2_KEX_METHOD;
|
|
|
|
typedef struct _LIBSSH2_HOSTKEY_METHOD LIBSSH2_HOSTKEY_METHOD;
|
|
|
|
typedef struct _LIBSSH2_CRYPT_METHOD LIBSSH2_CRYPT_METHOD;
|
|
|
|
typedef struct _LIBSSH2_COMP_METHOD LIBSSH2_COMP_METHOD;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
typedef struct _LIBSSH2_PACKET LIBSSH2_PACKET;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2007-06-06 12:34:06 +00:00
|
|
|
libssh2_NB_state_idle = 0,
|
|
|
|
libssh2_NB_state_allocated,
|
|
|
|
libssh2_NB_state_created,
|
|
|
|
libssh2_NB_state_sent,
|
|
|
|
libssh2_NB_state_sent1,
|
|
|
|
libssh2_NB_state_sent2,
|
|
|
|
libssh2_NB_state_sent3,
|
|
|
|
libssh2_NB_state_sent4,
|
|
|
|
libssh2_NB_state_sent5,
|
|
|
|
libssh2_NB_state_sent6,
|
|
|
|
libssh2_NB_state_sent7,
|
|
|
|
libssh2_NB_state_jump1,
|
|
|
|
libssh2_NB_state_jump2,
|
2010-01-28 14:30:25 +01:00
|
|
|
libssh2_NB_state_jump3,
|
2010-01-28 15:03:24 +01:00
|
|
|
libssh2_NB_state_jump4,
|
|
|
|
libssh2_NB_state_jump5
|
2007-06-06 12:34:06 +00:00
|
|
|
} libssh2_nonblocking_states;
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
typedef struct packet_require_state_t
|
|
|
|
{
|
|
|
|
libssh2_nonblocking_states state;
|
|
|
|
time_t start;
|
2007-06-06 12:34:06 +00:00
|
|
|
} packet_require_state_t;
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
typedef struct packet_requirev_state_t
|
|
|
|
{
|
|
|
|
time_t start;
|
2007-06-06 12:34:06 +00:00
|
|
|
} packet_requirev_state_t;
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
typedef struct kmdhgGPsha1kex_state_t
|
|
|
|
{
|
|
|
|
libssh2_nonblocking_states state;
|
|
|
|
unsigned char *e_packet;
|
|
|
|
unsigned char *s_packet;
|
|
|
|
unsigned char *tmp;
|
|
|
|
unsigned char h_sig_comp[SHA_DIGEST_LENGTH];
|
|
|
|
unsigned char c;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t e_packet_len;
|
|
|
|
size_t s_packet_len;
|
|
|
|
size_t tmp_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
_libssh2_bn_ctx *ctx;
|
|
|
|
_libssh2_bn *x;
|
|
|
|
_libssh2_bn *e;
|
|
|
|
_libssh2_bn *f;
|
|
|
|
_libssh2_bn *k;
|
|
|
|
unsigned char *s;
|
|
|
|
unsigned char *f_value;
|
|
|
|
unsigned char *k_value;
|
|
|
|
unsigned char *h_sig;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t f_value_len;
|
|
|
|
size_t k_value_len;
|
|
|
|
size_t h_sig_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_sha1_ctx exchange_hash;
|
|
|
|
packet_require_state_t req_state;
|
|
|
|
libssh2_nonblocking_states burn_state;
|
2007-06-06 12:34:06 +00:00
|
|
|
} kmdhgGPsha1kex_state_t;
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
typedef struct key_exchange_state_low_t
|
|
|
|
{
|
|
|
|
libssh2_nonblocking_states state;
|
|
|
|
packet_require_state_t req_state;
|
|
|
|
kmdhgGPsha1kex_state_t exchange_state;
|
|
|
|
_libssh2_bn *p; /* SSH2 defined value (p_value) */
|
|
|
|
_libssh2_bn *g; /* SSH2 defined value (2) */
|
|
|
|
unsigned char request[13];
|
|
|
|
unsigned char *data;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t request_len;
|
|
|
|
size_t data_len;
|
2007-06-06 12:34:06 +00:00
|
|
|
} key_exchange_state_low_t;
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
typedef struct key_exchange_state_t
|
|
|
|
{
|
|
|
|
libssh2_nonblocking_states state;
|
|
|
|
packet_require_state_t req_state;
|
|
|
|
key_exchange_state_low_t key_state_low;
|
|
|
|
unsigned char *data;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t data_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char *oldlocal;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t oldlocal_len;
|
2007-06-06 12:34:06 +00:00
|
|
|
} key_exchange_state_t;
|
|
|
|
|
|
|
|
#define FwdNotReq "Forward not requested"
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
typedef struct packet_queue_listener_state_t
|
|
|
|
{
|
|
|
|
libssh2_nonblocking_states state;
|
|
|
|
unsigned char packet[17 + (sizeof(FwdNotReq) - 1)];
|
|
|
|
unsigned char *host;
|
|
|
|
unsigned char *shost;
|
|
|
|
uint32_t sender_channel;
|
|
|
|
uint32_t initial_window_size;
|
|
|
|
uint32_t packet_size;
|
|
|
|
uint32_t port;
|
|
|
|
uint32_t sport;
|
|
|
|
uint32_t host_len;
|
|
|
|
uint32_t shost_len;
|
2009-08-20 00:56:05 +02:00
|
|
|
LIBSSH2_CHANNEL *channel;
|
2007-06-06 12:34:06 +00:00
|
|
|
} packet_queue_listener_state_t;
|
|
|
|
|
|
|
|
#define X11FwdUnAvil "X11 Forward Unavailable"
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
typedef struct packet_x11_open_state_t
|
|
|
|
{
|
|
|
|
libssh2_nonblocking_states state;
|
|
|
|
unsigned char packet[17 + (sizeof(X11FwdUnAvil) - 1)];
|
|
|
|
unsigned char *shost;
|
|
|
|
uint32_t sender_channel;
|
|
|
|
uint32_t initial_window_size;
|
|
|
|
uint32_t packet_size;
|
|
|
|
uint32_t sport;
|
|
|
|
uint32_t shost_len;
|
2009-08-20 00:56:05 +02:00
|
|
|
LIBSSH2_CHANNEL *channel;
|
2007-06-06 12:34:06 +00:00
|
|
|
} packet_x11_open_state_t;
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
struct _LIBSSH2_PACKET
|
|
|
|
{
|
2009-08-20 00:56:05 +02:00
|
|
|
struct list_node node; /* linked list header */
|
|
|
|
|
2010-11-10 14:56:14 +01:00
|
|
|
/* the raw unencrypted payload */
|
2007-05-28 17:56:08 +00:00
|
|
|
unsigned char *data;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t data_len;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* Where to start reading data from,
|
|
|
|
* used for channel data that's been partially consumed */
|
2010-12-15 09:52:18 +01:00
|
|
|
size_t data_head;
|
2004-12-07 21:17:20 +00:00
|
|
|
};
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
typedef struct _libssh2_channel_data
|
|
|
|
{
|
2007-05-28 17:56:08 +00:00
|
|
|
/* Identifier */
|
2010-04-17 13:34:44 +02:00
|
|
|
uint32_t id;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* Limits and restrictions */
|
2010-12-15 09:52:18 +01:00
|
|
|
uint32_t window_size_initial, window_size, packet_size;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* Set to 1 when CHANNEL_CLOSE / CHANNEL_EOF sent/received */
|
|
|
|
char close, eof, extended_data_ignore_mode;
|
2004-12-07 21:17:20 +00:00
|
|
|
} libssh2_channel_data;
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
struct _LIBSSH2_CHANNEL
|
|
|
|
{
|
2009-08-20 00:56:05 +02:00
|
|
|
struct list_node node;
|
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
unsigned char *channel_type;
|
|
|
|
unsigned channel_type_len;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* channel's program exit status */
|
|
|
|
int exit_status;
|
2005-06-23 05:55:01 +00:00
|
|
|
|
2010-10-13 15:31:06 +02:00
|
|
|
/* channel's program exit signal (without the SIG prefix) */
|
|
|
|
char *exit_signal;
|
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
libssh2_channel_data local, remote;
|
2007-06-06 12:34:06 +00:00
|
|
|
/* Amount of bytes to be refunded to receive window (but not yet sent) */
|
2010-12-29 23:36:45 +01:00
|
|
|
uint32_t adjust_queue;
|
2013-10-12 02:51:46 +02:00
|
|
|
/* Data immediately available for reading */
|
|
|
|
uint32_t read_avail;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
LIBSSH2_SESSION *session;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
void *abstract;
|
2007-08-06 20:48:04 +00:00
|
|
|
LIBSSH2_CHANNEL_CLOSE_FUNC((*close_cb));
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_setenv_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states setenv_state;
|
|
|
|
unsigned char *setenv_packet;
|
2010-04-17 13:34:44 +02:00
|
|
|
size_t setenv_packet_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char setenv_local_channel[4];
|
|
|
|
packet_requirev_state_t setenv_packet_requirev_state;
|
|
|
|
|
2010-10-23 00:11:59 +02:00
|
|
|
/* State variables used in libssh2_channel_request_pty_ex()
|
|
|
|
libssh2_channel_request_pty_size_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states reqPTY_state;
|
2010-10-23 00:11:59 +02:00
|
|
|
unsigned char reqPTY_packet[41 + 256];
|
2010-04-17 13:34:44 +02:00
|
|
|
size_t reqPTY_packet_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char reqPTY_local_channel[4];
|
|
|
|
packet_requirev_state_t reqPTY_packet_requirev_state;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_x11_req_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states reqX11_state;
|
|
|
|
unsigned char *reqX11_packet;
|
2010-04-17 13:34:44 +02:00
|
|
|
size_t reqX11_packet_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char reqX11_local_channel[4];
|
|
|
|
packet_requirev_state_t reqX11_packet_requirev_state;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_process_startup() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states process_state;
|
|
|
|
unsigned char *process_packet;
|
2010-04-17 13:34:44 +02:00
|
|
|
size_t process_packet_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char process_local_channel[4];
|
|
|
|
packet_requirev_state_t process_packet_requirev_state;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_flush_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states flush_state;
|
2010-04-17 13:34:44 +02:00
|
|
|
size_t flush_refund_bytes;
|
|
|
|
size_t flush_flush_bytes;
|
2007-08-06 20:48:04 +00:00
|
|
|
|
2007-06-17 23:35:07 +00:00
|
|
|
/* State variables used in libssh2_channel_receive_window_adjust() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states adjust_state;
|
|
|
|
unsigned char adjust_adjust[9]; /* packet_type(1) + channel(4) + adjustment(4) */
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_read_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states read_state;
|
2009-03-15 22:29:23 +00:00
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
uint32_t read_local_id;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_write_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states write_state;
|
2010-10-23 00:11:59 +02:00
|
|
|
unsigned char write_packet[13];
|
2010-04-17 13:34:44 +02:00
|
|
|
size_t write_packet_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
size_t write_bufwrite;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_close() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states close_state;
|
|
|
|
unsigned char close_packet[5];
|
2007-06-06 12:34:06 +00:00
|
|
|
|
|
|
|
/* State variables used in libssh2_channel_wait_closedeof() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states wait_eof_state;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_wait_closed() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states wait_closed_state;
|
|
|
|
|
2007-06-12 18:27:37 +00:00
|
|
|
/* State variables used in libssh2_channel_free() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states free_state;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_handle_extended_data2() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states extData2_state;
|
2010-10-23 01:16:12 +02:00
|
|
|
|
2004-12-07 21:17:20 +00:00
|
|
|
};
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
struct _LIBSSH2_LISTENER
|
|
|
|
{
|
2009-08-19 14:33:13 +02:00
|
|
|
struct list_node node; /* linked list header */
|
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
LIBSSH2_SESSION *session;
|
2004-12-29 19:26:28 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
char *host;
|
|
|
|
int port;
|
2004-12-29 19:26:28 +00:00
|
|
|
|
2009-08-20 00:56:05 +02:00
|
|
|
/* a list of CHANNELs for this listener */
|
|
|
|
struct list_head queue;
|
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
int queue_size;
|
|
|
|
int queue_maxsize;
|
2004-12-29 19:26:28 +00:00
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_forward_cancel() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states chanFwdCncl_state;
|
|
|
|
unsigned char *chanFwdCncl_data;
|
|
|
|
size_t chanFwdCncl_data_len;
|
2004-12-29 19:26:28 +00:00
|
|
|
};
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
typedef struct _libssh2_endpoint_data
|
|
|
|
{
|
2007-05-28 17:56:08 +00:00
|
|
|
unsigned char *banner;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
unsigned char *kexinit;
|
2010-04-17 13:34:44 +02:00
|
|
|
size_t kexinit_len;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
const LIBSSH2_CRYPT_METHOD *crypt;
|
|
|
|
void *crypt_abstract;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2010-12-15 09:52:18 +01:00
|
|
|
const struct _LIBSSH2_MAC_METHOD *mac;
|
|
|
|
uint32_t seqno;
|
2007-05-28 17:56:08 +00:00
|
|
|
void *mac_abstract;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
const LIBSSH2_COMP_METHOD *comp;
|
|
|
|
void *comp_abstract;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* Method Preferences -- NULL yields "load order" */
|
|
|
|
char *crypt_prefs;
|
|
|
|
char *mac_prefs;
|
|
|
|
char *comp_prefs;
|
|
|
|
char *lang_prefs;
|
2004-12-07 21:17:20 +00:00
|
|
|
} libssh2_endpoint_data;
|
|
|
|
|
2009-03-15 22:29:23 +00:00
|
|
|
#define PACKETBUFSIZE (1024*16)
|
2007-02-02 16:21:20 +00:00
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
struct transportpacket
|
|
|
|
{
|
2007-05-28 17:56:08 +00:00
|
|
|
/* ------------- for incoming data --------------- */
|
|
|
|
unsigned char buf[PACKETBUFSIZE];
|
2010-04-20 22:49:32 +02:00
|
|
|
unsigned char init[5]; /* first 5 bytes of the incoming data stream,
|
|
|
|
still encrypted */
|
2010-12-29 23:36:45 +01:00
|
|
|
size_t writeidx; /* at what array index we do the next write into
|
2010-04-20 22:49:32 +02:00
|
|
|
the buffer */
|
2010-12-29 23:36:45 +01:00
|
|
|
size_t readidx; /* at what array index we do the next read from
|
2010-04-20 22:49:32 +02:00
|
|
|
the buffer */
|
|
|
|
uint32_t packet_length; /* the most recent packet_length as read from the
|
|
|
|
network data */
|
|
|
|
uint8_t padding_length; /* the most recent padding_length as read from the
|
|
|
|
network data */
|
2010-12-29 23:36:45 +01:00
|
|
|
size_t data_num; /* How much of the total package that has been read
|
2010-04-20 22:49:32 +02:00
|
|
|
so far. */
|
2010-12-29 23:36:45 +01:00
|
|
|
size_t total_num; /* How much a total package is supposed to be, in
|
2010-04-20 22:49:32 +02:00
|
|
|
number of bytes. A full package is
|
|
|
|
packet_length + padding_length + 4 +
|
|
|
|
mac_length. */
|
|
|
|
unsigned char *payload; /* this is a pointer to a LIBSSH2_ALLOC()
|
|
|
|
area to which we write decrypted data */
|
|
|
|
unsigned char *wptr; /* write pointer into the payload to where we
|
|
|
|
are currently writing decrypted data */
|
2007-05-28 17:56:08 +00:00
|
|
|
|
|
|
|
/* ------------- for outgoing data --------------- */
|
2010-10-21 21:00:28 +02:00
|
|
|
unsigned char outbuf[MAX_SSH_PACKET_LEN]; /* area for the outgoing data */
|
|
|
|
|
2010-04-20 22:49:32 +02:00
|
|
|
int ototal_num; /* size of outbuf in number of bytes */
|
2010-10-23 00:11:59 +02:00
|
|
|
const unsigned char *odata; /* original pointer to the data */
|
2010-04-20 22:49:32 +02:00
|
|
|
size_t olen; /* original size of the data we stored in
|
|
|
|
outbuf */
|
|
|
|
size_t osent; /* number of bytes already sent */
|
2007-02-02 16:21:20 +00:00
|
|
|
};
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
struct _LIBSSH2_PUBLICKEY
|
|
|
|
{
|
2007-06-06 12:34:06 +00:00
|
|
|
LIBSSH2_CHANNEL *channel;
|
2010-12-15 09:52:18 +01:00
|
|
|
uint32_t version;
|
2007-08-06 20:48:04 +00:00
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_publickey_packet_receive() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states receive_state;
|
|
|
|
unsigned char *receive_packet;
|
2010-04-17 13:34:44 +02:00
|
|
|
size_t receive_packet_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_publickey_add_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states add_state;
|
|
|
|
unsigned char *add_packet;
|
|
|
|
unsigned char *add_s;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_publickey_remove_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states remove_state;
|
|
|
|
unsigned char *remove_packet;
|
|
|
|
unsigned char *remove_s;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_publickey_list_fetch() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states listFetch_state;
|
|
|
|
unsigned char *listFetch_s;
|
|
|
|
unsigned char listFetch_buffer[12];
|
|
|
|
unsigned char *listFetch_data;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t listFetch_data_len;
|
2007-06-06 12:34:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define LIBSSH2_SCP_RESPONSE_BUFLEN 256
|
|
|
|
|
2010-10-21 10:39:06 +02:00
|
|
|
struct flags {
|
|
|
|
int sigpipe; /* LIBSSH2_FLAG_SIGPIPE */
|
|
|
|
int compress; /* LIBSSH2_FLAG_COMPRESS */
|
|
|
|
};
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
struct _LIBSSH2_SESSION
|
|
|
|
{
|
2007-05-28 17:56:08 +00:00
|
|
|
/* Memory management callbacks */
|
|
|
|
void *abstract;
|
2007-08-06 20:48:04 +00:00
|
|
|
LIBSSH2_ALLOC_FUNC((*alloc));
|
|
|
|
LIBSSH2_REALLOC_FUNC((*realloc));
|
|
|
|
LIBSSH2_FREE_FUNC((*free));
|
2007-05-28 17:56:08 +00:00
|
|
|
|
|
|
|
/* Other callbacks */
|
2007-08-06 20:48:04 +00:00
|
|
|
LIBSSH2_IGNORE_FUNC((*ssh_msg_ignore));
|
|
|
|
LIBSSH2_DEBUG_FUNC((*ssh_msg_debug));
|
|
|
|
LIBSSH2_DISCONNECT_FUNC((*ssh_msg_disconnect));
|
|
|
|
LIBSSH2_MACERROR_FUNC((*macerror));
|
|
|
|
LIBSSH2_X11_OPEN_FUNC((*x11));
|
2011-08-11 22:26:56 +02:00
|
|
|
LIBSSH2_SEND_FUNC((*send));
|
|
|
|
LIBSSH2_RECV_FUNC((*recv));
|
2007-05-28 17:56:08 +00:00
|
|
|
|
|
|
|
/* Method preferences -- NULL yields "load order" */
|
|
|
|
char *kex_prefs;
|
|
|
|
char *hostkey_prefs;
|
|
|
|
|
|
|
|
int state;
|
2010-10-21 10:39:06 +02:00
|
|
|
|
|
|
|
/* Flag options */
|
|
|
|
struct flags flag;
|
2007-05-28 17:56:08 +00:00
|
|
|
|
|
|
|
/* Agreed Key Exchange Method */
|
|
|
|
const LIBSSH2_KEX_METHOD *kex;
|
2014-03-20 14:45:46 -04:00
|
|
|
unsigned int burn_optimistic_kexinit:1;
|
2007-05-28 17:56:08 +00:00
|
|
|
|
|
|
|
unsigned char *session_id;
|
2010-12-15 09:52:18 +01:00
|
|
|
uint32_t session_id_len;
|
2007-05-28 17:56:08 +00:00
|
|
|
|
2009-03-26 15:41:14 +00:00
|
|
|
/* this is set to TRUE if a blocking API behavior is requested */
|
|
|
|
int api_block_mode;
|
|
|
|
|
2011-05-03 11:20:24 +12:00
|
|
|
/* Timeout used when blocking API behavior is active */
|
|
|
|
long api_timeout;
|
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* Server's public key */
|
|
|
|
const LIBSSH2_HOSTKEY_METHOD *hostkey;
|
|
|
|
void *server_hostkey_abstract;
|
|
|
|
|
|
|
|
/* Either set with libssh2_session_hostkey() (for server mode)
|
|
|
|
* Or read from server in (eg) KEXDH_INIT (for client mode)
|
|
|
|
*/
|
|
|
|
unsigned char *server_hostkey;
|
2010-12-15 09:52:18 +01:00
|
|
|
uint32_t server_hostkey_len;
|
2007-01-17 14:41:06 +00:00
|
|
|
#if LIBSSH2_MD5
|
2007-05-28 17:56:08 +00:00
|
|
|
unsigned char server_hostkey_md5[MD5_DIGEST_LENGTH];
|
2012-09-10 15:32:40 +02:00
|
|
|
int server_hostkey_md5_valid;
|
2007-08-06 20:48:04 +00:00
|
|
|
#endif /* ! LIBSSH2_MD5 */
|
2007-05-28 17:56:08 +00:00
|
|
|
unsigned char server_hostkey_sha1[SHA_DIGEST_LENGTH];
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* (remote as source of data -- packet_read ) */
|
|
|
|
libssh2_endpoint_data remote;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* (local as source of data -- packet_write ) */
|
|
|
|
libssh2_endpoint_data local;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2009-08-20 00:56:05 +02:00
|
|
|
/* Inbound Data linked list -- Sometimes the packet that comes in isn't the
|
2009-03-17 13:48:35 +00:00
|
|
|
packet we're ready for */
|
2009-08-20 00:56:05 +02:00
|
|
|
struct list_head packets;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* Active connection channels */
|
2009-08-20 00:56:05 +02:00
|
|
|
struct list_head channels;
|
|
|
|
|
2010-12-15 09:52:18 +01:00
|
|
|
uint32_t next_channel;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2009-08-19 14:33:13 +02:00
|
|
|
struct list_head listeners; /* list of LIBSSH2_LISTENER structs */
|
2004-12-29 19:26:28 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* Actual I/O socket */
|
2009-08-24 14:07:05 +02:00
|
|
|
libssh2_socket_t socket_fd;
|
2007-05-28 17:56:08 +00:00
|
|
|
int socket_state;
|
2008-11-24 13:31:00 +00:00
|
|
|
int socket_block_directions;
|
2009-03-26 15:41:14 +00:00
|
|
|
int socket_prev_blockstate; /* stores the state of the socket blockiness
|
|
|
|
when libssh2_session_startup() is called */
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* Error tracking */
|
2010-03-01 13:16:19 +01:00
|
|
|
const char *err_msg;
|
2007-05-28 17:56:08 +00:00
|
|
|
int err_code;
|
2007-02-02 16:21:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* struct members for packet-level reading */
|
|
|
|
struct transportpacket packet;
|
2007-02-02 23:23:36 +00:00
|
|
|
#ifdef LIBSSH2DEBUG
|
2007-08-06 20:48:04 +00:00
|
|
|
int showmask; /* what debug/trace messages to display */
|
2010-01-15 22:58:44 +01:00
|
|
|
libssh2_trace_handler_func tracehandler; /* callback to display trace messages */
|
2010-01-20 12:02:13 -05:00
|
|
|
void* tracehandler_context; /* context for the trace handler */
|
2007-02-02 23:23:36 +00:00
|
|
|
#endif
|
2007-06-06 12:34:06 +00:00
|
|
|
|
|
|
|
/* State variables used in libssh2_banner_send() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states banner_TxRx_state;
|
|
|
|
char banner_TxRx_banner[256];
|
|
|
|
ssize_t banner_TxRx_total_send;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_kexinit() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states kexinit_state;
|
|
|
|
unsigned char *kexinit_data;
|
|
|
|
size_t kexinit_data_len;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_session_startup() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states startup_state;
|
|
|
|
unsigned char *startup_data;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t startup_data_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char startup_service[sizeof("ssh-userauth") + 5 - 1];
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t startup_service_length;
|
2007-08-06 20:48:04 +00:00
|
|
|
packet_require_state_t startup_req_state;
|
|
|
|
key_exchange_state_t startup_key_state;
|
|
|
|
|
2007-06-12 18:27:37 +00:00
|
|
|
/* State variables used in libssh2_session_free() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states free_state;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_session_disconnect_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states disconnect_state;
|
2010-10-23 00:11:59 +02:00
|
|
|
unsigned char disconnect_data[256 + 13];
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t disconnect_data_len;
|
2007-06-06 12:34:06 +00:00
|
|
|
|
|
|
|
/* State variables used in libssh2_packet_read() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states readPack_state;
|
|
|
|
int readPack_encrypted;
|
2007-06-06 12:34:06 +00:00
|
|
|
|
2007-06-10 13:59:05 +00:00
|
|
|
/* State variables used in libssh2_userauth_list() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states userauth_list_state;
|
|
|
|
unsigned char *userauth_list_data;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t userauth_list_data_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
packet_requirev_state_t userauth_list_packet_requirev_state;
|
|
|
|
|
2007-06-10 13:59:05 +00:00
|
|
|
/* State variables used in libssh2_userauth_password_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states userauth_pswd_state;
|
|
|
|
unsigned char *userauth_pswd_data;
|
|
|
|
unsigned char userauth_pswd_data0;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t userauth_pswd_data_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
char *userauth_pswd_newpw;
|
|
|
|
int userauth_pswd_newpw_len;
|
|
|
|
packet_requirev_state_t userauth_pswd_packet_requirev_state;
|
|
|
|
|
2007-06-10 13:59:05 +00:00
|
|
|
/* State variables used in libssh2_userauth_hostbased_fromfile_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states userauth_host_state;
|
|
|
|
unsigned char *userauth_host_data;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t userauth_host_data_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char *userauth_host_packet;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t userauth_host_packet_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char *userauth_host_method;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t userauth_host_method_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char *userauth_host_s;
|
|
|
|
packet_requirev_state_t userauth_host_packet_requirev_state;
|
|
|
|
|
2007-06-10 13:59:05 +00:00
|
|
|
/* State variables used in libssh2_userauth_publickey_fromfile_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states userauth_pblc_state;
|
|
|
|
unsigned char *userauth_pblc_data;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t userauth_pblc_data_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char *userauth_pblc_packet;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t userauth_pblc_packet_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char *userauth_pblc_method;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t userauth_pblc_method_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char *userauth_pblc_s;
|
|
|
|
unsigned char *userauth_pblc_b;
|
|
|
|
packet_requirev_state_t userauth_pblc_packet_requirev_state;
|
|
|
|
|
2009-08-20 00:56:05 +02:00
|
|
|
/* State variables used in libssh2_userauth_keyboard_interactive_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states userauth_kybd_state;
|
|
|
|
unsigned char *userauth_kybd_data;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t userauth_kybd_data_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char *userauth_kybd_packet;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t userauth_kybd_packet_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned int userauth_kybd_auth_name_len;
|
|
|
|
char *userauth_kybd_auth_name;
|
|
|
|
unsigned userauth_kybd_auth_instruction_len;
|
|
|
|
char *userauth_kybd_auth_instruction;
|
|
|
|
unsigned int userauth_kybd_num_prompts;
|
|
|
|
int userauth_kybd_auth_failure;
|
|
|
|
LIBSSH2_USERAUTH_KBDINT_PROMPT *userauth_kybd_prompts;
|
|
|
|
LIBSSH2_USERAUTH_KBDINT_RESPONSE *userauth_kybd_responses;
|
|
|
|
packet_requirev_state_t userauth_kybd_packet_requirev_state;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_open_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states open_state;
|
|
|
|
packet_requirev_state_t open_packet_requirev_state;
|
|
|
|
LIBSSH2_CHANNEL *open_channel;
|
|
|
|
unsigned char *open_packet;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t open_packet_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char *open_data;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t open_data_len;
|
|
|
|
uint32_t open_local_channel;
|
2007-08-06 20:48:04 +00:00
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_direct_tcpip_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states direct_state;
|
|
|
|
unsigned char *direct_message;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t direct_host_len;
|
|
|
|
size_t direct_shost_len;
|
|
|
|
size_t direct_message_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_channel_forward_listen_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states fwdLstn_state;
|
|
|
|
unsigned char *fwdLstn_packet;
|
2010-12-15 09:52:18 +01:00
|
|
|
uint32_t fwdLstn_host_len;
|
|
|
|
uint32_t fwdLstn_packet_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
packet_requirev_state_t fwdLstn_packet_requirev_state;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_publickey_init() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states pkeyInit_state;
|
|
|
|
LIBSSH2_PUBLICKEY *pkeyInit_pkey;
|
|
|
|
LIBSSH2_CHANNEL *pkeyInit_channel;
|
|
|
|
unsigned char *pkeyInit_data;
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t pkeyInit_data_len;
|
2010-04-24 20:21:22 +02:00
|
|
|
/* 19 = packet_len(4) + version_len(4) + "version"(7) + version_num(4) */
|
|
|
|
unsigned char pkeyInit_buffer[19];
|
|
|
|
size_t pkeyInit_buffer_sent; /* how much of buffer that has been sent */
|
2007-08-06 20:48:04 +00:00
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_packet_add() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states packAdd_state;
|
2010-11-10 14:56:14 +01:00
|
|
|
LIBSSH2_CHANNEL *packAdd_channelp; /* keeper of the channel during EAGAIN
|
|
|
|
states */
|
2007-08-06 20:48:04 +00:00
|
|
|
packet_queue_listener_state_t packAdd_Qlstn_state;
|
|
|
|
packet_x11_open_state_t packAdd_x11open_state;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in fullpacket() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states fullpacket_state;
|
|
|
|
int fullpacket_macstate;
|
2010-12-29 23:36:45 +01:00
|
|
|
size_t fullpacket_payload_len;
|
2009-08-24 23:57:15 +02:00
|
|
|
int fullpacket_packet_type;
|
2007-08-06 20:48:04 +00:00
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_sftp_init() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states sftpInit_state;
|
|
|
|
LIBSSH2_SFTP *sftpInit_sftp;
|
|
|
|
LIBSSH2_CHANNEL *sftpInit_channel;
|
2009-03-17 13:48:35 +00:00
|
|
|
unsigned char sftpInit_buffer[9]; /* sftp_header(5){excludes request_id}
|
|
|
|
+ version_id(4) */
|
2010-04-01 13:20:55 +02:00
|
|
|
int sftpInit_sent; /* number of bytes from the buffer that have been
|
|
|
|
sent */
|
2007-08-06 20:48:04 +00:00
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_scp_recv() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states scpRecv_state;
|
|
|
|
unsigned char *scpRecv_command;
|
2010-12-15 09:52:18 +01:00
|
|
|
size_t scpRecv_command_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char scpRecv_response[LIBSSH2_SCP_RESPONSE_BUFLEN];
|
2010-12-15 09:52:18 +01:00
|
|
|
size_t scpRecv_response_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
long scpRecv_mode;
|
2009-06-04 00:36:34 +02:00
|
|
|
#if defined(HAVE_LONGLONG) && defined(HAVE_STRTOLL)
|
2008-09-29 14:04:01 +00:00
|
|
|
/* we have the type and we can parse such numbers */
|
|
|
|
long long scpRecv_size;
|
|
|
|
#define scpsize_strtol strtoll
|
|
|
|
#else
|
2007-08-06 20:48:04 +00:00
|
|
|
long scpRecv_size;
|
2008-09-29 14:04:01 +00:00
|
|
|
#define scpsize_strtol strtol
|
|
|
|
#endif
|
2007-08-06 20:48:04 +00:00
|
|
|
long scpRecv_mtime;
|
|
|
|
long scpRecv_atime;
|
|
|
|
LIBSSH2_CHANNEL *scpRecv_channel;
|
|
|
|
|
2007-06-06 12:34:06 +00:00
|
|
|
/* State variables used in libssh2_scp_send_ex() */
|
2007-08-06 20:48:04 +00:00
|
|
|
libssh2_nonblocking_states scpSend_state;
|
|
|
|
unsigned char *scpSend_command;
|
2010-12-15 09:52:18 +01:00
|
|
|
size_t scpSend_command_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
unsigned char scpSend_response[LIBSSH2_SCP_RESPONSE_BUFLEN];
|
2010-12-15 09:52:18 +01:00
|
|
|
size_t scpSend_response_len;
|
2007-08-06 20:48:04 +00:00
|
|
|
LIBSSH2_CHANNEL *scpSend_channel;
|
2010-02-25 15:58:52 +01:00
|
|
|
|
|
|
|
/* Keepalive variables used by keepalive.c. */
|
|
|
|
int keepalive_interval;
|
|
|
|
int keepalive_want_reply;
|
|
|
|
time_t keepalive_last_sent;
|
2004-12-07 21:17:20 +00:00
|
|
|
};
|
|
|
|
|
2005-02-03 05:41:35 +00:00
|
|
|
/* session.state bits */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define LIBSSH2_STATE_EXCHANGING_KEYS 0x00000001
|
|
|
|
#define LIBSSH2_STATE_NEWKEYS 0x00000002
|
|
|
|
#define LIBSSH2_STATE_AUTHENTICATED 0x00000004
|
2008-07-03 16:26:55 +00:00
|
|
|
#define LIBSSH2_STATE_KEX_ACTIVE 0x00000008
|
2005-02-03 05:41:35 +00:00
|
|
|
|
2005-02-03 05:57:43 +00:00
|
|
|
/* session.flag helpers */
|
|
|
|
#ifdef MSG_NOSIGNAL
|
2011-08-25 22:41:17 +02:00
|
|
|
#define LIBSSH2_SOCKET_SEND_FLAGS(session) \
|
|
|
|
(((session)->flag.sigpipe) ? 0 : MSG_NOSIGNAL)
|
|
|
|
#define LIBSSH2_SOCKET_RECV_FLAGS(session) \
|
|
|
|
(((session)->flag.sigpipe) ? 0 : MSG_NOSIGNAL)
|
2005-02-03 05:57:43 +00:00
|
|
|
#else
|
|
|
|
/* If MSG_NOSIGNAL isn't defined we're SOL on blocking SIGPIPE */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define LIBSSH2_SOCKET_SEND_FLAGS(session) 0
|
|
|
|
#define LIBSSH2_SOCKET_RECV_FLAGS(session) 0
|
2005-02-03 05:57:43 +00:00
|
|
|
#endif
|
|
|
|
|
2009-05-07 13:09:48 +00:00
|
|
|
/* --------- */
|
|
|
|
|
|
|
|
/* libssh2 extensible ssh api, ultimately I'd like to allow loading additional
|
|
|
|
methods via .so/.dll */
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
struct _LIBSSH2_KEX_METHOD
|
|
|
|
{
|
2007-05-28 17:56:08 +00:00
|
|
|
const char *name;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* Key exchange, populates session->* and returns 0 on success, non-0 on error */
|
2007-08-06 20:48:04 +00:00
|
|
|
int (*exchange_keys) (LIBSSH2_SESSION * session,
|
|
|
|
key_exchange_state_low_t * key_state);
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
long flags;
|
2004-12-07 21:17:20 +00:00
|
|
|
};
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
struct _LIBSSH2_HOSTKEY_METHOD
|
|
|
|
{
|
2007-05-28 17:56:08 +00:00
|
|
|
const char *name;
|
|
|
|
unsigned long hash_len;
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
int (*init) (LIBSSH2_SESSION * session, const unsigned char *hostkey_data,
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t hostkey_data_len, void **abstract);
|
2007-08-06 20:48:04 +00:00
|
|
|
int (*initPEM) (LIBSSH2_SESSION * session, const char *privkeyfile,
|
|
|
|
unsigned const char *passphrase, void **abstract);
|
|
|
|
int (*sig_verify) (LIBSSH2_SESSION * session, const unsigned char *sig,
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t sig_len, const unsigned char *m,
|
|
|
|
size_t m_len, void **abstract);
|
2007-08-06 20:48:04 +00:00
|
|
|
int (*signv) (LIBSSH2_SESSION * session, unsigned char **signature,
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t *signature_len, int veccount,
|
2007-08-06 20:48:04 +00:00
|
|
|
const struct iovec datavec[], void **abstract);
|
|
|
|
int (*encrypt) (LIBSSH2_SESSION * session, unsigned char **dst,
|
2010-04-17 13:18:15 +02:00
|
|
|
size_t *dst_len, const unsigned char *src,
|
|
|
|
size_t src_len, void **abstract);
|
2007-08-06 20:48:04 +00:00
|
|
|
int (*dtor) (LIBSSH2_SESSION * session, void **abstract);
|
2004-12-07 21:17:20 +00:00
|
|
|
};
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
struct _LIBSSH2_CRYPT_METHOD
|
|
|
|
{
|
2007-05-28 17:56:08 +00:00
|
|
|
const char *name;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
int blocksize;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
/* iv and key sizes (-1 for variable length) */
|
|
|
|
int iv_len;
|
|
|
|
int secret_len;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
long flags;
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
int (*init) (LIBSSH2_SESSION * session,
|
|
|
|
const LIBSSH2_CRYPT_METHOD * method, unsigned char *iv,
|
|
|
|
int *free_iv, unsigned char *secret, int *free_secret,
|
|
|
|
int encrypt, void **abstract);
|
|
|
|
int (*crypt) (LIBSSH2_SESSION * session, unsigned char *block,
|
2012-09-11 09:33:34 +02:00
|
|
|
size_t blocksize, void **abstract);
|
2007-08-06 20:48:04 +00:00
|
|
|
int (*dtor) (LIBSSH2_SESSION * session, void **abstract);
|
2007-01-18 11:21:12 +00:00
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
_libssh2_cipher_type(algo);
|
2004-12-07 21:17:20 +00:00
|
|
|
};
|
|
|
|
|
2007-08-06 20:48:04 +00:00
|
|
|
struct _LIBSSH2_COMP_METHOD
|
|
|
|
{
|
2007-05-28 17:56:08 +00:00
|
|
|
const char *name;
|
2010-10-08 16:26:50 +02:00
|
|
|
int compress; /* 1 if it does compress, 0 if it doesn't */
|
2012-08-19 13:47:50 +02:00
|
|
|
int use_in_auth; /* 1 if compression should be used in userauth */
|
2010-10-21 21:00:28 +02:00
|
|
|
int (*init) (LIBSSH2_SESSION *session, int compress, void **abstract);
|
|
|
|
int (*comp) (LIBSSH2_SESSION *session,
|
|
|
|
unsigned char *dest,
|
|
|
|
size_t *dest_len,
|
|
|
|
const unsigned char *src,
|
|
|
|
size_t src_len,
|
|
|
|
void **abstract);
|
2010-11-03 14:52:42 +01:00
|
|
|
int (*decomp) (LIBSSH2_SESSION *session,
|
2010-10-20 23:58:41 +02:00
|
|
|
unsigned char **dest,
|
2010-11-03 15:03:57 +01:00
|
|
|
size_t *dest_len,
|
|
|
|
size_t payload_limit,
|
|
|
|
const unsigned char *src,
|
|
|
|
size_t src_len,
|
|
|
|
void **abstract);
|
2007-08-06 20:48:04 +00:00
|
|
|
int (*dtor) (LIBSSH2_SESSION * session, int compress, void **abstract);
|
2004-12-07 21:17:20 +00:00
|
|
|
};
|
|
|
|
|
2007-02-07 21:21:06 +00:00
|
|
|
#ifdef LIBSSH2DEBUG
|
2007-08-06 20:48:04 +00:00
|
|
|
void _libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format,
|
|
|
|
...);
|
2007-02-02 23:23:36 +00:00
|
|
|
#else
|
2009-07-29 22:03:40 +02:00
|
|
|
#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || defined(__GNUC__)
|
|
|
|
/* C99 supported and also by older GCC */
|
2007-02-02 23:23:36 +00:00
|
|
|
#define _libssh2_debug(x,y,z,...) do {} while (0)
|
|
|
|
#else
|
|
|
|
/* no gcc and not C99, do static and hopefully inline */
|
2007-08-06 20:48:04 +00:00
|
|
|
static inline void
|
|
|
|
_libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format, ...)
|
|
|
|
{
|
|
|
|
}
|
2007-02-02 23:23:36 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2005-05-11 05:11:31 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
#define LIBSSH2_SOCKET_UNKNOWN 1
|
|
|
|
#define LIBSSH2_SOCKET_CONNECTED 0
|
|
|
|
#define LIBSSH2_SOCKET_DISCONNECTED -1
|
2004-12-07 21:17:20 +00:00
|
|
|
|
|
|
|
/* Initial packet state, prior to MAC check */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define LIBSSH2_MAC_UNCONFIRMED 1
|
2004-12-07 21:17:20 +00:00
|
|
|
/* When MAC type is "none" (proto initiation phase) all packets are deemed "confirmed" */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define LIBSSH2_MAC_CONFIRMED 0
|
2004-12-07 21:17:20 +00:00
|
|
|
/* Something very bad is going on */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define LIBSSH2_MAC_INVALID -1
|
2004-12-07 21:17:20 +00:00
|
|
|
|
|
|
|
/* SSH Packet Types -- Defined by internet draft */
|
|
|
|
/* Transport Layer */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define SSH_MSG_DISCONNECT 1
|
|
|
|
#define SSH_MSG_IGNORE 2
|
|
|
|
#define SSH_MSG_UNIMPLEMENTED 3
|
|
|
|
#define SSH_MSG_DEBUG 4
|
|
|
|
#define SSH_MSG_SERVICE_REQUEST 5
|
|
|
|
#define SSH_MSG_SERVICE_ACCEPT 6
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-05-28 17:56:08 +00:00
|
|
|
#define SSH_MSG_KEXINIT 20
|
|
|
|
#define SSH_MSG_NEWKEYS 21
|
2004-12-07 21:17:20 +00:00
|
|
|
|
|
|
|
/* diffie-hellman-group1-sha1 */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define SSH_MSG_KEXDH_INIT 30
|
|
|
|
#define SSH_MSG_KEXDH_REPLY 31
|
2004-12-07 21:17:20 +00:00
|
|
|
|
|
|
|
/* diffie-hellman-group-exchange-sha1 */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define SSH_MSG_KEX_DH_GEX_REQUEST_OLD 30
|
|
|
|
#define SSH_MSG_KEX_DH_GEX_REQUEST 34
|
|
|
|
#define SSH_MSG_KEX_DH_GEX_GROUP 31
|
|
|
|
#define SSH_MSG_KEX_DH_GEX_INIT 32
|
|
|
|
#define SSH_MSG_KEX_DH_GEX_REPLY 33
|
2004-12-07 21:17:20 +00:00
|
|
|
|
|
|
|
/* User Authentication */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define SSH_MSG_USERAUTH_REQUEST 50
|
|
|
|
#define SSH_MSG_USERAUTH_FAILURE 51
|
|
|
|
#define SSH_MSG_USERAUTH_SUCCESS 52
|
|
|
|
#define SSH_MSG_USERAUTH_BANNER 53
|
2004-12-07 21:17:20 +00:00
|
|
|
|
|
|
|
/* "public key" method */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define SSH_MSG_USERAUTH_PK_OK 60
|
2004-12-07 21:17:20 +00:00
|
|
|
/* "password" method */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define SSH_MSG_USERAUTH_PASSWD_CHANGEREQ 60
|
2005-06-11 19:18:06 +00:00
|
|
|
/* "keyboard-interactive" method */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define SSH_MSG_USERAUTH_INFO_REQUEST 60
|
|
|
|
#define SSH_MSG_USERAUTH_INFO_RESPONSE 61
|
2004-12-07 21:17:20 +00:00
|
|
|
|
|
|
|
/* Channels */
|
2007-05-28 17:56:08 +00:00
|
|
|
#define SSH_MSG_GLOBAL_REQUEST 80
|
|
|
|
#define SSH_MSG_REQUEST_SUCCESS 81
|
|
|
|
#define SSH_MSG_REQUEST_FAILURE 82
|
|
|
|
|
|
|
|
#define SSH_MSG_CHANNEL_OPEN 90
|
|
|
|
#define SSH_MSG_CHANNEL_OPEN_CONFIRMATION 91
|
|
|
|
#define SSH_MSG_CHANNEL_OPEN_FAILURE 92
|
|
|
|
#define SSH_MSG_CHANNEL_WINDOW_ADJUST 93
|
|
|
|
#define SSH_MSG_CHANNEL_DATA 94
|
|
|
|
#define SSH_MSG_CHANNEL_EXTENDED_DATA 95
|
|
|
|
#define SSH_MSG_CHANNEL_EOF 96
|
|
|
|
#define SSH_MSG_CHANNEL_CLOSE 97
|
|
|
|
#define SSH_MSG_CHANNEL_REQUEST 98
|
|
|
|
#define SSH_MSG_CHANNEL_SUCCESS 99
|
|
|
|
#define SSH_MSG_CHANNEL_FAILURE 100
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2010-11-09 14:28:29 +01:00
|
|
|
/* Error codes returned in SSH_MSG_CHANNEL_OPEN_FAILURE message
|
|
|
|
(see RFC4254) */
|
|
|
|
#define SSH_OPEN_ADMINISTRATIVELY_PROHIBITED 1
|
|
|
|
#define SSH_OPEN_CONNECT_FAILED 2
|
|
|
|
#define SSH_OPEN_UNKNOWN_CHANNELTYPE 3
|
|
|
|
#define SSH_OPEN_RESOURCE_SHORTAGE 4
|
|
|
|
|
2010-11-12 21:53:35 +01:00
|
|
|
ssize_t _libssh2_recv(libssh2_socket_t socket, void *buffer,
|
2011-08-11 22:26:56 +02:00
|
|
|
size_t length, int flags, void **abstract);
|
2010-11-12 21:53:35 +01:00
|
|
|
ssize_t _libssh2_send(libssh2_socket_t socket, const void *buffer,
|
2011-08-11 22:26:56 +02:00
|
|
|
size_t length, int flags, void **abstract);
|
2009-03-19 12:45:59 +00:00
|
|
|
|
2007-02-02 16:21:20 +00:00
|
|
|
#define LIBSSH2_READ_TIMEOUT 60 /* generic timeout in seconds used when
|
2007-06-06 12:34:06 +00:00
|
|
|
waiting for more data to arrive */
|
2009-03-26 15:41:14 +00:00
|
|
|
|
2007-02-02 16:21:20 +00:00
|
|
|
|
2010-04-24 21:14:16 +02:00
|
|
|
int _libssh2_kex_exchange(LIBSSH2_SESSION * session, int reexchange,
|
|
|
|
key_exchange_state_t * state);
|
2007-02-02 16:21:20 +00:00
|
|
|
|
2009-03-26 22:25:23 +00:00
|
|
|
/* Let crypt.c/hostkey.c expose their method structs */
|
2007-04-17 18:12:41 +00:00
|
|
|
const LIBSSH2_CRYPT_METHOD **libssh2_crypt_methods(void);
|
|
|
|
const LIBSSH2_HOSTKEY_METHOD **libssh2_hostkey_methods(void);
|
2004-12-07 21:17:20 +00:00
|
|
|
|
2007-01-23 08:14:14 +00:00
|
|
|
/* pem.c */
|
2007-08-06 20:48:04 +00:00
|
|
|
int _libssh2_pem_parse(LIBSSH2_SESSION * session,
|
|
|
|
const char *headerbegin,
|
|
|
|
const char *headerend,
|
2008-11-20 10:29:01 +00:00
|
|
|
FILE * fp, unsigned char **data, unsigned int *datalen);
|
2007-08-06 20:48:04 +00:00
|
|
|
int _libssh2_pem_decode_sequence(unsigned char **data, unsigned int *datalen);
|
|
|
|
int _libssh2_pem_decode_integer(unsigned char **data, unsigned int *datalen,
|
|
|
|
unsigned char **i, unsigned int *ilen);
|
2007-01-23 08:14:14 +00:00
|
|
|
|
2010-03-19 09:14:21 +01:00
|
|
|
/* global.c */
|
|
|
|
void _libssh2_init_if_needed (void);
|
2009-03-26 15:41:14 +00:00
|
|
|
|
|
|
|
|
2009-12-08 08:40:30 +01:00
|
|
|
#define ARRAY_SIZE(a) (sizeof ((a)) / sizeof ((a)[0]))
|
|
|
|
|
2010-06-15 19:47:31 +02:00
|
|
|
/* define to output the libssh2_int64_t type in a *printf() */
|
2010-06-17 12:23:25 +02:00
|
|
|
#if defined( __BORLANDC__ ) || defined( _MSC_VER ) || defined( __MINGW32__ )
|
2012-06-04 22:54:25 +02:00
|
|
|
#define LIBSSH2_INT64_T_FORMAT "I64d"
|
2010-06-15 19:47:31 +02:00
|
|
|
#else
|
2012-06-04 22:54:25 +02:00
|
|
|
#define LIBSSH2_INT64_T_FORMAT "lld"
|
2010-06-15 19:47:31 +02:00
|
|
|
#endif
|
|
|
|
|
2004-12-07 21:17:20 +00:00
|
|
|
#endif /* LIBSSH2_H */
|