diff options
author | Matt Johnston <matt@ucc.asn.au> | 2014-08-19 23:08:56 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2014-08-19 23:08:56 +0800 |
commit | 6d2d3669f39f12182b79a0067f477b58948897f6 (patch) | |
tree | 710285eb2899e8dc49108f0d690edceb811d0644 /common-channel.c | |
parent | 1387654cc8ac3f14b1c144f838fee5d0f51921c0 (diff) |
Make keepalive handling more robust, this should now match what OpenSSH does
Diffstat (limited to 'common-channel.c')
-rw-r--r-- | common-channel.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/common-channel.c b/common-channel.c index 63a42fb..049658d 100644 --- a/common-channel.c +++ b/common-channel.c @@ -627,7 +627,12 @@ void recv_msg_channel_request() { && !channel->close_handler_done) { channel->type->reqhandler(channel); } else { - send_msg_channel_failure(channel); + int wantreply; + buf_eatstring(ses.payload); + wantreply = buf_getbool(ses.payload); + if (wantreply) { + send_msg_channel_failure(channel); + } } TRACE(("leave recv_msg_channel_request")) @@ -1134,3 +1139,30 @@ void send_msg_request_failure() { buf_putbyte(ses.writepayload, SSH_MSG_REQUEST_FAILURE); encrypt_packet(); } + +struct Channel* get_any_ready_channel() { + if (ses.chancount == 0) { + return NULL; + } + size_t i; + for (i = 0; i < ses.chansize; i++) { + struct Channel *chan = ses.channels[i]; + if (chan + && !(chan->sent_eof || chan->recv_eof) + && !(chan->await_open || chan->initconn)) { + return chan; + } + } + return NULL; +} + +void start_send_channel_request(struct Channel *channel, + unsigned char *type) { + + CHECKCLEARTOWRITE(); + buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_REQUEST); + buf_putint(ses.writepayload, channel->remotechan); + + buf_putstring(ses.writepayload, type, strlen(type)); + +} |