aboutsummaryrefslogtreecommitdiff
path: root/src/packet.c
diff options
context:
space:
mode:
authorAudrius Butkevicius <audrius.butkevicius@elastichosts.com>2014-02-12 16:53:18 +0000
committerAris Adamantiadis <aris@0xbadc0de.be>2014-02-12 18:21:16 +0100
commita277dd92776c5c18d4e08a555e169c46cf75ff94 (patch)
tree5873ed8615e8b0d52ac83337cd4b14d528276d34 /src/packet.c
parent370d4b014d22d6ae9229498f75a4f6d28d0d1614 (diff)
downloadlibssh-a277dd92776c5c18d4e08a555e169c46cf75ff94.tar.gz
libssh-a277dd92776c5c18d4e08a555e169c46cf75ff94.tar.xz
libssh-a277dd92776c5c18d4e08a555e169c46cf75ff94.zip
Add session/channel byte/packet counters
Signed-off-by: Audrius Butkevicius <audrius.butkevicius@elastichosts.com>
Diffstat (limited to 'src/packet.c')
-rw-r--r--src/packet.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/packet.c b/src/packet.c
index 4aed2fac..71ba40d1 100644
--- a/src/packet.c
+++ b/src/packet.c
@@ -311,6 +311,10 @@ int ssh_packet_socket_callback(const void *data, size_t receivedlen, void *user)
#endif /* WITH_ZLIB */
payloadsize = buffer_get_rest_len(session->in_buffer);
session->recv_seq++;
+ if (session->raw_counter != NULL) {
+ session->raw_counter->in_bytes += payloadsize;
+ session->raw_counter->in_packets++;
+ }
/*
* We don't want to rewrite a new packet while still executing the
@@ -560,6 +564,10 @@ static int packet_send2(ssh_session session) {
rc = ssh_packet_write(session);
session->send_seq++;
+ if (session->raw_counter != NULL) {
+ session->raw_counter->out_bytes += payloadsize;
+ session->raw_counter->out_packets++;
+ }
SSH_LOG(SSH_LOG_PACKET,
"packet: wrote [len=%d,padding=%hhd,comp=%d,payload=%d]",