]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
ike-config: Support exchange between IKE_SA_INIT and IKE_AUTH
authorTobias Brunner <tobias@strongswan.org>
Mon, 25 Jun 2018 10:32:27 +0000 (12:32 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 29 Jun 2022 08:28:50 +0000 (10:28 +0200)
This changes the MID of the first IKE_AUTH message.

src/libcharon/sa/ikev2/tasks/ike_config.c

index 9cba9aeac134b4d02616d2f8c75ae301310dea49..221bc0d2082e79c08df552fed1139b162bb8fb59 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2012-2018 Tobias Brunner
  * Copyright (C) 2007 Martin Willi
  * Copyright (C) 2006-2007 Fabian Hartmann, Noah Heusser
  *
@@ -240,8 +241,8 @@ static void process_payloads(private_ike_config_t *this, message_t *message)
 METHOD(task_t, build_i, status_t,
        private_ike_config_t *this, message_t *message)
 {
-       if (message->get_message_id(message) == 1)
-       {       /* in first IKE_AUTH only */
+       if (message->get_exchange_type(message) == IKE_AUTH)
+       {
                cp_payload_t *cp = NULL;
                enumerator_t *enumerator;
                attribute_handler_t *handler;
@@ -251,6 +252,10 @@ METHOD(task_t, build_i, status_t,
                linked_list_t *vips;
                host_t *host;
 
+               /* add attributes to first IKE_AUTH only, keep registered until
+                * attributes are received in the last IKE_AUTH */
+               this->public.task.build = (void*)return_need_more;
+
                vips = linked_list_create();
 
                /* reuse virtual IP if we already have one */
@@ -329,9 +334,11 @@ METHOD(task_t, build_i, status_t,
 METHOD(task_t, process_r, status_t,
        private_ike_config_t *this, message_t *message)
 {
-       if (message->get_message_id(message) == 1)
-       {       /* in first IKE_AUTH only */
+       if (message->get_exchange_type(message) == IKE_AUTH)
+       {
                process_payloads(this, message);
+               /* process attributes in first IKE_AUTH only */
+               this->public.task.process = (void*)return_need_more;
        }
        return NEED_MORE;
 }
@@ -486,6 +493,7 @@ METHOD(task_t, migrate, void,
        this->vips = linked_list_create();
        this->requested->destroy_function(this->requested, free);
        this->requested = linked_list_create();
+       this->public.task.build = _build_i;
 }
 
 METHOD(task_t, destroy, void,