Commit 46a0d4e7 authored by Niels Möller's avatar Niels Möller

(connection_set_timeout): New function.

(connection_clear_timeout): New function.

Rev: src/connection.c:1.67
Rev: src/connection.h:1.61
parent c6b539c8
......@@ -295,6 +295,8 @@ make_ssh_connection(UINT32 flags,
= connection->session_id = NULL;
connection->peer_flags = 0;
connection->timer = NULL;
connection->user = NULL;
connection->resources = make_resource_list();
......@@ -428,3 +430,48 @@ void connection_unlock(struct ssh_connection *self)
EXCEPTION_RAISE(self->e, &unpause);
}
/* Timeouts */
/* GABA:
(class
(name connection_timeout)
(super lsh_callback)
(vars
(connection object ssh_connection)
(e const object exception)))
*/
static void
do_connection_timeout(struct lsh_callback *s)
{
CAST(connection_timeout, self, s);
EXCEPTION_RAISE(self->connection->e, self->e);
}
void
connection_clear_timeout(struct ssh_connection *connection)
{
if (connection->timer)
{
KILL_RESOURCE(connection->timer);
connection->timer = NULL;
}
}
void
connection_set_timeout(struct ssh_connection *connection,
unsigned seconds,
const char *msg)
{
NEW(connection_timeout, timeout);
timeout->super.f = do_connection_timeout;
timeout->connection = connection;
timeout->e = make_protocol_exception(0, msg);
connection_clear_timeout(connection);
connection->timer = io_callout(&timeout->super,
seconds);
REMEMBER_RESOURCE(connection->resources, connection->timer);
}
......@@ -124,6 +124,9 @@ do_##NAME(struct packet_handler *s UNUSED, \
; Features or bugs peculiar to the peer
(peer_flags . UINT32)
; Timer, used both for timeouts and for key reexchange
(timer object resource)
; Information about a logged in user. NULL unless some kind of
; user authentication has been performed.
......@@ -201,6 +204,15 @@ make_connection_close_handler(struct ssh_connection *c);
void connection_lock(struct ssh_connection *self);
void connection_unlock(struct ssh_connection *self);
/* Timeouts */
void
connection_set_timeout(struct ssh_connection *connection,
unsigned seconds,
const char *msg);
void
connection_clear_timeout(struct ssh_connection *connection);
/* Table of packet types */
extern const char *packet_types[0x100];
......
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