diff options
author | Uros Majstorovic <majstor@majstor.org> | 2020-08-05 03:38:22 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2020-08-05 03:38:22 +0200 |
commit | 5cd610a07468137066ea4daa5176c3e7045113b0 (patch) | |
tree | a6a5b572572f8f37ec2cb87332fa46e9bcc53aa7 /code/test/vid/server.c | |
parent | 2473a7d5c51806ab8651cd3c4e07a15b62084eb5 (diff) |
ecp moved to root; fixed utils and tests
Diffstat (limited to 'code/test/vid/server.c')
-rw-r--r-- | code/test/vid/server.c | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/code/test/vid/server.c b/code/test/vid/server.c deleted file mode 100644 index 9d43b7a..0000000 --- a/code/test/vid/server.c +++ /dev/null @@ -1,76 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <stdlib.h> - -#include "server.h" - -static ECPContext ctx; -static ECPSocket sock; -static ECPDHKey key_perma; -static ECPConnHandler handler; - -static ECPConnection *conn_in; -static int is_open = 0; - -#define CTYPE_TEST 0 -#define MTYPE_MSG 8 - -ECPNode node; -ECPConnection conn; - -static ssize_t handle_open(ECPConnection *c, ecp_seq_t sq, unsigned char t, unsigned char *m, ssize_t sz, ECP2Buffer *b) { - fprintf(stderr, "IS OPEN!\n"); - - ssize_t rv = ecp_conn_handle_open(c, sq, t, m, sz, b); - if (rv < 0) return rv; - - conn_in = c; - is_open = 1; - - return rv; -} - -ssize_t send_frame(unsigned char *buffer, size_t size, ecp_pts_t pts) { - return ecp_send(conn_in, MTYPE_MSG, buffer, size); -} - -int conn_is_open(void) { - return is_open; -} - -int init_server(char *address, char *my_key, char *vcs_key) { - int rv; - - rv = ecp_init(&ctx); - fprintf(stderr, "ecp_init RV:%d\n", rv); - - if (!rv) rv = ecp_conn_handler_init(&handler); - if (!rv) { - handler.msg[ECP_MTYPE_OPEN] = handle_open; - ctx.handler[CTYPE_TEST] = &handler; - } - - if (!rv) rv = ecp_util_key_load(&ctx, &key_perma, my_key); - fprintf(stderr, "ecp_util_key_load RV:%d\n", rv); - - if (!rv) rv = ecp_sock_create(&sock, &ctx, &key_perma); - fprintf(stderr, "ecp_sock_create RV:%d\n", rv); - - if (!rv) rv = ecp_sock_open(&sock, address); - fprintf(stderr, "ecp_sock_open RV:%d\n", rv); - - if (!rv) rv = ecp_start_receiver(&sock); - fprintf(stderr, "ecp_start_receiver RV:%d\n", rv); - - if (!rv) rv = ecp_util_node_load(&ctx, &node, vcs_key); - printf("ecp_util_node_load RV:%d\n", rv); - - if (!rv) rv = ecp_conn_create(&conn, &sock, ECP_CTYPE_VLINK); - printf("ecp_conn_create RV:%d\n", rv); - - if (!rv) rv = ecp_conn_open(&conn, &node); - printf("ecp_conn_open RV:%d\n", rv); - - return rv; -} |