Migrated stroke_config_t to INIT/METHOD macros
This commit is contained in:
parent
a5ffb559d2
commit
a9ac8c51ea
|
@ -53,12 +53,8 @@ struct private_stroke_config_t {
|
|||
stroke_cred_t *cred;
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation of backend_t.create_peer_cfg_enumerator.
|
||||
*/
|
||||
static enumerator_t* create_peer_cfg_enumerator(private_stroke_config_t *this,
|
||||
identification_t *me,
|
||||
identification_t *other)
|
||||
METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
|
||||
private_stroke_config_t *this, identification_t *me, identification_t *other)
|
||||
{
|
||||
this->mutex->lock(this->mutex);
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of backend_t.create_ike_cfg_enumerator.
|
||||
*/
|
||||
static enumerator_t* create_ike_cfg_enumerator(private_stroke_config_t *this,
|
||||
host_t *me, host_t *other)
|
||||
METHOD(backend_t, create_ike_cfg_enumerator, enumerator_t*,
|
||||
private_stroke_config_t *this, host_t *me, host_t *other)
|
||||
{
|
||||
this->mutex->lock(this->mutex);
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* implements backend_t.get_peer_cfg_by_name.
|
||||
*/
|
||||
static peer_cfg_t *get_peer_cfg_by_name(private_stroke_config_t *this, char *name)
|
||||
METHOD(backend_t, get_peer_cfg_by_name, peer_cfg_t*,
|
||||
private_stroke_config_t *this, char *name)
|
||||
{
|
||||
enumerator_t *e1, *e2;
|
||||
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(
|
||||
msg->add_conn.name, &lifetime,
|
||||
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,
|
||||
&mark_in, &mark_out);
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of stroke_config_t.add.
|
||||
*/
|
||||
static void add(private_stroke_config_t *this, stroke_msg_t *msg)
|
||||
METHOD(stroke_config_t, add, void,
|
||||
private_stroke_config_t *this, stroke_msg_t *msg)
|
||||
{
|
||||
ike_cfg_t *ike_cfg, *existing_ike;
|
||||
peer_cfg_t *peer_cfg, *existing;
|
||||
|
@ -884,10 +873,8 @@ static void add(private_stroke_config_t *this, stroke_msg_t *msg)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of stroke_config_t.del.
|
||||
*/
|
||||
static void del(private_stroke_config_t *this, stroke_msg_t *msg)
|
||||
METHOD(stroke_config_t, del, void,
|
||||
private_stroke_config_t *this, stroke_msg_t *msg)
|
||||
{
|
||||
enumerator_t *enumerator, *children;
|
||||
peer_cfg_t *peer;
|
||||
|
@ -938,10 +925,8 @@ static void del(private_stroke_config_t *this, stroke_msg_t *msg)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of stroke_config_t.destroy
|
||||
*/
|
||||
static void destroy(private_stroke_config_t *this)
|
||||
METHOD(stroke_config_t, destroy, void,
|
||||
private_stroke_config_t *this)
|
||||
{
|
||||
this->list->destroy_offset(this->list, offsetof(peer_cfg_t, destroy));
|
||||
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)
|
||||
{
|
||||
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;
|
||||
this->public.backend.create_ike_cfg_enumerator = (enumerator_t*(*)(backend_t*, host_t *me, host_t *other))create_ike_cfg_enumerator;
|
||||
this->public.backend.get_peer_cfg_by_name = (peer_cfg_t* (*)(backend_t*,char*))get_peer_cfg_by_name;
|
||||
this->public.add = (void(*)(stroke_config_t*, stroke_msg_t *msg))add;
|
||||
this->public.del = (void(*)(stroke_config_t*, stroke_msg_t *msg))del;
|
||||
this->public.destroy = (void(*)(stroke_config_t*))destroy;
|
||||
|
||||
this->list = linked_list_create();
|
||||
this->mutex = mutex_create(MUTEX_TYPE_RECURSIVE);
|
||||
this->ca = ca;
|
||||
this->cred = cred;
|
||||
INIT(this,
|
||||
.public = {
|
||||
.backend = {
|
||||
.create_peer_cfg_enumerator = _create_peer_cfg_enumerator,
|
||||
.create_ike_cfg_enumerator = _create_ike_cfg_enumerator,
|
||||
.get_peer_cfg_by_name = _get_peer_cfg_by_name,
|
||||
},
|
||||
.add = _add,
|
||||
.del = _del,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.list = linked_list_create(),
|
||||
.mutex = mutex_create(MUTEX_TYPE_RECURSIVE),
|
||||
.ca = ca,
|
||||
.cred = cred,
|
||||
);
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue