]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
child-cfg: Add method to check if an algorithm is proposed
authorTobias Brunner <tobias@strongswan.org>
Fri, 20 Jul 2018 15:43:24 +0000 (17:43 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Sun, 29 Mar 2020 11:45:40 +0000 (13:45 +0200)
src/libcharon/config/child_cfg.c
src/libcharon/config/child_cfg.h

index 8b69e231d2e0c6d1556a1caeadd857cf0976219c..d38818b3688151d198422b34b004a2e68ad3f1a1 100644 (file)
@@ -492,6 +492,25 @@ METHOD(child_cfg_t, get_algorithm, uint16_t,
        return alg;
 }
 
+METHOD(child_cfg_t, has_transform, bool,
+       private_child_cfg_t *this, transform_type_t type, uint16_t algorithm)
+{
+       enumerator_t *enumerator;
+       proposal_t *proposal;
+
+       enumerator = this->proposals->create_enumerator(this->proposals);
+       while (enumerator->enumerate(enumerator, &proposal))
+       {
+               if (proposal->has_transform(proposal, type, algorithm))
+               {
+                       enumerator->destroy(enumerator);
+                       return TRUE;
+               }
+       }
+       enumerator->destroy(enumerator);
+       return FALSE;
+}
+
 METHOD(child_cfg_t, get_inactivity, uint32_t,
        private_child_cfg_t *this)
 {
@@ -654,6 +673,7 @@ child_cfg_t *child_cfg_create(char *name, child_cfg_create_t *data)
                        .get_close_action = _get_close_action,
                        .get_lifetime = _get_lifetime,
                        .get_algorithm = _get_algorithm,
+                       .has_transform = _has_transform,
                        .get_inactivity = _get_inactivity,
                        .get_reqid = _get_reqid,
                        .get_if_id = _get_if_id,
index 2717b2c599af7e2698c855b516042775388632c7..10c76ce735251a6d9fe9c2afc046135971817259 100644 (file)
@@ -214,6 +214,17 @@ struct child_cfg_t {
         */
        uint16_t (*get_algorithm)(child_cfg_t *this, transform_type_t type);
 
+       /**
+        * Check if any of the configured proposals has a specific transform.
+        *
+        * @param type                  transform type to check for
+        * @param algorithm             algorithm to check for (if 0, TRUE is returned if
+        *                                              no transform of the given type is found)
+        * @return                              TRUE if algorithm included
+        */
+       bool (*has_transform)(child_cfg_t *this, transform_type_t type,
+                                                 uint16_t algorithm);
+
        /**
         * Get the inactivity timeout value.
         *