summaryrefslogtreecommitdiff
path: root/packet.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2009-06-21 18:53:53 +1000
committerDarren Tucker <dtucker@zip.com.au>2009-06-21 18:53:53 +1000
commitc5564e1c4c41ae9af96973e2996e2a4285acbae8 (patch)
treef9fae51c40975704cc73af6073914b00821e3009 /packet.c
parent1cc55d7a607455d75db0204b5acebce47667b0f8 (diff)
- andreas@cvs.openbsd.org 2009/05/28 16:50:16
[sshd.c packet.c serverloop.c monitor_wrap.c clientloop.c sshconnect.c monitor.c Added roaming.h roaming_common.c roaming_dummy.c] Keep track of number of bytes read and written. Needed for upcoming changes. Most code from Martin Forssen, maf at appgate dot com. ok markus@ Also, applied appropriate changes to Makefile.in
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/packet.c b/packet.c
index cecab82e9..f3f8389a3 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.162 2009/05/27 06:36:07 andreas Exp $ */ 1/* $OpenBSD: packet.c,v 1.163 2009/05/28 16:50:16 andreas Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -77,6 +77,7 @@
77#include "canohost.h" 77#include "canohost.h"
78#include "misc.h" 78#include "misc.h"
79#include "ssh.h" 79#include "ssh.h"
80#include "roaming.h"
80 81
81#ifdef PACKET_DEBUG 82#ifdef PACKET_DEBUG
82#define DBG(x) x 83#define DBG(x) x
@@ -1012,7 +1013,7 @@ packet_send(void)
1012int 1013int
1013packet_read_seqnr(u_int32_t *seqnr_p) 1014packet_read_seqnr(u_int32_t *seqnr_p)
1014{ 1015{
1015 int type, len, ret, ms_remain; 1016 int type, len, ret, ms_remain, cont;
1016 fd_set *setp; 1017 fd_set *setp;
1017 char buf[8192]; 1018 char buf[8192];
1018 struct timeval timeout, start, *timeoutp = NULL; 1019 struct timeval timeout, start, *timeoutp = NULL;
@@ -1061,8 +1062,7 @@ packet_read_seqnr(u_int32_t *seqnr_p)
1061 if ((ret = select(active_state->connection_in + 1, setp, 1062 if ((ret = select(active_state->connection_in + 1, setp,
1062 NULL, NULL, timeoutp)) >= 0) 1063 NULL, NULL, timeoutp)) >= 0)
1063 break; 1064 break;
1064 if (errno != EAGAIN && errno != EINTR && 1065 if (errno != EAGAIN && errno != EINTR)
1065 errno != EWOULDBLOCK)
1066 break; 1066 break;
1067 if (active_state->packet_timeout_ms == -1) 1067 if (active_state->packet_timeout_ms == -1)
1068 continue; 1068 continue;
@@ -1078,7 +1078,11 @@ packet_read_seqnr(u_int32_t *seqnr_p)
1078 cleanup_exit(255); 1078 cleanup_exit(255);
1079 } 1079 }
1080 /* Read data from the socket. */ 1080 /* Read data from the socket. */
1081 len = read(active_state->connection_in, buf, sizeof(buf)); 1081 do {
1082 cont = 0;
1083 len = roaming_read(active_state->connection_in, buf,
1084 sizeof(buf), &cont);
1085 } while (len == 0 && cont);
1082 if (len == 0) { 1086 if (len == 0) {
1083 logit("Connection closed by %.200s", get_remote_ipaddr()); 1087 logit("Connection closed by %.200s", get_remote_ipaddr());
1084 cleanup_exit(255); 1088 cleanup_exit(255);
@@ -1624,23 +1628,23 @@ void
1624packet_write_poll(void) 1628packet_write_poll(void)
1625{ 1629{
1626 int len = buffer_len(&active_state->output); 1630 int len = buffer_len(&active_state->output);
1631 int cont;
1627 1632
1628 if (len > 0) { 1633 if (len > 0) {
1629 len = write(active_state->connection_out, 1634 cont = 0;
1630 buffer_ptr(&active_state->output), len); 1635 len = roaming_write(active_state->connection_out,
1636 buffer_ptr(&active_state->output), len, &cont);
1631 if (len == -1) { 1637 if (len == -1) {
1632 if (errno == EINTR || errno == EAGAIN || 1638 if (errno == EINTR || errno == EAGAIN)
1633 errno == EWOULDBLOCK)
1634 return; 1639 return;
1635 fatal("Write failed: %.100s", strerror(errno)); 1640 fatal("Write failed: %.100s", strerror(errno));
1636 } 1641 }
1637 if (len == 0) 1642 if (len == 0 && !cont)
1638 fatal("Write connection closed"); 1643 fatal("Write connection closed");
1639 buffer_consume(&active_state->output, len); 1644 buffer_consume(&active_state->output, len);
1640 } 1645 }
1641} 1646}
1642 1647
1643
1644/* 1648/*
1645 * Calls packet_write_poll repeatedly until all pending output data has been 1649 * Calls packet_write_poll repeatedly until all pending output data has been
1646 * written. 1650 * written.
@@ -1673,8 +1677,7 @@ packet_write_wait(void)
1673 if ((ret = select(active_state->connection_out + 1, 1677 if ((ret = select(active_state->connection_out + 1,
1674 NULL, setp, NULL, timeoutp)) >= 0) 1678 NULL, setp, NULL, timeoutp)) >= 0)
1675 break; 1679 break;
1676 if (errno != EAGAIN && errno != EINTR && 1680 if (errno != EAGAIN && errno != EINTR)
1677 errno != EWOULDBLOCK)
1678 break; 1681 break;
1679 if (active_state->packet_timeout_ms == -1) 1682 if (active_state->packet_timeout_ms == -1)
1680 continue; 1683 continue;
@@ -1713,7 +1716,6 @@ packet_not_very_much_data_to_write(void)
1713 return buffer_len(&active_state->output) < 128 * 1024; 1716 return buffer_len(&active_state->output) < 128 * 1024;
1714} 1717}
1715 1718
1716
1717static void 1719static void
1718packet_set_tos(int interactive) 1720packet_set_tos(int interactive)
1719{ 1721{