kernel-interface: Raise mapping event with a proto/SPI/dst tuple
[strongswan.git] / src / libcharon / processing / jobs / roam_job.c
index adc884a..0af4c6c 100644 (file)
@@ -38,18 +38,14 @@ struct private_roam_job_t {
        bool address;
 };
 
-/**
- * Implements job_t.destroy.
- */
-static void destroy(private_roam_job_t *this)
+METHOD(job_t, destroy, void,
+       private_roam_job_t *this)
 {
        free(this);
 }
 
-/**
- * Implementation of job_t.execute.
- */
-static void execute(private_roam_job_t *this)
+METHOD(job_t, execute, job_requeue_t,
+       private_roam_job_t *this)
 {
        ike_sa_t *ike_sa;
        linked_list_t *list;
@@ -59,7 +55,8 @@ static void execute(private_roam_job_t *this)
        /* enumerator over all IKE_SAs gives us no way to checkin_and_destroy
         * after a DESTROY_ME, so we check out each available IKE_SA by hand. */
        list = linked_list_create();
-       enumerator = charon->ike_sa_manager->create_enumerator(charon->ike_sa_manager);
+       enumerator = charon->ike_sa_manager->create_enumerator(
+                                                                                               charon->ike_sa_manager, TRUE);
        while (enumerator->enumerate(enumerator, &ike_sa))
        {
                id = ike_sa->get_id(ike_sa);
@@ -85,8 +82,13 @@ static void execute(private_roam_job_t *this)
                id->destroy(id);
        }
        list->destroy(list);
+       return JOB_REQUEUE_NONE;
+}
 
-       destroy(this);
+METHOD(job_t, get_priority, job_priority_t,
+       private_roam_job_t *this)
+{
+       return JOB_PRIO_MEDIUM;
 }
 
 /*
@@ -94,12 +96,18 @@ static void execute(private_roam_job_t *this)
  */
 roam_job_t *roam_job_create(bool address)
 {
-       private_roam_job_t *this = malloc_thing(private_roam_job_t);
-
-       this->public.job_interface.execute = (void (*) (job_t *)) execute;
-       this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
-
-       this->address = address;
+       private_roam_job_t *this;
+
+       INIT(this,
+               .public = {
+                       .job_interface = {
+                               .execute = _execute,
+                               .get_priority = _get_priority,
+                               .destroy = _destroy,
+                       },
+               },
+               .address = address,
+       );
 
        return &this->public;
 }