mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 02:38:09 +09:00
Begin of asynchronous SSH message parsing
This commit is contained in:
@@ -722,6 +722,10 @@ int ssh_handle_packets(SSH_SESSION *session);
|
|||||||
/* match.c */
|
/* match.c */
|
||||||
int match_hostname(const char *host, const char *pattern, unsigned int len);
|
int match_hostname(const char *host, const char *pattern, unsigned int len);
|
||||||
|
|
||||||
|
/* messages.c */
|
||||||
|
|
||||||
|
void message_handle(SSH_SESSION *session, u32 type);
|
||||||
|
|
||||||
/* log.c */
|
/* log.c */
|
||||||
|
|
||||||
#define _enter_function(sess) \
|
#define _enter_function(sess) \
|
||||||
|
|||||||
@@ -542,6 +542,8 @@ static void channel_rcv_request(SSH_SESSION *session) {
|
|||||||
leave_function();
|
leave_function();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/* TODO call message_handle since it handles channel requests as messages */
|
||||||
|
/* *but* reset buffer before !! */
|
||||||
ssh_log(session, SSH_LOG_PACKET, "Unknown request %s", request);
|
ssh_log(session, SSH_LOG_PACKET, "Unknown request %s", request);
|
||||||
SAFE_FREE(request);
|
SAFE_FREE(request);
|
||||||
|
|
||||||
|
|||||||
@@ -806,6 +806,18 @@ void ssh_message_free(SSH_MESSAGE *msg){
|
|||||||
SAFE_FREE(msg);
|
SAFE_FREE(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** \internal
|
||||||
|
* \brief handle various SSH request messages and stack them for callback
|
||||||
|
* \param session SSH session
|
||||||
|
* \param type packet type
|
||||||
|
* \returns nothing
|
||||||
|
*/
|
||||||
|
void message_handle(SSH_SESSION *session, u32 type){
|
||||||
|
SSH_MESSAGE *msg=ssh_message_retrieve(session,type);
|
||||||
|
if(msg){
|
||||||
|
/* TODO store msg somewhere */
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -594,7 +594,7 @@ int packet_send(SSH_SESSION *session) {
|
|||||||
void packet_parse(SSH_SESSION *session) {
|
void packet_parse(SSH_SESSION *session) {
|
||||||
STRING *error_s = NULL;
|
STRING *error_s = NULL;
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
int type = session->in_packet.type;
|
u32 type = session->in_packet.type;
|
||||||
u32 tmp;
|
u32 tmp;
|
||||||
|
|
||||||
#ifdef HAVE_SSH1
|
#ifdef HAVE_SSH1
|
||||||
@@ -652,9 +652,15 @@ void packet_parse(SSH_SESSION *session) {
|
|||||||
case SSH2_MSG_CHANNEL_EOF:
|
case SSH2_MSG_CHANNEL_EOF:
|
||||||
case SSH2_MSG_CHANNEL_CLOSE:
|
case SSH2_MSG_CHANNEL_CLOSE:
|
||||||
channel_handle(session,type);
|
channel_handle(session,type);
|
||||||
|
return;
|
||||||
case SSH2_MSG_IGNORE:
|
case SSH2_MSG_IGNORE:
|
||||||
case SSH2_MSG_DEBUG:
|
case SSH2_MSG_DEBUG:
|
||||||
return;
|
return;
|
||||||
|
case SSH2_MSG_SERVICE_REQUEST:
|
||||||
|
case SSH2_MSG_USERAUTH_REQUEST:
|
||||||
|
case SSH2_MSG_CHANNEL_OPEN:
|
||||||
|
message_handle(session,type);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user