Commit 7adbd3c6 authored by Niels Möller's avatar Niels Möller
Browse files

* src/channel_commands.h (channel_open_command): Added

local_channel_number argument to NEW_CHANNEL.

* src/channel_commands.c (do_channel_open_command): Call
alloc_channel() and register_channel(), rather than delegating it
to the NEW_CHANNEL method. Set the channel's exception handler
properly.

Rev: src/channel_commands.c:1.18
Rev: src/channel_commands.h:1.13
parent fd6ea746
......@@ -44,21 +44,35 @@ void do_channel_open_command(struct command *s,
CAST_SUBTYPE(channel_open_command, self, s);
CAST(ssh_connection, connection, x);
struct lsh_string *request;
struct ssh_channel *channel = NEW_CHANNEL(self, connection, &request);
struct ssh_channel *channel;
if (!channel)
int index = alloc_channel(connection->table);
if (index < 0)
{
/* Probably, we have run out of channel numbers. */
werror("do_channel_open_command: NEW_CHANNEL failed\n");
/* We have run out of channel numbers. */
werror("do_channel_open_command: alloc_channel() failed\n");
EXCEPTION_RAISE(e,
make_channel_open_exception(
SSH_OPEN_RESOURCE_SHORTAGE,
"Allocating a local channel number failed."));
}
channel = NEW_CHANNEL(self, connection, index, &request);
if (!channel)
{
werror("do_channel_open_command: NEW_CHANNEL failed\n");
dealloc_channel(connection->table, index);
}
else
{
/* FIXME: Set up channel->write here? If we do that, perhaps we
* need not pass the connection to NEW_CHANNEL. */
channel->open_continuation = c;
channel->e = e;
register_channel(connection, index, channel, 0);
C_WRITE(connection, request);
}
}
......
......@@ -44,10 +44,11 @@
;; prepare_channel_open.
(new_channel method "struct ssh_channel *"
"struct ssh_connection *connection"
"UINT32 local_channel_number"
"struct lsh_string **request")))
*/
#define NEW_CHANNEL(s, c,r) ((s)->new_channel((s), (c), (r)))
#define NEW_CHANNEL(s, c, n, r) ((s)->new_channel((s), (c), (n), (r)))
void do_channel_open_command(struct command *s,
struct lsh_object *x,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment