summaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@MacBookPro.lan>2017-06-06 15:16:15 +0200
committerUros Majstorovic <majstor@MacBookPro.lan>2017-06-06 15:16:15 +0200
commit25762246461186b92b71d256e098e0a7640875f1 (patch)
treefd180788da41432467aa2c65040ce54090c8374f /code
parent94e7265d1122c23361b0db0add4610a46f3814af (diff)
tests updated
Diffstat (limited to 'code')
-rw-r--r--code/test/Makefile22
-rw-r--r--code/test/pr_client.c18
-rw-r--r--code/test/proxy.c23
-rw-r--r--code/test/server.c8
4 files changed, 48 insertions, 23 deletions
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 <server.pub> <proxy.pub>\n", arg);
+ fprintf(stderr, "Usage: %s <server.pub> <p1.pub> ... <pn.pub>\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<argc-2; i++) {
+ rv = ecp_util_node_load(&ctx, &node_proxy[i], argv[i+2]);
+ printf("ecp_util_node_load RV:%d\n", rv);
+ }
rv = ecp_conn_create(&conn, &sock, CTYPE_TEST);
printf("ecp_conn_create RV:%d\n", rv);
- rv = ecp_conn_proxy_open(&conn, &node, &conn_proxy, &node_proxy, 1);
+ rv = ecp_conn_proxy_open(&conn, &node, conn_proxy, node_proxy, argc-2);
printf("ecp_conn_proxy_open RV:%d\n", rv);
while (1) sleep(1);
diff --git a/code/test/proxy.c b/code/test/proxy.c
index cfea6c1..ae7cce5 100644
--- a/code/test/proxy.c
+++ b/code/test/proxy.c
@@ -5,35 +5,50 @@
#include "core.h"
#include "util.h"
+#include "proxy.h"
ECPContext ctx;
ECPSocket sock;
ECPDHKey key_perma;
+ECPNode node;
+ECPConnection conn;
+
static void usage(char *arg) {
- fprintf(stderr, "Usage: %s <node.priv> [address]\n", arg);
+ fprintf(stderr, "Usage: %s <address> <node.priv> [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 <node.priv> [address]\n", arg);
+ fprintf(stderr, "Usage: %s <address> <node.priv>\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);