Migrated stroke_attribute_t to METHOD/INIT macros.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright (C) 2010 Tobias Brunner
|
||||||
* Copyright (C) 2008 Martin Willi
|
* Copyright (C) 2008 Martin Willi
|
||||||
* Hochschule fuer Technik Rapperswil
|
* Hochschule fuer Technik Rapperswil
|
||||||
*
|
*
|
||||||
@@ -64,12 +65,9 @@ static mem_pool_t *find_pool(private_stroke_attribute_t *this, char *name)
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(attribute_provider_t, acquire_address, host_t*,
|
||||||
* Implementation of attribute_provider_t.acquire_address
|
private_stroke_attribute_t *this, char *name, identification_t *id,
|
||||||
*/
|
host_t *requested)
|
||||||
static host_t* acquire_address(private_stroke_attribute_t *this,
|
|
||||||
char *name, identification_t *id,
|
|
||||||
host_t *requested)
|
|
||||||
{
|
{
|
||||||
mem_pool_t *pool;
|
mem_pool_t *pool;
|
||||||
host_t *addr = NULL;
|
host_t *addr = NULL;
|
||||||
@@ -83,11 +81,9 @@ static host_t* acquire_address(private_stroke_attribute_t *this,
|
|||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(attribute_provider_t, release_address, bool,
|
||||||
* Implementation of attribute_provider_t.release_address
|
private_stroke_attribute_t *this, char *name, host_t *address,
|
||||||
*/
|
identification_t *id)
|
||||||
static bool release_address(private_stroke_attribute_t *this,
|
|
||||||
char *name, host_t *address, identification_t *id)
|
|
||||||
{
|
{
|
||||||
mem_pool_t *pool;
|
mem_pool_t *pool;
|
||||||
bool found = FALSE;
|
bool found = FALSE;
|
||||||
@@ -101,10 +97,8 @@ static bool release_address(private_stroke_attribute_t *this,
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(stroke_attribute_t, add_pool, void,
|
||||||
* Implementation of stroke_attribute_t.add_pool.
|
private_stroke_attribute_t *this, stroke_msg_t *msg)
|
||||||
*/
|
|
||||||
static void add_pool(private_stroke_attribute_t *this, stroke_msg_t *msg)
|
|
||||||
{
|
{
|
||||||
if (msg->add_conn.other.sourceip_mask)
|
if (msg->add_conn.other.sourceip_mask)
|
||||||
{
|
{
|
||||||
@@ -135,10 +129,8 @@ static void add_pool(private_stroke_attribute_t *this, stroke_msg_t *msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(stroke_attribute_t, del_pool, void,
|
||||||
* Implementation of stroke_attribute_t.del_pool.
|
private_stroke_attribute_t *this, stroke_msg_t *msg)
|
||||||
*/
|
|
||||||
static void del_pool(private_stroke_attribute_t *this, stroke_msg_t *msg)
|
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
mem_pool_t *pool;
|
mem_pool_t *pool;
|
||||||
@@ -173,10 +165,8 @@ static bool pool_filter(void *mutex, mem_pool_t **poolp, const char **name,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(stroke_attribute_t, create_pool_enumerator, enumerator_t*,
|
||||||
* Implementation of stroke_attribute_t.create_pool_enumerator
|
private_stroke_attribute_t *this)
|
||||||
*/
|
|
||||||
static enumerator_t* create_pool_enumerator(private_stroke_attribute_t *this)
|
|
||||||
{
|
{
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
return enumerator_create_filter(this->pools->create_enumerator(this->pools),
|
return enumerator_create_filter(this->pools->create_enumerator(this->pools),
|
||||||
@@ -184,11 +174,8 @@ static enumerator_t* create_pool_enumerator(private_stroke_attribute_t *this)
|
|||||||
this->mutex, (void*)this->mutex->unlock);
|
this->mutex, (void*)this->mutex->unlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(stroke_attribute_t, create_lease_enumerator, enumerator_t*,
|
||||||
* Implementation of stroke_attribute_t.create_lease_enumerator
|
private_stroke_attribute_t *this, char *name)
|
||||||
*/
|
|
||||||
static enumerator_t* create_lease_enumerator(private_stroke_attribute_t *this,
|
|
||||||
char *name)
|
|
||||||
{
|
{
|
||||||
mem_pool_t *pool;
|
mem_pool_t *pool;
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
@@ -202,10 +189,8 @@ static enumerator_t* create_lease_enumerator(private_stroke_attribute_t *this,
|
|||||||
(void*)this->mutex->unlock, this->mutex);
|
(void*)this->mutex->unlock, this->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
METHOD(stroke_attribute_t, destroy, void,
|
||||||
* Implementation of stroke_attribute_t.destroy
|
private_stroke_attribute_t *this)
|
||||||
*/
|
|
||||||
static void destroy(private_stroke_attribute_t *this)
|
|
||||||
{
|
{
|
||||||
this->mutex->destroy(this->mutex);
|
this->mutex->destroy(this->mutex);
|
||||||
this->pools->destroy_offset(this->pools, offsetof(mem_pool_t, destroy));
|
this->pools->destroy_offset(this->pools, offsetof(mem_pool_t, destroy));
|
||||||
@@ -217,19 +202,24 @@ static void destroy(private_stroke_attribute_t *this)
|
|||||||
*/
|
*/
|
||||||
stroke_attribute_t *stroke_attribute_create()
|
stroke_attribute_t *stroke_attribute_create()
|
||||||
{
|
{
|
||||||
private_stroke_attribute_t *this = malloc_thing(private_stroke_attribute_t);
|
private_stroke_attribute_t *this;
|
||||||
|
|
||||||
this->public.provider.acquire_address = (host_t*(*)(attribute_provider_t *this, char*, identification_t *,host_t *))acquire_address;
|
INIT(this,
|
||||||
this->public.provider.release_address = (bool(*)(attribute_provider_t *this, char*,host_t *, identification_t*))release_address;
|
.public = {
|
||||||
this->public.provider.create_attribute_enumerator = (enumerator_t*(*)(attribute_provider_t*, identification_t *id, host_t *vip))enumerator_create_empty;
|
.provider = {
|
||||||
this->public.add_pool = (void(*)(stroke_attribute_t*, stroke_msg_t *msg))add_pool;
|
.acquire_address = _acquire_address,
|
||||||
this->public.del_pool = (void(*)(stroke_attribute_t*, stroke_msg_t *msg))del_pool;
|
.release_address = _release_address,
|
||||||
this->public.create_pool_enumerator = (enumerator_t*(*)(stroke_attribute_t*))create_pool_enumerator;
|
.create_attribute_enumerator = enumerator_create_empty,
|
||||||
this->public.create_lease_enumerator = (enumerator_t*(*)(stroke_attribute_t*, char *pool))create_lease_enumerator;
|
},
|
||||||
this->public.destroy = (void(*)(stroke_attribute_t*))destroy;
|
.add_pool = _add_pool,
|
||||||
|
.del_pool = _del_pool,
|
||||||
this->pools = linked_list_create();
|
.create_pool_enumerator = _create_pool_enumerator,
|
||||||
this->mutex = mutex_create(MUTEX_TYPE_RECURSIVE);
|
.create_lease_enumerator = _create_lease_enumerator,
|
||||||
|
.destroy = _destroy,
|
||||||
|
},
|
||||||
|
.pools = linked_list_create(),
|
||||||
|
.mutex = mutex_create(MUTEX_TYPE_RECURSIVE),
|
||||||
|
);
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user