Mercurial > dropbear
comparison common-channel.c @ 970:0bb16232e7c4
Make keepalive handling more robust, this should now match what OpenSSH does
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 19 Aug 2014 23:08:56 +0800 |
parents | 36eacc322e00 |
children | 02baa0b334e8 d3925ed45a85 |
comparison
equal
deleted
inserted
replaced
969:939944f0fca9 | 970:0bb16232e7c4 |
---|---|
625 | 625 |
626 if (channel->type->reqhandler | 626 if (channel->type->reqhandler |
627 && !channel->close_handler_done) { | 627 && !channel->close_handler_done) { |
628 channel->type->reqhandler(channel); | 628 channel->type->reqhandler(channel); |
629 } else { | 629 } else { |
630 send_msg_channel_failure(channel); | 630 int wantreply; |
631 buf_eatstring(ses.payload); | |
632 wantreply = buf_getbool(ses.payload); | |
633 if (wantreply) { | |
634 send_msg_channel_failure(channel); | |
635 } | |
631 } | 636 } |
632 | 637 |
633 TRACE(("leave recv_msg_channel_request")) | 638 TRACE(("leave recv_msg_channel_request")) |
634 | 639 |
635 } | 640 } |
1132 void send_msg_request_failure() { | 1137 void send_msg_request_failure() { |
1133 CHECKCLEARTOWRITE(); | 1138 CHECKCLEARTOWRITE(); |
1134 buf_putbyte(ses.writepayload, SSH_MSG_REQUEST_FAILURE); | 1139 buf_putbyte(ses.writepayload, SSH_MSG_REQUEST_FAILURE); |
1135 encrypt_packet(); | 1140 encrypt_packet(); |
1136 } | 1141 } |
1142 | |
1143 struct Channel* get_any_ready_channel() { | |
1144 if (ses.chancount == 0) { | |
1145 return NULL; | |
1146 } | |
1147 size_t i; | |
1148 for (i = 0; i < ses.chansize; i++) { | |
1149 struct Channel *chan = ses.channels[i]; | |
1150 if (chan | |
1151 && !(chan->sent_eof || chan->recv_eof) | |
1152 && !(chan->await_open || chan->initconn)) { | |
1153 return chan; | |
1154 } | |
1155 } | |
1156 return NULL; | |
1157 } | |
1158 | |
1159 void start_send_channel_request(struct Channel *channel, | |
1160 unsigned char *type) { | |
1161 | |
1162 CHECKCLEARTOWRITE(); | |
1163 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_REQUEST); | |
1164 buf_putint(ses.writepayload, channel->remotechan); | |
1165 | |
1166 buf_putstring(ses.writepayload, type, strlen(type)); | |
1167 | |
1168 } |