version 1.36, 2000/01/04 07:52:03 |
version 1.37, 2000/01/10 10:12:52 |
|
|
|
|
for (i = 0; i < channels_alloc; i++) { |
for (i = 0; i < channels_alloc; i++) { |
ch = &channels[i]; |
ch = &channels[i]; |
|
|
/* We are only interested in channels that can have buffered incoming data. */ |
/* We are only interested in channels that can have buffered incoming data. */ |
if (ch->type != SSH_CHANNEL_OPEN && |
if (compat13) { |
ch->type != SSH_CHANNEL_INPUT_DRAINING) |
if (ch->type != SSH_CHANNEL_OPEN && |
continue; |
ch->type != SSH_CHANNEL_INPUT_DRAINING) |
|
continue; |
|
} else { |
|
if (ch->type != SSH_CHANNEL_OPEN) |
|
continue; |
|
if (ch->istate != CHAN_INPUT_OPEN && |
|
ch->istate != CHAN_INPUT_WAIT_DRAIN) |
|
continue; |
|
} |
|
|
/* Get the amount of buffered data for this channel. */ |
/* Get the amount of buffered data for this channel. */ |
len = buffer_len(&ch->input); |
len = buffer_len(&ch->input); |
|
|
void |
void |
channel_input_data(int payload_len) |
channel_input_data(int payload_len) |
{ |
{ |
int channel; |
int id; |
char *data; |
char *data; |
unsigned int data_len; |
unsigned int data_len; |
|
Channel *ch; |
|
|
/* Get the channel number and verify it. */ |
/* Get the channel number and verify it. */ |
channel = packet_get_int(); |
id = packet_get_int(); |
if (channel < 0 || channel >= channels_alloc || |
if (id < 0 || id >= channels_alloc) |
channels[channel].type == SSH_CHANNEL_FREE) |
packet_disconnect("Received data for nonexistent channel %d.", id); |
packet_disconnect("Received data for nonexistent channel %d.", channel); |
ch = &channels[id]; |
|
|
|
if (ch->type == SSH_CHANNEL_FREE) |
|
packet_disconnect("Received data for free channel %d.", ch->self); |
|
|
/* Ignore any data for non-open channels (might happen on close) */ |
/* Ignore any data for non-open channels (might happen on close) */ |
if (channels[channel].type != SSH_CHANNEL_OPEN && |
if (ch->type != SSH_CHANNEL_OPEN && |
channels[channel].type != SSH_CHANNEL_X11_OPEN) |
ch->type != SSH_CHANNEL_X11_OPEN) |
return; |
return; |
|
|
|
/* same for protocol 1.5 if output end is no longer open */ |
|
if (!compat13 && ch->ostate != CHAN_OUTPUT_OPEN) |
|
return; |
|
|
/* Get the data. */ |
/* Get the data. */ |
data = packet_get_string(&data_len); |
data = packet_get_string(&data_len); |
packet_integrity_check(payload_len, 4 + 4 + data_len, SSH_MSG_CHANNEL_DATA); |
packet_integrity_check(payload_len, 4 + 4 + data_len, SSH_MSG_CHANNEL_DATA); |
buffer_append(&channels[channel].output, data, data_len); |
buffer_append(&ch->output, data, data_len); |
xfree(data); |
xfree(data); |
} |
} |
|
|
|
|
|
|
for (i = 0; i < channels_alloc; i++) { |
for (i = 0; i < channels_alloc; i++) { |
ch = &channels[i]; |
ch = &channels[i]; |
switch (ch->type) { |
if (ch->type == SSH_CHANNEL_OPEN) { |
case SSH_CHANNEL_X11_LISTENER: |
|
case SSH_CHANNEL_PORT_LISTENER: |
|
case SSH_CHANNEL_AUTH_SOCKET: |
|
continue; |
|
case SSH_CHANNEL_OPEN: |
|
if (buffer_len(&ch->input) > packet_get_maxsize()) |
if (buffer_len(&ch->input) > packet_get_maxsize()) |
return 0; |
return 0; |
if (buffer_len(&ch->output) > packet_get_maxsize()) |
if (buffer_len(&ch->output) > packet_get_maxsize()) |
return 0; |
return 0; |
continue; |
|
case SSH_CHANNEL_INPUT_DRAINING: |
|
case SSH_CHANNEL_OUTPUT_DRAINING: |
|
case SSH_CHANNEL_X11_OPEN: |
|
case SSH_CHANNEL_FREE: |
|
default: |
|
continue; |
|
} |
} |
} |
} |
return 1; |
return 1; |
|
|
case SSH_CHANNEL_X11_OPEN: |
case SSH_CHANNEL_X11_OPEN: |
case SSH_CHANNEL_INPUT_DRAINING: |
case SSH_CHANNEL_INPUT_DRAINING: |
case SSH_CHANNEL_OUTPUT_DRAINING: |
case SSH_CHANNEL_OUTPUT_DRAINING: |
snprintf(buf, sizeof buf, " #%d %.300s (t%d r%d i%d o%d)\r\n", |
snprintf(buf, sizeof buf, " #%d %.300s (t%d r%d i%d/%d o%d/%d)\r\n", |
c->self, c->remote_name, |
c->self, c->remote_name, |
c->type, c->remote_id, c->istate, c->ostate); |
c->type, c->remote_id, |
|
c->istate, buffer_len(&c->input), |
|
c->ostate, buffer_len(&c->output)); |
buffer_append(&buffer, buf, strlen(buf)); |
buffer_append(&buffer, buf, strlen(buf)); |
continue; |
continue; |
default: |
default: |