task-manager-v1: Clear retransmit alert on request retransmit
[strongswan.git] / src / libcharon / sa / trap_manager.c
index 012f0fe..148df39 100644 (file)
@@ -168,7 +168,7 @@ static bool dynamic_remote_ts(child_cfg_t *child)
        traffic_selector_t *ts;
        bool found = FALSE;
 
-       other_ts = child->get_traffic_selectors(child, FALSE, NULL, NULL);
+       other_ts = child->get_traffic_selectors(child, FALSE, NULL, NULL, FALSE);
        enumerator = other_ts->create_enumerator(other_ts);
        while (enumerator->enumerate(enumerator, &ts))
        {
@@ -183,9 +183,8 @@ static bool dynamic_remote_ts(child_cfg_t *child)
        return found;
 }
 
-METHOD(trap_manager_t, install, uint32_t,
-       private_trap_manager_t *this, peer_cfg_t *peer, child_cfg_t *child,
-       uint32_t reqid)
+METHOD(trap_manager_t, install, bool,
+       private_trap_manager_t *this, peer_cfg_t *peer, child_cfg_t *child)
 {
        entry_t *entry, *found = NULL;
        ike_cfg_t *ike_cfg;
@@ -197,7 +196,7 @@ METHOD(trap_manager_t, install, uint32_t,
        linked_list_t *proposals;
        proposal_t *proposal;
        protocol_id_t proto = PROTO_ESP;
-       bool wildcard = FALSE;
+       bool result = FALSE, wildcard = FALSE;
 
        /* try to resolve addresses */
        ike_cfg = peer->get_ike_cfg(peer);
@@ -213,7 +212,7 @@ METHOD(trap_manager_t, install, uint32_t,
        {
                other->destroy(other);
                DBG1(DBG_CFG, "installing trap failed, remote address unknown");
-               return 0;
+               return FALSE;
        }
        else
        {       /* depending on the traffic selectors we don't really need a remote
@@ -223,7 +222,7 @@ METHOD(trap_manager_t, install, uint32_t,
                         * which is probably not what users expect*/
                        DBG1(DBG_CFG, "installing trap failed, remote address unknown with "
                                 "dynamic traffic selector");
-                       return 0;
+                       return FALSE;
                }
                me = ike_cfg->resolve_me(ike_cfg, other ? other->get_family(other)
                                                                                                : AF_UNSPEC);
@@ -250,12 +249,14 @@ METHOD(trap_manager_t, install, uint32_t,
                this->lock->unlock(this->lock);
                other->destroy(other);
                me->destroy(me);
-               return 0;
+               return FALSE;
        }
        enumerator = this->traps->create_enumerator(this->traps);
        while (enumerator->enumerate(enumerator, &entry))
        {
-               if (streq(entry->name, child->get_name(child)))
+               if (streq(entry->name, child->get_name(child)) &&
+                       streq(entry->peer_cfg->get_name(entry->peer_cfg),
+                                 peer->get_name(peer)))
                {
                        found = entry;
                        if (entry->child_sa)
@@ -275,11 +276,10 @@ METHOD(trap_manager_t, install, uint32_t,
                        this->lock->unlock(this->lock);
                        other->destroy(other);
                        me->destroy(me);
-                       return 0;
+                       return FALSE;
                }
                /* config might have changed so update everything */
                DBG1(DBG_CFG, "updating already routed CHILD_SA '%s'", found->name);
-               reqid = found->child_sa->get_reqid(found->child_sa);
        }
 
        INIT(entry,
@@ -293,14 +293,14 @@ METHOD(trap_manager_t, install, uint32_t,
        this->lock->unlock(this->lock);
 
        /* create and route CHILD_SA */
-       child_sa = child_sa_create(me, other, child, reqid, FALSE, 0, 0);
+       child_sa = child_sa_create(me, other, child, 0, FALSE, 0, 0);
 
        list = linked_list_create_with_items(me, NULL);
-       my_ts = child->get_traffic_selectors(child, TRUE, NULL, list);
+       my_ts = child->get_traffic_selectors(child, TRUE, NULL, list, FALSE);
        list->destroy_offset(list, offsetof(host_t, destroy));
 
        list = linked_list_create_with_items(other, NULL);
-       other_ts = child->get_traffic_selectors(child, FALSE, NULL, list);
+       other_ts = child->get_traffic_selectors(child, FALSE, NULL, list, FALSE);
        list->destroy_offset(list, offsetof(host_t, destroy));
 
        /* We don't know the finally negotiated protocol (ESP|AH), we install
@@ -325,14 +325,13 @@ METHOD(trap_manager_t, install, uint32_t,
                this->lock->unlock(this->lock);
                entry->child_sa = child_sa;
                destroy_entry(entry);
-               reqid = 0;
        }
        else
        {
-               reqid = child_sa->get_reqid(child_sa);
                this->lock->write_lock(this->lock);
                entry->child_sa = child_sa;
                this->lock->unlock(this->lock);
+               result = TRUE;
        }
        if (found)
        {
@@ -343,7 +342,7 @@ METHOD(trap_manager_t, install, uint32_t,
        this->installing--;
        this->condvar->signal(this->condvar);
        this->lock->unlock(this->lock);
-       return reqid;
+       return result;
 }
 
 METHOD(trap_manager_t, uninstall, bool,
@@ -412,31 +411,6 @@ METHOD(trap_manager_t, create_enumerator, enumerator_t*,
                                                                        (void*)this->lock->unlock);
 }
 
-METHOD(trap_manager_t, find_reqid, uint32_t,
-       private_trap_manager_t *this, child_cfg_t *child)
-{
-       enumerator_t *enumerator;
-       entry_t *entry;
-       uint32_t reqid = 0;
-
-       this->lock->read_lock(this->lock);
-       enumerator = this->traps->create_enumerator(this->traps);
-       while (enumerator->enumerate(enumerator, &entry))
-       {
-               if (streq(entry->name, child->get_name(child)))
-               {
-                       if (entry->child_sa)
-                       {
-                               reqid = entry->child_sa->get_reqid(entry->child_sa);
-                       }
-                       break;
-               }
-       }
-       enumerator->destroy(enumerator);
-       this->lock->unlock(this->lock);
-       return reqid;
-}
-
 METHOD(trap_manager_t, acquire, void,
        private_trap_manager_t *this, uint32_t reqid,
        traffic_selector_t *src, traffic_selector_t *dst)
@@ -692,7 +666,6 @@ trap_manager_t *trap_manager_create(void)
                        .install = _install,
                        .uninstall = _uninstall,
                        .create_enumerator = _create_enumerator,
-                       .find_reqid = _find_reqid,
                        .acquire = _acquire,
                        .flush = _flush,
                        .destroy = _destroy,