summaryrefslogtreecommitdiff
path: root/ecp/test/basic.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-08-09 21:54:45 +0200
committerUros Majstorovic <majstor@majstor.org>2022-08-09 21:54:45 +0200
commit810dde21ee65653c15606917b19566cfbaaf165e (patch)
tree4cd84b109e06660a9c59f2487822905e5672681e /ecp/test/basic.c
parentaee853a208d6abec53ec81dc4ef110b63e13342f (diff)
ecp server added
Diffstat (limited to 'ecp/test/basic.c')
-rw-r--r--ecp/test/basic.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/ecp/test/basic.c b/ecp/test/basic.c
index b266a07..637a829 100644
--- a/ecp/test/basic.c
+++ b/ecp/test/basic.c
@@ -2,7 +2,9 @@
#include <unistd.h>
#include <stdio.h>
-#include <core.h>
+#include <ecp/core.h>
+
+#include "init.h"
ECPContext ctx_s;
ECPSocket sock_s;
@@ -43,6 +45,7 @@ static ssize_t handle_msg_s(ECPConnection *conn, ecp_seq_t seq, unsigned char mt
}
int main(int argc, char *argv[]) {
+ ecp_tr_addr_t addr;
ECPDHKey key_perma_c;
ECPDHKey key_perma_s;
ECPNode node;
@@ -53,7 +56,7 @@ int main(int argc, char *argv[]) {
printf("ecp_init RV:%d\n", rv);
ecp_conn_handler_init(&handler_s, handle_msg_s, NULL, NULL, NULL);
- ecp_ctx_set_handler(&ctx_s, &handler_s, CTYPE_TEST);
+ ecp_ctx_set_handler(&ctx_s, CTYPE_TEST, &handler_s);
rv = ecp_dhkey_gen(&key_perma_s);
printf("ecp_dhkey_gen RV:%d\n", rv);
@@ -61,7 +64,10 @@ int main(int argc, char *argv[]) {
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_addr_init(&addr, "0.0.0.0:3000");
+ printf("ecp_addr_init RV:%d\n", rv);
+
+ rv = ecp_sock_open(&sock_s, &addr);
printf("ecp_sock_open RV:%d\n", rv);
rv = ecp_start_receiver(&sock_s);
@@ -72,7 +78,7 @@ int main(int argc, char *argv[]) {
printf("ecp_init RV:%d\n", rv);
ecp_conn_handler_init(&handler_c, handle_msg_c, handle_open_c, NULL, NULL);
- ecp_ctx_set_handler(&ctx_c, &handler_c, CTYPE_TEST);
+ ecp_ctx_set_handler(&ctx_c, CTYPE_TEST, &handler_c);
rv = ecp_dhkey_gen(&key_perma_c);
printf("ecp_dhkey_gen RV:%d\n", rv);
@@ -86,12 +92,11 @@ int main(int argc, char *argv[]) {
rv = ecp_start_receiver(&sock_c);
printf("ecp_start_receiver RV:%d\n", rv);
- rv = ecp_node_init(&node, &key_perma_s.public, "127.0.0.1:3000");
- printf("ecp_node_init RV:%d\n", rv);
-
- rv = ecp_conn_create(&conn, &sock_c, CTYPE_TEST);
- printf("ecp_conn_create RV:%d\n", rv);
+ ecp_node_init(&node, &key_perma_s.public, NULL);
+ rv = ecp_node_set_addr(&node, "127.0.0.1:3000");
+ printf("ecp_node_set_addr RV:%d\n", rv);
+ ecp_conn_init(&conn, &sock_c, CTYPE_TEST);
rv = ecp_conn_open(&conn, &node);
printf("ecp_conn_open RV:%d\n", rv);