00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef CHANNELS_H_
00022 #define CHANNELS_H_
00023 #include "libssh/priv.h"
00024
00029 enum ssh_channel_request_state_e {
00031 SSH_CHANNEL_REQ_STATE_NONE = 0,
00033 SSH_CHANNEL_REQ_STATE_PENDING,
00035 SSH_CHANNEL_REQ_STATE_ACCEPTED,
00037 SSH_CHANNEL_REQ_STATE_DENIED,
00039 SSH_CHANNEL_REQ_STATE_ERROR
00040 };
00041
00042 enum ssh_channel_state_e {
00043 SSH_CHANNEL_STATE_NOT_OPEN = 0,
00044 SSH_CHANNEL_STATE_OPENING,
00045 SSH_CHANNEL_STATE_OPEN_DENIED,
00046 SSH_CHANNEL_STATE_OPEN,
00047 SSH_CHANNEL_STATE_CLOSED
00048 };
00049
00050
00051 #define SSH_CHANNEL_FLAG_CLOSED_REMOTE 0x1
00052
00053 #define SSH_CHANNEL_FLAG_FREED_LOCAL 0x2
00054
00055 #define SSH_CHANNEL_FLAG_NOT_BOUND 0x4
00056
00057 struct ssh_channel_struct {
00058 ssh_session session;
00059 uint32_t local_channel;
00060 uint32_t local_window;
00061 int local_eof;
00062 uint32_t local_maxpacket;
00063
00064 uint32_t remote_channel;
00065 uint32_t remote_window;
00066 int remote_eof;
00067 uint32_t remote_maxpacket;
00068 enum ssh_channel_state_e state;
00069 int delayed_close;
00070 int flags;
00071 ssh_buffer stdout_buffer;
00072 ssh_buffer stderr_buffer;
00073 void *userarg;
00074 int version;
00075 int exit_status;
00076 enum ssh_channel_request_state_e request_state;
00077 ssh_channel_callbacks callbacks;
00078
00079 ssh_counter counter;
00080 };
00081
00082 SSH_PACKET_CALLBACK(ssh_packet_channel_open_conf);
00083 SSH_PACKET_CALLBACK(ssh_packet_channel_open_fail);
00084 SSH_PACKET_CALLBACK(ssh_packet_channel_success);
00085 SSH_PACKET_CALLBACK(ssh_packet_channel_failure);
00086 SSH_PACKET_CALLBACK(ssh_request_success);
00087 SSH_PACKET_CALLBACK(ssh_request_denied);
00088
00089 SSH_PACKET_CALLBACK(channel_rcv_change_window);
00090 SSH_PACKET_CALLBACK(channel_rcv_eof);
00091 SSH_PACKET_CALLBACK(channel_rcv_close);
00092 SSH_PACKET_CALLBACK(channel_rcv_request);
00093 SSH_PACKET_CALLBACK(channel_rcv_data);
00094
00095 ssh_channel ssh_channel_new(ssh_session session);
00096 int channel_default_bufferize(ssh_channel channel, void *data, int len,
00097 int is_stderr);
00098 int ssh_channel_flush(ssh_channel channel);
00099 uint32_t ssh_channel_new_id(ssh_session session);
00100 ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id);
00101 void ssh_channel_do_free(ssh_channel channel);
00102 #ifdef WITH_SSH1
00103 SSH_PACKET_CALLBACK(ssh_packet_data1);
00104 SSH_PACKET_CALLBACK(ssh_packet_close1);
00105 SSH_PACKET_CALLBACK(ssh_packet_exist_status1);
00106
00107
00108 int channel_open_session1(ssh_channel channel);
00109 int channel_request_pty_size1(ssh_channel channel, const char *terminal,
00110 int cols, int rows);
00111 int channel_change_pty_size1(ssh_channel channel, int cols, int rows);
00112 int channel_request_shell1(ssh_channel channel);
00113 int channel_request_exec1(ssh_channel channel, const char *cmd);
00114 int channel_write1(ssh_channel channel, const void *data, int len);
00115 ssh_channel ssh_get_channel1(ssh_session session);
00116 #endif
00117
00118 #endif