summaryrefslogtreecommitdiff
path: root/ecp/test
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2024-04-27 01:23:43 +0200
committerUros Majstorovic <majstor@majstor.org>2024-04-27 01:23:43 +0200
commit38fdc24c2cc0c942337481e825c69004c93fc358 (patch)
tree46835e29b2ae3db88035c26359415c22587b777c /ecp/test
parent45e53e043ea0512215316a5ba21bd4cfd0a300e1 (diff)
updated tests
Diffstat (limited to 'ecp/test')
-rw-r--r--ecp/test/client.c4
-rw-r--r--ecp/test/server.c2
-rw-r--r--ecp/test/vc_client.c11
-rw-r--r--ecp/test/vc_inb.c6
-rw-r--r--ecp/test/vc_outb.c8
-rw-r--r--ecp/test/vc_server.c13
-rw-r--r--ecp/test/vcs.c35
7 files changed, 57 insertions, 22 deletions
diff --git a/ecp/test/client.c b/ecp/test/client.c
index 52a8587..af905d5 100644
--- a/ecp/test/client.c
+++ b/ecp/test/client.c
@@ -64,8 +64,8 @@ int main(int argc, char *argv[]) {
rv = ecp_start_receiver(&sock);
printf("ecp_start_receiver RV:%d\n", rv);
- rv = ecp_util_load_pub(&node_pub, argv[2]);
- printf("ecp_util_load_pub RV:%d\n", rv);
+ rv = ecp_util_load_key(argv[2], &node_pub, NULL);
+ printf("ecp_util_load_key RV:%d\n", rv);
ecp_node_init(&node, &node_pub, NULL);
rv = ecp_node_set_addr(&node, argv[1]);
diff --git a/ecp/test/server.c b/ecp/test/server.c
index 19b2f4f..003e3b3 100644
--- a/ecp/test/server.c
+++ b/ecp/test/server.c
@@ -46,7 +46,7 @@ int main(int argc, char *argv[]) {
ecp_conn_handler_init(&handler, handle_msg, NULL, NULL, NULL);
ecp_ctx_set_handler(&ctx, CTYPE_TEST, &handler);
- rv = ecp_util_load_key(&key_perma.public, &key_perma.private, argv[2]);
+ rv = ecp_util_load_key(argv[2], &key_perma.public, &key_perma.private);
printf("ecp_util_load_key RV:%d\n", rv);
key_perma.valid = 1;
diff --git a/ecp/test/vc_client.c b/ecp/test/vc_client.c
index 41c364d..af4a3cd 100644
--- a/ecp/test/vc_client.c
+++ b/ecp/test/vc_client.c
@@ -63,22 +63,25 @@ int main(int argc, char *argv[]) {
rv = ecp_sock_create(&sock, &ctx, &key_perma);
printf("ecp_sock_create RV:%d\n", rv);
+ rv = ecp_vconn_sock_create(&sock);
+ printf("ecp_vconn_htable_init RV:%d\n", rv);
+
rv = ecp_sock_open(&sock, NULL);
printf("ecp_sock_open RV:%d\n", rv);
rv = ecp_start_receiver(&sock);
printf("ecp_start_receiver RV:%d\n", rv);
- rv = ecp_util_load_pub(&node_pub, argv[1]);
- printf("ecp_util_load_pub RV:%d\n", rv);
+ rv = ecp_util_load_key(argv[1], &node_pub, NULL);
+ printf("ecp_util_load_key RV:%d\n", rv);
ecp_node_init(&node, &node_pub, NULL);
rv = ecp_node_set_addr(&node, argv[2]);
printf("ecp_node_set_addr RV:%d\n", rv);
for (i=3; i<argc; i++) {
- rv = ecp_util_load_pub(&vconn_pub[i-3], argv[i]);
- printf("ecp_util_load_pub RV:%d\n", rv);
+ rv = ecp_util_load_key(argv[i], &vconn_pub[i-3], NULL);
+ printf("ecp_util_load_key RV:%d\n", rv);
}
ecp_conn_init(&conn, &sock, CTYPE_TEST);
diff --git a/ecp/test/vc_inb.c b/ecp/test/vc_inb.c
index 13b493c..825d948 100644
--- a/ecp/test/vc_inb.c
+++ b/ecp/test/vc_inb.c
@@ -93,7 +93,7 @@ int main(int argc, char *argv[]) {
ecp_conn_handler_init(&handler, handle_msg, handle_open, NULL, NULL);
ecp_ctx_set_handler(&ctx, CTYPE_TEST, &handler);
- rv = ecp_util_load_key(&key_perma.public, &key_perma.private, argv[1]);
+ rv = ecp_util_load_key(argv[1], &key_perma.public, &key_perma.private);
printf("ecp_util_load_key RV:%d\n", rv);
key_perma.valid = 1;
@@ -106,8 +106,8 @@ int main(int argc, char *argv[]) {
rv = ecp_start_receiver(&sock);
printf("ecp_start_receiver RV:%d\n", rv);
- rv = ecp_util_load_pub(&dir_pub, argv[2]);
- printf("ecp_util_load_pub RV:%d\n", rv);
+ rv = ecp_util_load_key(argv[2], &dir_pub, NULL);
+ printf("ecp_util_load_key RV:%d\n", rv);
ecp_node_init(&node_dir, &dir_pub, NULL);
rv = ecp_node_set_addr(&node_dir, argv[3]);
diff --git a/ecp/test/vc_outb.c b/ecp/test/vc_outb.c
index 6018602..cc772d5 100644
--- a/ecp/test/vc_outb.c
+++ b/ecp/test/vc_outb.c
@@ -107,11 +107,11 @@ int main(int argc, char *argv[]) {
rv = ecp_start_receiver(&sock);
printf("ecp_start_receiver RV:%d\n", rv);
- rv = ecp_util_load_pub(&remote_pub, argv[1]);
- printf("ecp_util_load_pub RV:%d\n", rv);
+ rv = ecp_util_load_key(argv[1], &remote_pub, NULL);
+ printf("ecp_util_load_key RV:%d\n", rv);
- rv = ecp_util_load_pub(&dir_pub, argv[2]);
- printf("ecp_util_load_pub RV:%d\n", rv);
+ rv = ecp_util_load_key(argv[2], &dir_pub, NULL);
+ printf("ecp_util_load_key RV:%d\n", rv);
ecp_node_init(&node_dir, &dir_pub, NULL);
rv = ecp_node_set_addr(&node_dir, argv[3]);
diff --git a/ecp/test/vc_server.c b/ecp/test/vc_server.c
index 548b52d..daf35f8 100644
--- a/ecp/test/vc_server.c
+++ b/ecp/test/vc_server.c
@@ -56,21 +56,24 @@ int main(int argc, char *argv[]) {
ecp_conn_handler_init(&handler, handle_msg, handle_open, NULL, NULL);
ecp_ctx_set_handler(&ctx, CTYPE_TEST, &handler);
- rv = ecp_util_load_key(&key_perma.public, &key_perma.private, argv[1]);
+ rv = ecp_util_load_key(argv[1], &key_perma.public, &key_perma.private);
printf("ecp_util_load_key RV:%d\n", rv);
key_perma.valid = 1;
rv = ecp_sock_create(&sock, &ctx, &key_perma);
printf("ecp_sock_create RV:%d\n", rv);
+ rv = ecp_vconn_sock_create(&sock);
+ printf("ecp_vconn_htable_init RV:%d\n", rv);
+
rv = ecp_sock_open(&sock, NULL);
printf("ecp_sock_open RV:%d\n", rv);
rv = ecp_start_receiver(&sock);
printf("ecp_start_receiver RV:%d\n", rv);
- rv = ecp_util_load_pub(&node_pub, argv[argc-1]);
- printf("ecp_util_load_pub RV:%d\n", rv);
+ rv = ecp_util_load_key(argv[argc-1], &node_pub, NULL);
+ printf("ecp_util_load_key RV:%d\n", rv);
ecp_node_init(&node, &node_pub, NULL);
rv = ecp_node_set_addr(&node, argv[2]);
@@ -81,8 +84,8 @@ int main(int argc, char *argv[]) {
ecp_ecdh_public_t vconn_pub[3];
for (i=3; i<argc-1; i++) {
- rv = ecp_util_load_pub(&vconn_pub[i-3], argv[i]);
- printf("ecp_util_load_pub RV:%d\n", rv);
+ rv = ecp_util_load_key(argv[i], &vconn_pub[i-3], NULL);
+ printf("ecp_util_load_key RV:%d\n", rv);
}
ecp_vconn_init(vconn, vconn_pub, argc-4, &sock);
diff --git a/ecp/test/vcs.c b/ecp/test/vcs.c
index 92d1eb2..4f4564b 100644
--- a/ecp/test/vcs.c
+++ b/ecp/test/vcs.c
@@ -21,6 +21,29 @@ static void usage(char *arg) {
exit(1);
}
+static int vlink_handle_open(ECPConnection *_conn, ECP2Buffer *bufs) {
+ int rv;
+
+ /* open return connection */
+ if ((_conn->parent == NULL) && ecp_conn_is_inb(_conn) && (memcmp(&_conn->remote.key_perma.public, &conn.remote.key_perma.public, sizeof(conn.remote.key_perma.public)) != 0)) {
+ ECPNode node;
+ ECPConnection *conn_r;
+
+ ecp_node_init(&node, &_conn->remote.key_perma.public, &_conn->remote.addr);
+
+ conn_r = malloc(sizeof(ECPConnection));
+ if (conn_r == NULL) return ECP_ERR_ALLOC;
+
+ ecp_vlink_init(conn_r, _conn->sock);
+ rv = ecp_conn_open(conn_r, &node);
+ printf("open return connection: ecp_conn_open RV:%d\n", rv);
+ if (rv) return rv;
+ }
+
+ rv = ecp_vlink_handle_open(_conn, bufs);
+ return rv;
+}
+
int main(int argc, char *argv[]) {
ecp_tr_addr_t addr;
ECPDHKey key_perma;
@@ -30,14 +53,18 @@ int main(int argc, char *argv[]) {
rv = ecp_init(&ctx, &vconn_handler, &vlink_handler);
printf("ecp_init RV:%d\n", rv);
+ vlink_handler.handle_open = vlink_handle_open;
- rv = ecp_util_load_key(&key_perma.public, &key_perma.private, argv[2]);
+ rv = ecp_util_load_key(argv[2], &key_perma.public, &key_perma.private);
printf("ecp_util_load_key RV:%d\n", rv);
key_perma.valid = 1;
rv = ecp_sock_create(&sock, &ctx, &key_perma);
printf("ecp_sock_create RV:%d\n", rv);
+ rv = ecp_vconn_sock_create(&sock);
+ printf("ecp_vconn_htable_init RV:%d\n", rv);
+
rv = ecp_addr_init(&addr, argv[1]);
printf("ecp_addr_init RV:%d\n", rv);
@@ -51,8 +78,8 @@ int main(int argc, char *argv[]) {
ECPNode node;
ecp_ecdh_public_t node_pub;
- rv = ecp_util_load_pub(&node_pub, argv[4]);
- printf("ecp_util_load_pub RV:%d\n", rv);
+ rv = ecp_util_load_key(argv[4], &node_pub, NULL);
+ printf("ecp_util_load_key RV:%d\n", rv);
ecp_node_init(&node, &node_pub, NULL);
rv = ecp_node_set_addr(&node, argv[3]);
@@ -61,6 +88,8 @@ int main(int argc, char *argv[]) {
ecp_vlink_init(&conn, &sock);
rv = ecp_conn_open(&conn, &node);
printf("ecp_conn_open RV:%d\n", rv);
+ } else {
+ memset(&conn, 0, sizeof(conn));
}
while (1) sleep(1);