version 1.172.2.3, 2002/06/26 15:30:37 |
version 1.172.2.4, 2002/10/11 14:51:52 |
|
|
channel_send_open(int id) |
channel_send_open(int id) |
{ |
{ |
Channel *c = channel_lookup(id); |
Channel *c = channel_lookup(id); |
|
|
if (c == NULL) { |
if (c == NULL) { |
log("channel_send_open: %d: bad id", id); |
log("channel_send_open: %d: bad id", id); |
return; |
return; |
|
|
channel_request_start(int local_id, char *service, int wantconfirm) |
channel_request_start(int local_id, char *service, int wantconfirm) |
{ |
{ |
Channel *c = channel_lookup(local_id); |
Channel *c = channel_lookup(local_id); |
|
|
if (c == NULL) { |
if (c == NULL) { |
log("channel_request_start: %d: unknown channel id", local_id); |
log("channel_request_start: %d: unknown channel id", local_id); |
return; |
return; |
|
|
channel_register_confirm(int id, channel_callback_fn *fn) |
channel_register_confirm(int id, channel_callback_fn *fn) |
{ |
{ |
Channel *c = channel_lookup(id); |
Channel *c = channel_lookup(id); |
|
|
if (c == NULL) { |
if (c == NULL) { |
log("channel_register_comfirm: %d: bad id", id); |
log("channel_register_comfirm: %d: bad id", id); |
return; |
return; |
|
|
channel_register_cleanup(int id, channel_callback_fn *fn) |
channel_register_cleanup(int id, channel_callback_fn *fn) |
{ |
{ |
Channel *c = channel_lookup(id); |
Channel *c = channel_lookup(id); |
|
|
if (c == NULL) { |
if (c == NULL) { |
log("channel_register_cleanup: %d: bad id", id); |
log("channel_register_cleanup: %d: bad id", id); |
return; |
return; |
|
|
channel_cancel_cleanup(int id) |
channel_cancel_cleanup(int id) |
{ |
{ |
Channel *c = channel_lookup(id); |
Channel *c = channel_lookup(id); |
|
|
if (c == NULL) { |
if (c == NULL) { |
log("channel_cancel_cleanup: %d: bad id", id); |
log("channel_cancel_cleanup: %d: bad id", id); |
return; |
return; |
|
|
channel_register_filter(int id, channel_filter_fn *fn) |
channel_register_filter(int id, channel_filter_fn *fn) |
{ |
{ |
Channel *c = channel_lookup(id); |
Channel *c = channel_lookup(id); |
|
|
if (c == NULL) { |
if (c == NULL) { |
log("channel_register_filter: %d: bad id", id); |
log("channel_register_filter: %d: bad id", id); |
return; |
return; |
|
|
int extusage, int nonblock, u_int window_max) |
int extusage, int nonblock, u_int window_max) |
{ |
{ |
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, nonblock); |
|
|
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); |
|
|
if (ret == 1) { |
if (ret == 1) { |
/* Start normal processing for the channel. */ |
/* Start normal processing for the channel. */ |
c->type = SSH_CHANNEL_OPEN; |
c->type = SSH_CHANNEL_OPEN; |
|
|
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) |
{ |
{ |
u_char *p, *host; |
char *p, *host; |
int len, have, i, found; |
int len, have, i, found; |
char username[256]; |
char username[256]; |
struct { |
struct { |
|
|
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; |
|
|
/* Send buffered output data to the socket. */ |
/* Send buffered output data to the socket. */ |
if (FD_ISSET(c->sock, writeset) && buffer_len(&c->output) > 0) { |
if (FD_ISSET(c->sock, writeset) && buffer_len(&c->output) > 0) { |
len = write(c->sock, buffer_ptr(&c->output), |
len = write(c->sock, buffer_ptr(&c->output), |
|
|
channel_handler_init(void) |
channel_handler_init(void) |
{ |
{ |
int i; |
int i; |
|
|
for (i = 0; i < SSH_CHANNEL_MAX_TYPE; i++) { |
for (i = 0; i < SSH_CHANNEL_MAX_TYPE; i++) { |
channel_pre[i] = NULL; |
channel_pre[i] = NULL; |
channel_post[i] = NULL; |
channel_post[i] = NULL; |
|
|
struct addrinfo hints, *ai, *aitop; |
struct addrinfo hints, *ai, *aitop; |
const char *host; |
const char *host; |
char ntop[NI_MAXHOST], strport[NI_MAXSERV]; |
char ntop[NI_MAXHOST], strport[NI_MAXSERV]; |
struct linger linger; |
|
|
|
success = 0; |
success = 0; |
host = (type == SSH_CHANNEL_RPORT_LISTENER) ? |
host = (type == SSH_CHANNEL_RPORT_LISTENER) ? |
|
|
continue; |
continue; |
} |
} |
/* |
/* |
* Set socket options. We would like the socket to disappear |
* Set socket options. |
* as soon as it has been closed for whatever reason. |
* Allow local port reuse in TIME_WAIT. |
*/ |
*/ |
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); |
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, |
linger.l_onoff = 1; |
sizeof(on)) == -1) |
linger.l_linger = 5; |
error("setsockopt SO_REUSEADDR: %s", strerror(errno)); |
setsockopt(sock, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger)); |
|
debug("Local forwarding listening on %s port %s.", ntop, strport); |
debug("Local forwarding listening on %s port %s.", ntop, strport); |
|
|
/* Bind the socket to the address. */ |
/* Bind the socket to the address. */ |
|
|
if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) { |
if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) { |
debug("bind port %d: %.100s", port, strerror(errno)); |
debug("bind port %d: %.100s", port, strerror(errno)); |
close(sock); |
close(sock); |
|
|
|
if (ai->ai_next) |
|
continue; |
|
|
for (n = 0; n < num_socks; n++) { |
for (n = 0; n < num_socks; n++) { |
close(socks[n]); |
close(socks[n]); |
} |
} |
|
|
deny_input_open(int type, u_int32_t seq, void *ctxt) |
deny_input_open(int type, u_int32_t seq, void *ctxt) |
{ |
{ |
int rchan = packet_get_int(); |
int rchan = packet_get_int(); |
|
|
switch (type) { |
switch (type) { |
case SSH_SMSG_AGENT_OPEN: |
case SSH_SMSG_AGENT_OPEN: |
error("Warning: ssh server tried agent forwarding."); |
error("Warning: ssh server tried agent forwarding."); |