Migrated stroke_config_t to INIT/METHOD macros
This commit is contained in:
@@ -53,12 +53,8 @@ struct private_stroke_config_t {
|
|||||||
stroke_cred_t *cred;
|
stroke_cred_t *cred;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
|
||||||
* Implementation of backend_t.create_peer_cfg_enumerator.
|
private_stroke_config_t *this, identification_t *me, identification_t *other)
|
||||||
*/
|
|
||||||
static enumerator_t* create_peer_cfg_enumerator(private_stroke_config_t *this,
|
|
||||||
identification_t *me,
|
|
||||||
identification_t *other)
|
|
||||||
{
|
{
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
return enumerator_create_cleaner(this->list->create_enumerator(this->list),
|
return enumerator_create_cleaner(this->list->create_enumerator(this->list),
|
||||||
@@ -74,11 +70,8 @@ static bool ike_filter(void *data, peer_cfg_t **in, ike_cfg_t **out)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(backend_t, create_ike_cfg_enumerator, enumerator_t*,
|
||||||
* Implementation of backend_t.create_ike_cfg_enumerator.
|
private_stroke_config_t *this, host_t *me, host_t *other)
|
||||||
*/
|
|
||||||
static enumerator_t* create_ike_cfg_enumerator(private_stroke_config_t *this,
|
|
||||||
host_t *me, host_t *other)
|
|
||||||
{
|
{
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
return enumerator_create_filter(this->list->create_enumerator(this->list),
|
return enumerator_create_filter(this->list->create_enumerator(this->list),
|
||||||
@@ -86,10 +79,8 @@ static enumerator_t* create_ike_cfg_enumerator(private_stroke_config_t *this,
|
|||||||
(void*)this->mutex->unlock);
|
(void*)this->mutex->unlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(backend_t, get_peer_cfg_by_name, peer_cfg_t*,
|
||||||
* implements backend_t.get_peer_cfg_by_name.
|
private_stroke_config_t *this, char *name)
|
||||||
*/
|
|
||||||
static peer_cfg_t *get_peer_cfg_by_name(private_stroke_config_t *this, char *name)
|
|
||||||
{
|
{
|
||||||
enumerator_t *e1, *e2;
|
enumerator_t *e1, *e2;
|
||||||
peer_cfg_t *current, *found = NULL;
|
peer_cfg_t *current, *found = NULL;
|
||||||
@@ -808,7 +799,7 @@ static child_cfg_t *build_child_cfg(private_stroke_config_t *this,
|
|||||||
child_cfg = child_cfg_create(
|
child_cfg = child_cfg_create(
|
||||||
msg->add_conn.name, &lifetime,
|
msg->add_conn.name, &lifetime,
|
||||||
msg->add_conn.me.updown, msg->add_conn.me.hostaccess,
|
msg->add_conn.me.updown, msg->add_conn.me.hostaccess,
|
||||||
msg->add_conn.mode, dpd, dpd, msg->add_conn.ipcomp,
|
msg->add_conn.mode, ACTION_NONE, dpd, dpd, msg->add_conn.ipcomp,
|
||||||
msg->add_conn.inactivity, msg->add_conn.reqid,
|
msg->add_conn.inactivity, msg->add_conn.reqid,
|
||||||
&mark_in, &mark_out);
|
&mark_in, &mark_out);
|
||||||
child_cfg->set_mipv6_options(child_cfg, msg->add_conn.proxy_mode,
|
child_cfg->set_mipv6_options(child_cfg, msg->add_conn.proxy_mode,
|
||||||
@@ -821,10 +812,8 @@ static child_cfg_t *build_child_cfg(private_stroke_config_t *this,
|
|||||||
return child_cfg;
|
return child_cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(stroke_config_t, add, void,
|
||||||
* Implementation of stroke_config_t.add.
|
private_stroke_config_t *this, stroke_msg_t *msg)
|
||||||
*/
|
|
||||||
static void add(private_stroke_config_t *this, stroke_msg_t *msg)
|
|
||||||
{
|
{
|
||||||
ike_cfg_t *ike_cfg, *existing_ike;
|
ike_cfg_t *ike_cfg, *existing_ike;
|
||||||
peer_cfg_t *peer_cfg, *existing;
|
peer_cfg_t *peer_cfg, *existing;
|
||||||
@@ -884,10 +873,8 @@ static void add(private_stroke_config_t *this, stroke_msg_t *msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(stroke_config_t, del, void,
|
||||||
* Implementation of stroke_config_t.del.
|
private_stroke_config_t *this, stroke_msg_t *msg)
|
||||||
*/
|
|
||||||
static void del(private_stroke_config_t *this, stroke_msg_t *msg)
|
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator, *children;
|
enumerator_t *enumerator, *children;
|
||||||
peer_cfg_t *peer;
|
peer_cfg_t *peer;
|
||||||
@@ -938,10 +925,8 @@ static void del(private_stroke_config_t *this, stroke_msg_t *msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(stroke_config_t, destroy, void,
|
||||||
* Implementation of stroke_config_t.destroy
|
private_stroke_config_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_stroke_config_t *this)
|
|
||||||
{
|
{
|
||||||
this->list->destroy_offset(this->list, offsetof(peer_cfg_t, destroy));
|
this->list->destroy_offset(this->list, offsetof(peer_cfg_t, destroy));
|
||||||
this->mutex->destroy(this->mutex);
|
this->mutex->destroy(this->mutex);
|
||||||
@@ -953,19 +938,24 @@ static void destroy(private_stroke_config_t *this)
|
|||||||
*/
|
*/
|
||||||
stroke_config_t *stroke_config_create(stroke_ca_t *ca, stroke_cred_t *cred)
|
stroke_config_t *stroke_config_create(stroke_ca_t *ca, stroke_cred_t *cred)
|
||||||
{
|
{
|
||||||
private_stroke_config_t *this = malloc_thing(private_stroke_config_t);
|
private_stroke_config_t *this;
|
||||||
|
|
||||||
this->public.backend.create_peer_cfg_enumerator = (enumerator_t*(*)(backend_t*, identification_t *me, identification_t *other))create_peer_cfg_enumerator;
|
INIT(this,
|
||||||
this->public.backend.create_ike_cfg_enumerator = (enumerator_t*(*)(backend_t*, host_t *me, host_t *other))create_ike_cfg_enumerator;
|
.public = {
|
||||||
this->public.backend.get_peer_cfg_by_name = (peer_cfg_t* (*)(backend_t*,char*))get_peer_cfg_by_name;
|
.backend = {
|
||||||
this->public.add = (void(*)(stroke_config_t*, stroke_msg_t *msg))add;
|
.create_peer_cfg_enumerator = _create_peer_cfg_enumerator,
|
||||||
this->public.del = (void(*)(stroke_config_t*, stroke_msg_t *msg))del;
|
.create_ike_cfg_enumerator = _create_ike_cfg_enumerator,
|
||||||
this->public.destroy = (void(*)(stroke_config_t*))destroy;
|
.get_peer_cfg_by_name = _get_peer_cfg_by_name,
|
||||||
|
},
|
||||||
this->list = linked_list_create();
|
.add = _add,
|
||||||
this->mutex = mutex_create(MUTEX_TYPE_RECURSIVE);
|
.del = _del,
|
||||||
this->ca = ca;
|
.destroy = _destroy,
|
||||||
this->cred = cred;
|
},
|
||||||
|
.list = linked_list_create(),
|
||||||
|
.mutex = mutex_create(MUTEX_TYPE_RECURSIVE),
|
||||||
|
.ca = ca,
|
||||||
|
.cred = cred,
|
||||||
|
);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user