diff options
author | Damien Miller <djm@mindrot.org> | 2008-07-11 17:36:48 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2008-07-11 17:36:48 +1000 |
commit | b61f3fc31ff6eb1693431e21fb1086c33eb66549 (patch) | |
tree | 53538eed568ff248b0f76ab019db53a0a7525368 /clientloop.c | |
parent | dda5fffb847cd98164cb4020e3287a9960c37aaa (diff) |
- markus@cvs.openbsd.org 2008/07/10 18:08:11
[clientloop.c monitor.c monitor_wrap.c packet.c packet.h sshd.c]
sync v1 and v2 traffic accounting; add it to sshd, too;
ok djm@, dtucker@
Diffstat (limited to 'clientloop.c')
-rw-r--r-- | clientloop.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/clientloop.c b/clientloop.c index ba2f0b79e..5a8727eb9 100644 --- a/clientloop.c +++ b/clientloop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: clientloop.c,v 1.199 2008/06/12 21:06:25 djm Exp $ */ | 1 | /* $OpenBSD: clientloop.c,v 1.200 2008/07/10 18:08:11 markus 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 |
@@ -152,7 +152,6 @@ static int stdin_eof; /* EOF has been encountered on stderr. */ | |||
152 | static Buffer stdin_buffer; /* Buffer for stdin data. */ | 152 | static Buffer stdin_buffer; /* Buffer for stdin data. */ |
153 | static Buffer stdout_buffer; /* Buffer for stdout data. */ | 153 | static Buffer stdout_buffer; /* Buffer for stdout data. */ |
154 | static Buffer stderr_buffer; /* Buffer for stderr data. */ | 154 | static Buffer stderr_buffer; /* Buffer for stderr data. */ |
155 | static u_long stdin_bytes, stdout_bytes, stderr_bytes; | ||
156 | static u_int buffer_high;/* Soft max buffer size. */ | 155 | static u_int buffer_high;/* Soft max buffer size. */ |
157 | static int connection_in; /* Connection to server (input). */ | 156 | static int connection_in; /* Connection to server (input). */ |
158 | static int connection_out; /* Connection to server (output). */ | 157 | static int connection_out; /* Connection to server (output). */ |
@@ -437,7 +436,6 @@ client_make_packets_from_stdin_data(void) | |||
437 | packet_put_string(buffer_ptr(&stdin_buffer), len); | 436 | packet_put_string(buffer_ptr(&stdin_buffer), len); |
438 | packet_send(); | 437 | packet_send(); |
439 | buffer_consume(&stdin_buffer, len); | 438 | buffer_consume(&stdin_buffer, len); |
440 | stdin_bytes += len; | ||
441 | /* If we have a pending EOF, send it now. */ | 439 | /* If we have a pending EOF, send it now. */ |
442 | if (stdin_eof && buffer_len(&stdin_buffer) == 0) { | 440 | if (stdin_eof && buffer_len(&stdin_buffer) == 0) { |
443 | packet_start(SSH_CMSG_EOF); | 441 | packet_start(SSH_CMSG_EOF); |
@@ -1205,7 +1203,6 @@ client_process_output(fd_set *writeset) | |||
1205 | } | 1203 | } |
1206 | /* Consume printed data from the buffer. */ | 1204 | /* Consume printed data from the buffer. */ |
1207 | buffer_consume(&stdout_buffer, len); | 1205 | buffer_consume(&stdout_buffer, len); |
1208 | stdout_bytes += len; | ||
1209 | } | 1206 | } |
1210 | /* Write buffered output to stderr. */ | 1207 | /* Write buffered output to stderr. */ |
1211 | if (FD_ISSET(fileno(stderr), writeset)) { | 1208 | if (FD_ISSET(fileno(stderr), writeset)) { |
@@ -1227,7 +1224,6 @@ client_process_output(fd_set *writeset) | |||
1227 | } | 1224 | } |
1228 | /* Consume printed characters from the buffer. */ | 1225 | /* Consume printed characters from the buffer. */ |
1229 | buffer_consume(&stderr_buffer, len); | 1226 | buffer_consume(&stderr_buffer, len); |
1230 | stderr_bytes += len; | ||
1231 | } | 1227 | } |
1232 | } | 1228 | } |
1233 | 1229 | ||
@@ -1302,6 +1298,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | |||
1302 | fd_set *readset = NULL, *writeset = NULL; | 1298 | fd_set *readset = NULL, *writeset = NULL; |
1303 | double start_time, total_time; | 1299 | double start_time, total_time; |
1304 | int max_fd = 0, max_fd2 = 0, len, rekeying = 0; | 1300 | int max_fd = 0, max_fd2 = 0, len, rekeying = 0; |
1301 | u_int64_t ibytes, obytes; | ||
1305 | u_int nalloc = 0; | 1302 | u_int nalloc = 0; |
1306 | char buf[100]; | 1303 | char buf[100]; |
1307 | 1304 | ||
@@ -1333,9 +1330,6 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | |||
1333 | max_fd = MAX(max_fd, fileno(stdout)); | 1330 | max_fd = MAX(max_fd, fileno(stdout)); |
1334 | max_fd = MAX(max_fd, fileno(stderr)); | 1331 | max_fd = MAX(max_fd, fileno(stderr)); |
1335 | } | 1332 | } |
1336 | stdin_bytes = 0; | ||
1337 | stdout_bytes = 0; | ||
1338 | stderr_bytes = 0; | ||
1339 | quit_pending = 0; | 1333 | quit_pending = 0; |
1340 | escape_char1 = escape_char_arg; | 1334 | escape_char1 = escape_char_arg; |
1341 | 1335 | ||
@@ -1521,7 +1515,6 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | |||
1521 | break; | 1515 | break; |
1522 | } | 1516 | } |
1523 | buffer_consume(&stdout_buffer, len); | 1517 | buffer_consume(&stdout_buffer, len); |
1524 | stdout_bytes += len; | ||
1525 | } | 1518 | } |
1526 | 1519 | ||
1527 | /* Output any buffered data for stderr. */ | 1520 | /* Output any buffered data for stderr. */ |
@@ -1533,7 +1526,6 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | |||
1533 | break; | 1526 | break; |
1534 | } | 1527 | } |
1535 | buffer_consume(&stderr_buffer, len); | 1528 | buffer_consume(&stderr_buffer, len); |
1536 | stderr_bytes += len; | ||
1537 | } | 1529 | } |
1538 | 1530 | ||
1539 | /* Clear and free any buffers. */ | 1531 | /* Clear and free any buffers. */ |
@@ -1544,13 +1536,13 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | |||
1544 | 1536 | ||
1545 | /* Report bytes transferred, and transfer rates. */ | 1537 | /* Report bytes transferred, and transfer rates. */ |
1546 | total_time = get_current_time() - start_time; | 1538 | total_time = get_current_time() - start_time; |
1547 | debug("Transferred: stdin %lu, stdout %lu, stderr %lu bytes in %.1f " | 1539 | packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes); |
1548 | "seconds", stdin_bytes, stdout_bytes, stderr_bytes, total_time); | 1540 | packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes); |
1541 | verbose("Transferred: sent %llu, received %llu bytes, in %.1f seconds", | ||
1542 | obytes, ibytes, total_time); | ||
1549 | if (total_time > 0) | 1543 | if (total_time > 0) |
1550 | debug("Bytes per second: stdin %.1f, stdout %.1f, stderr %.1f", | 1544 | verbose("Bytes per second: sent %.1f, received %.1f", |
1551 | stdin_bytes / total_time, stdout_bytes / total_time, | 1545 | obytes / total_time, ibytes / total_time); |
1552 | stderr_bytes / total_time); | ||
1553 | |||
1554 | /* Return the exit status of the program. */ | 1546 | /* Return the exit status of the program. */ |
1555 | debug("Exit status %d", exit_status); | 1547 | debug("Exit status %d", exit_status); |
1556 | return exit_status; | 1548 | return exit_status; |