mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-12 11:10:28 +09:00
Respond to keepalives/global requests
This commit is contained in:
@@ -118,5 +118,5 @@ struct ssh_session_struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int ssh_handle_packets(ssh_session session);
|
int ssh_handle_packets(ssh_session session);
|
||||||
|
void ssh_global_request_handle(ssh_session session);
|
||||||
#endif /* SESSION_H_ */
|
#endif /* SESSION_H_ */
|
||||||
|
|||||||
@@ -693,6 +693,9 @@ void packet_parse(ssh_session session) {
|
|||||||
case SSH2_MSG_CHANNEL_OPEN:
|
case SSH2_MSG_CHANNEL_OPEN:
|
||||||
message_handle(session,type);
|
message_handle(session,type);
|
||||||
return;
|
return;
|
||||||
|
case SSH2_MSG_GLOBAL_REQUEST:
|
||||||
|
ssh_global_request_handle(session);
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
ssh_log(session, SSH_LOG_RARE, "Received unhandled packet %d", type);
|
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");
|
ssh_log(session, SSH_LOG_PACKET, "received disconnect packet");
|
||||||
leave_function();
|
leave_function();
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
|
case SSH2_MSG_GLOBAL_REQUEST:
|
||||||
case SSH2_MSG_CHANNEL_WINDOW_ADJUST:
|
case SSH2_MSG_CHANNEL_WINDOW_ADJUST:
|
||||||
case SSH2_MSG_CHANNEL_DATA:
|
case SSH2_MSG_CHANNEL_DATA:
|
||||||
case SSH2_MSG_CHANNEL_EXTENDED_DATA:
|
case SSH2_MSG_CHANNEL_EXTENDED_DATA:
|
||||||
|
|||||||
@@ -32,7 +32,8 @@
|
|||||||
#include "libssh/packet.h"
|
#include "libssh/packet.h"
|
||||||
#include "libssh/session.h"
|
#include "libssh/session.h"
|
||||||
#include "libssh/misc.h"
|
#include "libssh/misc.h"
|
||||||
|
#include "libssh/ssh2.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
#define FIRST_CHANNEL 42 // why not ? it helps to find bugs.
|
#define FIRST_CHANNEL 42 // why not ? it helps to find bugs.
|
||||||
|
|
||||||
/** \defgroup ssh_session SSH Session
|
/** \defgroup ssh_session SSH Session
|
||||||
@@ -409,5 +410,32 @@ int ssh_get_version(ssh_session session) {
|
|||||||
return session->version;
|
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: */
|
/* vim: set ts=2 sw=2 et cindent: */
|
||||||
|
|||||||
Reference in New Issue
Block a user