version 1.70, 2000/09/28 18:03:18 |
version 1.71, 2000/10/27 07:32:17 |
|
|
*/ |
*/ |
|
|
void |
void |
channel_register_fds(Channel *c, int rfd, int wfd, int efd, int extusage) |
channel_register_fds(Channel *c, int rfd, int wfd, int efd, |
|
int extusage, int nonblock) |
{ |
{ |
/* Update the maximum file descriptor value. */ |
/* Update the maximum file descriptor value. */ |
if (rfd > channel_max_fd_value) |
if (rfd > channel_max_fd_value) |
|
|
c->sock = (rfd == wfd) ? rfd : -1; |
c->sock = (rfd == wfd) ? rfd : -1; |
c->efd = efd; |
c->efd = efd; |
c->extended_usage = extusage; |
c->extended_usage = extusage; |
if (rfd != -1) |
|
set_nonblock(rfd); |
/* enable nonblocking mode */ |
if (wfd != -1) |
if (nonblock) { |
set_nonblock(wfd); |
if (rfd != -1) |
if (efd != -1) |
set_nonblock(rfd); |
set_nonblock(efd); |
if (wfd != -1) |
|
set_nonblock(wfd); |
|
if (efd != -1) |
|
set_nonblock(efd); |
|
} |
} |
} |
|
|
/* |
/* |
|
|
|
|
int |
int |
channel_new(char *ctype, int type, int rfd, int wfd, int efd, |
channel_new(char *ctype, int type, int rfd, int wfd, int efd, |
int window, int maxpack, int extusage, char *remote_name) |
int window, int maxpack, int extusage, char *remote_name, int nonblock) |
{ |
{ |
int i, found; |
int i, found; |
Channel *c; |
Channel *c; |
|
|
buffer_init(&c->output); |
buffer_init(&c->output); |
buffer_init(&c->extended); |
buffer_init(&c->extended); |
chan_init_iostates(c); |
chan_init_iostates(c); |
channel_register_fds(c, rfd, wfd, efd, extusage); |
channel_register_fds(c, rfd, wfd, efd, extusage, nonblock); |
c->self = found; |
c->self = found; |
c->type = type; |
c->type = type; |
c->ctype = ctype; |
c->ctype = ctype; |
|
|
int |
int |
channel_allocate(int type, int sock, char *remote_name) |
channel_allocate(int type, int sock, char *remote_name) |
{ |
{ |
return channel_new("", type, sock, sock, -1, 0, 0, 0, remote_name); |
return channel_new("", type, sock, sock, -1, 0, 0, 0, remote_name, 1); |
} |
} |
|
|
|
|
|
|
newch = channel_new("x11", |
newch = channel_new("x11", |
SSH_CHANNEL_OPENING, newsock, newsock, -1, |
SSH_CHANNEL_OPENING, newsock, newsock, -1, |
c->local_window_max, c->local_maxpacket, |
c->local_window_max, c->local_maxpacket, |
0, xstrdup(buf)); |
0, xstrdup(buf), 1); |
if (compat20) { |
if (compat20) { |
packet_start(SSH2_MSG_CHANNEL_OPEN); |
packet_start(SSH2_MSG_CHANNEL_OPEN); |
packet_put_cstring("x11"); |
packet_put_cstring("x11"); |
|
|
newch = channel_new("direct-tcpip", |
newch = channel_new("direct-tcpip", |
SSH_CHANNEL_OPENING, newsock, newsock, -1, |
SSH_CHANNEL_OPENING, newsock, newsock, -1, |
c->local_window_max, c->local_maxpacket, |
c->local_window_max, c->local_maxpacket, |
0, xstrdup(buf)); |
0, xstrdup(buf), 1); |
if (compat20) { |
if (compat20) { |
packet_start(SSH2_MSG_CHANNEL_OPEN); |
packet_start(SSH2_MSG_CHANNEL_OPEN); |
packet_put_cstring("direct-tcpip"); |
packet_put_cstring("direct-tcpip"); |
|
|
"port listener", SSH_CHANNEL_PORT_LISTENER, |
"port listener", SSH_CHANNEL_PORT_LISTENER, |
sock, sock, -1, |
sock, sock, -1, |
CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, |
CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, |
0, xstrdup("port listener")); |
0, xstrdup("port listener"), 1); |
strlcpy(channels[ch].path, host, sizeof(channels[ch].path)); |
strlcpy(channels[ch].path, host, sizeof(channels[ch].path)); |
channels[ch].host_port = host_port; |
channels[ch].host_port = host_port; |
channels[ch].listening_port = port; |
channels[ch].listening_port = port; |
|
|
(void) channel_new("x11 listener", |
(void) channel_new("x11 listener", |
SSH_CHANNEL_X11_LISTENER, sock, sock, -1, |
SSH_CHANNEL_X11_LISTENER, sock, sock, -1, |
CHAN_X11_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, |
CHAN_X11_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, |
0, xstrdup("X11 inet listener")); |
0, xstrdup("X11 inet listener"), 1); |
} |
} |
|
|
/* Return a suitable value for the DISPLAY environment variable. */ |
/* Return a suitable value for the DISPLAY environment variable. */ |
|
|
} |
} |
|
|
void |
void |
channel_set_fds(int id, int rfd, int wfd, int efd, int extusage) |
channel_set_fds(int id, int rfd, int wfd, int efd, |
|
int extusage, int nonblock) |
{ |
{ |
Channel *c = channel_lookup(id); |
Channel *c = channel_lookup(id); |
if (c == NULL || c->type != SSH_CHANNEL_LARVAL) |
if (c == NULL || c->type != SSH_CHANNEL_LARVAL) |
fatal("channel_activate for non-larval channel %d.", id); |
fatal("channel_activate for non-larval channel %d.", id); |
|
channel_register_fds(c, rfd, wfd, efd, extusage, nonblock); |
channel_register_fds(c, rfd, wfd, efd, extusage); |
|
c->type = SSH_CHANNEL_OPEN; |
c->type = SSH_CHANNEL_OPEN; |
/* XXX window size? */ |
/* XXX window size? */ |
c->local_window = c->local_window_max = c->local_maxpacket * 2; |
c->local_window = c->local_window_max = c->local_maxpacket * 2; |