[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5 of 6 V1] Implement session raw byte counter
[Thread Prev] | [Thread Next]
- Subject: [PATCH 5 of 6 V1] Implement session raw byte counter
- From: Audrius Butkevicius <audrius.butkevicius@xxxxxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 15 Jan 2014 16:43:05 +0000
- To: libssh@xxxxxxxxxx
- Cc: audrius.butkevicius@xxxxxxxxx
include/libssh/counters.h | 11 ++++++++++- include/libssh/session.h | 1 + src/counters.c | 2 ++ src/packet.c | 4 ++++ 4 files changed, 17 insertions(+), 1 deletions(-) # HG changeset patch # User Audrius Butkevicius <audrius.butkevicius@xxxxxxxxxxxxxxxx> # Date 1389803790 0 # Wed Jan 15 16:36:30 2014 +0000 # Node ID 3b842c373559f9d51b3e3485a59a6456545e74b5 # Parent 9e462bb4ad281e6b8f8f278726ec601596c35c21 Implement session raw byte counter diff --git a/include/libssh/counters.h b/include/libssh/counters.h --- a/include/libssh/counters.h +++ b/include/libssh/counters.h @@ -67,23 +67,32 @@ * .out_bytes = 0 * }; * + * struct ssh_byte_counter_struct rcounter = { + * .in_bytes = 0, + * .out_bytes = 0 + * }; + * * struct ssh_packet_counter_struct pcounter = { * .in_packets = 0, * .out_packets = 0 * }; * - * ssh_set_session_counters(session, &scounter, &pcounter); + * ssh_set_session_counters(session, &scounter, &rcounter, &pcounter); * @endcode * * @param session The session to set the counter structures. * * @param scounter The byte counter structure for data passed to sockets. * + * @param rcounter The byte counter structure for raw data handled by the + * session, prior compression and SSH overhead. + * * @param pcounter The packet counter structure for SSH packets handled by * the session. */ LIBSSH_API void ssh_set_session_counters(ssh_session session, ssh_bytes_counter scounter, + ssh_bytes_counter rcounter, ssh_packet_counter pcounter); /** @} */ diff --git a/include/libssh/session.h b/include/libssh/session.h --- a/include/libssh/session.h +++ b/include/libssh/session.h @@ -191,6 +191,7 @@ /* counters */ ssh_bytes_counter socket_byte_counter; + ssh_bytes_counter raw_byte_counter; ssh_packet_counter packet_counter; }; diff --git a/src/counters.c b/src/counters.c --- a/src/counters.c +++ b/src/counters.c @@ -25,10 +25,12 @@ #include "libssh/session.h" void ssh_set_session_counters(ssh_session session, ssh_bytes_counter scounter, + ssh_bytes_counter rcounter, ssh_packet_counter pcounter) { if (session == NULL) return; session->socket_byte_counter = scounter; + session->raw_byte_counter = rcounter; session->packet_counter = pcounter; } diff --git a/src/packet.c b/src/packet.c --- a/src/packet.c +++ b/src/packet.c @@ -307,6 +307,8 @@ session->recv_seq++; if (session->packet_counter) session->packet_counter->in_packets++; + if (session->raw_byte_counter) + session->raw_byte_counter->in_bytes += payloadsize; /* * We don't want to rewrite a new packet while still executing the @@ -558,6 +560,8 @@ session->send_seq++; if (session->packet_counter) session->packet_counter->out_packets++; + if (session->raw_byte_counter) + session->raw_byte_counter->out_bytes += payloadsize; SSH_LOG(SSH_LOG_PACKET, "packet: wrote [len=%d,padding=%hhd,comp=%d,payload=%d]",
[PATCH 0 of 6 V1] Counters | Audrius Butkevicius <audrius.butkevicius@xxxxxxxxxxxxxxxx> |