From fbb5a477eaed7a4dc0a8adf2785c20653f064af7 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Tue, 15 Mar 2022 04:34:50 +0100 Subject: basic test passed --- ecp/test/init.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'ecp/test/init.c') diff --git a/ecp/test/init.c b/ecp/test/init.c index 7b59578..f4b033a 100644 --- a/ecp/test/init.c +++ b/ecp/test/init.c @@ -1,17 +1,10 @@ #include -#include -#include +#include -#include "core.h" +#include -static int v_rng(void *buf, size_t bufsize) { - int fd; - - if((fd = open("/dev/urandom", O_RDONLY)) < 0) return -1; - size_t nb = read(fd, buf, bufsize); - close(fd); - if (nb != bufsize) return -1; - return 0; +void handle_err(ECPConnection *conn, unsigned char mtype, int err) { + printf("ERR: CTYPE:%d MTYPE:%x ERR:%d\n", conn->type, mtype, err); } static ECPConnection *conn_alloc(ECPSocket *sock, unsigned char type) { @@ -21,7 +14,7 @@ static ECPConnection *conn_alloc(ECPSocket *sock, unsigned char type) { conn = malloc(sizeof(ECPConnection)); if (conn == NULL) return NULL; - rv = ecp_conn_init(conn, sock, type); + rv = ecp_conn_create_inb(conn, sock, type); if (rv) { free(conn); return NULL; @@ -36,12 +29,6 @@ static void conn_free(ECPConnection *conn) { int ecp_init(ECPContext *ctx) { int rv; - rv = ecp_ctx_init(ctx); - if (rv) return rv; - - ctx->rng = v_rng; - ctx->conn_alloc = conn_alloc; - ctx->conn_free = conn_free; - - return ECP_OK; -} \ No newline at end of file + rv = ecp_ctx_init(ctx, handle_err, NULL, conn_alloc, conn_free); + return rv; +} -- cgit v1.2.3