From f2bc5ddbeca144fa79208a5ac6a029da6ed5c10c Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Thu, 31 Mar 2022 13:09:12 +0200 Subject: vconn bugfix --- ecp/test/vcs.c | 58 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 26 deletions(-) (limited to 'ecp/test/vcs.c') diff --git a/ecp/test/vcs.c b/ecp/test/vcs.c index f3a0156..c4beed7 100644 --- a/ecp/test/vcs.c +++ b/ecp/test/vcs.c @@ -1,54 +1,60 @@ -#include +#include #include #include -#include +#include -#include "core.h" -#include "util.h" -#include "vconn/vconn.h" +#include +#include + +#include ECPContext ctx; ECPSocket sock; -ECPDHKey key_perma; - -ECPNode node; ECPConnection conn; static void usage(char *arg) { - fprintf(stderr, "Usage: %s
[node.pub]\n", arg); + fprintf(stderr, "Usage: %s [ ]\n", arg); exit(1); } int main(int argc, char *argv[]) { + ECPDHKey key_perma; int rv; - - if ((argc < 3) || (argc > 4)) usage(argv[0]); - + + if ((argc < 3) || (argc > 5)) usage(argv[0]); + rv = ecp_init(&ctx); printf("ecp_init RV:%d\n", rv); - - rv = ecp_util_key_load(&ctx, &key_perma, argv[2]); - printf("ecp_util_key_load RV:%d\n", rv); - - rv = ecp_sock_init(&sock, &ctx, &key_perma); - printf("ecp_sock_init RV:%d\n", rv); + + rv = ecp_util_load_key(&key_perma.public, &key_perma.private, argv[2]); + 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_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_init(&conn, &sock, ECP_CTYPE_VLINK); - printf("ecp_conn_init RV:%d\n", rv); + if (argc == 5) { + ECPNode node; + ecp_ecdh_public_t node_pub; + + rv = ecp_vlink_create(&conn, &sock); + printf("ecp_vlink_create RV:%d\n", rv); + + rv = ecp_util_load_pub(&node_pub, argv[4]); + printf("ecp_util_load_pub RV:%d\n", rv); + + rv = ecp_node_init(&node, &node_pub, argv[3]); + printf("ecp_node_init 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 +} -- cgit v1.2.3