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

(connect_simple_comand,

connect_connection_command): New static commands, replacing
make_simple_connect and make_connect_connection. Updated users.

Rev: src/io_commands.c:1.47
Rev: src/io_commands.h:1.22
Rev: src/lsh.c:1.149
Rev: src/lsh_proxy.c:1.26
Rev: src/tcpforward_commands.c:1.37
parent 7c0f7879
......@@ -294,74 +294,31 @@ make_connect_port(struct address_info *target)
return &self->super;
}
/* GABA:
(class
(name simple_io_command)
(super command)
(vars
(resources object resource_list)))
*/
/* Simple connect function taking port only as argument. Also used for
* listen.
*
* (connect address) */
/* FIXME: The resources are never used. So replace with a simple DEFINE_COMMAND */
static void
do_simple_connect(struct command *s,
struct lsh_object *a,
struct command_continuation *c,
struct exception_handler *e)
/* (connect address) */
DEFINE_COMMAND(connect_simple_command)
(struct command *self UNUSED,
struct lsh_object *a,
struct command_continuation *c,
struct exception_handler *e)
{
CAST(simple_io_command, self, s);
CAST(address_info, address, a);
do_connect(address, self->resources, c, e);
}
struct command *
make_simple_connect(struct resource_list *resources)
{
NEW(simple_io_command, self);
self->resources = resources;
self->super.call = do_simple_connect;
return &self->super;
do_connect(address, NULL, c, e);
}
/* (connect port) */
/* ;; GABA:
(class
(name connect_connection)
(super command)
(vars
(backend object io_backend)))
*/
static void
do_connect_connection(struct command *self,
struct lsh_object *x,
struct command_continuation *c,
struct exception_handler *e UNUSED)
{
CAST(ssh_connection, connection, x);
COMMAND_RETURN(c,
make_simple_connect(connection->resources));
}
/* FIXME: Use DEFINE_COMMAND */
struct command *
make_connect_connection(void)
/* (connect_connection connection port) */
DEFINE_COMMAND2(connect_connection_command)
(struct command_2 *self UNUSED,
struct lsh_object *a1,
struct lsh_object *a2,
struct command_continuation *c,
struct exception_handler *e UNUSED)
{
NEW(command, self);
self->call = do_connect_connection;
CAST(ssh_connection, connection, a1);
CAST(address_info, address, a2);
return self;
do_connect(address, connection->resources, c, e);
}
......
......@@ -81,11 +81,12 @@ extern struct command_2 listen_with_callback;
struct command *
make_connect_port(struct address_info *target);
struct command *
make_connect_connection(void);
struct command *
make_simple_connect(struct resource_list *resources);
extern struct command_2 connect_connection_command;
#define CONNECT_CONNECTION (&connect_connection_command.super.super)
extern struct command connect_simple_command;
#define CONNECT_SIMPLE (&connect_simple_command.super)
struct command *
make_listen_local(struct local_info *info);
......
......@@ -542,7 +542,6 @@ DEFINE_COMMAND2(lsh_login_command)
(expr
(name make_lsh_connect)
(params
(connect object command)
(handshake object handshake_info)
(init object make_kexinit))
(expr (lambda (options)
......@@ -559,7 +558,7 @@ DEFINE_COMMAND2(lsh_login_command)
(options2verifier options
(options2known_hosts options))
; Connect using tcp
(connect (options2remote options)))))))))
(connect_simple (options2remote options)))))))))
*/
......@@ -953,7 +952,6 @@ int main(int argc, char **argv)
{
struct lsh_object *o =
make_lsh_connect(
make_simple_connect(NULL),
make_handshake_info(CONNECTION_CLIENT,
"lsh - a free ssh", NULL,
SSH_MAX_PACKET,
......
......@@ -514,7 +514,6 @@ DEFINE_COMMAND2(proxy_destination)
(expr
(name lsh_proxy_handshake_server)
(params
(connect object command)
(verifier object lookup_verifier)
(handshake object handshake_info)
(init object make_kexinit))
......@@ -524,7 +523,7 @@ DEFINE_COMMAND2(proxy_destination)
(connection_handshake
handshake init
verifier
(connect (proxy_destination options client_addr)))))))
(connect_simple (proxy_destination options client_addr)))))))
*/
/* Invoked when the client requests the userauth service. */
......@@ -776,8 +775,7 @@ int main(int argc, char **argv)
-1)),
/* callback to call when client<->proxy handshake finished */
(struct command *)lsh_proxy_handshake_server(make_simple_connect(NULL),
make_fake_host_db(),
(struct command *)lsh_proxy_handshake_server(make_fake_host_db(),
make_handshake_info
(CONNECTION_CLIENT,
"lsh_proxy_client - a free ssh",
......
......@@ -461,21 +461,19 @@ STATIC_INSTALL_OPEN_HANDLER(ATOM_FORWARDED_TCPIP);
/* GABA:
(expr
(name direct_tcpip_hook)
(params
(connect object command))
(expr
(lambda (connection)
(install_direct_tcpip connection
(direct_tcpip_handler (lambda (port)
(tcpip_connect_io (connect connection port))))))))
(tcpip_connect_io (connect_connection connection port))))))))
*/
struct command *
make_direct_tcpip_hook(void)
{
CAST_SUBTYPE(command, res,
direct_tcpip_hook(make_connect_connection()));
direct_tcpip_hook());
debug("tcpforward_commands.c: make_direct_tcpip_hook\n");
return res;
......
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