kernel-interface: Raise mapping event with a proto/SPI/dst tuple
[strongswan.git] / src / libcharon / processing / jobs / send_dpd_job.c
index 1c2da52..d2f38b8 100644 (file)
@@ -38,19 +38,15 @@ struct private_send_dpd_job_t {
        ike_sa_id_t *ike_sa_id;
 };
 
-/**
- * Implements job_t.destroy.
- */
-static void destroy(private_send_dpd_job_t *this)
+METHOD(job_t, destroy, void,
+       private_send_dpd_job_t *this)
 {
        this->ike_sa_id->destroy(this->ike_sa_id);
        free(this);
 }
 
-/**
- * Implementation of job_t.execute.
- */
-static void execute(private_send_dpd_job_t *this)
+METHOD(job_t, execute, job_requeue_t,
+       private_send_dpd_job_t *this)
 {
        ike_sa_t *ike_sa;
 
@@ -67,7 +63,13 @@ static void execute(private_send_dpd_job_t *this)
                        charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
                }
        }
-       destroy(this);
+       return JOB_REQUEUE_NONE;
+}
+
+METHOD(job_t, get_priority, job_priority_t,
+       private_send_dpd_job_t *this)
+{
+       return JOB_PRIO_HIGH;
 }
 
 /*
@@ -75,14 +77,18 @@ static void execute(private_send_dpd_job_t *this)
  */
 send_dpd_job_t *send_dpd_job_create(ike_sa_id_t *ike_sa_id)
 {
-       private_send_dpd_job_t *this = malloc_thing(private_send_dpd_job_t);
-
-       /* interface functions */
-       this->public.job_interface.execute = (void (*) (job_t *)) execute;
-       this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
+       private_send_dpd_job_t *this;
 
-       /* private variables */
-       this->ike_sa_id = ike_sa_id->clone(ike_sa_id);
+       INIT(this,
+               .public = {
+                       .job_interface = {
+                               .execute = _execute,
+                               .get_priority = _get_priority,
+                               .destroy = _destroy,
+                       },
+               },
+               .ike_sa_id = ike_sa_id->clone(ike_sa_id),
+       );
 
        return &this->public;
 }