From: Laurent Mazet Date: Sun, 8 Jun 2025 23:02:50 +0000 (+0200) Subject: closer... X-Git-Tag: v1.0~14 X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=9b600023e35d312798e9aef627c2659b09390482;p=ulvpn.git closer... --- diff --git a/encrypted_data.eth b/encrypted_data.eth index 0427538..d943c2b 100644 --- a/encrypted_data.eth +++ b/encrypted_data.eth @@ -1 +1 @@ -T0809 MSG=1 DATA=00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:45:00:00:2f:91:d7:40:00:40:11:93:e1:0a:02:00:01:0a:02:01:01:8e:bb:0b:b8:00:1b:53:3b:54:68:69:73:20:69:73:20:61:20:6c:6f:6e:67:20:54:45:53:0a:01:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 +T0809 MSG=1 DATA=00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:45:00:00:3b:bf:14:40:00:40:11:66:98:0a:02:00:01:0a:02:01:01:8f:6f:0b:b8:00:27:e4:7f:54:45:53:54:3a:20:54:68:69:73:20:69:73:20:61:20:76:65:72:79:20:6c:6f:6e:67:20:74:65:78:74:0a:00:00:00:00:05:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 diff --git a/test.sh b/test.sh index 90498ed..9fa3526 100755 --- a/test.sh +++ b/test.sh @@ -17,7 +17,7 @@ rm -f in.log out.log -t $DEV://00:00:00:00:00:00/0829 \ -l out.log | \ awk '{print "CM R->B [rx]:", $0}'; - grep 54:45:53:54 out.log || break + grep 54:45:53:54 out.log && break done; $MOREP -v 4 \ @@ -33,7 +33,7 @@ rm -f in.log out.log -t $DEV://00:00:00:00:00:00/0809 \ -l in.log | \ awk '{print "CM B->R [rx]:", $0}'; - grep 54:45:53:54 in.log || break + grep 54:45:53:54 in.log && break done; $MOREP -v 4 \ @@ -43,11 +43,12 @@ rm -f in.log out.log awk '{print "CM B->R [tx]:", $0}'; } & pid=$! +trap "kill -9 $pid; ip addr del dev eth0 10.1.0.1/24 && ip link del eth0 type dummy || echo no need to remove eth0;" 0 1 2 15 { sleep 1; echo "TEST: This is a very long text" | nc -uq0 10.2.1.1 3000; } & -$VPN \ #gdb $VPN --args $VPN \ +$VPN \ -v 5 -V 4 \ -d tun://tun0:$MTU \ -l tun://10.2.0.1 -r tun://10.2.1.0 \ diff --git a/ulvpn.c b/ulvpn.c index be29eac..1655e6b 100644 --- a/ulvpn.c +++ b/ulvpn.c @@ -45,7 +45,7 @@ char *cmlocred = NULL; char *cmremred = NULL; int seqcheck = 0; -int timeout = 100; /* ms */ +int timeout = 900; /* ms */ int stop = 0; #define BUFMAX 4096 @@ -125,8 +125,8 @@ int encrypt (uint8_t *buffer, int len, cm_t *cm) uint8_t msgtype = 0; int in_len = 0; int seqrx = MOREP_Receive_timeout (cm->rxblack, &msgtype, in, &in_len, timeout); - 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, DEBUG, PRINTF ("received msg %d, seq %d/%d, length %d/%d bytes from MOREP CM black\n", msgtype, seqtx, seqrx, out_len, in_len)); + if ((msgtype != 0x01) || (in_len != out_len + 12 + 16) || ((seqcheck) && (seqtx != seqrx))) { VERBOSE (ulvpn, WARNING, PRINTF ("non-coherent encrypted message\n")); return 0; } @@ -200,8 +200,9 @@ int decrypt (uint8_t *buffer, int len, cm_t *cm) uint8_t msgtype = 0; int in_len = 0; int seqrx = MOREP_Receive_timeout (cm->rxred, &msgtype, in, &in_len, timeout); + VERBOSE (ulvpn, DEBUG, PRINTF ("received msg %d, seq %d/%d, length %d/%d bytes from MOREP CM black\n", msgtype, seqtx, seqrx, out_len, in_len)); 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))) { + if ((msgtype != 0x03) || (in_len != out_len - 12 - 16) || ((seqcheck) && (seqtx != seqrx))) { VERBOSE (ulvpn, WARNING, PRINTF ("non-coherent decrypted message\n")); return 0; }