Reformat channel_open()

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
This commit is contained in:
Jakub Jelen
2019-09-17 15:58:07 +02:00
parent 3cf2b41f5e
commit 89a9eb8811

View File

@@ -277,8 +277,13 @@ static int ssh_channel_open_termination(void *c){
*
* @return SSH_OK if successful; SSH_ERROR otherwise.
*/
static int channel_open(ssh_channel channel, const char *type, int window,
int maxpacket, ssh_buffer payload) {
static int
channel_open(ssh_channel channel,
const char *type,
int window,
int maxpacket,
ssh_buffer payload)
{
ssh_session session = channel->session;
int err = SSH_ERROR;
int rc;
@@ -293,8 +298,10 @@ static int channel_open(ssh_channel channel, const char *type, int window,
case SSH_CHANNEL_STATE_OPEN_DENIED:
goto end;
default:
ssh_set_error(session,SSH_FATAL,"Bad state in channel_open: %d",channel->state);
ssh_set_error(session, SSH_FATAL, "Bad state in channel_open: %d",
channel->state);
}
channel->local_channel = ssh_channel_new_id(session);
channel->local_maxpacket = maxpacket;
channel->local_window = window;
@@ -324,13 +331,13 @@ static int channel_open(ssh_channel channel, const char *type, int window,
}
channel->state = SSH_CHANNEL_STATE_OPENING;
if (ssh_packet_send(session) == SSH_ERROR) {
return err;
}
SSH_LOG(SSH_LOG_PACKET,
"Sent a SSH_MSG_CHANNEL_OPEN type %s for channel %d",
type, channel->local_channel);
pending:
/* wait until channel is opened by server */
err = ssh_handle_packets_termination(session,
@@ -338,11 +345,14 @@ pending:
ssh_channel_open_termination,
channel);
if (session->session_state == SSH_SESSION_STATE_ERROR)
if (session->session_state == SSH_SESSION_STATE_ERROR) {
err = SSH_ERROR;
}
end:
if(channel->state == SSH_CHANNEL_STATE_OPEN)
if (channel->state == SSH_CHANNEL_STATE_OPEN) {
err = SSH_OK;
}
return err;
}