1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-05-17 19:21:11 +03:00

Changes all CHANNEL * to ssh_channel

This commit is contained in:
Aris Adamantiadis 2009-07-24 22:15:33 +02:00
parent 23b6c95e04
commit 2bc8819e8f
11 changed files with 118 additions and 118 deletions

View File

@ -76,8 +76,8 @@ typedef struct ssh_string_struct STRING;
typedef struct ssh_buffer_struct BUFFER; typedef struct ssh_buffer_struct BUFFER;
typedef struct ssh_public_key_struct PUBLIC_KEY; typedef struct ssh_public_key_struct PUBLIC_KEY;
typedef struct ssh_private_key_struct PRIVATE_KEY; typedef struct ssh_private_key_struct PRIVATE_KEY;
#endif
typedef struct ssh_channel_struct CHANNEL; typedef struct ssh_channel_struct CHANNEL;
#endif
typedef struct ssh_agent_struct AGENT; typedef struct ssh_agent_struct AGENT;
//#endif //#endif
@ -257,7 +257,7 @@ ssh_string ssh_get_pubkey(SSH_SESSION *session);
/* in connect.c */ /* in connect.c */
int ssh_fd_poll(SSH_SESSION *session,int *write, int *except); int ssh_fd_poll(SSH_SESSION *session,int *write, int *except);
int ssh_select(CHANNEL **channels, CHANNEL **outchannels, socket_t maxfd, int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
fd_set *readfds, struct timeval *timeout); fd_set *readfds, struct timeval *timeout);
void publickey_free(ssh_public_key key); void publickey_free(ssh_public_key key);
@ -276,37 +276,37 @@ int ssh_write_knownhost(SSH_SESSION *session);
/* in channels.c */ /* in channels.c */
CHANNEL *channel_new(SSH_SESSION *session); ssh_channel channel_new(SSH_SESSION *session);
int channel_open_forward(CHANNEL *channel, const char *remotehost, int channel_open_forward(ssh_channel channel, const char *remotehost,
int remoteport, const char *sourcehost, int localport); int remoteport, const char *sourcehost, int localport);
int channel_open_session(CHANNEL *channel); int channel_open_session(ssh_channel channel);
void channel_free(CHANNEL *channel); void channel_free(ssh_channel channel);
int channel_request_pty(CHANNEL *channel); int channel_request_pty(ssh_channel channel);
int channel_request_pty_size(CHANNEL *channel, const char *term, int channel_request_pty_size(ssh_channel channel, const char *term,
int cols, int rows); int cols, int rows);
int channel_change_pty_size(CHANNEL *channel,int cols,int rows); int channel_change_pty_size(ssh_channel channel,int cols,int rows);
int channel_request_shell(CHANNEL *channel); int channel_request_shell(ssh_channel channel);
int channel_request_subsystem(CHANNEL *channel, const char *system); int channel_request_subsystem(ssh_channel channel, const char *system);
int channel_request_env(CHANNEL *channel, const char *name, const char *value); int channel_request_env(ssh_channel channel, const char *name, const char *value);
int channel_request_exec(CHANNEL *channel, const char *cmd); int channel_request_exec(ssh_channel channel, const char *cmd);
int channel_request_sftp(CHANNEL *channel); int channel_request_sftp(ssh_channel channel);
int channel_write(CHANNEL *channel, const void *data, u32 len); int channel_write(ssh_channel channel, const void *data, u32 len);
int channel_send_eof(CHANNEL *channel); int channel_send_eof(ssh_channel channel);
int channel_is_eof(CHANNEL *channel); int channel_is_eof(ssh_channel channel);
int channel_read(CHANNEL *channel, void *dest, u32 count, int is_stderr); int channel_read(ssh_channel channel, void *dest, u32 count, int is_stderr);
int channel_read_buffer(CHANNEL *channel, ssh_buffer buffer, u32 count, int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, u32 count,
int is_stderr); int is_stderr);
int channel_poll(CHANNEL *channel, int is_stderr); int channel_poll(ssh_channel channel, int is_stderr);
int channel_close(CHANNEL *channel); int channel_close(ssh_channel channel);
void channel_set_blocking(CHANNEL *channel, int blocking); void channel_set_blocking(ssh_channel channel, int blocking);
int channel_read_nonblocking(CHANNEL *channel, void *dest, u32 count, int channel_read_nonblocking(ssh_channel channel, void *dest, u32 count,
int is_stderr); int is_stderr);
int channel_is_open(CHANNEL *channel); int channel_is_open(ssh_channel channel);
int channel_is_closed(CHANNEL *channel); int channel_is_closed(ssh_channel channel);
int channel_select(CHANNEL **readchans, CHANNEL **writechans, CHANNEL **exceptchans, struct int channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct
timeval * timeout); timeval * timeout);
SSH_SESSION *channel_get_session(CHANNEL *channel); SSH_SESSION *channel_get_session(ssh_channel channel);
int channel_get_exit_status(CHANNEL *channel); int channel_get_exit_status(ssh_channel channel);
/* in options.c */ /* in options.c */
/** /**

View File

@ -378,7 +378,7 @@ struct ssh_session {
CRYPTO *current_crypto; CRYPTO *current_crypto;
CRYPTO *next_crypto; /* next_crypto is going to be used after a SSH2_MSG_NEWKEYS */ CRYPTO *next_crypto; /* next_crypto is going to be used after a SSH2_MSG_NEWKEYS */
CHANNEL *channels; /* linked list of channels */ ssh_channel channels; /* linked list of channels */
int maxchannel; int maxchannel;
int exec_channel_opened; /* version 1 only. more int exec_channel_opened; /* version 1 only. more
info in channels1.c */ info in channels1.c */
@ -441,7 +441,7 @@ struct ssh_service_request {
struct ssh_channel_request { struct ssh_channel_request {
int type; int type;
CHANNEL *channel; ssh_channel channel;
u8 want_reply; u8 want_reply;
/* pty-req type specifics */ /* pty-req type specifics */
char *TERM; char *TERM;
@ -678,11 +678,11 @@ ssh_string ssh_sign_session_id(SSH_SESSION *session, ssh_private_key privatekey)
ssh_string ssh_encrypt_rsa1(SSH_SESSION *session, ssh_string data, ssh_public_key key); ssh_string ssh_encrypt_rsa1(SSH_SESSION *session, ssh_string data, ssh_public_key key);
/* channel.c */ /* channel.c */
void channel_handle(SSH_SESSION *session, int type); void channel_handle(SSH_SESSION *session, int type);
CHANNEL *channel_new(SSH_SESSION *session); ssh_channel channel_new(SSH_SESSION *session);
int channel_default_bufferize(CHANNEL *channel, void *data, int len, int channel_default_bufferize(ssh_channel channel, void *data, int len,
int is_stderr); int is_stderr);
u32 ssh_channel_new_id(SSH_SESSION *session); u32 ssh_channel_new_id(SSH_SESSION *session);
CHANNEL *ssh_channel_from_local(SSH_SESSION *session, u32 id); ssh_channel ssh_channel_from_local(SSH_SESSION *session, u32 id);
/* options.c */ /* options.c */
@ -788,14 +788,14 @@ const void *_ssh_list_get_head(struct ssh_list *list);
/* channels1.c */ /* channels1.c */
int channel_open_session1(CHANNEL *channel); int channel_open_session1(ssh_channel channel);
int channel_request_pty_size1(CHANNEL *channel, const char *terminal, int channel_request_pty_size1(ssh_channel channel, const char *terminal,
int cols, int rows); int cols, int rows);
int channel_change_pty_size1(CHANNEL *channel, int cols, int rows); int channel_change_pty_size1(ssh_channel channel, int cols, int rows);
int channel_request_shell1(CHANNEL *channel); int channel_request_shell1(ssh_channel channel);
int channel_request_exec1(CHANNEL *channel, const char *cmd); int channel_request_exec1(ssh_channel channel, const char *cmd);
int channel_handle1(SSH_SESSION *session, int type); int channel_handle1(SSH_SESSION *session, int type);
int channel_write1(CHANNEL *channel, const void *data, int len); int channel_write1(ssh_channel channel, const void *data, int len);
/* session.c */ /* session.c */

View File

@ -162,9 +162,9 @@ char *ssh_message_auth_password(SSH_MESSAGE *msg);
int ssh_message_auth_reply_success(SSH_MESSAGE *msg,int partial); int ssh_message_auth_reply_success(SSH_MESSAGE *msg,int partial);
int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods); int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods);
CHANNEL *ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg); ssh_channel ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg);
CHANNEL *ssh_message_channel_request_channel(SSH_MESSAGE *msg); ssh_channel ssh_message_channel_request_channel(SSH_MESSAGE *msg);
// returns the TERM env variable // returns the TERM env variable
char *ssh_message_channel_request_pty_term(SSH_MESSAGE *msg); char *ssh_message_channel_request_pty_term(SSH_MESSAGE *msg);
char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg); char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg);

View File

@ -60,7 +60,7 @@ extern "C" {
typedef struct sftp_session_struct { typedef struct sftp_session_struct {
SSH_SESSION *session; SSH_SESSION *session;
CHANNEL *channel; ssh_channel channel;
int server_version; int server_version;
int client_version; int client_version;
int version; int version;
@ -622,7 +622,7 @@ int sftp_server_version(SFTP_SESSION *sftp);
* *
* @return A new sftp server session. * @return A new sftp server session.
*/ */
SFTP_SESSION *sftp_server_new(SSH_SESSION *session, CHANNEL *chan); SFTP_SESSION *sftp_server_new(SSH_SESSION *session, ssh_channel chan);
/** /**
* @brief Intialize the sftp server. * @brief Intialize the sftp server.

View File

@ -55,14 +55,14 @@
* *
* @return A pointer to a newly allocated channel, NULL on error. * @return A pointer to a newly allocated channel, NULL on error.
*/ */
CHANNEL *channel_new(SSH_SESSION *session) { ssh_channel channel_new(SSH_SESSION *session) {
CHANNEL *channel = NULL; ssh_channel channel = NULL;
channel = malloc(sizeof(CHANNEL)); channel = malloc(sizeof(struct ssh_channel_struct));
if (channel == NULL) { if (channel == NULL) {
return NULL; return NULL;
} }
memset(channel,0,sizeof(CHANNEL)); memset(channel,0,sizeof(struct ssh_channel_struct));
channel->stdout_buffer = buffer_new(); channel->stdout_buffer = buffer_new();
if (channel->stdout_buffer == NULL) { if (channel->stdout_buffer == NULL) {
@ -106,7 +106,7 @@ u32 ssh_channel_new_id(SSH_SESSION *session) {
return ++(session->maxchannel); return ++(session->maxchannel);
} }
static int channel_open(CHANNEL *channel, const char *type_c, int window, static int channel_open(ssh_channel channel, const char *type_c, int window,
int maxpacket, ssh_buffer payload) { int maxpacket, ssh_buffer payload) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
ssh_string type = NULL; ssh_string type = NULL;
@ -233,9 +233,9 @@ static int channel_open(CHANNEL *channel, const char *type_c, int window,
} }
/* get ssh channel from local session? */ /* get ssh channel from local session? */
CHANNEL *ssh_channel_from_local(SSH_SESSION *session, u32 id) { ssh_channel ssh_channel_from_local(SSH_SESSION *session, u32 id) {
CHANNEL *initchan = session->channels; ssh_channel initchan = session->channels;
CHANNEL *channel; ssh_channel channel;
/* We assume we are always the local */ /* We assume we are always the local */
if (initchan == NULL) { if (initchan == NULL) {
@ -252,7 +252,7 @@ CHANNEL *ssh_channel_from_local(SSH_SESSION *session, u32 id) {
return channel; return channel;
} }
static int grow_window(SSH_SESSION *session, CHANNEL *channel, int minimumsize) { static int grow_window(SSH_SESSION *session, ssh_channel channel, int minimumsize) {
u32 new_window = minimumsize > WINDOWBASE ? minimumsize : WINDOWBASE; u32 new_window = minimumsize > WINDOWBASE ? minimumsize : WINDOWBASE;
enter_function(); enter_function();
@ -286,8 +286,8 @@ error:
return -1; return -1;
} }
static CHANNEL *channel_from_msg(SSH_SESSION *session) { static ssh_channel channel_from_msg(SSH_SESSION *session) {
CHANNEL *channel; ssh_channel channel;
u32 chan; u32 chan;
if (buffer_get_u32(session->in_buffer, &chan) != sizeof(u32)) { if (buffer_get_u32(session->in_buffer, &chan) != sizeof(u32)) {
@ -307,7 +307,7 @@ static CHANNEL *channel_from_msg(SSH_SESSION *session) {
} }
static void channel_rcv_change_window(SSH_SESSION *session) { static void channel_rcv_change_window(SSH_SESSION *session) {
CHANNEL *channel; ssh_channel channel;
u32 bytes; u32 bytes;
int rc; int rc;
@ -341,7 +341,7 @@ static void channel_rcv_change_window(SSH_SESSION *session) {
/* is_stderr is set to 1 if the data are extended, ie stderr */ /* is_stderr is set to 1 if the data are extended, ie stderr */
static void channel_rcv_data(SSH_SESSION *session,int is_stderr) { static void channel_rcv_data(SSH_SESSION *session,int is_stderr) {
CHANNEL *channel; ssh_channel channel;
ssh_string str; ssh_string str;
size_t len; size_t len;
@ -407,7 +407,7 @@ static void channel_rcv_data(SSH_SESSION *session,int is_stderr) {
} }
static void channel_rcv_eof(SSH_SESSION *session) { static void channel_rcv_eof(SSH_SESSION *session) {
CHANNEL *channel; ssh_channel channel;
enter_function(); enter_function();
@ -429,7 +429,7 @@ static void channel_rcv_eof(SSH_SESSION *session) {
} }
static void channel_rcv_close(SSH_SESSION *session) { static void channel_rcv_close(SSH_SESSION *session) {
CHANNEL *channel; ssh_channel channel;
enter_function(); enter_function();
@ -468,7 +468,7 @@ static void channel_rcv_close(SSH_SESSION *session) {
} }
static void channel_rcv_request(SSH_SESSION *session) { static void channel_rcv_request(SSH_SESSION *session) {
CHANNEL *channel; ssh_channel channel;
ssh_string request_s; ssh_string request_s;
char *request; char *request;
u32 status; u32 status;
@ -592,7 +592,7 @@ void channel_handle(SSH_SESSION *session, int type){
* *
* FIXME is the window changed? * FIXME is the window changed?
*/ */
int channel_default_bufferize(CHANNEL *channel, void *data, int len, int channel_default_bufferize(ssh_channel channel, void *data, int len,
int is_stderr) { int is_stderr) {
struct ssh_session *session = channel->session; struct ssh_session *session = channel->session;
@ -642,7 +642,7 @@ int channel_default_bufferize(CHANNEL *channel, void *data, int len,
* @see channel_request_shell() * @see channel_request_shell()
* @see channel_request_exec() * @see channel_request_exec()
*/ */
int channel_open_session(CHANNEL *channel) { int channel_open_session(ssh_channel channel) {
#ifdef HAVE_SSH1 #ifdef HAVE_SSH1
if (channel->session->version == 1) { if (channel->session->version == 1) {
return channel_open_session1(channel); return channel_open_session1(channel);
@ -670,7 +670,7 @@ int channel_open_session(CHANNEL *channel) {
* @return SSH_OK on success\n * @return SSH_OK on success\n
* SSH_ERROR on error * SSH_ERROR on error
*/ */
int channel_open_forward(CHANNEL *channel, const char *remotehost, int channel_open_forward(ssh_channel channel, const char *remotehost,
int remoteport, const char *sourcehost, int localport) { int remoteport, const char *sourcehost, int localport) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
ssh_buffer payload = NULL; ssh_buffer payload = NULL;
@ -721,7 +721,7 @@ error:
* *
* @warning Any data unread on this channel will be lost. * @warning Any data unread on this channel will be lost.
*/ */
void channel_free(CHANNEL *channel) { void channel_free(ssh_channel channel) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
enter_function(); enter_function();
@ -751,7 +751,7 @@ void channel_free(CHANNEL *channel) {
buffer_free(channel->stderr_buffer); buffer_free(channel->stderr_buffer);
/* debug trick to catch use after frees */ /* debug trick to catch use after frees */
memset(channel, 'X', sizeof(CHANNEL)); memset(channel, 'X', sizeof(struct ssh_channel_struct));
SAFE_FREE(channel); SAFE_FREE(channel);
leave_function(); leave_function();
@ -770,7 +770,7 @@ void channel_free(CHANNEL *channel) {
* @see channel_close() * @see channel_close()
* @see channel_free() * @see channel_free()
*/ */
int channel_send_eof(CHANNEL *channel){ int channel_send_eof(ssh_channel channel){
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
int rc = SSH_ERROR; int rc = SSH_ERROR;
@ -813,7 +813,7 @@ error:
* @see channel_free() * @see channel_free()
* @see channel_eof() * @see channel_eof()
*/ */
int channel_close(CHANNEL *channel){ int channel_close(ssh_channel channel){
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
int rc = 0; int rc = 0;
@ -865,7 +865,7 @@ error:
* *
* @see channel_read() * @see channel_read()
*/ */
int channel_write(CHANNEL *channel, const void *data, u32 len) { int channel_write(ssh_channel channel, const void *data, u32 len) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
int origlen = len; int origlen = len;
int effectivelen; int effectivelen;
@ -955,7 +955,7 @@ error:
* *
* @see channel_is_closed() * @see channel_is_closed()
*/ */
int channel_is_open(CHANNEL *channel) { int channel_is_open(ssh_channel channel) {
return (channel->open != 0 && channel->session->alive != 0); return (channel->open != 0 && channel->session->alive != 0);
} }
@ -968,7 +968,7 @@ int channel_is_open(CHANNEL *channel) {
* *
* @see channel_is_open() * @see channel_is_open()
*/ */
int channel_is_closed(CHANNEL *channel) { int channel_is_closed(ssh_channel channel) {
return (channel->open == 0 || channel->session->alive == 0); return (channel->open == 0 || channel->session->alive == 0);
} }
@ -979,7 +979,7 @@ int channel_is_closed(CHANNEL *channel) {
* *
* @return 0 if there is no EOF, nonzero otherwise. * @return 0 if there is no EOF, nonzero otherwise.
*/ */
int channel_is_eof(CHANNEL *channel) { int channel_is_eof(ssh_channel channel) {
if ((channel->stdout_buffer && if ((channel->stdout_buffer &&
buffer_get_rest_len(channel->stdout_buffer) > 0) || buffer_get_rest_len(channel->stdout_buffer) > 0) ||
(channel->stderr_buffer && (channel->stderr_buffer &&
@ -1000,11 +1000,11 @@ int channel_is_eof(CHANNEL *channel) {
* @bug This functionnality is still under development and * @bug This functionnality is still under development and
* doesn't work correctly. * doesn't work correctly.
*/ */
void channel_set_blocking(CHANNEL *channel, int blocking) { void channel_set_blocking(ssh_channel channel, int blocking) {
channel->blocking = (blocking == 0 ? 0 : 1); channel->blocking = (blocking == 0 ? 0 : 1);
} }
static int channel_request(CHANNEL *channel, const char *request, static int channel_request(ssh_channel channel, const char *request,
ssh_buffer buffer, int reply) { ssh_buffer buffer, int reply) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
ssh_string req = NULL; ssh_string req = NULL;
@ -1082,7 +1082,7 @@ error:
* *
* @return SSH_SUCCESS on success, SSH_ERROR on error. * @return SSH_SUCCESS on success, SSH_ERROR on error.
*/ */
int channel_request_pty_size(CHANNEL *channel, const char *terminal, int channel_request_pty_size(ssh_channel channel, const char *terminal,
int col, int row) { int col, int row) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
ssh_string term = NULL; ssh_string term = NULL;
@ -1135,7 +1135,7 @@ error:
* *
* @see channel_request_pty_size() * @see channel_request_pty_size()
*/ */
int channel_request_pty(CHANNEL *channel) { int channel_request_pty(ssh_channel channel) {
return channel_request_pty_size(channel, "xterm", 80, 24); return channel_request_pty_size(channel, "xterm", 80, 24);
} }
@ -1152,7 +1152,7 @@ int channel_request_pty(CHANNEL *channel) {
* sure any other libssh function using the same channel/session * sure any other libssh function using the same channel/session
* is running at same time (not 100% threadsafe). * is running at same time (not 100% threadsafe).
*/ */
int channel_change_pty_size(CHANNEL *channel, int cols, int rows) { int channel_change_pty_size(ssh_channel channel, int cols, int rows) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
ssh_buffer buffer = NULL; ssh_buffer buffer = NULL;
int rc = SSH_ERROR; int rc = SSH_ERROR;
@ -1194,7 +1194,7 @@ error:
* *
* @returns SSH_SUCCESS on success, SSH_ERROR on error. * @returns SSH_SUCCESS on success, SSH_ERROR on error.
*/ */
int channel_request_shell(CHANNEL *channel) { int channel_request_shell(ssh_channel channel) {
#ifdef HAVE_SSH1 #ifdef HAVE_SSH1
if (channel->version == 1) { if (channel->version == 1) {
return channel_request_shell1(channel); return channel_request_shell1(channel);
@ -1214,7 +1214,7 @@ int channel_request_shell(CHANNEL *channel) {
* *
* @warning You normally don't have to call it for sftp, see sftp_new(). * @warning You normally don't have to call it for sftp, see sftp_new().
*/ */
int channel_request_subsystem(CHANNEL *channel, const char *sys) { int channel_request_subsystem(ssh_channel channel, const char *sys) {
ssh_buffer buffer = NULL; ssh_buffer buffer = NULL;
ssh_string subsystem = NULL; ssh_string subsystem = NULL;
int rc = SSH_ERROR; int rc = SSH_ERROR;
@ -1241,7 +1241,7 @@ error:
return rc; return rc;
} }
int channel_request_sftp( CHANNEL *channel){ int channel_request_sftp( ssh_channel channel){
return channel_request_subsystem(channel, "sftp"); return channel_request_subsystem(channel, "sftp");
} }
@ -1258,7 +1258,7 @@ int channel_request_sftp( CHANNEL *channel){
* *
* @warning Some environement variables may be refused by security reasons. * @warning Some environement variables may be refused by security reasons.
* */ * */
int channel_request_env(CHANNEL *channel, const char *name, const char *value) { int channel_request_env(ssh_channel channel, const char *name, const char *value) {
ssh_buffer buffer = NULL; ssh_buffer buffer = NULL;
ssh_string str = NULL; ssh_string str = NULL;
int rc = SSH_ERROR; int rc = SSH_ERROR;
@ -1309,7 +1309,7 @@ error:
* *
* @see channel_request_shell() * @see channel_request_shell()
*/ */
int channel_request_exec(CHANNEL *channel, const char *cmd) { int channel_request_exec(ssh_channel channel, const char *cmd) {
ssh_buffer buffer = NULL; ssh_buffer buffer = NULL;
ssh_string command = NULL; ssh_string command = NULL;
int rc = SSH_ERROR; int rc = SSH_ERROR;
@ -1359,7 +1359,7 @@ error:
* *
* @return The number of bytes read, 0 on end of file or SSH_ERROR on error. * @return The number of bytes read, 0 on end of file or SSH_ERROR on error.
*/ */
int channel_read_buffer(CHANNEL *channel, ssh_buffer buffer, u32 count, int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, u32 count,
int is_stderr) { int is_stderr) {
SSH_SESSION *session=channel->session; SSH_SESSION *session=channel->session;
ssh_buffer stdbuf = channel->stdout_buffer; ssh_buffer stdbuf = channel->stdout_buffer;
@ -1468,7 +1468,7 @@ int channel_read_buffer(CHANNEL *channel, ssh_buffer buffer, u32 count,
* @warning The read function using a buffer has been renamed to * @warning The read function using a buffer has been renamed to
* channel_read_buffer(). * channel_read_buffer().
*/ */
int channel_read(CHANNEL *channel, void *dest, u32 count, int is_stderr) { int channel_read(ssh_channel channel, void *dest, u32 count, int is_stderr) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
ssh_buffer stdbuf = channel->stdout_buffer; ssh_buffer stdbuf = channel->stdout_buffer;
u32 len; u32 len;
@ -1566,7 +1566,7 @@ int channel_read(CHANNEL *channel, void *dest, u32 count, int is_stderr) {
* *
* @see channel_is_eof() * @see channel_is_eof()
*/ */
int channel_read_nonblocking(CHANNEL *channel, void *dest, u32 count, int channel_read_nonblocking(ssh_channel channel, void *dest, u32 count,
int is_stderr) { int is_stderr) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
u32 to_read; u32 to_read;
@ -1604,7 +1604,7 @@ int channel_read_nonblocking(CHANNEL *channel, void *dest, u32 count,
* *
* @see channel_is_eof() * @see channel_is_eof()
*/ */
int channel_poll(CHANNEL *channel, int is_stderr){ int channel_poll(ssh_channel channel, int is_stderr){
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
ssh_buffer stdbuf = channel->stdout_buffer; ssh_buffer stdbuf = channel->stdout_buffer;
@ -1636,7 +1636,7 @@ int channel_poll(CHANNEL *channel, int is_stderr){
* *
* @return The session pointer. * @return The session pointer.
*/ */
SSH_SESSION *channel_get_session(CHANNEL *channel) { SSH_SESSION *channel_get_session(ssh_channel channel) {
return channel->session; return channel->session;
} }
@ -1649,7 +1649,7 @@ SSH_SESSION *channel_get_session(CHANNEL *channel) {
* @return -1 if no exit status has been returned or eof not sent, * @return -1 if no exit status has been returned or eof not sent,
* the exit status othewise. * the exit status othewise.
*/ */
int channel_get_exit_status(CHANNEL *channel) { int channel_get_exit_status(ssh_channel channel) {
if (channel->local_eof == 0) { if (channel->local_eof == 0) {
return -1; return -1;
} }
@ -1676,9 +1676,9 @@ int channel_get_exit_status(CHANNEL *channel) {
* This is made in two parts: protocol select and network select. The protocol * This is made in two parts: protocol select and network select. The protocol
* select does not use the network functions at all * select does not use the network functions at all
*/ */
static int channel_protocol_select(CHANNEL **rchans, CHANNEL **wchans, static int channel_protocol_select(ssh_channel *rchans, ssh_channel *wchans,
CHANNEL **echans, CHANNEL **rout, CHANNEL **wout, CHANNEL **eout) { ssh_channel *echans, ssh_channel *rout, ssh_channel *wout, ssh_channel *eout) {
CHANNEL *chan; ssh_channel chan;
int i; int i;
int j = 0; int j = 0;
@ -1725,7 +1725,7 @@ static int channel_protocol_select(CHANNEL **rchans, CHANNEL **wchans,
} }
/* Just count number of pointers in the array */ /* Just count number of pointers in the array */
static int count_ptrs(CHANNEL **ptrs) { static int count_ptrs(ssh_channel *ptrs) {
int c; int c;
for (c = 0; ptrs[c] != NULL; c++) for (c = 0; ptrs[c] != NULL; c++)
; ;
@ -1754,10 +1754,10 @@ static int count_ptrs(CHANNEL **ptrs) {
* @return SSH_SUCCESS operation successful\n * @return SSH_SUCCESS operation successful\n
* SSH_EINTR select(2) syscall was interrupted, relaunch the function * SSH_EINTR select(2) syscall was interrupted, relaunch the function
*/ */
int channel_select(CHANNEL **readchans, CHANNEL **writechans, int channel_select(ssh_channel *readchans, ssh_channel *writechans,
CHANNEL **exceptchans, struct timeval * timeout) { ssh_channel *exceptchans, struct timeval * timeout) {
CHANNEL **rchans, **wchans, **echans; ssh_channel *rchans, **wchans, **echans;
CHANNEL *dummy = NULL; ssh_channel dummy = NULL;
fd_set rset; fd_set rset;
fd_set wset; fd_set wset;
fd_set eset; fd_set eset;
@ -1784,18 +1784,18 @@ int channel_select(CHANNEL **readchans, CHANNEL **writechans,
} }
/* Prepare the outgoing temporary arrays */ /* Prepare the outgoing temporary arrays */
rchans = malloc(sizeof(CHANNEL *) * (count_ptrs(readchans) + 1)); rchans = malloc(sizeof(ssh_channel ) * (count_ptrs(readchans) + 1));
if (rchans == NULL) { if (rchans == NULL) {
return SSH_ERROR; return SSH_ERROR;
} }
wchans = malloc(sizeof(CHANNEL *) * (count_ptrs(writechans) + 1)); wchans = malloc(sizeof(ssh_channel ) * (count_ptrs(writechans) + 1));
if (wchans == NULL) { if (wchans == NULL) {
SAFE_FREE(rchans); SAFE_FREE(rchans);
return SSH_ERROR; return SSH_ERROR;
} }
echans = malloc(sizeof(CHANNEL *) * (count_ptrs(exceptchans) + 1)); echans = malloc(sizeof(ssh_channel ) * (count_ptrs(exceptchans) + 1));
if (echans == NULL) { if (echans == NULL) {
SAFE_FREE(rchans); SAFE_FREE(rchans);
SAFE_FREE(wchans); SAFE_FREE(wchans);
@ -1811,9 +1811,9 @@ int channel_select(CHANNEL **readchans, CHANNEL **writechans,
rchans, wchans, echans); rchans, wchans, echans);
if (rchans[0] != NULL || wchans[0] != NULL || echans[0] != NULL) { if (rchans[0] != NULL || wchans[0] != NULL || echans[0] != NULL) {
/* We've got one without doing any select overwrite the begining arrays */ /* We've got one without doing any select overwrite the begining arrays */
memcpy(readchans, rchans, (count_ptrs(rchans) + 1) * sizeof(CHANNEL *)); memcpy(readchans, rchans, (count_ptrs(rchans) + 1) * sizeof(ssh_channel ));
memcpy(writechans, wchans, (count_ptrs(wchans) + 1) * sizeof(CHANNEL *)); memcpy(writechans, wchans, (count_ptrs(wchans) + 1) * sizeof(ssh_channel ));
memcpy(exceptchans, echans, (count_ptrs(echans) + 1) * sizeof(CHANNEL *)); memcpy(exceptchans, echans, (count_ptrs(echans) + 1) * sizeof(ssh_channel ));
SAFE_FREE(rchans); SAFE_FREE(rchans);
SAFE_FREE(wchans); SAFE_FREE(wchans);
SAFE_FREE(echans); SAFE_FREE(echans);

View File

@ -40,7 +40,7 @@
* protocol. * protocol.
*/ */
int channel_open_session1(CHANNEL *chan) { int channel_open_session1(ssh_channel chan) {
/* /*
* We guess we are requesting an *exec* channel. It can only have one exec * We guess we are requesting an *exec* channel. It can only have one exec
* channel. So we abort with an error if we need more than one. * channel. So we abort with an error if we need more than one.
@ -73,7 +73,7 @@ int channel_open_session1(CHANNEL *chan) {
* much simplier under ssh2. I just hope the defaults values are ok ... * much simplier under ssh2. I just hope the defaults values are ok ...
*/ */
int channel_request_pty_size1(CHANNEL *channel, const char *terminal, int col, int channel_request_pty_size1(ssh_channel channel, const char *terminal, int col,
int row) { int row) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
ssh_string str = NULL; ssh_string str = NULL;
@ -126,7 +126,7 @@ int channel_request_pty_size1(CHANNEL *channel, const char *terminal, int col,
return -1; return -1;
} }
int channel_change_pty_size1(CHANNEL *channel, int cols, int rows) { int channel_change_pty_size1(ssh_channel channel, int cols, int rows) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
if (buffer_add_u8(session->out_buffer, SSH_CMSG_WINDOW_SIZE) < 0 || if (buffer_add_u8(session->out_buffer, SSH_CMSG_WINDOW_SIZE) < 0 ||
@ -163,7 +163,7 @@ int channel_change_pty_size1(CHANNEL *channel, int cols, int rows) {
return -1; return -1;
} }
int channel_request_shell1(CHANNEL *channel) { int channel_request_shell1(ssh_channel channel) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
if (buffer_add_u8(session->out_buffer,SSH_CMSG_EXEC_SHELL) < 0) { if (buffer_add_u8(session->out_buffer,SSH_CMSG_EXEC_SHELL) < 0) {
@ -179,7 +179,7 @@ int channel_request_shell1(CHANNEL *channel) {
return 0; return 0;
} }
int channel_request_exec1(CHANNEL *channel, const char *cmd) { int channel_request_exec1(ssh_channel channel, const char *cmd) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
ssh_string command = NULL; ssh_string command = NULL;
@ -205,7 +205,7 @@ int channel_request_exec1(CHANNEL *channel, const char *cmd) {
} }
static int channel_rcv_data1(SSH_SESSION *session, int is_stderr) { static int channel_rcv_data1(SSH_SESSION *session, int is_stderr) {
CHANNEL *channel = session->channels; ssh_channel channel = session->channels;
ssh_string str = NULL; ssh_string str = NULL;
str = buffer_get_ssh_string(session->in_buffer); str = buffer_get_ssh_string(session->in_buffer);
@ -229,7 +229,7 @@ static int channel_rcv_data1(SSH_SESSION *session, int is_stderr) {
} }
static int channel_rcv_close1(SSH_SESSION *session) { static int channel_rcv_close1(SSH_SESSION *session) {
CHANNEL *channel = session->channels; ssh_channel channel = session->channels;
u32 status; u32 status;
buffer_get_u32(session->in_buffer, &status); buffer_get_u32(session->in_buffer, &status);
@ -273,7 +273,7 @@ int channel_handle1(SSH_SESSION *session, int type) {
return 0; return 0;
} }
int channel_write1(CHANNEL *channel, const void *data, int len) { int channel_write1(ssh_channel channel, const void *data, int len) {
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
int origlen = len; int origlen = len;
int effectivelen; int effectivelen;

View File

@ -353,7 +353,7 @@ socket_t ssh_connect_host(SSH_SESSION *session, const char *host,
* *
* @see select(2) * @see select(2)
*/ */
int ssh_select(CHANNEL **channels, CHANNEL **outchannels, socket_t maxfd, int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
fd_set *readfds, struct timeval *timeout) { fd_set *readfds, struct timeval *timeout) {
struct timeval zerotime; struct timeval zerotime;
fd_set localset, localset2; fd_set localset, localset2;

View File

@ -391,9 +391,9 @@ error:
return NULL; return NULL;
} }
CHANNEL *ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg) { ssh_channel ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg) {
SSH_SESSION *session = msg->session; SSH_SESSION *session = msg->session;
CHANNEL *chan = NULL; ssh_channel chan = NULL;
enter_function(); enter_function();

View File

@ -93,7 +93,7 @@ SFTP_SESSION *sftp_new(SSH_SESSION *session){
} }
#ifdef WITH_SERVER #ifdef WITH_SERVER
SFTP_SESSION *sftp_server_new(SSH_SESSION *session, CHANNEL *chan){ SFTP_SESSION *sftp_server_new(SSH_SESSION *session, ssh_channel chan){
SFTP_SESSION *sftp = NULL; SFTP_SESSION *sftp = NULL;
sftp = malloc(sizeof(SFTP_SESSION)); sftp = malloc(sizeof(SFTP_SESSION));

View File

@ -109,7 +109,7 @@ static void do_exit(int i) {
exit(0); exit(0);
} }
CHANNEL *chan; ssh_channel chan;
int signal_delayed=0; int signal_delayed=0;
static void sigwindowchanged(int i){ static void sigwindowchanged(int i){
@ -129,12 +129,12 @@ static void sizechanged(void){
// printf("Changed pty size\n"); // printf("Changed pty size\n");
setsignal(); setsignal();
} }
static void select_loop(SSH_SESSION *session,CHANNEL *channel){ static void select_loop(SSH_SESSION *session,ssh_channel channel){
fd_set fds; fd_set fds;
struct timeval timeout; struct timeval timeout;
char buffer[10]; char buffer[10];
ssh_buffer readbuf=buffer_new(); ssh_buffer readbuf=buffer_new();
CHANNEL *channels[2]; ssh_channel channels[2];
int lus; int lus;
int eof=0; int eof=0;
int maxfd; int maxfd;
@ -229,7 +229,7 @@ static void select_loop(SSH_SESSION *session,CHANNEL *channel){
static void shell(SSH_SESSION *session){ static void shell(SSH_SESSION *session){
CHANNEL *channel; ssh_channel channel;
struct termios terminal_local; struct termios terminal_local;
int interactive=isatty(0); int interactive=isatty(0);
channel = channel_new(session); channel = channel_new(session);
@ -260,7 +260,7 @@ static void shell(SSH_SESSION *session){
} }
static void batch_shell(SSH_SESSION *session){ static void batch_shell(SSH_SESSION *session){
CHANNEL *channel; ssh_channel channel;
char buffer[1024]; char buffer[1024];
int i,s=0; int i,s=0;
for(i=0;i<MAXCMD && cmds[i];++i) for(i=0;i<MAXCMD && cmds[i];++i)

View File

@ -44,7 +44,7 @@ int main(int argc, char **argv){
SSH_SESSION *session; SSH_SESSION *session;
SSH_BIND *ssh_bind; SSH_BIND *ssh_bind;
SSH_MESSAGE *message; SSH_MESSAGE *message;
CHANNEL *chan=0; ssh_channel chan=0;
ssh_buffer buf; ssh_buffer buf;
int auth=0; int auth=0;
int sftp=0; int sftp=0;