libssh  0.5.4
channels.h
1 /*
2  * This file is part of the SSH Library
3  *
4  * Copyright (c) 2009 by Aris Adamantiadis
5  *
6  * The SSH Library is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or (at your
9  * option) any later version.
10  *
11  * The SSH Library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with the SSH Library; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19  * MA 02111-1307, USA.
20  */
21 
22 #ifndef CHANNELS_H_
23 #define CHANNELS_H_
24 #include "libssh/priv.h"
25 
30 enum ssh_channel_request_state_e {
32  SSH_CHANNEL_REQ_STATE_NONE = 0,
34  SSH_CHANNEL_REQ_STATE_PENDING,
36  SSH_CHANNEL_REQ_STATE_ACCEPTED,
38  SSH_CHANNEL_REQ_STATE_DENIED,
40  SSH_CHANNEL_REQ_STATE_ERROR
41 };
42 
43 enum ssh_channel_state_e {
44  SSH_CHANNEL_STATE_NOT_OPEN = 0,
45  SSH_CHANNEL_STATE_OPEN_DENIED,
46  SSH_CHANNEL_STATE_OPEN,
47  SSH_CHANNEL_STATE_CLOSED
48 };
49 
50 struct ssh_channel_struct {
51  ssh_session session; /* SSH_SESSION pointer */
52  uint32_t local_channel;
53  uint32_t local_window;
54  int local_eof;
55  uint32_t local_maxpacket;
56 
57  uint32_t remote_channel;
58  uint32_t remote_window;
59  int remote_eof; /* end of file received */
60  uint32_t remote_maxpacket;
61  enum ssh_channel_state_e state;
62  int delayed_close;
63  ssh_buffer stdout_buffer;
64  ssh_buffer stderr_buffer;
65  void *userarg;
66  int version;
67  int blocking;
68  int exit_status;
69  enum ssh_channel_request_state_e request_state;
70  ssh_channel_callbacks callbacks;
71 };
72 
73 SSH_PACKET_CALLBACK(ssh_packet_channel_open_conf);
74 SSH_PACKET_CALLBACK(ssh_packet_channel_open_fail);
75 SSH_PACKET_CALLBACK(ssh_packet_channel_success);
76 SSH_PACKET_CALLBACK(ssh_packet_channel_failure);
77 SSH_PACKET_CALLBACK(ssh_request_success);
78 SSH_PACKET_CALLBACK(ssh_request_denied);
79 
80 SSH_PACKET_CALLBACK(channel_rcv_change_window);
81 SSH_PACKET_CALLBACK(channel_rcv_eof);
82 SSH_PACKET_CALLBACK(channel_rcv_close);
83 SSH_PACKET_CALLBACK(channel_rcv_request);
84 SSH_PACKET_CALLBACK(channel_rcv_data);
85 
86 ssh_channel ssh_channel_new(ssh_session session);
87 int channel_default_bufferize(ssh_channel channel, void *data, int len,
88  int is_stderr);
89 uint32_t ssh_channel_new_id(ssh_session session);
90 ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id);
91 int channel_write_common(ssh_channel channel, const void *data,
92  uint32_t len, int is_stderr);
93 #ifdef WITH_SSH1
94 SSH_PACKET_CALLBACK(ssh_packet_data1);
95 SSH_PACKET_CALLBACK(ssh_packet_close1);
96 SSH_PACKET_CALLBACK(ssh_packet_exist_status1);
97 
98 /* channels1.c */
99 int channel_open_session1(ssh_channel channel);
100 int channel_request_pty_size1(ssh_channel channel, const char *terminal,
101  int cols, int rows);
102 int channel_change_pty_size1(ssh_channel channel, int cols, int rows);
103 int channel_request_shell1(ssh_channel channel);
104 int channel_request_exec1(ssh_channel channel, const char *cmd);
105 int channel_write1(ssh_channel channel, const void *data, int len);
106 ssh_channel ssh_get_channel1(ssh_session session);
107 #endif
108 
109 #endif /* CHANNELS_H_ */