|
Lines 122-127
static int server_side = 0;
Link Here
|
| 122 |
/* Set to true if we are authenticated. */ |
122 |
/* Set to true if we are authenticated. */ |
| 123 |
static int after_authentication = 0; |
123 |
static int after_authentication = 0; |
| 124 |
|
124 |
|
|
|
125 |
/* Set to the maximum time that we will wait to send or receive a packet */ |
| 126 |
static struct timeval packet_wait_tv; |
| 127 |
static struct timeval *packet_wait_tvp = NULL; |
| 128 |
|
| 125 |
/* Session key information for Encryption and MAC */ |
129 |
/* Session key information for Encryption and MAC */ |
| 126 |
Newkeys *newkeys[MODE_MAX]; |
130 |
Newkeys *newkeys[MODE_MAX]; |
| 127 |
static struct packet_state { |
131 |
static struct packet_state { |
|
Lines 175-180
packet_set_connection(int fd_in, int fd_
Link Here
|
| 175 |
} |
179 |
} |
| 176 |
} |
180 |
} |
| 177 |
|
181 |
|
|
|
182 |
void |
| 183 |
packet_set_timeout(int timeout, int count) |
| 184 |
{ |
| 185 |
if (timeout == 0 || count == 0) { |
| 186 |
packet_wait_tvp = NULL; |
| 187 |
return; |
| 188 |
} |
| 189 |
if (LONG_MAX / count < timeout) |
| 190 |
packet_wait_tv.tv_sec = LONG_MAX; |
| 191 |
else |
| 192 |
packet_wait_tv.tv_sec = timeout * count; |
| 193 |
packet_wait_tv.tv_usec = 0; |
| 194 |
packet_wait_tvp = &packet_wait_tv; |
| 195 |
} |
| 196 |
|
| 178 |
/* Returns 1 if remote host is connected via socket, 0 if not. */ |
197 |
/* Returns 1 if remote host is connected via socket, 0 if not. */ |
| 179 |
|
198 |
|
| 180 |
int |
199 |
int |
|
Lines 863-869
packet_send(void)
Link Here
|
| 863 |
int |
882 |
int |
| 864 |
packet_read_seqnr(u_int32_t *seqnr_p) |
883 |
packet_read_seqnr(u_int32_t *seqnr_p) |
| 865 |
{ |
884 |
{ |
| 866 |
int type, len; |
885 |
int type, len, ret; |
| 867 |
fd_set *setp; |
886 |
fd_set *setp; |
| 868 |
char buf[8192]; |
887 |
char buf[8192]; |
| 869 |
DBG(debug("packet_read()")); |
888 |
DBG(debug("packet_read()")); |
|
Lines 898-907
packet_read_seqnr(u_int32_t *seqnr_p)
Link Here
|
| 898 |
FD_SET(connection_in, setp); |
917 |
FD_SET(connection_in, setp); |
| 899 |
|
918 |
|
| 900 |
/* Wait for some data to arrive. */ |
919 |
/* Wait for some data to arrive. */ |
| 901 |
while (select(connection_in + 1, setp, NULL, NULL, NULL) == -1 && |
920 |
while ((ret = select(connection_in + 1, setp, NULL, NULL, |
|
|
921 |
packet_wait_tvp)) == -1 && |
| 902 |
(errno == EAGAIN || errno == EINTR)) |
922 |
(errno == EAGAIN || errno == EINTR)) |
| 903 |
; |
923 |
; |
| 904 |
|
924 |
if (ret == 0) { |
|
|
925 |
logit("Connection to %.200s timed out while waiting to read", |
| 926 |
get_remote_ipaddr()); |
| 927 |
cleanup_exit(255); |
| 928 |
} |
| 905 |
/* Read data from the socket. */ |
929 |
/* Read data from the socket. */ |
| 906 |
len = read(connection_in, buf, sizeof(buf)); |
930 |
len = read(connection_in, buf, sizeof(buf)); |
| 907 |
if (len == 0) { |
931 |
if (len == 0) { |
|
Lines 1411-1416
void
Link Here
|
| 1411 |
packet_write_wait(void) |
1435 |
packet_write_wait(void) |
| 1412 |
{ |
1436 |
{ |
| 1413 |
fd_set *setp; |
1437 |
fd_set *setp; |
|
|
1438 |
int ret; |
| 1414 |
|
1439 |
|
| 1415 |
setp = (fd_set *)xmalloc(howmany(connection_out + 1, NFDBITS) * |
1440 |
setp = (fd_set *)xmalloc(howmany(connection_out + 1, NFDBITS) * |
| 1416 |
sizeof(fd_mask)); |
1441 |
sizeof(fd_mask)); |
|
Lines 1419-1427
packet_write_wait(void)
Link Here
|
| 1419 |
memset(setp, 0, howmany(connection_out + 1, NFDBITS) * |
1444 |
memset(setp, 0, howmany(connection_out + 1, NFDBITS) * |
| 1420 |
sizeof(fd_mask)); |
1445 |
sizeof(fd_mask)); |
| 1421 |
FD_SET(connection_out, setp); |
1446 |
FD_SET(connection_out, setp); |
| 1422 |
while (select(connection_out + 1, NULL, setp, NULL, NULL) == -1 && |
1447 |
while ((ret = select(connection_out + 1, NULL, setp, NULL, |
|
|
1448 |
packet_wait_tvp)) == -1 && |
| 1423 |
(errno == EAGAIN || errno == EINTR)) |
1449 |
(errno == EAGAIN || errno == EINTR)) |
| 1424 |
; |
1450 |
; |
|
|
1451 |
if (ret == 0) { |
| 1452 |
logit("Connection to %.200s timed out while waiting to write", |
| 1453 |
get_remote_ipaddr()); |
| 1454 |
cleanup_exit(255); |
| 1455 |
} |
| 1425 |
packet_write_poll(); |
1456 |
packet_write_poll(); |
| 1426 |
} |
1457 |
} |
| 1427 |
xfree(setp); |
1458 |
xfree(setp); |