Test corner cases in the SPTPS protocol.
authorGuus Sliepen <guus@tinc-vpn.org>
Wed, 5 Oct 2011 20:05:13 +0000 (22:05 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Wed, 5 Oct 2011 20:05:13 +0000 (22:05 +0200)
* Test zero-byte messages.
* Test maximum size (65535 byte) messages.
* Test different message types.
* Test key renegotiation.

src/sptps_test.c

index 7b33eef..866159e 100644 (file)
@@ -121,7 +121,7 @@ int main(int argc, char *argv[]) {
                return 1;
 
        while(true) {
-               char buf[4095];
+               char buf[65535] = "";
 
                struct pollfd fds[2];
                fds[0].fd = 0;
@@ -139,7 +139,12 @@ int main(int argc, char *argv[]) {
                        }
                        if(len == 0)
                                break;
-                       if(!send_record(&s, 0, buf, len))
+                       if(buf[0] == '^')
+                               send_record(&s, SPTPS_HANDSHAKE, NULL, 0);
+                       else if(buf[0] == '$')
+                               force_kex(&s);
+                       else
+                       if(!send_record(&s, buf[0] == '!' ? 1 : 0, buf, buf[0] == '\n' ? 0 : buf[0] == '*' ? sizeof buf : len))
                                return 1;
                }