mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 20:30:38 +09:00
channels: add ssh_channel_request_send_break to support RFC 4335
Signed-off-by: Axel Eppe <aeppe@google.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
6026fc8036
commit
fb2fefb3c6
@@ -418,6 +418,7 @@ LIBSSH_API int ssh_channel_request_pty_size(ssh_channel channel, const char *ter
|
||||
int cols, int rows);
|
||||
LIBSSH_API int ssh_channel_request_shell(ssh_channel channel);
|
||||
LIBSSH_API int ssh_channel_request_send_signal(ssh_channel channel, const char *signum);
|
||||
LIBSSH_API int ssh_channel_request_send_break(ssh_channel channel, uint32_t length);
|
||||
LIBSSH_API int ssh_channel_request_sftp(ssh_channel channel);
|
||||
LIBSSH_API int ssh_channel_request_subsystem(ssh_channel channel, const char *subsystem);
|
||||
LIBSSH_API int ssh_channel_request_x11(ssh_channel channel, int single_connection, const char *protocol,
|
||||
|
||||
@@ -2528,6 +2528,55 @@ error:
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Send a break signal to the server (as described in RFC 4335).
|
||||
*
|
||||
* Sends a break signal to the remote process.
|
||||
* Note, that remote system may not support breaks.
|
||||
* In such a case this request will be silently ignored.
|
||||
* Only SSH-v2 is supported.
|
||||
*
|
||||
* @param[in] channel The channel to send the break to.
|
||||
*
|
||||
* @param[in] length The break-length in milliseconds to send.
|
||||
*
|
||||
* @return SSH_OK on success, SSH_ERROR if an error occurred
|
||||
* (including attempts to send signal via SSH-v1 session).
|
||||
*/
|
||||
int ssh_channel_request_send_break(ssh_channel channel, uint32_t length) {
|
||||
ssh_buffer buffer = NULL;
|
||||
int rc = SSH_ERROR;
|
||||
|
||||
if (channel == NULL) {
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
#ifdef WITH_SSH1
|
||||
if (channel->version == 1) {
|
||||
return SSH_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
buffer = ssh_buffer_new();
|
||||
if (buffer == NULL) {
|
||||
ssh_set_error_oom(channel->session);
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = ssh_buffer_pack(buffer, "d", length);
|
||||
if (rc != SSH_OK) {
|
||||
ssh_set_error_oom(channel->session);
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = channel_request(channel, "break", buffer, 0);
|
||||
|
||||
error:
|
||||
ssh_buffer_free(buffer);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read data from a channel into a buffer.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user