}
/**
+ * Implementation of ike_sa_t.set_message_id
+ */
+static void set_message_id(private_ike_sa_t *this, bool initiate, u_int32_t mid)
+{
+ if (initiate)
+ {
+ this->task_manager->reset(this->task_manager, UINT_MAX, mid);
+ }
+ else
+ {
+ this->task_manager->reset(this->task_manager, mid, UINT_MAX);
+ }
+}
+
+/**
* Implementation of ike_sa_t.send_keepalive
*/
static void send_keepalive(private_ike_sa_t *this)
set_state(this, IKE_CREATED);
- this->task_manager->reset(this->task_manager);
+ this->task_manager->reset(this->task_manager, 0, 0);
}
/**
this->public.set_my_host = (void (*)(ike_sa_t*,host_t*)) set_my_host;
this->public.get_other_host = (host_t* (*)(ike_sa_t*)) get_other_host;
this->public.set_other_host = (void (*)(ike_sa_t*,host_t*)) set_other_host;
+ this->public.set_message_id = (void(*)(ike_sa_t*, bool inbound, u_int32_t mid))set_message_id;
this->public.update_hosts = (void(*)(ike_sa_t*, host_t *me, host_t *other))update_hosts;
this->public.get_my_id = (identification_t* (*)(ike_sa_t*)) get_my_id;
this->public.set_my_id = (void (*)(ike_sa_t*,identification_t*)) set_my_id;
void (*set_proposal)(ike_sa_t *this, proposal_t *proposal);
/**
+ * Set the message id of the IKE_SA.
+ *
+ * The IKE_SA stores two message IDs, one for initiating exchanges (send)
+ * and one to respond to exchanges (expect).
+ *
+ * @param initiate TRUE to set message ID for initiating
+ * @param mid message id to set
+ */
+ void (*set_message_id)(ike_sa_t *this, bool initiate, u_int32_t mid);
+
+ /**
* Add an additional address for the peer.
*
* In MOBIKE, a peer may transmit additional addresses where it is
/**
* Implementation of task_manager_t.reset
*/
-static void reset(private_task_manager_t *this)
+static void reset(private_task_manager_t *this,
+ u_int32_t initiate, u_int32_t respond)
{
task_t *task;
DESTROY_IF(this->initiating.packet);
this->responding.packet = NULL;
this->initiating.packet = NULL;
- this->responding.mid = 0;
- this->initiating.mid = 0;
+ if (initiate != UINT_MAX)
+ {
+ this->initiating.mid = initiate;
+ }
+ if (respond != UINT_MAX)
+ {
+ this->responding.mid = respond;
+ }
this->initiating.type = EXCHANGE_TYPE_UNDEFINED;
/* reset active tasks */
this->public.queue_task = (void(*)(task_manager_t*,task_t*))queue_task;
this->public.initiate = (status_t(*)(task_manager_t*))build_request;
this->public.retransmit = (status_t(*)(task_manager_t*,u_int32_t))retransmit;
- this->public.reset = (void(*)(task_manager_t*))reset;
+ this->public.reset = (void(*)(task_manager_t*,u_int32_t,u_int32_t))reset;
this->public.adopt_tasks = (void(*)(task_manager_t*,task_manager_t*))adopt_tasks;
this->public.busy = (bool(*)(task_manager_t*))busy;
this->public.destroy = (void(*)(task_manager_t*))destroy;
typedef struct task_manager_t task_manager_t;
+#include <limits.h>
+
#include <library.h>
#include <encoding/message.h>
#include <sa/ike_sa.h>
* - SUCCESS if retransmission sent
*/
status_t (*retransmit) (task_manager_t *this, u_int32_t message_id);
-
+
/**
* Migrate all tasks from other to this.
*
* reset to zero (INVALID_KE_PAYLOAD, COOKIES, ...). The reset() method
* resets the message IDs and resets all active tasks using the migrate()
* method.
- *
- * @param other manager which gives away its tasks
+ * Use a value of UINT_MAX to keep the current message ID.
+ *
+ * @param initiate message ID to initiate exchanges (send)
+ * @param respond message ID to respond to exchanges (expect)
*/
- void (*reset) (task_manager_t *this);
+ void (*reset) (task_manager_t *this, u_int32_t initiate, u_int32_t respond);
/**
* Check if we are currently waiting for a reply.