~psiphon-inc/psiphon/trunk

« back to all changes in this revision

Viewing changes to trunk/PsiphonX/libraries/src/libssh2/channel.h

  • Committer: Adam Kruger
  • Date: 2011-02-07 20:43:10 UTC
  • mfrom: (157.1.3 psiphon-with-psiphonx)
  • Revision ID: akruger@kruger-xps-20110207204310-6ph82r21rce8ldze
Merge PsiphonX.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __LIBSSH2_CHANNEL_H
 
2
#define __LIBSSH2_CHANNEL_H
 
3
/* Copyright (c) 2008-2010 by Daniel Stenberg
 
4
 *
 
5
 * All rights reserved.
 
6
 *
 
7
 * Redistribution and use in source and binary forms,
 
8
 * with or without modification, are permitted provided
 
9
 * that the following conditions are met:
 
10
 *
 
11
 *   Redistributions of source code must retain the above
 
12
 *   copyright notice, this list of conditions and the
 
13
 *   following disclaimer.
 
14
 *
 
15
 *   Redistributions in binary form must reproduce the above
 
16
 *   copyright notice, this list of conditions and the following
 
17
 *   disclaimer in the documentation and/or other materials
 
18
 *   provided with the distribution.
 
19
 *
 
20
 *   Neither the name of the copyright holder nor the names
 
21
 *   of any other contributors may be used to endorse or
 
22
 *   promote products derived from this software without
 
23
 *   specific prior written permission.
 
24
 *
 
25
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 
26
 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 
27
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 
28
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
29
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 
30
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
31
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 
32
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
33
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
34
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 
35
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 
36
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 
37
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 
38
 * OF SUCH DAMAGE.
 
39
 */
 
40
 
 
41
/*
 
42
 * _libssh2_channel_receive_window_adjust
 
43
 *
 
44
 * Adjust the receive window for a channel by adjustment bytes. If the amount
 
45
 * to be adjusted is less than LIBSSH2_CHANNEL_MINADJUST and force is 0 the
 
46
 * adjustment amount will be queued for a later packet.
 
47
 *
 
48
 * Always non-blocking.
 
49
 */
 
50
int _libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL * channel,
 
51
                                           unsigned long adjustment,
 
52
                                           unsigned char force,
 
53
                                           unsigned int *store);
 
54
 
 
55
/*
 
56
 * _libssh2_channel_flush
 
57
 *
 
58
 * Flush data from one (or all) stream
 
59
 * Returns number of bytes flushed, or negative on failure
 
60
 */
 
61
int _libssh2_channel_flush(LIBSSH2_CHANNEL *channel, int streamid);
 
62
 
 
63
/*
 
64
 * _libssh2_channel_free
 
65
 *
 
66
 * Make sure a channel is closed, then remove the channel from the session
 
67
 * and free its resource(s)
 
68
 *
 
69
 * Returns 0 on success, negative on failure
 
70
 */
 
71
int _libssh2_channel_free(LIBSSH2_CHANNEL *channel);
 
72
 
 
73
int
 
74
_libssh2_channel_extended_data(LIBSSH2_CHANNEL *channel, int ignore_mode);
 
75
 
 
76
/*
 
77
 * _libssh2_channel_write
 
78
 *
 
79
 * Send data to a channel
 
80
 */
 
81
ssize_t
 
82
_libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id,
 
83
                       const char *buf, size_t buflen);
 
84
 
 
85
/*
 
86
 * _libssh2_channel_open
 
87
 *
 
88
 * Establish a generic session channel
 
89
 */
 
90
LIBSSH2_CHANNEL *
 
91
_libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type,
 
92
                      uint32_t channel_type_len,
 
93
                      uint32_t window_size,
 
94
                      uint32_t packet_size,
 
95
                      const char *message, unsigned int message_len);
 
96
 
 
97
 
 
98
/*
 
99
 * _libssh2_channel_process_startup
 
100
 *
 
101
 * Primitive for libssh2_channel_(shell|exec|subsystem)
 
102
 */
 
103
int
 
104
_libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
 
105
                                 const char *request, unsigned int request_len,
 
106
                                 const char *message, unsigned int message_len);
 
107
 
 
108
 
 
109
/*
 
110
 * _libssh2_channel_read
 
111
 *
 
112
 * Read data from a channel
 
113
 *
 
114
 * It is important to not return 0 until the currently read channel is
 
115
 * complete. If we read stuff from the wire but it was no payload data to fill
 
116
 * in the buffer with, we MUST make sure to return PACKET_EAGAIN.
 
117
 */
 
118
ssize_t _libssh2_channel_read(LIBSSH2_CHANNEL *channel, int stream_id,
 
119
                              char *buf, size_t buflen);
 
120
 
 
121
uint32_t _libssh2_channel_nextid(LIBSSH2_SESSION * session);
 
122
 
 
123
LIBSSH2_CHANNEL *_libssh2_channel_locate(LIBSSH2_SESSION * session,
 
124
                                         uint32_t channel_id);
 
125
 
 
126
size_t _libssh2_channel_packet_data_len(LIBSSH2_CHANNEL * channel,
 
127
                                        int stream_id);
 
128
 
 
129
int _libssh2_channel_close(LIBSSH2_CHANNEL * channel);
 
130
 
 
131
/*
 
132
 * _libssh2_channel_forward_cancel
 
133
 *
 
134
 * Stop listening on a remote port and free the listener
 
135
 * Toss out any pending (un-accept()ed) connections
 
136
 *
 
137
 * Return 0 on success, LIBSSH2_ERROR_EAGAIN if would block, -1 on error
 
138
 */
 
139
int _libssh2_channel_forward_cancel(LIBSSH2_LISTENER *listener);
 
140
 
 
141
#endif /* __LIBSSH2_CHANNEL_H */
 
142