summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/main.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-12-02 15:22:52 +0100
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-12-02 17:45:24 +0100
commit85b3822a4cc121dcb3d87937c2a44395d8887ae3 (patch)
tree941b20c216e21bceb8741704debfe6efc07f2c2f /src/ipcpd/normal/main.c
parent552f2eb19f04968c0c5ebc7b16f6aa1cb61b6b29 (diff)
downloadouroboros-85b3822a4cc121dcb3d87937c2a44395d8887ae3.tar.gz
ouroboros-85b3822a4cc121dcb3d87937c2a44395d8887ae3.zip
ipcpd: normal: Provide directory for registered names
This adds a directory to the normal IPCP that maps names on IPCP addresses.
Diffstat (limited to 'src/ipcpd/normal/main.c')
-rw-r--r--src/ipcpd/normal/main.c55
1 files changed, 7 insertions, 48 deletions
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index 810fbca5..64138838 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -32,6 +32,7 @@
#include "ribmgr.h"
#include "ipcp.h"
#include "frct.h"
+#include "dir.h"
#include <stdbool.h>
#include <signal.h>
@@ -68,51 +69,6 @@ void ipcp_sig_handler(int sig, siginfo_t * info, void * c)
}
}
-static int normal_ipcp_name_reg(char * name)
-{
- pthread_rwlock_rdlock(&ipcpi.state_lock);
-
- if (ipcp_data_reg_add_entry(ipcpi.data, name)) {
- pthread_rwlock_unlock(&ipcpi.state_lock);
- LOG_ERR("Failed to add %s to local registry.", name);
- return -1;
- }
-
- pthread_rwlock_unlock(&ipcpi.state_lock);
-
- LOG_DBG("Registered %s.", name);
-
- return 0;
-}
-
-static int normal_ipcp_name_unreg(char * name)
-{
- pthread_rwlock_rdlock(&ipcpi.state_lock);
-
- ipcp_data_reg_del_entry(ipcpi.data, name);
-
- pthread_rwlock_unlock(&ipcpi.state_lock);
-
- return 0;
-}
-
-static int normal_ipcp_name_query(char * name)
-{
- LOG_MISSING;
-
- /*
- * NOTE: For the moment we just return -1,
- * for testing purposes we may return zero here
- * for certain names.
- */
-
- /* FIXME: Here for testing purposes */
- if (strcmp(name, "normal.app") == 0)
- return 0;
-
- return -1;
-}
-
static int normal_ipcp_enroll(char * dif_name)
{
struct timespec timeout = {(ENROLL_TIMEOUT / 1000),
@@ -206,9 +162,9 @@ static int normal_ipcp_bootstrap(struct dif_config * conf)
static struct ipcp_ops normal_ops = {
.ipcp_bootstrap = normal_ipcp_bootstrap,
.ipcp_enroll = normal_ipcp_enroll,
- .ipcp_name_reg = normal_ipcp_name_reg,
- .ipcp_name_unreg = normal_ipcp_name_unreg,
- .ipcp_name_query = normal_ipcp_name_query,
+ .ipcp_name_reg = dir_name_reg,
+ .ipcp_name_unreg = dir_name_unreg,
+ .ipcp_name_query = dir_name_query,
.ipcp_flow_alloc = fmgr_np1_alloc,
.ipcp_flow_alloc_resp = fmgr_np1_alloc_resp,
.ipcp_flow_dealloc = fmgr_np1_dealloc
@@ -292,6 +248,9 @@ int main(int argc, char * argv[])
if (frct_fini())
LOG_ERR("Failed to finalize FRCT.");
+ if (dir_fini())
+ LOG_ERR("Failed to finalize directory.");
+
close_logfile();
ap_fini();