Use the vararg list constructor in quick mode task
[strongswan.git] / src / libcharon / sa / trap_manager.c
index 86d9f4c..b3d9e15 100644 (file)
@@ -127,14 +127,14 @@ METHOD(trap_manager_t, install, u_int32_t,
 
        /* try to resolve addresses */
        ike_cfg = peer->get_ike_cfg(peer);
-       other = host_create_from_dns(ike_cfg->get_other_addr(ike_cfg),
+       other = host_create_from_dns(ike_cfg->get_other_addr(ike_cfg, NULL),
                                                                 0, ike_cfg->get_other_port(ike_cfg));
        if (!other || other->is_anyaddr(other))
        {
                DBG1(DBG_CFG, "installing trap failed, remote address unknown");
                return 0;
        }
-       me = host_create_from_dns(ike_cfg->get_my_addr(ike_cfg),
+       me = host_create_from_dns(ike_cfg->get_my_addr(ike_cfg, NULL),
                                        other->get_family(other), ike_cfg->get_my_port(ike_cfg));
        if (!me || me->is_anyaddr(me))
        {
@@ -284,26 +284,34 @@ METHOD(trap_manager_t, acquire, void,
 
        ike_sa = charon->ike_sa_manager->checkout_by_config(
                                                                                        charon->ike_sa_manager, peer);
-       if (ike_sa->get_peer_cfg(ike_sa) == NULL)
+       if (ike_sa)
        {
-               ike_sa->set_peer_cfg(ike_sa, peer);
-       }
-       if (ike_sa->initiate(ike_sa, child, reqid, src, dst) != DESTROY_ME)
-       {
-               /* make sure the entry is still there */
-               this->lock->read_lock(this->lock);
-               if (this->traps->find_first(this->traps, NULL,
-                                                                       (void**)&found) == SUCCESS)
+               if (ike_sa->get_peer_cfg(ike_sa) == NULL)
                {
-                       found->ike_sa = ike_sa;
+                       ike_sa->set_peer_cfg(ike_sa, peer);
+               }
+               if (ike_sa->get_version(ike_sa) == IKEV1)
+               {       /* in IKEv1, don't prepend the acquiring packet TS, as we only
+                        * have a single TS that we can establish in a Quick Mode. */
+                       src = dst = NULL;
+               }
+               if (ike_sa->initiate(ike_sa, child, reqid, src, dst) != DESTROY_ME)
+               {
+                       /* make sure the entry is still there */
+                       this->lock->read_lock(this->lock);
+                       if (this->traps->find_first(this->traps, NULL,
+                                                                               (void**)&found) == SUCCESS)
+                       {
+                               found->ike_sa = ike_sa;
+                       }
+                       this->lock->unlock(this->lock);
+                       charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
+               }
+               else
+               {
+                       charon->ike_sa_manager->checkin_and_destroy(
+                                                                                               charon->ike_sa_manager, ike_sa);
                }
-               this->lock->unlock(this->lock);
-               charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
-       }
-       else
-       {
-               charon->ike_sa_manager->checkin_and_destroy(
-                                                                                       charon->ike_sa_manager, ike_sa);
        }
        peer->destroy(peer);
 }