]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
ike-sa: Add property for interface ID
authorTobias Brunner <tobias@strongswan.org>
Fri, 22 Mar 2019 16:19:51 +0000 (17:19 +0100)
committerTobias Brunner <tobias@strongswan.org>
Thu, 4 Apr 2019 07:36:38 +0000 (09:36 +0200)
src/libcharon/sa/ike_sa.c
src/libcharon/sa/ike_sa.h

index 3d576a0e89a67b6e76e636ed744e88bdbec3a551..e75aa755cda3327ea60911adaa78e266de4070a3 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2006-2018 Tobias Brunner
+ * Copyright (C) 2006-2019 Tobias Brunner
  * Copyright (C) 2006 Daniel Roethlisberger
  * Copyright (C) 2005-2009 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * Copyright (C) 2006 Daniel Roethlisberger
  * Copyright (C) 2005-2009 Martin Willi
  * Copyright (C) 2005 Jan Hutter
@@ -296,6 +296,16 @@ struct private_ike_sa_t {
         * Timestamps of redirect attempts to handle loops
         */
        array_t *redirected_at;
         * Timestamps of redirect attempts to handle loops
         */
        array_t *redirected_at;
+
+       /**
+        * Inbound interface ID
+        */
+       uint32_t if_id_in;
+
+       /**
+        * Outbound interface ID
+        */
+       uint32_t if_id_out;
 };
 
 /**
 };
 
 /**
@@ -419,11 +429,15 @@ METHOD(ike_sa_t, set_peer_cfg, void,
        DESTROY_IF(this->peer_cfg);
        this->peer_cfg = peer_cfg;
 
        DESTROY_IF(this->peer_cfg);
        this->peer_cfg = peer_cfg;
 
-       if (this->ike_cfg == NULL)
+       if (!this->ike_cfg)
        {
                this->ike_cfg = peer_cfg->get_ike_cfg(peer_cfg);
                this->ike_cfg->get_ref(this->ike_cfg);
        }
        {
                this->ike_cfg = peer_cfg->get_ike_cfg(peer_cfg);
                this->ike_cfg->get_ref(this->ike_cfg);
        }
+
+       this->if_id_in = peer_cfg->get_if_id(peer_cfg, TRUE);
+       this->if_id_out = peer_cfg->get_if_id(peer_cfg, FALSE);
+       allocate_unique_if_ids(&this->if_id_in, &this->if_id_out);
 }
 
 METHOD(ike_sa_t, get_auth_cfg, auth_cfg_t*,
 }
 
 METHOD(ike_sa_t, get_auth_cfg, auth_cfg_t*,
@@ -1656,6 +1670,12 @@ METHOD(ike_sa_t, set_other_id, void,
        this->other_id = other;
 }
 
        this->other_id = other;
 }
 
+METHOD(ike_sa_t, get_if_id, uint32_t,
+       private_ike_sa_t *this, bool inbound)
+{
+       return inbound ? this->if_id_in : this->if_id_out;
+}
+
 METHOD(ike_sa_t, add_child_sa, void,
        private_ike_sa_t *this, child_sa_t *child_sa)
 {
 METHOD(ike_sa_t, add_child_sa, void,
        private_ike_sa_t *this, child_sa_t *child_sa)
 {
@@ -2810,6 +2830,8 @@ METHOD(ike_sa_t, inherit_post, void,
        this->other_host = other->other_host->clone(other->other_host);
        this->my_id = other->my_id->clone(other->my_id);
        this->other_id = other->other_id->clone(other->other_id);
        this->other_host = other->other_host->clone(other->other_host);
        this->my_id = other->my_id->clone(other->my_id);
        this->other_id = other->other_id->clone(other->other_id);
+       this->if_id_in = other->if_id_in;
+       this->if_id_out = other->if_id_out;
 
        /* apply assigned virtual IPs... */
        while (array_remove(other->my_vips, ARRAY_HEAD, &vip))
 
        /* apply assigned virtual IPs... */
        while (array_remove(other->my_vips, ARRAY_HEAD, &vip))
@@ -3087,6 +3109,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id, bool initiator,
                        .create_virtual_ip_enumerator = _create_virtual_ip_enumerator,
                        .add_configuration_attribute = _add_configuration_attribute,
                        .create_attribute_enumerator = _create_attribute_enumerator,
                        .create_virtual_ip_enumerator = _create_virtual_ip_enumerator,
                        .add_configuration_attribute = _add_configuration_attribute,
                        .create_attribute_enumerator = _create_attribute_enumerator,
+                       .get_if_id = _get_if_id,
                        .set_kmaddress = _set_kmaddress,
                        .create_task_enumerator = _create_task_enumerator,
                        .remove_task = _remove_task,
                        .set_kmaddress = _set_kmaddress,
                        .create_task_enumerator = _create_task_enumerator,
                        .remove_task = _remove_task,
index be480eac861708b4b1fa938ccd1eb6247a22a4e0..c7ef1fe3c349ef9de1e9d9831509cd9b072071ec 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2006-2018 Tobias Brunner
+ * Copyright (C) 2006-2019 Tobias Brunner
  * Copyright (C) 2006 Daniel Roethlisberger
  * Copyright (C) 2005-2009 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * Copyright (C) 2006 Daniel Roethlisberger
  * Copyright (C) 2005-2009 Martin Willi
  * Copyright (C) 2005 Jan Hutter
@@ -1068,6 +1068,14 @@ struct ike_sa_t {
         */
        void (*clear_virtual_ips) (ike_sa_t *this, bool local);
 
         */
        void (*clear_virtual_ips) (ike_sa_t *this, bool local);
 
+       /**
+        * Get interface ID to use as default for children of this IKE_SA.
+        *
+        * @param inbound               TRUE for inbound interface ID
+        * @return                              interface ID
+        */
+       uint32_t (*get_if_id)(ike_sa_t *this, bool inbound);
+
        /**
         * Create an enumerator over virtual IPs.
         *
        /**
         * Create an enumerator over virtual IPs.
         *