Migrated trap_manager_t to INIT/METHOD macros

This commit is contained in:
Andreas Steffen 2011-06-28 14:42:29 +02:00
parent 32af7f32ea
commit 06356a2981
1 changed files with 31 additions and 44 deletions

View File

@ -88,11 +88,8 @@ static void destroy_entry(entry_t *entry)
free(entry); free(entry);
} }
/** METHOD(trap_manager_t, install, u_int32_t,
* Implementation of trap_manager_t.install private_trap_manager_t *this, peer_cfg_t *peer, child_cfg_t *child)
*/
static u_int32_t install(private_trap_manager_t *this, peer_cfg_t *peer,
child_cfg_t *child)
{ {
entry_t *entry; entry_t *entry;
ike_cfg_t *ike_cfg; ike_cfg_t *ike_cfg;
@ -185,10 +182,8 @@ static u_int32_t install(private_trap_manager_t *this, peer_cfg_t *peer,
return reqid; return reqid;
} }
/** METHOD(trap_manager_t, uninstall, bool,
* Implementation of trap_manager_t.uninstall private_trap_manager_t *this, u_int32_t reqid)
*/
static bool uninstall(private_trap_manager_t *this, u_int32_t reqid)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
entry_t *entry, *found = NULL; entry_t *entry, *found = NULL;
@ -234,10 +229,8 @@ static bool trap_filter(rwlock_t *lock, entry_t **entry, peer_cfg_t **peer_cfg,
return TRUE; return TRUE;
} }
/** METHOD(trap_manager_t, create_enumerator, enumerator_t*,
* Implementation of trap_manager_t.create_enumerator private_trap_manager_t *this)
*/
static enumerator_t* create_enumerator(private_trap_manager_t *this)
{ {
this->lock->read_lock(this->lock); this->lock->read_lock(this->lock);
return enumerator_create_filter(this->traps->create_enumerator(this->traps), return enumerator_create_filter(this->traps->create_enumerator(this->traps),
@ -245,11 +238,9 @@ static enumerator_t* create_enumerator(private_trap_manager_t *this)
(void*)this->lock->unlock); (void*)this->lock->unlock);
} }
/** METHOD(trap_manager_t, acquire, void,
* Implementation of trap_manager_t.acquire private_trap_manager_t *this, u_int32_t reqid,
*/ traffic_selector_t *src, traffic_selector_t *dst)
static void acquire(private_trap_manager_t *this, u_int32_t reqid,
traffic_selector_t *src, traffic_selector_t *dst)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
entry_t *entry, *found = NULL; entry_t *entry, *found = NULL;
@ -331,11 +322,8 @@ static void complete(private_trap_manager_t *this, ike_sa_t *ike_sa,
this->lock->unlock(this->lock); this->lock->unlock(this->lock);
} }
/** METHOD(listener_t, ike_state_change, bool,
* Implementation of listener_t.ike_state_change trap_listener_t *listener, ike_sa_t *ike_sa, ike_sa_state_t state)
*/
static bool ike_state_change(trap_listener_t *listener, ike_sa_t *ike_sa,
ike_sa_state_t state)
{ {
switch (state) switch (state)
{ {
@ -347,11 +335,9 @@ static bool ike_state_change(trap_listener_t *listener, ike_sa_t *ike_sa,
} }
} }
/** METHOD(listener_t, child_state_change, bool,
* Implementation of listener_t.child_state_change trap_listener_t *listener, ike_sa_t *ike_sa, child_sa_t *child_sa,
*/ child_sa_state_t state)
static bool child_state_change(trap_listener_t *listener, ike_sa_t *ike_sa,
child_sa_t *child_sa, child_sa_state_t state)
{ {
switch (state) switch (state)
{ {
@ -364,10 +350,8 @@ static bool child_state_change(trap_listener_t *listener, ike_sa_t *ike_sa,
} }
} }
/** METHOD(trap_manager_t, destroy, void,
* Implementation of trap_manager_t.destroy. private_trap_manager_t *this)
*/
static void destroy(private_trap_manager_t *this)
{ {
charon->bus->remove_listener(charon->bus, &this->listener.listener); charon->bus->remove_listener(charon->bus, &this->listener.listener);
this->traps->invoke_function(this->traps, (void*)destroy_entry); this->traps->invoke_function(this->traps, (void*)destroy_entry);
@ -379,24 +363,27 @@ static void destroy(private_trap_manager_t *this)
/** /**
* See header * See header
*/ */
trap_manager_t *trap_manager_create() trap_manager_t *trap_manager_create(void)
{ {
private_trap_manager_t *this = malloc_thing(private_trap_manager_t); private_trap_manager_t *this;
this->public.install = (u_int(*)(trap_manager_t*, peer_cfg_t *peer, child_cfg_t *child))install; INIT(this,
this->public.uninstall = (bool(*)(trap_manager_t*, u_int32_t id))uninstall; .public = {
this->public.create_enumerator = (enumerator_t*(*)(trap_manager_t*))create_enumerator; .install = _install,
this->public.acquire = (void(*)(trap_manager_t*, u_int32_t reqid, traffic_selector_t *src, traffic_selector_t *dst))acquire; .uninstall = _uninstall,
this->public.destroy = (void(*)(trap_manager_t*))destroy; .create_enumerator = _create_enumerator,
.acquire = _acquire,
this->traps = linked_list_create(); .destroy = _destroy,
this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT); },
.traps = linked_list_create(),
.lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
);
/* register listener for IKE state changes */ /* register listener for IKE state changes */
this->listener.traps = this; this->listener.traps = this;
memset(&this->listener.listener, 0, sizeof(listener_t)); memset(&this->listener.listener, 0, sizeof(listener_t));
this->listener.listener.ike_state_change = (void*)ike_state_change; this->listener.listener.ike_state_change = _ike_state_change;
this->listener.listener.child_state_change = (void*)child_state_change; this->listener.listener.child_state_change = _child_state_change;
charon->bus->add_listener(charon->bus, &this->listener.listener); charon->bus->add_listener(charon->bus, &this->listener.listener);
return &this->public; return &this->public;