version 1.162, 2009/05/27 06:36:07 |
version 1.163, 2009/05/28 16:50:16 |
|
|
#include "canohost.h" |
#include "canohost.h" |
#include "misc.h" |
#include "misc.h" |
#include "ssh.h" |
#include "ssh.h" |
|
#include "roaming.h" |
|
|
#ifdef PACKET_DEBUG |
#ifdef PACKET_DEBUG |
#define DBG(x) x |
#define DBG(x) x |
|
|
int |
int |
packet_read_seqnr(u_int32_t *seqnr_p) |
packet_read_seqnr(u_int32_t *seqnr_p) |
{ |
{ |
int type, len, ret, ms_remain; |
int type, len, ret, ms_remain, cont; |
fd_set *setp; |
fd_set *setp; |
char buf[8192]; |
char buf[8192]; |
struct timeval timeout, start, *timeoutp = NULL; |
struct timeval timeout, start, *timeoutp = NULL; |
|
|
cleanup_exit(255); |
cleanup_exit(255); |
} |
} |
/* Read data from the socket. */ |
/* Read data from the socket. */ |
len = read(active_state->connection_in, buf, sizeof(buf)); |
do { |
|
cont = 0; |
|
len = roaming_read(active_state->connection_in, buf, |
|
sizeof(buf), &cont); |
|
} while (len == 0 && cont); |
if (len == 0) { |
if (len == 0) { |
logit("Connection closed by %.200s", get_remote_ipaddr()); |
logit("Connection closed by %.200s", get_remote_ipaddr()); |
cleanup_exit(255); |
cleanup_exit(255); |
|
|
packet_write_poll(void) |
packet_write_poll(void) |
{ |
{ |
int len = buffer_len(&active_state->output); |
int len = buffer_len(&active_state->output); |
|
int cont; |
|
|
if (len > 0) { |
if (len > 0) { |
len = write(active_state->connection_out, |
cont = 0; |
buffer_ptr(&active_state->output), len); |
len = roaming_write(active_state->connection_out, |
|
buffer_ptr(&active_state->output), len, &cont); |
if (len == -1) { |
if (len == -1) { |
if (errno == EINTR || errno == EAGAIN) |
if (errno == EINTR || errno == EAGAIN) |
return; |
return; |
fatal("Write failed: %.100s", strerror(errno)); |
fatal("Write failed: %.100s", strerror(errno)); |
} |
} |
if (len == 0) |
if (len == 0 && !cont) |
fatal("Write connection closed"); |
fatal("Write connection closed"); |
buffer_consume(&active_state->output, len); |
buffer_consume(&active_state->output, len); |
} |
} |