Added some stats printing to c-decrypt

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
Toni Uhlig
2025-01-09 11:31:43 +01:00
parent a47bc9caa3
commit 7ab7bb3772
3 changed files with 18 additions and 1 deletions

View File

@@ -132,6 +132,21 @@ int udp_server(struct ncrypt * const nc)
if ((msgs_recvd % 25) == 0)
{
printf("*** Messages received: %zu ***\n", msgs_recvd);
struct peer * current_peer;
struct peer * ctmp;
HASH_ITER(hh, nc->peers, current_peer, ctmp)
{
printf(
"*** Peer: %8X | Cryptions: %5zu | Crypto Errors: %2zu | IV Mismatches: %2zu | Send Errors: "
"%2zu | "
"Partial Writes: %2zu ***\n",
current_peer->hash_key,
current_peer->cryptions,
current_peer->crypto_errors,
current_peer->iv_mismatches,
current_peer->send_errors,
current_peer->partial_writes);
}
}
}

View File

@@ -554,6 +554,7 @@ int ncrypt_dgram_send(struct ncrypt * const nc, int fd, char const * const plain
retval++;
continue;
}
current_peer->cryptions++;
memcpy(encrypted.iv, current_peer->iv, NCRYPT_AES_IVLEN);
ssize_t bytes_written = sendto(fd,
@@ -629,6 +630,7 @@ int ncrypt_dgram_recv(struct ncrypt * const nc, int fd, char * const plaintext,
{
return -6;
}
peer->cryptions++;
return 0;
}

View File

@@ -24,10 +24,10 @@ struct peer
nDPIsrvd_hashkey hash_key;
struct nDPIsrvd_address address;
unsigned char iv[NCRYPT_AES_IVLEN];
size_t cryptions;
size_t crypto_errors;
size_t iv_mismatches;
size_t send_errors;
size_t recv_errors;
size_t partial_writes;
struct aes aes;
UT_hash_handle hh;