summaryrefslogtreecommitdiff
path: root/ecp/test/vc_server.c
diff options
context:
space:
mode:
Diffstat (limited to 'ecp/test/vc_server.c')
-rw-r--r--ecp/test/vc_server.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/ecp/test/vc_server.c b/ecp/test/vc_server.c
index de7f275..548b52d 100644
--- a/ecp/test/vc_server.c
+++ b/ecp/test/vc_server.c
@@ -3,16 +3,20 @@
#include <unistd.h>
#include <stdio.h>
-#include <core.h>
-#include <vconn/vconn.h>
+#include <ecp/core.h>
+#include <ecp/vconn/vconn.h>
#include <util.h>
+#include "init_vconn.h"
+
ECPContext ctx;
ECPSocket sock;
ECPConnHandler handler;
+ECPConnHandler vconn_handler;
+ECPConnHandler vlink_handler;
ECPConnection conn;
-ECPConnection vconn[3];
+ECPVConnOutb vconn[3];
#define CTYPE_TEST 0
#define MTYPE_MSG 0
@@ -46,11 +50,11 @@ int main(int argc, char *argv[]) {
if ((argc < 4) || (argc > 7)) usage(argv[0]);
- rv = ecp_init(&ctx);
+ rv = ecp_init(&ctx, &vconn_handler, &vlink_handler);
printf("ecp_init RV:%d\n", rv);
ecp_conn_handler_init(&handler, handle_msg, handle_open, NULL, NULL);
- ecp_ctx_set_handler(&ctx, &handler, CTYPE_TEST);
+ ecp_ctx_set_handler(&ctx, CTYPE_TEST, &handler);
rv = ecp_util_load_key(&key_perma.public, &key_perma.private, argv[1]);
printf("ecp_util_load_key RV:%d\n", rv);
@@ -65,29 +69,29 @@ int main(int argc, char *argv[]) {
rv = ecp_start_receiver(&sock);
printf("ecp_start_receiver RV:%d\n", rv);
- rv = ecp_vlink_create(&conn, &sock);
- printf("ecp_vlink_create RV:%d\n", rv);
+ rv = ecp_util_load_pub(&node_pub, argv[argc-1]);
+ printf("ecp_util_load_pub 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);
+
+ ecp_vlink_init(&conn, &sock);
if (argc > 4) {
- ecp_ecdh_public_t vconn_key[3];
+ ecp_ecdh_public_t vconn_pub[3];
for (i=3; i<argc-1; i++) {
- rv = ecp_util_load_pub(&vconn_key[i-3], argv[i]);
+ rv = ecp_util_load_pub(&vconn_pub[i-3], argv[i]);
printf("ecp_util_load_pub RV:%d\n", rv);
}
+ ecp_vconn_init(vconn, vconn_pub, argc-4, &sock);
- rv = ecp_vconn_create(vconn, vconn_key, argc-4, &conn);
- printf("ecp_vconn_create RV:%d\n", rv);
+ rv = ecp_vconn_open(vconn, &conn, &node);
+ printf("ecp_vconn_open RV:%d\n", rv);
+ } else {
+ rv = ecp_conn_open(&conn, &node);
+ printf("ecp_conn_open 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_node_init(&node, &node_pub, argv[2]);
- printf("ecp_node_init RV:%d\n", rv);
-
- rv = ecp_vconn_open(&conn, &node);
- printf("ecp_vconn_open RV:%d\n", rv);
-
while (1) sleep(1);
}