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

(enum channel_event): New event types

CHANNEL_EVENT_DENY and CHANNEL_EVENT_CLOSE.
(struct channel_request_info): Use enum lsh_atom for the type.
(struct channel_request_methods): New struct, used by gateway
channels to replace the handling of channel requests.
(class ssh_channel): New attribute request_methods. Deleted
request_fallback and channel_open_context.
(class channel_request): Made the struct channel_request_info *
argument const.

Rev: src/channel.h:1.77.2.15
parent a80ef662
......@@ -37,14 +37,22 @@ enum channel_event
/* Channel is ready for use; we receieved or sent a
CHANNEL_OPEN_CONFIRMATION. */
CHANNEL_EVENT_CONFIRM = 1,
#if 0
/* We received a CHANNEL_OPEN_FAILURE. */
CHANNEL_EVENT_DENY,
#endif
/* We received a CHANNEL_EOF. */
CHANNEL_EVENT_EOF,
/* FIXME: Not yet generated by anything. */
/* We received a CHANNEL_CLOSE. Most channels need not process this,
since the kill method is invoked automatically when the
CHANNEL_CLOSE handshake is finished. */
CHANNEL_EVENT_CLOSE,
/* FIXME: Not yet generated by anything. On the server side, it may
not really be needed, since we can block waiting for the client
to consume the data. Except if we're having forwarded channel
with reverse notion of client and server responsibilities... */
/* Local buffers are full. Stop sending data. */
CHANNEL_EVENT_STOP,
/* Start sending again (subject to the current send window size). */
......@@ -56,11 +64,21 @@ struct channel_request_info
uint32_t type_length;
const uint8_t *type_data;
int type;
enum lsh_atom type;
int want_reply;
};
/* Overridden for gatewayed channels. */
struct channel_request_methods
{
void (*request)(struct ssh_channel *channel,
const struct channel_request_info *info,
struct simple_buffer *args);
void (*success)(struct ssh_channel *channel);
void (*failure)(struct ssh_channel *channel);
};
#define GABA_DECLARE
#include "channel.h.x"
#undef GABA_DECLARE
......@@ -83,7 +101,7 @@ enum channel_flag {
/* This flags means that we don't expect any more data from the other
end, and that we don't want to wait for an SSH_MSG_CHANNEL_EOF
before closing the channel. */
CHANNEL_NO_WAIT_FOR_EOF = 0x10
CHANNEL_NO_WAIT_FOR_EOF = 0x10,
};
/* GABA:
......@@ -105,13 +123,15 @@ enum channel_flag {
(send_window_size . uint32_t)
(send_max_packet . uint32_t)
; FIXME: Really need this backward link? It seems to be
; essential for gateway_channel, but not for anything else.
(connection object ssh_connection)
; At most one of these can be non-NULL. The first is used
; for gatewayed channels.
(request_methods . "const struct channel_request_methods *")
(request_types object alist)
; If non-NULL, invoked for unknown channel requests.
(request_fallback object channel_request)
(flags . int)
; Number of sources connected to this channel. We should not
......@@ -136,9 +156,6 @@ enum channel_flag {
(event method void "enum channel_event")
; Pass on responce from CHANNEL_OPEN
(channel_open_context object command_context)
; Queue of channel requests that we expect replies on
(pending_requests struct object_queue)
......@@ -152,9 +169,6 @@ enum channel_flag {
((s)->receive((s), (t), (l), (d)))
#define CHANNEL_SEND_ADJUST(s, i) ((s)->send_adjust((s), (i)))
#define CHANNEL_CLOSE(s) \
((s)->close((s)))
#define CHANNEL_EVENT(s, t) \
((s)->event((s), (t)))
......@@ -175,7 +189,7 @@ enum channel_flag {
(vars
(handler method void
"struct ssh_channel *channel"
"struct channel_request_info *info"
"const struct channel_request_info *info"
"struct simple_buffer *args"
"struct command_continuation *c"
"struct exception_handler *e")))
......@@ -184,17 +198,17 @@ enum channel_flag {
#define CHANNEL_REQUEST(s, c, i, a, n, e) \
((s)->handler((s), (c), (i), (a), (n), (e)))
#define DEFINE_CHANNEL_REQUEST(name) \
static void do_##name(struct channel_request *s, \
struct ssh_channel *channel, \
struct channel_request_info *info, \
struct simple_buffer *args, \
struct command_continuation *c, \
struct exception_handler *e); \
\
struct channel_request name = \
{ STATIC_HEADER, do_##name }; \
\
#define DEFINE_CHANNEL_REQUEST(name) \
static void do_##name(struct channel_request *s, \
struct ssh_channel *channel, \
const struct channel_request_info *info, \
struct simple_buffer *args, \
struct command_continuation *c, \
struct exception_handler *e); \
\
struct channel_request name = \
{ STATIC_HEADER, do_##name }; \
\
static void do_##name
void
......@@ -224,12 +238,12 @@ channel_open_new_v(struct ssh_connection *connection,
int
channel_open_new_type(struct ssh_connection *connection,
struct ssh_channel *channel,
int type,
uint32_t type_length, const uint8_t *type,
const char *format, ...);
void
channel_send_request(struct ssh_channel *channel, int type,
struct command_context *ctx,
int close_on_error,
const char *format, ...);
void
......@@ -243,7 +257,21 @@ format_channel_request_i(struct channel_request_info *info,
uint32_t args_length, const uint8_t *args_data);
struct lsh_string *format_channel_close(struct ssh_channel *channel);
struct lsh_string *format_channel_eof(struct ssh_channel *channel);
struct lsh_string *format_channel_eof(uint32_t number);
struct lsh_string *
format_open_confirmation(struct ssh_channel *channel,
const char *format, ...);
struct lsh_string *
format_open_failure(uint32_t channel, uint32_t reason,
const char *msg, const char *language);
struct lsh_string *
format_channel_success(uint32_t channel);
struct lsh_string *
format_channel_failure(uint32_t channel);
void
channel_eof(struct ssh_channel *channel);
......
Supports Markdown
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