version 1.227, 2005/10/14 02:29:37 |
version 1.228, 2005/12/06 22:38:27 |
|
|
debug2("channel %d: filter stops", c->self); |
debug2("channel %d: filter stops", c->self); |
chan_read_failed(c); |
chan_read_failed(c); |
} |
} |
|
} else if (c->datagram) { |
|
buffer_put_string(&c->input, buf, len); |
} else { |
} else { |
buffer_append(&c->input, buf, len); |
buffer_append(&c->input, buf, len); |
} |
} |
|
|
if (c->wfd != -1 && |
if (c->wfd != -1 && |
FD_ISSET(c->wfd, writeset) && |
FD_ISSET(c->wfd, writeset) && |
buffer_len(&c->output) > 0) { |
buffer_len(&c->output) > 0) { |
|
if (c->datagram) { |
|
data = buffer_get_string(&c->output, &dlen); |
|
/* ignore truncated writes, datagrams might get lost */ |
|
c->local_consumed += dlen + 4; |
|
len = write(c->wfd, data, dlen); |
|
xfree(data); |
|
if (len < 0 && (errno == EINTR || errno == EAGAIN)) |
|
return 1; |
|
if (len <= 0) { |
|
if (c->type != SSH_CHANNEL_OPEN) |
|
chan_mark_dead(c); |
|
else |
|
chan_write_failed(c); |
|
return -1; |
|
} |
|
return 1; |
|
} |
data = buffer_ptr(&c->output); |
data = buffer_ptr(&c->output); |
dlen = buffer_len(&c->output); |
dlen = buffer_len(&c->output); |
len = write(c->wfd, data, dlen); |
len = write(c->wfd, data, dlen); |
|
|
if ((c->istate == CHAN_INPUT_OPEN || |
if ((c->istate == CHAN_INPUT_OPEN || |
c->istate == CHAN_INPUT_WAIT_DRAIN) && |
c->istate == CHAN_INPUT_WAIT_DRAIN) && |
(len = buffer_len(&c->input)) > 0) { |
(len = buffer_len(&c->input)) > 0) { |
|
if (c->datagram) { |
|
if (len > 0) { |
|
u_char *data; |
|
u_int dlen; |
|
|
|
data = buffer_get_string(&c->input, |
|
&dlen); |
|
packet_start(SSH2_MSG_CHANNEL_DATA); |
|
packet_put_int(c->remote_id); |
|
packet_put_string(data, dlen); |
|
packet_send(); |
|
c->remote_window -= dlen + 4; |
|
xfree(data); |
|
} |
|
continue; |
|
} |
/* |
/* |
* Send some data for the other side over the secure |
* Send some data for the other side over the secure |
* connection. |
* connection. |
|
|
c->local_window -= data_len; |
c->local_window -= data_len; |
} |
} |
packet_check_eom(); |
packet_check_eom(); |
buffer_append(&c->output, data, data_len); |
if (c->datagram) |
|
buffer_put_string(&c->output, data, data_len); |
|
else |
|
buffer_append(&c->output, data, data_len); |
xfree(data); |
xfree(data); |
} |
} |
|
|