diff --git a/include/libssh/channels.h b/include/libssh/channels.h index 19d29607..343aa7f7 100644 --- a/include/libssh/channels.h +++ b/include/libssh/channels.h @@ -98,5 +98,9 @@ int ssh_channel_flush(ssh_channel channel); uint32_t ssh_channel_new_id(ssh_session session); ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id); void ssh_channel_do_free(ssh_channel channel); +int ssh_global_request(ssh_session session, + const char *request, + ssh_buffer buffer, + int reply); #endif /* CHANNELS_H_ */ diff --git a/src/channels.c b/src/channels.c index f031b021..0dfa946d 100644 --- a/src/channels.c +++ b/src/channels.c @@ -2090,8 +2090,11 @@ static int ssh_global_request_termination(void *s){ * SSH_AGAIN if in nonblocking mode and call has * to be done again. */ -static int global_request(ssh_session session, const char *request, - ssh_buffer buffer, int reply) { +int ssh_global_request(ssh_session session, + const char *request, + ssh_buffer buffer, + int reply) +{ int rc; switch (session->global_req_state) { @@ -2222,7 +2225,7 @@ int ssh_channel_listen_forward(ssh_session session, goto error; } pending: - rc = global_request(session, "tcpip-forward", buffer, 1); + rc = ssh_global_request(session, "tcpip-forward", buffer, 1); /* TODO: FIXME no guarantee the last packet we received contains * that info */ @@ -2302,7 +2305,7 @@ int ssh_channel_cancel_forward(ssh_session session, goto error; } pending: - rc = global_request(session, "cancel-tcpip-forward", buffer, 1); + rc = ssh_global_request(session, "cancel-tcpip-forward", buffer, 1); error: ssh_buffer_free(buffer); diff --git a/src/server.c b/src/server.c index 84cc4f7a..b998c9cb 100644 --- a/src/server.c +++ b/src/server.c @@ -1253,30 +1253,10 @@ int ssh_execute_message_callbacks(ssh_session session){ int ssh_send_keepalive(ssh_session session) { - int rc; + /* Client denies the request, so the error code is not meaningful */ + (void)ssh_global_request(session, "keepalive@openssh.com", NULL, 1); - rc = ssh_buffer_pack(session->out_buffer, - "bsb", - SSH2_MSG_GLOBAL_REQUEST, - "keepalive@openssh.com", - 1); - if (rc != SSH_OK) { - goto err; - } - - if (ssh_packet_send(session) == SSH_ERROR) { - goto err; - } - - ssh_handle_packets(session, SSH_TIMEOUT_NONBLOCKING); - - SSH_LOG(SSH_LOG_PACKET, "Sent a keepalive"); - return SSH_OK; - -err: - ssh_set_error_oom(session); - ssh_buffer_reinit(session->out_buffer); - return SSH_ERROR; + return SSH_OK; } /** @} */