From ebf1b0c7415f394712c8dd71ae8c8e6821fd5fa3 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Mon, 27 Dec 2021 12:57:50 +0100 Subject: ipcpd: Allow creation of multiple directories To allow merging large network layers, a situation will arise where multiple directories need to coexist within the layer. This reverts commit 9422e6be94ac1007e8115a920379fd545055e531. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/unicast/dir.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/ipcpd/unicast/dir.c') diff --git a/src/ipcpd/unicast/dir.c b/src/ipcpd/unicast/dir.c index 0c48de0d..870d0e10 100644 --- a/src/ipcpd/unicast/dir.c +++ b/src/ipcpd/unicast/dir.c @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2021 * - * Directory + * Directory Management * * Dimitri Staessens * Sander Vrijders @@ -44,14 +44,16 @@ struct { struct dir_ops * ops; -} dir; + void * dir; +} dirmgr; int dir_init(void) { - dir.ops = &dht_dir_ops; + dirmgr.ops = &dht_dir_ops; - if (dir.ops->init() < 0) { - dir.ops = NULL; + dirmgr.dir = dirmgr.ops->create(); + if (dirmgr.dir == NULL) { + dirmgr.ops = NULL; return -ENOMEM; } @@ -60,31 +62,32 @@ int dir_init(void) void dir_fini(void) { - dir.ops->fini(); - dir.ops = NULL; + dirmgr.ops->destroy(dirmgr.dir); + dirmgr.ops = NULL; + dirmgr.dir = NULL; } int dir_bootstrap(void) { - return dir.ops->bootstrap(); + return dirmgr.ops->bootstrap(dirmgr.dir); } int dir_reg(const uint8_t * hash) { - return dir.ops->reg(hash); + return dirmgr.ops->reg(dirmgr.dir, hash); } int dir_unreg(const uint8_t * hash) { - return dir.ops->unreg(hash); + return dirmgr.ops->unreg(dirmgr.dir, hash); } uint64_t dir_query(const uint8_t * hash) { - return dir.ops->query(hash); + return dirmgr.ops->query(dirmgr.dir, hash); } int dir_wait_running(void) { - return dir.ops->wait_running(); + return dirmgr.ops->wait_running(dirmgr.dir); } -- cgit v1.2.3