libssh  0.10.6
The SSH library
channels.h
1 /*
2  * This file is part of the SSH Library
3  *
4  * Copyright (c) 2009 by Aris Adamantiadis
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef CHANNELS_H_
22 #define CHANNELS_H_
23 #include "libssh/priv.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
33 enum ssh_channel_request_state_e {
35  SSH_CHANNEL_REQ_STATE_NONE = 0,
37  SSH_CHANNEL_REQ_STATE_PENDING,
39  SSH_CHANNEL_REQ_STATE_ACCEPTED,
41  SSH_CHANNEL_REQ_STATE_DENIED,
43  SSH_CHANNEL_REQ_STATE_ERROR
44 };
45 
46 enum ssh_channel_state_e {
47  SSH_CHANNEL_STATE_NOT_OPEN = 0,
48  SSH_CHANNEL_STATE_OPENING,
49  SSH_CHANNEL_STATE_OPEN_DENIED,
50  SSH_CHANNEL_STATE_OPEN,
51  SSH_CHANNEL_STATE_CLOSED
52 };
53 
54 /* The channel has been closed by the remote side */
55 #define SSH_CHANNEL_FLAG_CLOSED_REMOTE 0x0001
56 
57 /* The channel has been closed locally */
58 #define SSH_CHANNEL_FLAG_CLOSED_LOCAL 0x0002
59 
60 /* The channel has been freed by the calling program */
61 #define SSH_CHANNEL_FLAG_FREED_LOCAL 0x0004
62 
63 /* the channel has not yet been bound to a remote one */
64 #define SSH_CHANNEL_FLAG_NOT_BOUND 0x0008
65 
67  ssh_session session; /* SSH_SESSION pointer */
68  uint32_t local_channel;
69  uint32_t local_window;
70  int local_eof;
71  uint32_t local_maxpacket;
72 
73  uint32_t remote_channel;
74  uint32_t remote_window;
75  int remote_eof; /* end of file received */
76  uint32_t remote_maxpacket;
77  enum ssh_channel_state_e state;
78  int delayed_close;
79  int flags;
80  ssh_buffer stdout_buffer;
81  ssh_buffer stderr_buffer;
82  void *userarg;
83  int exit_status;
84  enum ssh_channel_request_state_e request_state;
85  struct ssh_list *callbacks; /* list of ssh_channel_callbacks */
86 
87  /* counters */
88  ssh_counter counter;
89 };
90 
91 SSH_PACKET_CALLBACK(ssh_packet_channel_open_conf);
92 SSH_PACKET_CALLBACK(ssh_packet_channel_open_fail);
93 SSH_PACKET_CALLBACK(ssh_packet_channel_success);
94 SSH_PACKET_CALLBACK(ssh_packet_channel_failure);
95 SSH_PACKET_CALLBACK(ssh_request_success);
96 SSH_PACKET_CALLBACK(ssh_request_denied);
97 
98 SSH_PACKET_CALLBACK(channel_rcv_change_window);
99 SSH_PACKET_CALLBACK(channel_rcv_eof);
100 SSH_PACKET_CALLBACK(channel_rcv_close);
101 SSH_PACKET_CALLBACK(channel_rcv_request);
102 SSH_PACKET_CALLBACK(channel_rcv_data);
103 
104 int channel_default_bufferize(ssh_channel channel,
105  void *data, uint32_t len,
106  bool is_stderr);
107 int ssh_channel_flush(ssh_channel channel);
108 uint32_t ssh_channel_new_id(ssh_session session);
109 ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id);
110 void ssh_channel_do_free(ssh_channel channel);
111 int ssh_global_request(ssh_session session,
112  const char *request,
113  ssh_buffer buffer,
114  int reply);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* CHANNELS_H_ */
ssh_channel_struct
Definition: channels.h:66
ssh_counter_struct
Definition: libssh.h:95
SSH_PACKET_CALLBACK
#define SSH_PACKET_CALLBACK(name)
This macro declares a packet callback handler.
Definition: callbacks.h:532
ssh_buffer_struct
Definition: buffer.c:48
ssh_session_struct
Definition: session.h:127
ssh_global_request
Definition: messages.h:51
ssh_list
Definition: misc.h:43