summaryrefslogtreecommitdiff
path: root/ecp/test/vcs.c
diff options
context:
space:
mode:
Diffstat (limited to 'ecp/test/vcs.c')
-rw-r--r--ecp/test/vcs.c58
1 files changed, 32 insertions, 26 deletions
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 <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <stdlib.h>
+#include <stdio.h>
-#include "core.h"
-#include "util.h"
-#include "vconn/vconn.h"
+#include <core.h>
+#include <vconn/vconn.h>
+
+#include <util.h>
ECPContext ctx;
ECPSocket sock;
-ECPDHKey key_perma;
-
-ECPNode node;
ECPConnection conn;
static void usage(char *arg) {
- fprintf(stderr, "Usage: %s <address> <node.priv> [node.pub]\n", arg);
+ fprintf(stderr, "Usage: %s <my addr> <my.priv> [ <node addr> <node.pub> ]\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
+}