Simplified the search for ME_CONNECTID notifies.
authorTobias Brunner <tobias@strongswan.org>
Wed, 2 Sep 2009 15:29:02 +0000 (17:29 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 2 Sep 2009 15:30:47 +0000 (17:30 +0200)
src/charon/sa/tasks/ike_init.c

index ce94cd1..a64ec3d 100644 (file)
@@ -314,50 +314,13 @@ static status_t process_r(private_ike_init_t *this, message_t *message)
        
 #ifdef ME
        {
-               chunk_t connect_id = chunk_empty;
-               enumerator_t *enumerator;
-               payload_t *payload;
-               
-               /* check for a ME_CONNECTID notify */
-               enumerator = message->create_payload_enumerator(message);
-               while (enumerator->enumerate(enumerator, &payload))
-               {
-                       if (payload->get_type(payload) == NOTIFY)
-                       {
-                               notify_payload_t *notify = (notify_payload_t*)payload;
-                               notify_type_t type = notify->get_notify_type(notify);
-                       
-                               switch (type)
-                               {
-                                       case ME_CONNECTID:
-                                       {
-                                               chunk_free(&connect_id);
-                                               connect_id = chunk_clone(notify->get_notification_data(notify));
-                                               DBG2(DBG_IKE, "received ME_CONNECTID %#B", &connect_id);
-                                               break;
-                                       }
-                                       default:
-                                       {
-                                               if (type < 16383)
-                                               {
-                                                       DBG1(DBG_IKE, "received %N notify error",
-                                                               notify_type_names, type);
-                                                       break;  
-                                               }
-                                               DBG2(DBG_IKE, "received %N notify",
-                                                       notify_type_names, type);
-                                               break;
-                                       }
-                               }
-                       }
-               }
-               enumerator->destroy(enumerator);
-               
-               if (connect_id.ptr)
+               notify_payload_t *notify = message->get_notify(message, ME_CONNECTID);
+               if (notify)
                {
+                       chunk_t connect_id = notify->get_notification_data(notify);
+                       DBG2(DBG_IKE, "received ME_CONNECTID %#B", &connect_id);
                        charon->connect_manager->stop_checks(charon->connect_manager,
-                               connect_id);
-                       chunk_free(&connect_id);
+                                                                                                connect_id);
                }
        }
 #endif /* ME */