libssh  0.10.1
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
29enum ssh_channel_request_state_e {
31 SSH_CHANNEL_REQ_STATE_NONE = 0,
33 SSH_CHANNEL_REQ_STATE_PENDING,
35 SSH_CHANNEL_REQ_STATE_ACCEPTED,
37 SSH_CHANNEL_REQ_STATE_DENIED,
39 SSH_CHANNEL_REQ_STATE_ERROR
40};
41
42enum ssh_channel_state_e {
43 SSH_CHANNEL_STATE_NOT_OPEN = 0,
44 SSH_CHANNEL_STATE_OPENING,
45 SSH_CHANNEL_STATE_OPEN_DENIED,
46 SSH_CHANNEL_STATE_OPEN,
47 SSH_CHANNEL_STATE_CLOSED
48};
49
50/* The channel has been closed by the remote side */
51#define SSH_CHANNEL_FLAG_CLOSED_REMOTE 0x0001
52
53/* The channel has been closed locally */
54#define SSH_CHANNEL_FLAG_CLOSED_LOCAL 0x0002
55
56/* The channel has been freed by the calling program */
57#define SSH_CHANNEL_FLAG_FREED_LOCAL 0x0004
58
59/* the channel has not yet been bound to a remote one */
60#define SSH_CHANNEL_FLAG_NOT_BOUND 0x0008
61
63 ssh_session session; /* SSH_SESSION pointer */
64 uint32_t local_channel;
65 uint32_t local_window;
66 int local_eof;
67 uint32_t local_maxpacket;
68
69 uint32_t remote_channel;
70 uint32_t remote_window;
71 int remote_eof; /* end of file received */
72 uint32_t remote_maxpacket;
73 enum ssh_channel_state_e state;
74 int delayed_close;
75 int flags;
76 ssh_buffer stdout_buffer;
77 ssh_buffer stderr_buffer;
78 void *userarg;
79 int exit_status;
80 enum ssh_channel_request_state_e request_state;
81 struct ssh_list *callbacks; /* list of ssh_channel_callbacks */
82
83 /* counters */
84 ssh_counter counter;
85};
86
87SSH_PACKET_CALLBACK(ssh_packet_channel_open_conf);
88SSH_PACKET_CALLBACK(ssh_packet_channel_open_fail);
89SSH_PACKET_CALLBACK(ssh_packet_channel_success);
90SSH_PACKET_CALLBACK(ssh_packet_channel_failure);
91SSH_PACKET_CALLBACK(ssh_request_success);
92SSH_PACKET_CALLBACK(ssh_request_denied);
93
94SSH_PACKET_CALLBACK(channel_rcv_change_window);
95SSH_PACKET_CALLBACK(channel_rcv_eof);
96SSH_PACKET_CALLBACK(channel_rcv_close);
97SSH_PACKET_CALLBACK(channel_rcv_request);
98SSH_PACKET_CALLBACK(channel_rcv_data);
99
100int channel_default_bufferize(ssh_channel channel,
101 void *data, uint32_t len,
102 bool is_stderr);
103int ssh_channel_flush(ssh_channel channel);
104uint32_t ssh_channel_new_id(ssh_session session);
105ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id);
106void ssh_channel_do_free(ssh_channel channel);
108 const char *request,
109 ssh_buffer buffer,
110 int reply);
111
112#endif /* CHANNELS_H_ */
#define SSH_PACKET_CALLBACK(name)
This macro declares a packet callback handler.
Definition: callbacks.h:530
Definition: buffer.c:47
Definition: channels.h:62
Definition: libssh.h:95
Definition: messages.h:51
Definition: misc.h:39
Definition: session.h:110