|
|
@@ -52,8 +52,7 @@ int do_client_loop(SSL* ssl) |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
void test_Handshake(size_t handshake_nb) { |
|
|
|
|
|
|
|
void test_Handshake(const char* IP, size_t handshake_nb) { |
|
|
|
SSL* ssl; |
|
|
|
SSL_CTX* ctx; |
|
|
|
int err; |
|
|
@@ -63,16 +62,14 @@ void test_Handshake(size_t handshake_nb) { |
|
|
|
|
|
|
|
DBG("Trying to connect"); |
|
|
|
for (size_t i=0; i<handshake_nb; i++) { |
|
|
|
int fd = connect_once(); |
|
|
|
const int fd = connect_once(IP); |
|
|
|
|
|
|
|
DBG("SSL ctx setup"); |
|
|
|
if (!(ssl = SSL_new(ctx))) { |
|
|
|
ERR("Error creating an SSL context"); |
|
|
|
} |
|
|
|
SSL_set_fd(ssl, fd); |
|
|
|
|
|
|
|
DBG("SSL handshake"); |
|
|
|
|
|
|
|
// OZAPTF: do handshake thing |
|
|
|
err = SSL_connect(ssl); |
|
|
|
if (err<=0) { |
|
|
@@ -84,10 +81,9 @@ void test_Handshake(size_t handshake_nb) { |
|
|
|
close(fd); |
|
|
|
} |
|
|
|
SSL_CTX_free(ctx); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void test_Read() { |
|
|
|
void test_Read(const char* IP) { |
|
|
|
int err, nread=0; |
|
|
|
SSL* ssl; |
|
|
|
SSL_CTX* ctx; |
|
|
@@ -96,7 +92,7 @@ void test_Read() { |
|
|
|
ctx = setup_client_ctx(); |
|
|
|
|
|
|
|
DBG("Trying to connect"); |
|
|
|
int fd = connect_once(); |
|
|
|
int fd = connect_once(IP); |
|
|
|
|
|
|
|
DBG("SSL ctx setup"); |
|
|
|
if (!(ssl = SSL_new(ctx))) { |
|
|
@@ -140,7 +136,7 @@ void test_Read() { |
|
|
|
close(fd); |
|
|
|
} |
|
|
|
|
|
|
|
void test_Write() { |
|
|
|
void test_Write(const char* IP) { |
|
|
|
SSL* ssl; |
|
|
|
SSL_CTX* ctx; |
|
|
|
int err,nread=0; |
|
|
@@ -149,7 +145,7 @@ void test_Write() { |
|
|
|
ctx = setup_client_ctx(); |
|
|
|
|
|
|
|
DBG("Trying to connect"); |
|
|
|
int fd = connect_once(); |
|
|
|
int fd = connect_once(IP); |
|
|
|
|
|
|
|
DBG("SSL ctx setup"); |
|
|
|
if (!(ssl = SSL_new(ctx))) { |
|
|
@@ -186,16 +182,16 @@ void test_Write() { |
|
|
|
|
|
|
|
int main(int argc, char* argv[]) { |
|
|
|
|
|
|
|
if (argc < 2) { |
|
|
|
if (argc < 3) { |
|
|
|
goto usage; |
|
|
|
} |
|
|
|
|
|
|
|
if (!strncmp("test_Handshake", argv[1], strlen("test_Handshake"))) { |
|
|
|
test_Handshake(HANDHAKE_REPS); |
|
|
|
} else if (!strncmp("test_Read", argv[1], strlen("test_Read"))) { |
|
|
|
test_Read(); |
|
|
|
} else if (!strncmp("test_Write", argv[1], strlen("test_Write"))) { |
|
|
|
test_Write(); |
|
|
|
if (!strncmp("test_Handshake", argv[2], strlen("test_Handshake"))) { |
|
|
|
test_Handshake(argv[1], HANDHAKE_REPS); |
|
|
|
} else if (!strncmp("test_Read", argv[2], strlen("test_Read"))) { |
|
|
|
test_Read(argv[1]); |
|
|
|
} else if (!strncmp("test_Write", argv[2], strlen("test_Write"))) { |
|
|
|
test_Write(argv[1]); |
|
|
|
} else { |
|
|
|
printf("Unknown test"); |
|
|
|
goto usage; |
|
|
@@ -206,7 +202,7 @@ exit: |
|
|
|
return 0; |
|
|
|
|
|
|
|
usage: |
|
|
|
ERR("\n\nUsage: %s <host>:<port> test_name\nOptions for 'test_name':\n\t" |
|
|
|
ERR("\n\nUsage: %s <host_ip> test_name\nOptions for 'test_name':\n\t" |
|
|
|
"test_Handshake\n\ttest_Write\n\ttest_Read\n", argv[0]); |
|
|
|
goto exit; |
|
|
|
} |