fixed peer_cfg lookup when omitting IDr
authorMartin Willi <martin@strongswan.org>
Wed, 19 Mar 2008 10:08:59 +0000 (10:08 -0000)
committerMartin Willi <martin@strongswan.org>
Wed, 19 Mar 2008 10:08:59 +0000 (10:08 -0000)
src/charon/config/backend_manager.c
src/charon/plugins/stroke/stroke.c

index 075ab24..7b2ddca 100644 (file)
@@ -216,7 +216,12 @@ static peer_cfg_t *get_peer_cfg(private_backend_manager_t *this,
                my_candidate = current->get_my_id(current);
                other_candidate = current->get_other_id(current);
                
+               /* own ID may have wildcards in both, config and request (missing IDr) */
                m1 = my_candidate->matches(my_candidate, me);
+               if (!m1)
+               {
+                       m1 = me->matches(me, my_candidate);
+               }
                m2 = other->matches(other, other_candidate);
                sum = m1 + m2;
                
index 401cb22..c92e6ee 100755 (executable)
@@ -1287,9 +1287,19 @@ static void peer_data_destroy(peer_data_t *data)
  */
 static bool peer_filter(peer_data_t *data, peer_cfg_t **in, peer_cfg_t **out)
 {
-
-       if ((!data->me || data->me->matches(data->me, (*in)->get_my_id(*in))) &&
-               (!data->other || data->other->matches(data->other, (*in)->get_other_id(*in))))
+       bool match_me = FALSE, match_other = FALSE;
+       identification_t *me, *other;
+       
+       me = (*in)->get_my_id(*in);
+       other = (*in)->get_other_id(*in);
+       
+       /* own ID may have wildcards in data (no IDr payload) or in config */
+       match_me = (!data->me || data->me->matches(data->me, me) ||
+                               me->matches(me, data->me));
+       /* others ID has wildcards in config only */
+       match_other = (!data->other || data->other->matches(data->other, other));
+       
+       if (match_me && match_other)
        {
                *out = *in;
                return TRUE;