From 85b3822a4cc121dcb3d87937c2a44395d8887ae3 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Fri, 2 Dec 2016 15:22:52 +0100 Subject: ipcpd: normal: Provide directory for registered names This adds a directory to the normal IPCP that maps names on IPCP addresses. --- src/ipcpd/normal/main.c | 55 +++++++------------------------------------------ 1 file changed, 7 insertions(+), 48 deletions(-) (limited to 'src/ipcpd/normal/main.c') 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 #include @@ -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(); -- cgit v1.2.3