summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/main.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-03-03 10:31:03 +0000
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2017-03-03 10:31:03 +0000
commitb1b59cc4642faa99514f2288ba1bb5324a79850f (patch)
treecec27d3c2064f0c0bcb564060d9d9012f819b22f /src/ipcpd/normal/main.c
parent46c2f9d5363cdff2d99cf1b1c4a41c5bf97d2c03 (diff)
parenta409fd81dfc6d22f9a287f15394b86490dea5273 (diff)
downloadouroboros-b1b59cc4642faa99514f2288ba1bb5324a79850f.tar.gz
ouroboros-b1b59cc4642faa99514f2288ba1bb5324a79850f.zip
Merged in sandervrijders/ouroboros/be-ae-conn (pull request #396)
ipcpd: normal: Refactor application entities and add neighbors struct
Diffstat (limited to 'src/ipcpd/normal/main.c')
-rw-r--r--src/ipcpd/normal/main.c54
1 files changed, 41 insertions, 13 deletions
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index 3e5907a8..8b9a7c09 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -105,11 +105,6 @@ static int boot_components(void)
log_dbg("Starting components.");
- if (connmgr_init()) {
- log_err("Failed to init ap connection manager");
- return -1;
- }
-
if (rib_read(BOOT_PATH "/addr_auth/type", &pa, sizeof(pa))
!= sizeof(pa)) {
log_err("Failed to read policy for address authority.");
@@ -126,7 +121,6 @@ static int boot_components(void)
if (ipcpi.dt_addr == 0) {
log_err("Failed to get a valid address.");
addr_auth_fini();
- connmgr_fini();
return -1;
}
@@ -137,7 +131,6 @@ static int boot_components(void)
if (ribmgr_init()) {
log_err("Failed to initialize RIB manager.");
addr_auth_fini();
- connmgr_fini();
return -1;
}
@@ -145,7 +138,6 @@ static int boot_components(void)
log_err("Failed to initialize directory.");
ribmgr_fini();
addr_auth_fini();
- connmgr_fini();
return -1;
}
@@ -155,7 +147,6 @@ static int boot_components(void)
dir_fini();
ribmgr_fini();
addr_auth_fini();
- connmgr_fini();
log_err("Failed to start flow manager.");
return -1;
}
@@ -165,20 +156,29 @@ static int boot_components(void)
dir_fini();
ribmgr_fini();
addr_auth_fini();
- connmgr_fini();
log_err("Failed to initialize FRCT.");
return -1;
}
+ if (enroll_start()) {
+ fmgr_fini();
+ dir_fini();
+ ribmgr_fini();
+ addr_auth_fini();
+ log_err("Failed to start enroll.");
+ return -1;
+ }
+
ipcp_set_state(IPCP_OPERATIONAL);
if (connmgr_start()) {
ipcp_set_state(IPCP_INIT);
+ enroll_stop();
+ frct_fini();
fmgr_fini();
dir_fini();
ribmgr_fini();
addr_auth_fini();
- connmgr_fini();
log_err("Failed to start AP connection manager.");
return -1;
}
@@ -190,6 +190,8 @@ void shutdown_components(void)
{
connmgr_stop();
+ enroll_stop();
+
frct_fini();
fmgr_fini();
@@ -199,8 +201,6 @@ void shutdown_components(void)
ribmgr_fini();
addr_auth_fini();
-
- connmgr_fini();
}
static int normal_ipcp_enroll(char * dst_name)
@@ -418,11 +418,33 @@ int main(int argc,
exit(EXIT_FAILURE);
}
+
+ if (connmgr_init()) {
+ log_err("Failed to initialize connection manager.");
+ ipcp_create_r(getpid(), -1);
+ rib_fini();
+ irm_unbind_api(getpid(), ipcpi.name);
+ ipcp_fini();
+ exit(EXIT_FAILURE);
+ }
+
+ if (enroll_init()) {
+ log_err("Failed to initialize enroll component.");
+ ipcp_create_r(getpid(), -1);
+ connmgr_fini();
+ rib_fini();
+ irm_unbind_api(getpid(), ipcpi.name);
+ ipcp_fini();
+ exit(EXIT_FAILURE);
+ }
+
pthread_sigmask(SIG_BLOCK, &sigset, NULL);
if (ipcp_boot() < 0) {
log_err("Failed to boot IPCP.");
ipcp_create_r(getpid(), -1);
+ enroll_fini();
+ connmgr_fini();
rib_fini();
irm_unbind_api(getpid(), ipcpi.name);
ipcp_fini();
@@ -435,6 +457,8 @@ int main(int argc,
log_err("Failed to notify IRMd we are initialized.");
ipcp_set_state(IPCP_NULL);
ipcp_shutdown();
+ enroll_fini();
+ connmgr_fini();
rib_fini();
irm_unbind_api(getpid(), ipcpi.name);
ipcp_fini();
@@ -448,6 +472,10 @@ int main(int argc,
rib_fini();
+ connmgr_fini();
+
+ enroll_fini();
+
irm_unbind_api(getpid(), ipcpi.name);
ipcp_fini();