diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-07-18 00:39:51 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-07-18 00:39:51 +0200 |
commit | a9248690961b96aafb9065916f4263ff6ba48c0c (patch) | |
tree | 984cfc4a48d11245c79f1fcca39f8aafbe8b3e20 | |
parent | 8c08b062d0a1bebd7b9397036ea1b11b51577647 (diff) | |
download | libssh-a9248690961b96aafb9065916f4263ff6ba48c0c.tar.gz libssh-a9248690961b96aafb9065916f4263ff6ba48c0c.tar.xz libssh-a9248690961b96aafb9065916f4263ff6ba48c0c.zip |
Receive and send SSH_MSG_UNIMPLEMENTED
-rw-r--r-- | include/libssh/packet.h | 2 | ||||
-rw-r--r-- | libssh/packet.c | 36 |
2 files changed, 36 insertions, 2 deletions
diff --git a/include/libssh/packet.h b/include/libssh/packet.h index 7a78f646..06566f71 100644 --- a/include/libssh/packet.h +++ b/include/libssh/packet.h @@ -53,6 +53,8 @@ int ssh_packet_socket_callback1(const void *data, size_t receivedlen, void *user #endif +SSH_PACKET_CALLBACK(ssh_packet_unimplemented); +int ssh_packet_send_unimplemented(ssh_session session, uint32_t seqnum); int ssh_packet_parse_type(ssh_session session); int packet_flush(ssh_session session, int enforce_blocking); diff --git a/libssh/packet.c b/libssh/packet.c index b0ae1458..a2a78378 100644 --- a/libssh/packet.c +++ b/libssh/packet.c @@ -49,7 +49,7 @@ ssh_packet_callback default_packet_handlers[]= { ssh_packet_disconnect_callback, // SSH2_MSG_DISCONNECT 1 ssh_packet_ignore_callback, // SSH2_MSG_IGNORE 2 - NULL, // SSH2_MSG_UNIMPLEMENTED 3 + ssh_packet_unimplemented, // SSH2_MSG_UNIMPLEMENTED 3 ssh_packet_ignore_callback, // SSH2_MSG_DEBUG 4 ssh_packet_service_request, // SSH2_MSG_SERVICE_REQUEST 5 ssh_packet_service_accept, // SSH2_MSG_SERVICE_ACCEPT 6 @@ -355,13 +355,45 @@ void ssh_packet_process(ssh_session session, uint8_t type){ if(r==SSH_PACKET_USED) break; } - if(r==SSH_PACKET_NOT_USED) + if(r==SSH_PACKET_NOT_USED){ ssh_log(session,SSH_LOG_RARE,"Couldn't do anything with packet type %d",type); + ssh_packet_send_unimplemented(session, session->recv_seq-1); + } error: leave_function(); } /** @internal + * @brief sends a SSH_MSG_UNIMPLEMENTED answer to an unhandled packet + * @param session the SSH session + * @param seqnum the sequence number of the unknown packet + * @return SSH_ERROR on error, else SSH_OK + */ +int ssh_packet_send_unimplemented(ssh_session session, uint32_t seqnum){ + int r; + enter_function(); + buffer_add_u8(session->out_buffer, SSH2_MSG_UNIMPLEMENTED); + buffer_add_u32(session->out_buffer, htonl(seqnum)); + r = packet_send(session); + leave_function(); + return r; +} + +/** @internal + * @brief handles a SSH_MSG_UNIMPLEMENTED packet + */ +SSH_PACKET_CALLBACK(ssh_packet_unimplemented){ + uint32_t seq; + (void)type; + (void)user; + buffer_get_u32(packet,&seq); + seq=ntohl(seq); + ssh_log(session,SSH_LOG_RARE, + "Received SSH_MSG_UNIMPLEMENTED (sequence number %d)",seq); + return SSH_PACKET_USED; +} + +/** @internal * @parse the "Type" header field of a packet and updates the session */ int ssh_packet_parse_type(ssh_session session) { |