From 0b9804a95b95ccc5056359cbd58d423d497f5eae Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Mon, 14 Mar 2016 22:28:03 +0100 Subject: [PATCH] server: handle keepalive@openssh.com global requests --- include/libssh/libssh.h | 1 + src/messages.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 0cd4bdc3..6d45e4df 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -208,6 +208,7 @@ enum ssh_global_requests_e { SSH_GLOBAL_REQUEST_UNKNOWN=0, SSH_GLOBAL_REQUEST_TCPIP_FORWARD, SSH_GLOBAL_REQUEST_CANCEL_TCPIP_FORWARD, + SSH_GLOBAL_REQUEST_KEEPALIVE }; enum ssh_publickey_state_e { diff --git a/src/messages.c b/src/messages.c index 131eacde..0e2b781a 100644 --- a/src/messages.c +++ b/src/messages.c @@ -1396,6 +1396,15 @@ SSH_PACKET_CALLBACK(ssh_packet_global_request){ } else { ssh_message_reply_default(msg); } + } else if(strcmp(request, "keepalive@openssh.com") == 0) { + msg->global_request.type = SSH_GLOBAL_REQUEST_KEEPALIVE; + msg->global_request.want_reply = want_reply; + SSH_LOG(SSH_LOG_PROTOCOL, "Received keepalive@openssh.com %d", want_reply); + if(ssh_callbacks_exists(session->common.callbacks, global_request_function)) { + session->common.callbacks->global_request_function(session, msg, session->common.callbacks->userdata); + } else { + ssh_message_global_request_reply_success(msg, 0); + } } else { SSH_LOG(SSH_LOG_PROTOCOL, "UNKNOWN SSH_MSG_GLOBAL_REQUEST %s %d", request, want_reply); rc = SSH_PACKET_NOT_USED;