Ticket #65 (closed defect)

Opened 9 years ago

Last modified 8 years ago

Response to keepalive@openssh.com

Reported by: anonymous Owned by:
Priority: normal Milestone:
Component: Version:
Keywords: Cc: bagder
Blocked By: Blocks:

Description

Version 0.18 does not response to keepalive@… message. Here is some code you could add to make it work. (based on what PuTTY does...)

case SSH_MSG_CHANNEL_REQUEST:

{

if (libssh2_ntohu32(data + 5) == sizeof("exit-status") - 1

&& !memcmp("exit-status", data + 9,
sizeof("exit-status") - 1)) {

/* we've got "exit-status" packet. Set the session value */
session->packAdd_channel =

libssh2_channel_locate(session,
libssh2_ntohu32(data + 1));

if (session->packAdd_channel) {

session->packAdd_channel->exit_status =

libssh2_ntohu32(data + 9 + sizeof("exit-status"));

_libssh2_debug(session, LIBSSH2_DBG_CONN,

"Exit status %lu received for channel %lu/%lu",
session->packAdd_channel->exit_status,
session->packAdd_channel->local.id,
session->packAdd_channel->remote.id);

}

LIBSSH2_FREE(session, data);
session->packAdd_state = libssh2_NB_state_idle;
return 0;

}
else if(libssh2_ntohu32(data+5) == sizeof("keepalive@…")-1 &&

!memcmp("keepalive@…", data+9, sizeof("keepalive@…")-1))

{

libssh2_channel_send_keepalive(session->packAdd_channel);
LIBSSH2_FREE(session, data);
session->packAdd_state = libssh2_NB_state_idle;
return 0;

}

}
break;

LIBSSH2_API int
libssh2_channel_send_keepalive(LIBSSH2_CHANNEL * channel)
{

LIBSSH2_SESSION *session = channel->session;
unsigned char packet[5]; /* packet_type(1) + channelno(4) */
int rc;
_libssh2_debug(session, LIBSSH2_DBG_CONN, "Sending Keepalive on channel %lu/%lu",

channel->local.id, channel->remote.id);

packet[0] = SSH_MSG_CHANNEL_FAILURE;
libssh2_htonu32(packet + 1, channel->remote.id);
rc = libssh2_packet_write(session, packet, 5);
if (rc == PACKET_EAGAIN) {

return PACKET_EAGAIN;

} else if (rc) {

libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,

"Unable to send Keepalive on channel", 0);

return -1;

}
channel->local.eof = 1;
return 0;

}

Change History

comment:1 Changed 8 years ago by bagder

Please make a patch with 'diff -u' and submit it here and we can use it for inclusion!

comment:2 Changed 8 years ago by sf-robot

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).

Note: See TracTickets for help on using tickets.