From 25762246461186b92b71d256e098e0a7640875f1 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Tue, 6 Jun 2017 15:16:15 +0200 Subject: tests updated --- code/test/Makefile | 22 +++++++++++++++------- code/test/pr_client.c | 18 ++++++++++-------- code/test/proxy.c | 23 +++++++++++++++++++---- code/test/server.c | 8 ++++---- 4 files changed, 48 insertions(+), 23 deletions(-) (limited to 'code') diff --git a/code/test/Makefile b/code/test/Makefile index a6ebb90..6c5a7e5 100644 --- a/code/test/Makefile +++ b/code/test/Makefile @@ -9,25 +9,33 @@ dep=../core/libecpcore.a ../core/crypto/libecpcr.a ../core/htable/libecpht.a ../ all: client server basic stress proxy pr_server pr_client client: client.o init.o $(dep) - $(CC) -o $@ $(LDFLAGS) $< init.o $(dep) + $(CC) -o $@ $< init.o $(dep) $(LDFLAGS) server: server.o init.o $(dep) - $(CC) -o $@ $(LDFLAGS) $< init.o $(dep) + $(CC) -o $@ $< init.o $(dep) $(LDFLAGS) basic: basic.o init.o $(dep) - $(CC) -o $@ $(LDFLAGS) $< init.o $(dep) + $(CC) -o $@ $< init.o $(dep) $(LDFLAGS) stress: stress.o init.o $(dep) - $(CC) -o $@ $(LDFLAGS) $< init.o $(dep) + $(CC) -o $@ $< init.o $(dep) $(LDFLAGS) proxy: proxy.o init_proxy.o $(dep) - $(CC) -o $@ $(LDFLAGS) $< init_proxy.o $(dep) + $(CC) -o $@ $< init_proxy.o $(dep) $(LDFLAGS) pr_server: pr_server.o init_proxy.o $(dep) - $(CC) -o $@ $(LDFLAGS) $< init_proxy.o $(dep) + $(CC) -o $@ $< init_proxy.o $(dep) $(LDFLAGS) pr_client: pr_client.o init_proxy.o $(dep) - $(CC) -o $@ $(LDFLAGS) $< init_proxy.o $(dep) + $(CC) -o $@ $< init_proxy.o $(dep) $(LDFLAGS) + +opus_root=../../../opus-1.1.5 + +voip.o: voip.c + $(CC) $(CFLAGS) -I $(opus_root)/include -c $< + +voip: voip.o init.o $(dep) + $(CC) -o $@ $< init.o $(dep) $(opus_root)/.libs/libopus.a -lm $(LDFLAGS) -l asound clean: rm -f *.o diff --git a/code/test/pr_client.c b/code/test/pr_client.c index a40831c..7d0cd90 100644 --- a/code/test/pr_client.c +++ b/code/test/pr_client.c @@ -14,8 +14,8 @@ ECPConnHandler handler; ECPConnection conn; ECPNode node; -ECPConnProxy conn_proxy; -ECPNode node_proxy; +ECPConnProxy conn_proxy[20]; +ECPNode node_proxy[20]; #define CTYPE_TEST 0 #define MTYPE_MSG 8 @@ -47,14 +47,14 @@ ssize_t handle_msg(ECPConnection *conn, unsigned char t, unsigned char *p, ssize } static void usage(char *arg) { - fprintf(stderr, "Usage: %s \n", arg); + fprintf(stderr, "Usage: %s ... \n", arg); exit(1); } int main(int argc, char *argv[]) { - int rv; + int rv, i; - if (argc != 3) usage(argv[0]); + if ((argc < 3) || (argc > 22)) usage(argv[0]); rv = ecp_init(&ctx); printf("ecp_init RV:%d\n", rv); @@ -76,13 +76,15 @@ int main(int argc, char *argv[]) { rv = ecp_util_node_load(&ctx, &node, argv[1]); printf("ecp_util_node_load RV:%d\n", rv); - rv = ecp_util_node_load(&ctx, &node_proxy, argv[2]); - printf("ecp_util_node_load RV:%d\n", rv); + for (i=0; i [address]\n", arg); + fprintf(stderr, "Usage: %s
[node.pub]\n", arg); exit(1); } int main(int argc, char *argv[]) { int rv; - if (argc != 2) usage(argv[0]); + if ((argc < 3) || (argc > 4)) usage(argv[0]); rv = ecp_init(&ctx); printf("ecp_init RV:%d\n", rv); - rv = ecp_util_key_load(&ctx, &key_perma, argv[1]); + rv = ecp_util_key_load(&ctx, &key_perma, argv[2]); printf("ecp_util_key_load RV:%d\n", rv); rv = ecp_sock_create(&sock, &ctx, &key_perma); printf("ecp_sock_create RV:%d\n", rv); - rv = ecp_sock_open(&sock, "0.0.0.0:3000"); + rv = ecp_sock_open(&sock, argv[1]); printf("ecp_sock_open RV:%d\n", rv); rv = ecp_start_receiver(&sock); printf("ecp_start_receiver RV:%d\n", rv); + + if (argc == 4) { + rv = ecp_util_node_load(&ctx, &node, argv[3]); + printf("ecp_util_node_load RV:%d\n", rv); + + rv = ecp_conn_create(&conn, &sock, ECP_CTYPE_PROXYB); + printf("ecp_conn_create RV:%d\n", rv); + + rv = ecp_conn_open(&conn, &node); + printf("ecp_conn_open RV:%d\n", rv); + } while (1) sleep(1); } \ No newline at end of file diff --git a/code/test/server.c b/code/test/server.c index 71ec2ef..a83c1c5 100644 --- a/code/test/server.c +++ b/code/test/server.c @@ -29,14 +29,14 @@ ssize_t handle_msg_s(ECPConnection *conn, unsigned char t, unsigned char *p, ssi } static void usage(char *arg) { - fprintf(stderr, "Usage: %s [address]\n", arg); + fprintf(stderr, "Usage: %s
\n", arg); exit(1); } int main(int argc, char *argv[]) { int rv; - if (argc != 2) usage(argv[0]); + if (argc != 3) usage(argv[0]); rv = ecp_init(&ctx_s); printf("ecp_init RV:%d\n", rv); @@ -45,13 +45,13 @@ int main(int argc, char *argv[]) { handler_s.msg[MTYPE_MSG] = handle_msg_s; ctx_s.handler[CTYPE_TEST] = &handler_s; - rv = ecp_util_key_load(&ctx_s, &key_perma_s, argv[1]); + rv = ecp_util_key_load(&ctx_s, &key_perma_s, argv[2]); printf("ecp_util_key_load RV:%d\n", rv); rv = ecp_sock_create(&sock_s, &ctx_s, &key_perma_s); printf("ecp_sock_create RV:%d\n", rv); - rv = ecp_sock_open(&sock_s, "0.0.0.0:3000"); + rv = ecp_sock_open(&sock_s, argv[1]); printf("ecp_sock_open RV:%d\n", rv); rv = ecp_start_receiver(&sock_s); -- cgit v1.2.3