Migrated ike_natd to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2011-10-03 22:06:56 +02:00
parent 7db8fd0d9a
commit 6ade8d6163
+38 -55
View File
@@ -256,10 +256,8 @@ static void process_payloads(private_ike_natd_t *this, message_t *message)
} }
} }
/** METHOD(task_t, process_i, status_t,
* Implementation of task_t.process for initiator private_ike_natd_t *this, message_t *message)
*/
static status_t process_i(private_ike_natd_t *this, message_t *message)
{ {
process_payloads(this, message); process_payloads(this, message);
@@ -281,10 +279,8 @@ static status_t process_i(private_ike_natd_t *this, message_t *message)
return SUCCESS; return SUCCESS;
} }
/** METHOD(task_t, build_i, status_t,
* Implementation of task_t.process for initiator private_ike_natd_t *this, message_t *message)
*/
static status_t build_i(private_ike_natd_t *this, message_t *message)
{ {
notify_payload_t *notify; notify_payload_t *notify;
enumerator_t *enumerator; enumerator_t *enumerator;
@@ -345,10 +341,8 @@ static status_t build_i(private_ike_natd_t *this, message_t *message)
return NEED_MORE; return NEED_MORE;
} }
/** METHOD(task_t, build_r, status_t,
* Implementation of task_t.build for responder private_ike_natd_t *this, message_t *message)
*/
static status_t build_r(private_ike_natd_t *this, message_t *message)
{ {
notify_payload_t *notify; notify_payload_t *notify;
host_t *me, *other; host_t *me, *other;
@@ -380,28 +374,22 @@ static status_t build_r(private_ike_natd_t *this, message_t *message)
return SUCCESS; return SUCCESS;
} }
/** METHOD(task_t, process_r, status_t,
* Implementation of task_t.process for responder private_ike_natd_t *this, message_t *message)
*/
static status_t process_r(private_ike_natd_t *this, message_t *message)
{ {
process_payloads(this, message); process_payloads(this, message);
return NEED_MORE; return NEED_MORE;
} }
/** METHOD(task_t, get_type, task_type_t,
* Implementation of task_t.get_type private_ike_natd_t *this)
*/
static task_type_t get_type(private_ike_natd_t *this)
{ {
return IKE_NATD; return IKE_NATD;
} }
/** METHOD(task_t, migrate, void,
* Implementation of task_t.migrate private_ike_natd_t *this, ike_sa_t *ike_sa)
*/
static void migrate(private_ike_natd_t *this, ike_sa_t *ike_sa)
{ {
this->ike_sa = ike_sa; this->ike_sa = ike_sa;
this->src_seen = FALSE; this->src_seen = FALSE;
@@ -411,55 +399,50 @@ static void migrate(private_ike_natd_t *this, ike_sa_t *ike_sa)
this->mapping_changed = FALSE; this->mapping_changed = FALSE;
} }
/** METHOD(task_t, destroy, void,
* Implementation of ike_natd_t.has_mapping_changed private_ike_natd_t *this)
*/
static bool has_mapping_changed(private_ike_natd_t *this)
{
return this->mapping_changed;
}
/**
* Implementation of task_t.destroy
*/
static void destroy(private_ike_natd_t *this)
{ {
DESTROY_IF(this->hasher); DESTROY_IF(this->hasher);
free(this); free(this);
} }
METHOD(ike_natd_t, has_mapping_changed, bool,
private_ike_natd_t *this)
{
return this->mapping_changed;
}
/* /*
* Described in header. * Described in header.
*/ */
ike_natd_t *ike_natd_create(ike_sa_t *ike_sa, bool initiator) ike_natd_t *ike_natd_create(ike_sa_t *ike_sa, bool initiator)
{ {
private_ike_natd_t *this = malloc_thing(private_ike_natd_t); private_ike_natd_t *this;
this->public.task.get_type = (task_type_t(*)(task_t*))get_type; INIT(this,
this->public.task.migrate = (void(*)(task_t*,ike_sa_t*))migrate; .public = {
this->public.task.destroy = (void(*)(task_t*))destroy; .task = {
.get_type = _get_type,
.migrate = _migrate,
.destroy = _destroy,
},
.has_mapping_changed = _has_mapping_changed,
},
.ike_sa = ike_sa,
.initiator = initiator,
.hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1),
);
if (initiator) if (initiator)
{ {
this->public.task.build = (status_t(*)(task_t*,message_t*))build_i; this->public.task.build = _build_i;
this->public.task.process = (status_t(*)(task_t*,message_t*))process_i; this->public.task.process = _process_i;
} }
else else
{ {
this->public.task.build = (status_t(*)(task_t*,message_t*))build_r; this->public.task.build = _build_r;
this->public.task.process = (status_t(*)(task_t*,message_t*))process_r; this->public.task.process = _process_r;
} }
this->public.has_mapping_changed = (bool(*)(ike_natd_t*))has_mapping_changed;
this->ike_sa = ike_sa;
this->initiator = initiator;
this->hasher = lib->crypto->create_hasher(lib->crypto, HASH_SHA1);
this->src_seen = FALSE;
this->dst_seen = FALSE;
this->src_matched = FALSE;
this->dst_matched = FALSE;
this->mapping_changed = FALSE;
return &this->public; return &this->public;
} }