peer-cfg: Add property for interface ID
authorTobias Brunner <tobias@strongswan.org>
Fri, 22 Mar 2019 15:23:59 +0000 (16:23 +0100)
committerTobias Brunner <tobias@strongswan.org>
Thu, 4 Apr 2019 07:31:38 +0000 (09:31 +0200)
src/libcharon/config/peer_cfg.c
src/libcharon/config/peer_cfg.h

index e7dfb5f..58e791f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2018 Tobias Brunner
+ * Copyright (C) 2007-2019 Tobias Brunner
  * Copyright (C) 2005-2009 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * HSR Hochschule fuer Technik Rapperswil
@@ -156,6 +156,16 @@ struct private_peer_cfg_t {
        linked_list_t *remote_auth;
 
        /**
+        * Optionl interface ID to use for inbound CHILD_SA
+        */
+       uint32_t if_id_in;
+
+       /**
+        * Optionl interface ID to use for outbound CHILD_SA
+        */
+       uint32_t if_id_out;
+
+       /**
         * PPK ID
         */
        identification_t *ppk_id;
@@ -587,6 +597,12 @@ METHOD(peer_cfg_t, create_auth_cfg_enumerator, enumerator_t*,
        return this->remote_auth->create_enumerator(this->remote_auth);
 }
 
+METHOD(peer_cfg_t, get_if_id, uint32_t,
+       private_peer_cfg_t *this, bool inbound)
+{
+       return inbound ? this->if_id_in : this->if_id_out;
+}
+
 METHOD(peer_cfg_t, get_ppk_id, identification_t*,
        private_peer_cfg_t *this)
 {
@@ -715,6 +731,8 @@ METHOD(peer_cfg_t, equals, bool,
                this->aggressive == other->aggressive &&
                this->pull_mode == other->pull_mode &&
                auth_cfg_equal(this, other) &&
+               this->if_id_in == other->if_id_in &&
+               this->if_id_out == other->if_id_out &&
                this->ppk_required == other->ppk_required &&
                id_equal(this->ppk_id, other->ppk_id)
 #ifdef ME
@@ -805,6 +823,7 @@ peer_cfg_t *peer_cfg_create(char *name, ike_cfg_t *ike_cfg,
                        .create_pool_enumerator = _create_pool_enumerator,
                        .add_auth_cfg = _add_auth_cfg,
                        .create_auth_cfg_enumerator = _create_auth_cfg_enumerator,
+                       .get_if_id = _get_if_id,
                        .get_ppk_id = _get_ppk_id,
                        .ppk_required = _ppk_required,
                        .equals = (void*)_equals,
@@ -832,6 +851,8 @@ peer_cfg_t *peer_cfg_create(char *name, ike_cfg_t *ike_cfg,
                .pull_mode = !data->push_mode,
                .dpd = data->dpd,
                .dpd_timeout = data->dpd_timeout,
+               .if_id_in = data->if_id_in,
+               .if_id_out = data->if_id_out,
                .ppk_id = data->ppk_id,
                .ppk_required = data->ppk_required,
                .vips = linked_list_create(),
index 49c4d14..f443126 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2018 Tobias Brunner
+ * Copyright (C) 2007-2019 Tobias Brunner
  * Copyright (C) 2005-2009 Martin Willi
  * Copyright (C) 2005 Jan Hutter
  * HSR Hochschule fuer Technik Rapperswil
@@ -312,6 +312,14 @@ struct peer_cfg_t {
        enumerator_t* (*create_pool_enumerator)(peer_cfg_t *this);
 
        /**
+        * Optional interface ID to set on policies/SAs.
+        *
+        * @param inbound               TRUE for inbound, FALSE for outbound
+        * @return                              interface ID
+        */
+       uint32_t (*get_if_id)(peer_cfg_t *this, bool inbound);
+
+       /**
         * Get the PPK ID to use with this peer.
         *
         * @return                              PPK id
@@ -407,6 +415,10 @@ struct peer_cfg_create_t {
        uint32_t dpd;
        /** DPD timeout interval (IKEv1 only), if 0 default applies */
        uint32_t dpd_timeout;
+       /** Optional inbound interface ID */
+       uint32_t if_id_in;
+       /** Optional outbound interface ID */
+       uint32_t if_id_out;
        /** Postquantum Preshared Key ID (adopted) */
        identification_t *ppk_id;
        /** TRUE if a PPK is required, FALSE if it's optional */