add verbose messages
authorLaurent Mazet <mazet@softndesign.org>
Sun, 8 Jun 2025 21:35:13 +0000 (23:35 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Sun, 8 Jun 2025 21:35:13 +0000 (23:35 +0200)
ulvpn.c

diff --git a/ulvpn.c b/ulvpn.c
index 1d53073ea0a4f52f6291984f688b0ea609b6f455..be29eac08f54f8a93dcc64593305ddc46a07b667 100644 (file)
--- 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;