diff options
Diffstat (limited to 'src/ipcpd')
-rw-r--r-- | src/ipcpd/broadcast/main.c | 9 | ||||
-rw-r--r-- | src/ipcpd/eth/eth.c | 1 | ||||
-rw-r--r-- | src/ipcpd/ipcp.c | 16 | ||||
-rw-r--r-- | src/ipcpd/local/main.c | 2 | ||||
-rw-r--r-- | src/ipcpd/udp/main.c | 2 | ||||
-rw-r--r-- | src/ipcpd/unicast/main.c | 7 |
6 files changed, 12 insertions, 25 deletions
diff --git a/src/ipcpd/broadcast/main.c b/src/ipcpd/broadcast/main.c index ab8fc5bd..b0cbc6a7 100644 --- a/src/ipcpd/broadcast/main.c +++ b/src/ipcpd/broadcast/main.c @@ -78,10 +78,6 @@ static void finalize_components(void) static int start_components(void) { - assert(ipcp_get_state() == IPCP_INIT); - - ipcp_set_state(IPCP_OPERATIONAL); - if (enroll_start() < 0) { log_err("Failed to start enrollment."); goto fail_enroll_start; @@ -103,14 +99,9 @@ static int start_components(void) static void stop_components(void) { - assert(ipcp_get_state() == IPCP_OPERATIONAL || - ipcp_get_state() == IPCP_SHUTDOWN); - connmgr_stop(); enroll_stop(); - - ipcp_set_state(IPCP_INIT); } static int broadcast_ipcp_enroll(const char * dst, diff --git a/src/ipcpd/eth/eth.c b/src/ipcpd/eth/eth.c index a429c0a0..12bd294e 100644 --- a/src/ipcpd/eth/eth.c +++ b/src/ipcpd/eth/eth.c @@ -1477,7 +1477,6 @@ static int eth_ipcp_bootstrap(const struct ipcp_config * conf) } #endif /* HAVE_NETMAP */ - ipcp_set_state(IPCP_OPERATIONAL); #if defined(__linux__) if (pthread_create(ð_data.if_monitor, diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index b32e7cda..f40c70e6 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -267,6 +267,8 @@ static void handle_bootstrap(ipcp_config_msg_t * conf_msg, { struct ipcp_config conf; + assert(ipcp_get_state() == IPCP_INIT); + if (ipcpi.ops->ipcp_bootstrap == NULL) { log_err("Bootstrap unsupported."); ret_msg->result = -ENOTSUP; @@ -281,8 +283,10 @@ static void handle_bootstrap(ipcp_config_msg_t * conf_msg, conf = ipcp_config_msg_to_s(conf_msg); ret_msg->result = ipcpi.ops->ipcp_bootstrap(&conf); - if (ret_msg->result == 0) + if (ret_msg->result == 0) { ret_msg->layer_info = layer_info_s_to_msg(&conf.layer_info); + ipcp_set_state(IPCP_OPERATIONAL); + } } static void handle_enroll(const char * dst, @@ -290,6 +294,8 @@ static void handle_enroll(const char * dst, { struct layer_info info; + assert(ipcp_get_state() == IPCP_INIT); + if (ipcpi.ops->ipcp_enroll == NULL) { log_err("Enroll unsupported."); ret_msg->result = -ENOTSUP; @@ -303,8 +309,10 @@ static void handle_enroll(const char * dst, } ret_msg->result = ipcpi.ops->ipcp_enroll(dst, &info); - if (ret_msg->result == 0) + if (ret_msg->result == 0) { ret_msg->layer_info = layer_info_s_to_msg(&info); + ipcp_set_state(IPCP_OPERATIONAL); + } } static void handle_connect(const char * dst, @@ -760,6 +768,8 @@ int ipcp_init(int argc, pthread_condattr_destroy(&cattr); + ipcp_set_state(IPCP_INIT); + return 0; fail_tpm_create: @@ -802,8 +812,6 @@ int ipcp_start(void) if (tpm_start(ipcpi.tpm)) goto fail_tpm_start; - ipcp_set_state(IPCP_INIT); - if (pthread_create(&ipcpi.acceptor, NULL, acceptloop, NULL)) { log_err("Failed to create acceptor thread."); goto fail_acceptor; diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index e0ba04be..2a5199bb 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -148,8 +148,6 @@ static int local_ipcp_bootstrap(const struct ipcp_config * conf) ipcpi.dir_hash_algo = conf->layer_info.dir_hash_algo; strcpy(ipcpi.layer_name,conf->layer_info.layer_name); - ipcp_set_state(IPCP_OPERATIONAL); - if (pthread_create(&local_data.packet_loop, NULL, local_ipcp_packet_loop, NULL)) { ipcp_set_state(IPCP_INIT); diff --git a/src/ipcpd/udp/main.c b/src/ipcpd/udp/main.c index 62cd3181..86bb1afe 100644 --- a/src/ipcpd/udp/main.c +++ b/src/ipcpd/udp/main.c @@ -658,8 +658,6 @@ static int udp_ipcp_bootstrap(const struct ipcp_config * conf) udp_data.dns_addr = conf->udp.dns_addr; - ipcp_set_state(IPCP_OPERATIONAL); - if (pthread_create(&udp_data.mgmt_handler, NULL, udp_ipcp_mgmt_handler, NULL)) { ipcp_set_state(IPCP_INIT); diff --git a/src/ipcpd/unicast/main.c b/src/ipcpd/unicast/main.c index 994b1fd3..e1c3d5d0 100644 --- a/src/ipcpd/unicast/main.c +++ b/src/ipcpd/unicast/main.c @@ -129,10 +129,6 @@ static void finalize_components(void) static int start_components(void) { - assert(ipcp_get_state() == IPCP_INIT); - - ipcp_set_state(IPCP_OPERATIONAL); - if (dt_start() < 0) { log_err("Failed to start data transfer."); goto fail_dt_start; @@ -168,9 +164,6 @@ static int start_components(void) static void stop_components(void) { - assert(ipcp_get_state() == IPCP_OPERATIONAL || - ipcp_get_state() == IPCP_SHUTDOWN); - connmgr_stop(); enroll_stop(); |