summaryrefslogtreecommitdiff
path: root/src/libcharon/processing/jobs/initiate_mediation_job.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcharon/processing/jobs/initiate_mediation_job.c')
-rw-r--r--src/libcharon/processing/jobs/initiate_mediation_job.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/libcharon/processing/jobs/initiate_mediation_job.c b/src/libcharon/processing/jobs/initiate_mediation_job.c
index ffe8755e2..e52f3c6df 100644
--- a/src/libcharon/processing/jobs/initiate_mediation_job.c
+++ b/src/libcharon/processing/jobs/initiate_mediation_job.c
@@ -41,10 +41,8 @@ struct private_initiate_mediation_job_t {
ike_sa_id_t *mediation_sa_id;
};
-/**
- * Implements job_t.destroy.
- */
-static void destroy(private_initiate_mediation_job_t *this)
+METHOD(job_t, destroy, void,
+ private_initiate_mediation_job_t *this)
{
DESTROY_IF(this->mediation_sa_id);
DESTROY_IF(this->mediated_sa_id);
@@ -66,10 +64,8 @@ static bool initiate_callback(private_initiate_mediation_job_t *this,
return TRUE;
}
-/**
- * Implementation of job_t.execute.
- */
-static void initiate(private_initiate_mediation_job_t *this)
+METHOD(job_t, initiate, void,
+ private_initiate_mediation_job_t *this)
{
ike_sa_t *mediated_sa, *mediation_sa;
peer_cfg_t *mediated_cfg, *mediation_cfg;
@@ -126,7 +122,7 @@ static void initiate(private_initiate_mediation_job_t *this)
mediation_cfg->get_ref(mediation_cfg);
if (charon->controller->initiate(charon->controller, mediation_cfg,
- NULL, (controller_cb_t)initiate_callback, this) != SUCCESS)
+ NULL, (controller_cb_t)initiate_callback, this, 0) != SUCCESS)
{
mediation_cfg->destroy(mediation_cfg);
mediated_cfg->destroy(mediated_cfg);
@@ -172,10 +168,8 @@ static void initiate(private_initiate_mediation_job_t *this)
destroy(this);
}
-/**
- * Implementation of job_t.execute.
- */
-static void reinitiate(private_initiate_mediation_job_t *this)
+METHOD(job_t, reinitiate, void,
+ private_initiate_mediation_job_t *this)
{
ike_sa_t *mediated_sa, *mediation_sa;
peer_cfg_t *mediated_cfg;
@@ -223,20 +217,26 @@ static void reinitiate(private_initiate_mediation_job_t *this)
destroy(this);
}
+METHOD(job_t, get_priority, job_priority_t,
+ private_initiate_mediation_job_t *this)
+{
+ return JOB_PRIO_MEDIUM;
+}
+
/**
* Creates an empty job
*/
static private_initiate_mediation_job_t *initiate_mediation_job_create_empty()
{
- private_initiate_mediation_job_t *this = malloc_thing(private_initiate_mediation_job_t);
-
- /* interface functions */
- this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
-
- /* private variables */
- this->mediation_sa_id = NULL;
- this->mediated_sa_id = NULL;
-
+ private_initiate_mediation_job_t *this;
+ INIT(this,
+ .public = {
+ .job_interface = {
+ .get_priority = _get_priority,
+ .destroy = _destroy,
+ },
+ },
+ );
return this;
}
@@ -247,8 +247,7 @@ initiate_mediation_job_t *initiate_mediation_job_create(ike_sa_id_t *ike_sa_id)
{
private_initiate_mediation_job_t *this = initiate_mediation_job_create_empty();
- this->public.job_interface.execute = (void (*) (job_t *)) initiate;
-
+ this->public.job_interface.execute = _initiate;
this->mediated_sa_id = ike_sa_id->clone(ike_sa_id);
return &this->public;
@@ -262,8 +261,7 @@ initiate_mediation_job_t *reinitiate_mediation_job_create(ike_sa_id_t *mediation
{
private_initiate_mediation_job_t *this = initiate_mediation_job_create_empty();
- this->public.job_interface.execute = (void (*) (job_t *)) reinitiate;
-
+ this->public.job_interface.execute = _reinitiate;
this->mediation_sa_id = mediation_sa_id->clone(mediation_sa_id);
this->mediated_sa_id = mediated_sa_id->clone(mediated_sa_id);