- * Implementation of ike_sa_t.retransmit.
- */
-static status_t retransmit(private_ike_sa_t *this, u_int32_t message_id)
-{ /* FIXME: IKE-ME */
- this->time.outbound = time(NULL);
- if (this->task_manager->retransmit(this->task_manager, message_id) != SUCCESS)
- {
- child_cfg_t *child_cfg;
- child_sa_t* child_sa;
- linked_list_t *to_route, *to_restart;
- iterator_t *iterator;
-
- /* send a proper signal to brief interested bus listeners */
- switch (this->state)
- {
- case IKE_CONNECTING:
- {
- /* retry IKE_SA_INIT if we have multiple keyingtries */
- u_int32_t tries = this->peer_cfg->get_keyingtries(this->peer_cfg);
- this->keyingtry++;
- if (tries == 0 || tries > this->keyingtry)
- {
- SIG(IKE_UP_FAILED, "peer not responding, trying again "
- "(%d/%d) in background ", this->keyingtry + 1, tries);
- reset(this);
- return this->task_manager->initiate(this->task_manager);
- }
- SIG(IKE_UP_FAILED, "establishing IKE_SA failed, peer not responding");
- break;
- }
- case IKE_REKEYING:
- SIG(IKE_REKEY_FAILED, "rekeying IKE_SA failed, peer not responding");
- break;
- case IKE_DELETING:
- SIG(IKE_DOWN_FAILED, "proper IKE_SA delete failed, peer not responding");
- break;
- default:
- break;
- }
-
- /* summarize how we have to handle each child */
- to_route = linked_list_create();
- to_restart = linked_list_create();
- iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
- while (iterator->iterate(iterator, (void**)&child_sa))
- {
- child_cfg = child_sa->get_config(child_sa);
-
- if (child_sa->get_state(child_sa) == CHILD_ROUTED)
- {
- /* reroute routed CHILD_SAs */
- to_route->insert_last(to_route, child_cfg);
- }
- else
- {
- /* use DPD action for established CHILD_SAs */
- switch (this->peer_cfg->get_dpd_action(this->peer_cfg))
- {
- case DPD_ROUTE:
- to_route->insert_last(to_route, child_cfg);
- break;
- case DPD_RESTART:
- to_restart->insert_last(to_restart, child_cfg);
- break;
- default:
- break;
- }
- }
- }
- iterator->destroy(iterator);
-
- /* create a new IKE_SA if we have to route or to restart */
- if (to_route->get_count(to_route) || to_restart->get_count(to_restart))
- {
- private_ike_sa_t *new;
- task_t *task;
-
- new = (private_ike_sa_t*)charon->ike_sa_manager->checkout_new(
- charon->ike_sa_manager, TRUE);
-
- set_peer_cfg(new, this->peer_cfg);
- /* use actual used host, not the wildcarded one in config */
- new->other_host->destroy(new->other_host);
- new->other_host = this->other_host->clone(this->other_host);
- /* reset port to 500, but only if peer is not NATed */
- if (!has_condition(this, COND_NAT_THERE))
- {
- new->other_host->set_port(new->other_host, IKEV2_UDP_PORT);
- }
- /* take over virtual ip, as we need it for a proper route */
- if (this->my_virtual_ip)
- {
- set_virtual_ip(new, TRUE, this->my_virtual_ip);
- }
-
- /* install routes */
- while (to_route->remove_last(to_route, (void**)&child_cfg) == SUCCESS)
- {
- route(new, child_cfg);
- }
-
- /* restart children */
- if (to_restart->get_count(to_restart))
- {
- task = (task_t*)ike_init_create(&new->public, TRUE, NULL);
- new->task_manager->queue_task(new->task_manager, task);
- task = (task_t*)ike_natd_create(&new->public, TRUE);
- new->task_manager->queue_task(new->task_manager, task);
- task = (task_t*)ike_cert_pre_create(&new->public, TRUE);
- new->task_manager->queue_task(new->task_manager, task);
- task = (task_t*)ike_config_create(&new->public, TRUE);
- new->task_manager->queue_task(new->task_manager, task);
- task = (task_t*)ike_auth_create(&new->public, TRUE);
- new->task_manager->queue_task(new->task_manager, task);
- task = (task_t*)ike_cert_post_create(&new->public, TRUE);
- new->task_manager->queue_task(new->task_manager, task);
-
- while (to_restart->remove_last(to_restart, (void**)&child_cfg) == SUCCESS)
- {
- task = (task_t*)child_create_create(&new->public, child_cfg);
- new->task_manager->queue_task(new->task_manager, task);
- }
- task = (task_t*)ike_auth_lifetime_create(&new->public, TRUE);
- new->task_manager->queue_task(new->task_manager, task);
- if (this->peer_cfg->use_mobike(this->peer_cfg))
- {
- task = (task_t*)ike_mobike_create(&new->public, TRUE);
- new->task_manager->queue_task(new->task_manager, task);
- }
- new->task_manager->initiate(new->task_manager);
- }
- charon->ike_sa_manager->checkin(charon->ike_sa_manager, &new->public);
- }
- to_route->destroy(to_route);
- to_restart->destroy(to_restart);
- return DESTROY_ME;
- }
- return SUCCESS;
-}
-
-/**