version 1.236, 2006/03/19 18:51:18 |
version 1.237, 2006/03/19 18:52:11 |
|
|
if ((c = channel_by_id(id)) == NULL) |
if ((c = channel_by_id(id)) == NULL) |
return (NULL); |
return (NULL); |
|
|
switch(c->type) { |
switch (c->type) { |
case SSH_CHANNEL_X11_OPEN: |
case SSH_CHANNEL_X11_OPEN: |
case SSH_CHANNEL_LARVAL: |
case SSH_CHANNEL_LARVAL: |
case SSH_CHANNEL_CONNECTING: |
case SSH_CHANNEL_CONNECTING: |
|
|
case SSH_CHANNEL_INPUT_DRAINING: |
case SSH_CHANNEL_INPUT_DRAINING: |
case SSH_CHANNEL_OUTPUT_DRAINING: |
case SSH_CHANNEL_OUTPUT_DRAINING: |
return (c); |
return (c); |
break; |
|
} |
} |
logit("Non-public channel %d, type %d.", id, c->type); |
logit("Non-public channel %d, type %d.", id, c->type); |
return (NULL); |
return (NULL); |
|
|
* 'channel_post*': perform any appropriate operations for channels which |
* 'channel_post*': perform any appropriate operations for channels which |
* have events pending. |
* have events pending. |
*/ |
*/ |
typedef void chan_fn(Channel *c, fd_set * readset, fd_set * writeset); |
typedef void chan_fn(Channel *c, fd_set *readset, fd_set *writeset); |
chan_fn *channel_pre[SSH_CHANNEL_MAX_TYPE]; |
chan_fn *channel_pre[SSH_CHANNEL_MAX_TYPE]; |
chan_fn *channel_post[SSH_CHANNEL_MAX_TYPE]; |
chan_fn *channel_post[SSH_CHANNEL_MAX_TYPE]; |
|
|
static void |
static void |
channel_pre_listener(Channel *c, fd_set * readset, fd_set * writeset) |
channel_pre_listener(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
FD_SET(c->sock, readset); |
FD_SET(c->sock, readset); |
} |
} |
|
|
static void |
static void |
channel_pre_connecting(Channel *c, fd_set * readset, fd_set * writeset) |
channel_pre_connecting(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
debug3("channel %d: waiting for connection", c->self); |
debug3("channel %d: waiting for connection", c->self); |
FD_SET(c->sock, writeset); |
FD_SET(c->sock, writeset); |
} |
} |
|
|
static void |
static void |
channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset) |
channel_pre_open_13(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
if (buffer_len(&c->input) < packet_get_maxsize()) |
if (buffer_len(&c->input) < packet_get_maxsize()) |
FD_SET(c->sock, readset); |
FD_SET(c->sock, readset); |
|
|
} |
} |
|
|
static void |
static void |
channel_pre_open(Channel *c, fd_set * readset, fd_set * writeset) |
channel_pre_open(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
u_int limit = compat20 ? c->remote_window : packet_get_maxsize(); |
u_int limit = compat20 ? c->remote_window : packet_get_maxsize(); |
|
|
|
|
} |
} |
|
|
static void |
static void |
channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset) |
channel_pre_input_draining(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
if (buffer_len(&c->input) == 0) { |
if (buffer_len(&c->input) == 0) { |
packet_start(SSH_MSG_CHANNEL_CLOSE); |
packet_start(SSH_MSG_CHANNEL_CLOSE); |
|
|
} |
} |
|
|
static void |
static void |
channel_pre_output_draining(Channel *c, fd_set * readset, fd_set * writeset) |
channel_pre_output_draining(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
if (buffer_len(&c->output) == 0) |
if (buffer_len(&c->output) == 0) |
chan_mark_dead(c); |
chan_mark_dead(c); |
|
|
} |
} |
|
|
static void |
static void |
channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset) |
channel_pre_x11_open_13(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
int ret = x11_open_helper(&c->output); |
int ret = x11_open_helper(&c->output); |
|
|
|
|
} |
} |
|
|
static void |
static void |
channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) |
channel_pre_x11_open(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
int ret = x11_open_helper(&c->output); |
int ret = x11_open_helper(&c->output); |
|
|
|
|
|
|
/* try to decode a socks4 header */ |
/* try to decode a socks4 header */ |
static int |
static int |
channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) |
channel_decode_socks4(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
char *p, *host; |
char *p, *host; |
u_int len, have, i, found; |
u_int len, have, i, found; |
|
|
#define SSH_SOCKS5_SUCCESS 0x00 |
#define SSH_SOCKS5_SUCCESS 0x00 |
|
|
static int |
static int |
channel_decode_socks5(Channel *c, fd_set * readset, fd_set * writeset) |
channel_decode_socks5(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
struct { |
struct { |
u_int8_t version; |
u_int8_t version; |
|
|
|
|
/* dynamic port forwarding */ |
/* dynamic port forwarding */ |
static void |
static void |
channel_pre_dynamic(Channel *c, fd_set * readset, fd_set * writeset) |
channel_pre_dynamic(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
u_char *p; |
u_char *p; |
u_int have; |
u_int have; |
|
|
|
|
/* This is our fake X11 server socket. */ |
/* This is our fake X11 server socket. */ |
static void |
static void |
channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) |
channel_post_x11_listener(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
Channel *nc; |
Channel *nc; |
struct sockaddr addr; |
struct sockaddr addr; |
|
|
* This socket is listening for connections to a forwarded TCP/IP port. |
* This socket is listening for connections to a forwarded TCP/IP port. |
*/ |
*/ |
static void |
static void |
channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset) |
channel_post_port_listener(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
Channel *nc; |
Channel *nc; |
struct sockaddr addr; |
struct sockaddr addr; |
|
|
* clients. |
* clients. |
*/ |
*/ |
static void |
static void |
channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset) |
channel_post_auth_listener(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
Channel *nc; |
Channel *nc; |
int newsock; |
int newsock; |
|
|
} |
} |
|
|
static void |
static void |
channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset) |
channel_post_connecting(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
int err = 0; |
int err = 0; |
socklen_t sz = sizeof(err); |
socklen_t sz = sizeof(err); |
|
|
} |
} |
|
|
static int |
static int |
channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) |
channel_handle_rfd(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
char buf[CHAN_RBUF]; |
char buf[CHAN_RBUF]; |
int len; |
int len; |
|
|
return 1; |
return 1; |
} |
} |
static int |
static int |
channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) |
channel_handle_wfd(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
struct termios tio; |
struct termios tio; |
u_char *data = NULL, *buf; |
u_char *data = NULL, *buf; |
|
|
return 1; |
return 1; |
} |
} |
static int |
static int |
channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) |
channel_handle_efd(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
char buf[CHAN_RBUF]; |
char buf[CHAN_RBUF]; |
int len; |
int len; |
|
|
return 1; |
return 1; |
} |
} |
static int |
static int |
channel_handle_ctl(Channel *c, fd_set * readset, fd_set * writeset) |
channel_handle_ctl(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
char buf[16]; |
char buf[16]; |
int len; |
int len; |
|
|
} |
} |
|
|
static void |
static void |
channel_post_open(Channel *c, fd_set * readset, fd_set * writeset) |
channel_post_open(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
if (c->delayed) |
if (c->delayed) |
return; |
return; |
|
|
} |
} |
|
|
static void |
static void |
channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset) |
channel_post_output_drain_13(Channel *c, fd_set *readset, fd_set *writeset) |
{ |
{ |
int len; |
int len; |
|
|
|
|
} |
} |
|
|
static void |
static void |
channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset) |
channel_handler(chan_fn *ftab[], fd_set *readset, fd_set *writeset) |
{ |
{ |
static int did_init = 0; |
static int did_init = 0; |
u_int i; |
u_int i; |
|
|
* events pending. |
* events pending. |
*/ |
*/ |
void |
void |
channel_after_select(fd_set * readset, fd_set * writeset) |
channel_after_select(fd_set *readset, fd_set *writeset) |
{ |
{ |
channel_handler(channel_post, readset, writeset); |
channel_handler(channel_post, readset, writeset); |
} |
} |