aboutsummaryrefslogtreecommitdiff
path: root/libssh
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-07-18 00:39:51 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-07-18 00:39:51 +0200
commita9248690961b96aafb9065916f4263ff6ba48c0c (patch)
tree984cfc4a48d11245c79f1fcca39f8aafbe8b3e20 /libssh
parent8c08b062d0a1bebd7b9397036ea1b11b51577647 (diff)
downloadlibssh-a9248690961b96aafb9065916f4263ff6ba48c0c.tar.gz
libssh-a9248690961b96aafb9065916f4263ff6ba48c0c.tar.xz
libssh-a9248690961b96aafb9065916f4263ff6ba48c0c.zip
Receive and send SSH_MSG_UNIMPLEMENTED
Diffstat (limited to 'libssh')
-rw-r--r--libssh/packet.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/libssh/packet.c b/libssh/packet.c
index b0ae145..a2a7837 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) {