summaryrefslogtreecommitdiff
path: root/src/ipcpd/unicast/dir.c
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2021-12-27 12:57:50 +0100
committerSander Vrijders <[email protected]>2021-12-29 09:12:20 +0100
commitebf1b0c7415f394712c8dd71ae8c8e6821fd5fa3 (patch)
tree8a976b5541b97617b7edece8329754acaa5ed48c /src/ipcpd/unicast/dir.c
parent0a0c244b9939059b86d304dd127763fed7d10af4 (diff)
downloadouroboros-ebf1b0c7415f394712c8dd71ae8c8e6821fd5fa3.tar.gz
ouroboros-ebf1b0c7415f394712c8dd71ae8c8e6821fd5fa3.zip
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 <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/ipcpd/unicast/dir.c')
-rw-r--r--src/ipcpd/unicast/dir.c27
1 files changed, 15 insertions, 12 deletions
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 <[email protected]>
* Sander Vrijders <[email protected]>
@@ -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);
}