Functions | |
int | channel_change_pty_size (CHANNEL *channel, int cols, int rows) |
change the size of the terminal associated to a channel | |
int | channel_close (CHANNEL *channel) |
close a channel | |
void | channel_free (CHANNEL *channel) |
close and free a channel | |
SSH_SESSION * | channel_get_session (CHANNEL *channel) |
recover the session in which belong a channel | |
int | channel_is_closed (CHANNEL *channel) |
returns if the channel is closed or not | |
int | channel_is_eof (CHANNEL *channel) |
returns if the remote has sent an EOF | |
int | channel_is_open (CHANNEL *channel) |
returns if the channel is open or not | |
CHANNEL * | channel_new (SSH_SESSION *session) |
allocate a new channel | |
int | channel_open_forward (CHANNEL *channel, char *remotehost, int remoteport, char *sourcehost, int localport) |
open a TCP/IP forwarding channel. | |
int | channel_open_session (CHANNEL *channel) |
open a session channel (suited for a shell. Not tcp) | |
int | channel_poll (CHANNEL *channel, int is_stderr) |
polls the channel for data to read | |
int | channel_read (CHANNEL *channel, BUFFER *buffer, int bytes, int is_stderr) |
reads data from a channel | |
int | channel_read_nonblocking (CHANNEL *channel, char *dest, int len, int is_stderr) |
nonblocking read | |
int | channel_request_env (CHANNEL *channel, char *name, char *value) |
set the environement variables | |
int | channel_request_exec (CHANNEL *channel, char *cmd) |
run a shell command without an interactive shell | |
int | channel_request_pty (CHANNEL *channel) |
requests a pty | |
int | channel_request_pty_size (CHANNEL *channel, char *terminal, int col, int row) |
requests a pty with a specific type and size | |
int | channel_request_shell (CHANNEL *channel) |
requests a shell | |
int | channel_request_subsystem (CHANNEL *channel, char *system) |
requests a subsystem (for example sftp) | |
int | channel_select (CHANNEL **readchans, CHANNEL **writechans, CHANNEL **exceptchans, struct timeval *timeout) |
act as the standard select(2) for channels | |
int | channel_send_eof (CHANNEL *channel) |
send an end of file on the channel | |
void | channel_set_blocking (CHANNEL *channel, int blocking) |
put the channel into nonblocking mode | |
int | channel_write (CHANNEL *channel, void *data, int len) |
blocking write on channel |
defgroup ssh_channel
int channel_change_pty_size | ( | CHANNEL * | channel, | |
int | cols, | |||
int | rows | |||
) |
change the size of the terminal associated to a channel
channel | channel | |
cols | new number of cols | |
rows | new number of rows |
int channel_close | ( | CHANNEL * | channel | ) |
close a channel
It 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 | channel |
channel_eof()
void channel_free | ( | CHANNEL * | channel | ) |
close and free a channel
channel | channel to free |
SSH_SESSION* channel_get_session | ( | CHANNEL * | channel | ) |
recover the session in which belong a channel
channel | channel |
int channel_is_closed | ( | CHANNEL * | channel | ) |
returns if the channel is closed or not
channel | channel |
int channel_is_eof | ( | CHANNEL * | channel | ) |
returns if the remote has sent an EOF
channel | channel |
int channel_is_open | ( | CHANNEL * | channel | ) |
returns if the channel is open or not
channel | channel |
CHANNEL* channel_new | ( | SSH_SESSION * | session | ) |
allocate a new channel
session | ssh session |
int channel_open_forward | ( | CHANNEL * | channel, | |
char * | remotehost, | |||
int | remoteport, | |||
char * | sourcehost, | |||
int | localport | |||
) |
open a TCP/IP forwarding channel.
channel | an allocated channel (see channel_new()) | |
remotehost | remote host to be connected (host name or IP) | |
remoteport | remote port | |
sourcehost | source host (your local computer). It's facultative and for logging purpose | |
localport | source port (your local computer). It's facultative and for logging purpose |
int channel_open_session | ( | CHANNEL * | channel | ) |
open a session channel (suited for a shell. Not tcp)
channel | an allocated channel (see channel_new()) |
int channel_poll | ( | CHANNEL * | channel, | |
int | is_stderr | |||
) |
polls the channel for data to read
channel | channel | |
is_stderr | boolean to select the stderr stream |
int channel_read | ( | CHANNEL * | channel, | |
BUFFER * | buffer, | |||
int | bytes, | |||
int | is_stderr | |||
) |
reads data from a channel
channel | channel | |
buffer | buffer which will get the data | |
bytes | number of bytes to be read. If it is bigger than 0, the exact size will be read, else (bytes=0) it will return once anything is available | |
is_stderr | boolean value to mark reading from the stderr flow. |
int channel_read_nonblocking | ( | CHANNEL * | channel, | |
char * | dest, | |||
int | len, | |||
int | is_stderr | |||
) |
nonblocking read
This read will make a nonblocking read (unlike channel_read()) and won't force you to deal with BUFFER's
channel | channel | |
dest | pointer to destination for data | |
len | maximum length of data to be read | |
is_stderr | boolean to select the stderr stream |
int channel_request_env | ( | CHANNEL * | channel, | |
char * | name, | |||
char * | value | |||
) |
set the environement variables
channel | channel | |
name | name of the variable | |
value | value |
int channel_request_exec | ( | CHANNEL * | channel, | |
char * | cmd | |||
) |
run a shell command without an interactive shell
it's similar to sh -c "command"
channel | channel | |
cmd | command to execute (by ex. "ls ~/ -al | grep -i reports") |
int channel_request_pty | ( | CHANNEL * | channel | ) |
requests a pty
channel | channel |
int channel_request_pty_size | ( | CHANNEL * | channel, | |
char * | terminal, | |||
int | col, | |||
int | row | |||
) |
requests a pty with a specific type and size
channel | channel | |
terminal | terminal type ("vt100, xterm,...") | |
col | number of cols | |
row | number of rows |
int channel_request_shell | ( | CHANNEL * | channel | ) |
requests a shell
channel |
int channel_request_subsystem | ( | CHANNEL * | channel, | |
char * | system | |||
) |
requests a subsystem (for example sftp)
channel | channel | |
system | subsystem to request (for example sftp) |
int channel_select | ( | CHANNEL ** | readchans, | |
CHANNEL ** | writechans, | |||
CHANNEL ** | exceptchans, | |||
struct timeval * | timeout | |||
) |
act as the standard select(2) for 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, finished by a NULL | |
writechans | a NULL pointer or an array of channel pointers, finished by a NULL | |
exceptchans | a NULL pointer or an array of channel pointers, finished by a NULL | |
timeout | timeout as defined by select(2) |
int channel_send_eof | ( | CHANNEL * | channel | ) |
send an end of file on the channel
it doesn't close the channel. You may still read from it but not write.
channel | channel |
void channel_set_blocking | ( | CHANNEL * | channel, | |
int | blocking | |||
) |
put the channel into nonblocking mode
channel | channel | |
blocking | boolean for blocking or nonblocking |
int channel_write | ( | CHANNEL * | channel, | |
void * | data, | |||
int | len | |||
) |
blocking write on channel
channel | channel | |
data | pointer to data to write | |
len | length of data |