|
libssh
0.7.2
|
00001 /* 00002 * This file is part of the SSH Library 00003 * 00004 * Copyright (c) 2009 by Aris Adamantiadis 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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 /* The channel has been closed by the remote side */ 00051 #define SSH_CHANNEL_FLAG_CLOSED_REMOTE 0x1 00052 /* The channel has been freed by the calling program */ 00053 #define SSH_CHANNEL_FLAG_FREED_LOCAL 0x2 00054 /* the channel has not yet been bound to a remote one */ 00055 #define SSH_CHANNEL_FLAG_NOT_BOUND 0x4 00056 00057 struct ssh_channel_struct { 00058 ssh_session session; /* SSH_SESSION pointer */ 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; /* end of file received */ 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 /* counters */ 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 /* channels1.c */ 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 /* CHANNELS_H_ */
1.7.5.1