summaryrefslogtreecommitdiffstats
path: root/libssh
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-05-12 21:58:09 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-05-12 21:58:09 +0200
commite94bff02ba513628088fd112c5c7cbd9f9a4a57f (patch)
treea2de174f644a33579aed2f2ab89b3261ab9c6610 /libssh
parent3671c610235a94a2a799650662cbef0234d0b7c2 (diff)
Respond to keepalives/global requests
Diffstat (limited to 'libssh')
-rw-r--r--libssh/packet.c4
-rw-r--r--libssh/session.c30
2 files changed, 33 insertions, 1 deletions
diff --git a/libssh/packet.c b/libssh/packet.c
index 84c6466a..3e0575f7 100644
--- a/libssh/packet.c
+++ b/libssh/packet.c
@@ -693,6 +693,9 @@ void packet_parse(ssh_session session) {
case SSH2_MSG_CHANNEL_OPEN:
message_handle(session,type);
return;
+ case SSH2_MSG_GLOBAL_REQUEST:
+ ssh_global_request_handle(session);
+ return;
default:
ssh_log(session, SSH_LOG_RARE, "Received unhandled packet %d", type);
}
@@ -779,6 +782,7 @@ static int packet_wait2(ssh_session session, int type, int blocking) {
ssh_log(session, SSH_LOG_PACKET, "received disconnect packet");
leave_function();
return SSH_ERROR;
+ case SSH2_MSG_GLOBAL_REQUEST:
case SSH2_MSG_CHANNEL_WINDOW_ADJUST:
case SSH2_MSG_CHANNEL_DATA:
case SSH2_MSG_CHANNEL_EXTENDED_DATA:
diff --git a/libssh/session.c b/libssh/session.c
index 57a3e80f..d6d232a2 100644
--- a/libssh/session.c
+++ b/libssh/session.c
@@ -32,7 +32,8 @@
#include "libssh/packet.h"
#include "libssh/session.h"
#include "libssh/misc.h"
-
+#include "libssh/ssh2.h"
+#include "libssh/buffer.h"
#define FIRST_CHANNEL 42 // why not ? it helps to find bugs.
/** \defgroup ssh_session SSH Session
@@ -409,5 +410,32 @@ int ssh_get_version(ssh_session session) {
return session->version;
}
+
+/**
+ * @internal
+ * @handle a SSH_MSG_GLOBAL_REQUEST packet
+ * @param session the SSH session
+ */
+void ssh_global_request_handle(ssh_session session){
+ ssh_string type;
+ char *type_c;
+ uint32_t needreply;
+ type=buffer_get_ssh_string(session->in_buffer);
+ buffer_get_u32(session->in_buffer,&needreply);
+ if(type==NULL)
+ return;
+ type_c=string_to_char(type);
+ if(!type_c)
+ return;
+ ssh_log(session, SSH_LOG_PROTOCOL,
+ "Received SSH_GLOBAL_REQUEST %s (wantreply=%d)",type_c,needreply);
+ SAFE_FREE(type_c);
+ string_free(type);
+ if(needreply != 0){
+ buffer_add_u8(session->out_buffer,SSH2_MSG_REQUEST_FAILURE);
+ packet_send(session);
+ }
+}
+
/** @} */
/* vim: set ts=2 sw=2 et cindent: */