libssh 0.4.8
|
Functions that manage a channel. More...
Functions | |
ssh_channel | channel_accept_x11 (ssh_channel channel, int timeout_ms) |
Accept an X11 forwarding channel. | |
int | channel_change_pty_size (ssh_channel channel, int cols, int rows) |
Change the size of the terminal associated to a channel. | |
int | channel_close (ssh_channel channel) |
Close a channel. | |
ssh_channel | channel_forward_accept (ssh_session session, int timeout_ms) |
Accept an incoming TCP/IP forwarding channel. | |
int | channel_forward_cancel (ssh_session session, const char *address, int port) |
Sends the "cancel-tcpip-forward" global request to ask the server to cancel the tcpip-forward request. | |
int | channel_forward_listen (ssh_session session, const char *address, int port, int *bound_port) |
Sends the "tcpip-forward" global request to ask the server to begin listening for inbound connections. | |
void | channel_free (ssh_channel channel) |
Close and free a channel. | |
int | channel_get_exit_status (ssh_channel channel) |
Get the exit status of the channel (error code from the executed instruction). | |
ssh_session | channel_get_session (ssh_channel channel) |
Recover the session in which belongs a channel. | |
int | channel_is_closed (ssh_channel channel) |
Check if the channel is closed or not. | |
int | channel_is_eof (ssh_channel channel) |
Check if remote has sent an EOF. | |
int | channel_is_open (ssh_channel channel) |
Check if the channel is open or not. | |
ssh_channel | channel_new (ssh_session session) |
Allocate a new channel. | |
int | channel_open_forward (ssh_channel channel, const char *remotehost, int remoteport, const char *sourcehost, int localport) |
Open a TCP/IP forwarding channel. | |
int | channel_open_session (ssh_channel channel) |
Open a session channel (suited for a shell, not TCP forwarding). | |
int | channel_poll (ssh_channel channel, int is_stderr) |
Polls a channel for data to read. | |
int | channel_read (ssh_channel channel, void *dest, uint32_t count, int is_stderr) |
Reads data from a channel. | |
int | channel_read_buffer (ssh_channel channel, ssh_buffer buffer, uint32_t count, int is_stderr) |
Read data from a channel into a buffer. | |
int | channel_read_nonblocking (ssh_channel channel, void *dest, uint32_t count, int is_stderr) |
Do a nonblocking read on the channel. | |
int | channel_request_env (ssh_channel channel, const char *name, const char *value) |
Set environement variables. | |
int | channel_request_exec (ssh_channel channel, const char *cmd) |
Run a shell command without an interactive shell. | |
int | channel_request_pty (ssh_channel channel) |
Request a PTY. | |
int | channel_request_pty_size (ssh_channel channel, const char *terminal, int col, int row) |
Request a pty with a specific type and size. | |
int | channel_request_send_signal (ssh_channel channel, const char *signal) |
Send a signal to remote process (as described in RFC 4254, section 6.9). | |
int | channel_request_shell (ssh_channel channel) |
Request a shell. | |
int | channel_request_subsystem (ssh_channel channel, const char *subsys) |
Request a subsystem (for example "sftp"). | |
int | channel_request_x11 (ssh_channel channel, int single_connection, const char *protocol, const char *cookie, int screen_number) |
Sends the "x11-req" channel request over an existing session channel. | |
int | channel_select (ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct timeval *timeout) |
Act like the standard select(2) on channels. | |
int | channel_send_eof (ssh_channel channel) |
Send an end of file on the channel. | |
void | channel_set_blocking (ssh_channel channel, int blocking) |
Put the channel into blocking or nonblocking mode. | |
int | channel_write (ssh_channel channel, const void *data, uint32_t len) |
Blocking write on channel. |
Functions that manage a channel.
ssh_channel channel_accept_x11 | ( | ssh_channel | channel, |
int | timeout_ms | ||
) |
Accept an X11 forwarding channel.
channel | An x11-enabled session channel. |
timeout_ms | Timeout in milli-seconds. |
int channel_change_pty_size | ( | ssh_channel | channel, |
int | cols, | ||
int | rows | ||
) |
Change the size of the terminal associated to a channel.
channel | The channel to change the size. |
cols | The new number of columns. |
rows | The new number of rows. |
References buffer_free(), and buffer_new().
int channel_close | ( | ssh_channel | channel | ) |
Close a channel.
This sends an end of file and then closes the channel. You won't be able to recover any data the server was going to send or was in buffers.
channel | The channel to close. |
References channel_send_eof(), ssh_log(), and SSH_LOG_PACKET.
Referenced by channel_free().
ssh_channel channel_forward_accept | ( | ssh_session | session, |
int | timeout_ms | ||
) |
Accept an incoming TCP/IP forwarding channel.
session | The ssh session to use. |
timeout_ms | Timeout in milli-seconds. |
int channel_forward_cancel | ( | ssh_session | session, |
const char * | address, | ||
int | port | ||
) |
Sends the "cancel-tcpip-forward" global request to ask the server to cancel the tcpip-forward request.
session | The ssh session to send the request. |
address | The bound address on the server. |
port | The bound port on the server. |
References buffer_free(), buffer_new(), string_free(), and string_from_char().
int channel_forward_listen | ( | ssh_session | session, |
const char * | address, | ||
int | port, | ||
int * | bound_port | ||
) |
Sends the "tcpip-forward" global request to ask the server to begin listening for inbound connections.
session | The ssh session to send the request. |
address | The address to bind to on the server. Pass NULL to bind to all available addresses on all protocol families supported by the server. |
port | The port to bind to on the server. Pass 0 to ask the server to allocate the next available unprivileged port number |
bound_port | The pointer to get actual bound port. Pass NULL to ignore. |
References buffer_free(), buffer_new(), string_free(), and string_from_char().
void channel_free | ( | ssh_channel | channel | ) |
Close and free a channel.
channel | The channel to free. |
References buffer_free(), and channel_close().
Referenced by ssh_free().
int channel_get_exit_status | ( | ssh_channel | channel | ) |
Get the exit status of the channel (error code from the executed instruction).
channel | The channel to get the status from. |
ssh_session channel_get_session | ( | ssh_channel | channel | ) |
Recover the session in which belongs a channel.
channel | The channel to recover the session from. |
int channel_is_closed | ( | ssh_channel | channel | ) |
Check if the channel is closed or not.
channel | The channel to check. |
int channel_is_eof | ( | ssh_channel | channel | ) |
Check if remote has sent an EOF.
channel | The channel to check. |
Referenced by ssh_scp_pull_request().
int channel_is_open | ( | ssh_channel | channel | ) |
Check if the channel is open or not.
channel | The channel to check. |
ssh_channel channel_new | ( | ssh_session | session | ) |
Allocate a new channel.
session | The ssh session to use. |
References buffer_free(), and buffer_new().
int channel_open_forward | ( | ssh_channel | channel, |
const char * | remotehost, | ||
int | remoteport, | ||
const char * | sourcehost, | ||
int | localport | ||
) |
Open a TCP/IP forwarding channel.
channel | An allocated channel. |
remotehost | The remote host to connected (host name or IP). |
remoteport | The remote port. |
sourcehost | The source host (your local computer). It's facultative and for logging purpose. |
localport | The source port (your local computer). It's facultative and for logging purpose. |
References buffer_free(), buffer_new(), string_free(), and string_from_char().
int channel_open_session | ( | ssh_channel | channel | ) |
Open a session channel (suited for a shell, not TCP forwarding).
channel | An allocated channel. |
int channel_poll | ( | ssh_channel | channel, |
int | is_stderr | ||
) |
Polls a channel for data to read.
channel | The channel to poll. |
is_stderr | A boolean to select the stderr stream. |
References ssh_handle_packets().
Referenced by channel_read_nonblocking(), ssh_scp_write(), and ssh_select().
int channel_read | ( | ssh_channel | channel, |
void * | dest, | ||
uint32_t | count, | ||
int | is_stderr | ||
) |
Reads data from a channel.
channel | The channel to read from. |
dest | The destination buffer which will get the data. |
count | The count of bytes to be read. |
is_stderr | A boolean value to mark reading from the stderr flow. |
References ssh_log(), and SSH_LOG_PROTOCOL.
Referenced by channel_read_nonblocking(), ssh_scp_leave_directory(), ssh_scp_push_directory(), ssh_scp_push_file(), ssh_scp_read(), ssh_scp_read_string(), and ssh_scp_response().
int channel_read_buffer | ( | ssh_channel | channel, |
ssh_buffer | buffer, | ||
uint32_t | count, | ||
int | is_stderr | ||
) |
Read data from a channel into a buffer.
channel | The channel to read from. |
buffer | The buffer which will get the data. |
count | The count of bytes to be read. If it is biggerthan 0, the exact size will be read, else (bytes=0) it will return once anything is available. |
is_stderr | A boolean value to mark reading from the stderr stream. |
References buffer_get_len(), ssh_log(), and SSH_LOG_PROTOCOL.
int channel_read_nonblocking | ( | ssh_channel | channel, |
void * | dest, | ||
uint32_t | count, | ||
int | is_stderr | ||
) |
Do a nonblocking read on the channel.
A nonblocking read on the specified channel. it will return <= count bytes of data read atomicly.
channel | The channel to read from. |
dest | A pointer to a destination buffer. |
count | The count of bytes of data to be read. |
is_stderr | A boolean to select the stderr stream. |
References channel_poll(), and channel_read().
int channel_request_env | ( | ssh_channel | channel, |
const char * | name, | ||
const char * | value | ||
) |
Set environement variables.
channel | The channel to set the environement variables. |
name | The name of the variable. |
value | The value to set. |
References buffer_free(), buffer_new(), string_free(), and string_from_char().
int channel_request_exec | ( | ssh_channel | channel, |
const char * | cmd | ||
) |
Run a shell command without an interactive shell.
This is similar to 'sh -c command'.
channel | The channel to execute the command. |
cmd | The command to execute (e.g. "ls ~/ -al | grep -i reports"). |
References buffer_free(), buffer_new(), string_free(), and string_from_char().
int channel_request_pty | ( | ssh_channel | channel | ) |
Request a PTY.
channel | The channel to send the request. |
References channel_request_pty_size().
int channel_request_pty_size | ( | ssh_channel | channel, |
const char * | terminal, | ||
int | col, | ||
int | row | ||
) |
Request a pty with a specific type and size.
channel | The channel to sent the request. |
terminal | The terminal type ("vt100, xterm,..."). |
col | The number of columns. |
row | The number of rows. |
References buffer_free(), buffer_new(), string_free(), and string_from_char().
Referenced by channel_request_pty().
int channel_request_send_signal | ( | ssh_channel | channel, |
const char * | signal | ||
) |
Send a signal to remote process (as described in RFC 4254, section 6.9).
Sends a signal 'signal' to the remote process. Note, that remote system may not support signals concept. In such a case this request will be silently ignored. Only SSH-v2 is supported (I'm not sure about SSH-v1).
channel | The channel to send signal. |
signal | The signal to send (without SIG prefix) (e.g. "TERM" or "KILL"). |
References buffer_free(), buffer_new(), string_free(), and string_from_char().
int channel_request_shell | ( | ssh_channel | channel | ) |
Request a shell.
channel | The channel to send the request. |
int channel_request_subsystem | ( | ssh_channel | channel, |
const char * | subsys | ||
) |
Request a subsystem (for example "sftp").
channel | The channel to send the request. |
subsys | The subsystem to request (for example "sftp"). |
References buffer_free(), buffer_new(), string_free(), and string_from_char().
int channel_request_x11 | ( | ssh_channel | channel, |
int | single_connection, | ||
const char * | protocol, | ||
const char * | cookie, | ||
int | screen_number | ||
) |
Sends the "x11-req" channel request over an existing session channel.
This will enable redirecting the display of the remote X11 applications to local X server over an secure tunnel.
channel | An existing session channel where the remote X11 applications are going to be executed. |
single_connection | A boolean to mark only one X11 app will be redirected. |
protocol | x11 authentication protocol. Pass NULL to use the default value MIT-MAGIC-COOKIE-1 |
cookie | x11 authentication cookie. Pass NULL to generate a random cookie. |
screen_number | Screen number. |
References buffer_free(), buffer_new(), string_free(), and string_from_char().
int channel_select | ( | ssh_channel * | readchans, |
ssh_channel * | writechans, | ||
ssh_channel * | exceptchans, | ||
struct timeval * | timeout | ||
) |
Act like the standard select(2) on channels.
The list of pointers are then actualized and will only contain pointers to channels that are respectively readable, writable or have an exception to trap.
readchans | A NULL pointer or an array of channel pointers, terminated by a NULL. |
writechans | A NULL pointer or an array of channel pointers, terminated by a NULL. |
exceptchans | A NULL pointer or an array of channel pointers, terminated by a NULL. |
timeout | Timeout as defined by select(2). |
int channel_send_eof | ( | ssh_channel | channel | ) |
Send an end of file on the channel.
This doesn't close the channel. You may still read from it but not write.
channel | The channel to send the eof to. |
References ssh_log(), and SSH_LOG_PACKET.
Referenced by channel_close().
void channel_set_blocking | ( | ssh_channel | channel, |
int | blocking | ||
) |
Put the channel into blocking or nonblocking mode.
channel | The channel to use. |
blocking | A boolean for blocking or nonblocking. |
int channel_write | ( | ssh_channel | channel, |
const void * | data, | ||
uint32_t | len | ||
) |
Blocking write on channel.
channel | The channel to write to. |
data | A pointer to the data to write. |
len | The length of the buffer to write to. |
Referenced by ssh_scp_accept_request(), ssh_scp_deny_request(), ssh_scp_leave_directory(), ssh_scp_pull_request(), ssh_scp_push_directory(), ssh_scp_push_file(), ssh_scp_read(), and ssh_scp_write().