From c37e81a144e0534b3970d97cbf8106fd5ea18e93 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Sun, 8 Jun 2025 23:35:13 +0200 Subject: [PATCH] add verbose messages --- ulvpn.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ulvpn.c b/ulvpn.c index 1d53073..be29eac 100644 --- a/ulvpn.c +++ b/ulvpn.c @@ -44,6 +44,7 @@ char *cmremblack = NULL; char *cmlocred = NULL; char *cmremred = NULL; +int seqcheck = 0; int timeout = 100; /* ms */ int stop = 0; @@ -117,13 +118,15 @@ int encrypt (uint8_t *buffer, int len, cm_t *cm) return 0; } int seqtx = MOREP_Send (cm->txred, 0x00, out, out_len); + VERBOSE (ulvpn, DEBUG, PRINTF ("send %d bytes to MOREP CM red\n", out_len)); /* get encrypted message and check it */ uint8_t in[MAXPAYLOAD] = {0}; uint8_t msgtype = 0; int in_len = 0; int seqrx = MOREP_Receive_timeout (cm->rxblack, &msgtype, in, &in_len, timeout); - if ((msgtype != 0x01) || (in_len != out_len + 16) || (seqtx != seqrx)) { + VERBOSE (ulvpn, DEBUG, PRINTF ("received %d bytes from MOREP CM black\n", in_len)); + if ((msgtype != 0x01) || (in_len != out_len + 16) || ((seqcheck) && (seqtx != seqrx))) { VERBOSE (ulvpn, WARNING, PRINTF ("non-coherent encrypted message\n")); return 0; } @@ -190,13 +193,15 @@ int decrypt (uint8_t *buffer, int len, cm_t *cm) return 0; } int seqtx = MOREP_Send (cm->txblack, 0x02, out, out_len); + VERBOSE (ulvpn, DEBUG, PRINTF ("send %d bytes to MOREP CM black\n", out_len)); /* get clear message and check it */ uint8_t in[MAXPAYLOAD] = {0}; uint8_t msgtype = 0; int in_len = 0; int seqrx = MOREP_Receive_timeout (cm->rxred, &msgtype, in, &in_len, timeout); - if ((msgtype != 0x03) || (in_len != out_len - 16) || (seqtx != seqrx)) { + VERBOSE (ulvpn, DEBUG, PRINTF ("received %d bytes from MOREP CM red\n", in_len)); + if ((msgtype != 0x03) || (in_len != out_len - 16) || ((seqcheck) && (seqtx != seqrx))) { VERBOSE (ulvpn, WARNING, PRINTF ("non-coherent decrypted message\n")); return 0; } @@ -298,6 +303,7 @@ int main (int argc, char **argv) return 1; } CHANGE_VERBOSE_LEVEL (mapec, atoi (arg)); + CHANGE_VERBOSE_LEVEL (morep, atoi (arg)); break; case 'x': arg = (arg[2]) ? arg + 2 : (--argc > 0) ? *(++argv) : NULL; -- 2.30.2