Migrated migrate_job_t to INIT/METHOD macros
authorAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 10 Feb 2011 07:06:06 +0000 (08:06 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 10 Feb 2011 07:06:06 +0000 (08:06 +0100)
src/libcharon/processing/jobs/migrate_job.c

index 05f4734..5e7c7ae 100644 (file)
@@ -57,10 +57,8 @@ struct private_migrate_job_t {
        host_t *remote;
 };
 
-/**
- * Implementation of job_t.destroy.
- */
-static void destroy(private_migrate_job_t *this)
+METHOD(job_t, destroy, void,
+       private_migrate_job_t *this)
 {
        DESTROY_IF(this->src_ts);
        DESTROY_IF(this->dst_ts);
@@ -69,10 +67,8 @@ static void destroy(private_migrate_job_t *this)
        free(this);
 }
 
-/**
- * Implementation of job_t.execute.
- */
-static void execute(private_migrate_job_t *this)
+METHOD(job_t, execute, void,
+       private_migrate_job_t *this)
 {
        ike_sa_t *ike_sa = NULL;
 
@@ -133,18 +129,21 @@ migrate_job_t *migrate_job_create(u_int32_t reqid,
                                                                  policy_dir_t dir,
                                                                  host_t *local, host_t *remote)
 {
-       private_migrate_job_t *this = malloc_thing(private_migrate_job_t);
-
-       /* interface functions */
-       this->public.job_interface.execute = (void (*) (job_t *)) execute;
-       this->public.job_interface.destroy = (void (*)(job_t*)) destroy;
-
-       /* private variables */
-       this->reqid = reqid;
-       this->src_ts = (dir == POLICY_OUT) ? src_ts : dst_ts;
-       this->dst_ts = (dir == POLICY_OUT) ? dst_ts : src_ts;
-       this->local = local;
-       this->remote = remote;
+       private_migrate_job_t *this;
+
+       INIT(this,
+               .public = {
+                       .job_interface = {
+                               .execute = _execute,
+                               .destroy = _destroy,
+                       },
+               },
+               .reqid = reqid,
+               .src_ts = (dir == POLICY_OUT) ? src_ts : dst_ts,
+               .dst_ts = (dir == POLICY_OUT) ? dst_ts : src_ts,
+               .local = local,
+               .remote = remote,
+       );
 
        return &this->public;
 }