From d830d95720e41b3374dd1edda04ef1ea4272967d Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 13 Aug 2017 00:22:37 +0200 Subject: proxy renamed to vconn --- code/test/init_vconn.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 code/test/init_vconn.c (limited to 'code/test/init_vconn.c') diff --git a/code/test/init_vconn.c b/code/test/init_vconn.c new file mode 100644 index 0000000..2e82598 --- /dev/null +++ b/code/test/init_vconn.c @@ -0,0 +1,42 @@ +#include +#include +#include + +#include "core.h" +#include "vconn.h" + +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; +} + +static ECPConnection *conn_alloc(unsigned char type) { + switch (type) { + case ECP_CTYPE_VCONN: + return malloc(sizeof(ECPVConnIn)); + default: + return malloc(sizeof(ECPConnection)); + } +} + +static void conn_free(ECPConnection *conn) { + free(conn); +} + +int ecp_init(ECPContext *ctx) { + int rv; + + rv = ecp_ctx_create(ctx); + if (rv) return rv; + + ctx->rng = v_rng; + ctx->conn_alloc = conn_alloc; + ctx->conn_free = conn_free; + + return ecp_ctx_vconn_init(ctx); +} \ No newline at end of file -- cgit v1.2.3