Migrated child_cfg_t to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2010-11-26 16:32:15 +01:00
parent 03a6719f46
commit 31f6f1513d
+88 -144
View File
@@ -129,26 +129,20 @@ struct private_child_cfg_t {
bool install_policy; bool install_policy;
}; };
/** METHOD(child_cfg_t, get_name, char*,
* Implementation of child_cfg_t.get_name. private_child_cfg_t *this)
*/
static char *get_name(private_child_cfg_t *this)
{ {
return this->name; return this->name;
} }
/** METHOD(child_cfg_t, add_proposal, void,
* Implementation of child_cfg_t.add_proposal. private_child_cfg_t *this, proposal_t *proposal)
*/
static void add_proposal(private_child_cfg_t *this, proposal_t *proposal)
{ {
this->proposals->insert_last(this->proposals, proposal); this->proposals->insert_last(this->proposals, proposal);
} }
/** METHOD(child_cfg_t, get_proposals, linked_list_t*,
* Implementation of child_cfg_t.get_proposals. private_child_cfg_t *this, bool strip_dh)
*/
static linked_list_t* get_proposals(private_child_cfg_t *this, bool strip_dh)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
proposal_t *current; proposal_t *current;
@@ -169,12 +163,9 @@ static linked_list_t* get_proposals(private_child_cfg_t *this, bool strip_dh)
return proposals; return proposals;
} }
/** METHOD(child_cfg_t, select_proposal, proposal_t*,
* Implementation of child_cfg_t.select_proposal. private_child_cfg_t*this, linked_list_t *proposals, bool strip_dh,
*/ bool private)
static proposal_t* select_proposal(private_child_cfg_t*this,
linked_list_t *proposals, bool strip_dh,
bool private)
{ {
enumerator_t *stored_enum, *supplied_enum; enumerator_t *stored_enum, *supplied_enum;
proposal_t *stored, *supplied, *selected = NULL; proposal_t *stored, *supplied, *selected = NULL;
@@ -219,11 +210,8 @@ static proposal_t* select_proposal(private_child_cfg_t*this,
return selected; return selected;
} }
/** METHOD(child_cfg_t, add_traffic_selector, void,
* Implementation of child_cfg_t.add_traffic_selector. private_child_cfg_t *this, bool local, traffic_selector_t *ts)
*/
static void add_traffic_selector(private_child_cfg_t *this, bool local,
traffic_selector_t *ts)
{ {
if (local) if (local)
{ {
@@ -235,12 +223,8 @@ static void add_traffic_selector(private_child_cfg_t *this, bool local,
} }
} }
/** METHOD(child_cfg_t, get_traffic_selectors, linked_list_t*,
* Implementation of child_cfg_t.get_traffic_selectors. private_child_cfg_t *this, bool local, linked_list_t *supplied, host_t *host)
*/
static linked_list_t* get_traffic_selectors(private_child_cfg_t *this, bool local,
linked_list_t *supplied,
host_t *host)
{ {
enumerator_t *e1, *e2; enumerator_t *e1, *e2;
traffic_selector_t *ts1, *ts2, *selected; traffic_selector_t *ts1, *ts2, *selected;
@@ -346,18 +330,14 @@ static linked_list_t* get_traffic_selectors(private_child_cfg_t *this, bool loca
return result; return result;
} }
/** METHOD(child_cfg_t, get_updown, char*,
* Implementation of child_cfg_t.get_updown. private_child_cfg_t *this)
*/
static char* get_updown(private_child_cfg_t *this)
{ {
return this->updown; return this->updown;
} }
/** METHOD(child_cfg_t, get_hostaccess, bool,
* Implementation of child_cfg_t.get_hostaccess. private_child_cfg_t *this)
*/
static bool get_hostaccess(private_child_cfg_t *this)
{ {
return this->hostaccess; return this->hostaccess;
} }
@@ -378,10 +358,8 @@ static u_int64_t apply_jitter(u_int64_t rekey, u_int64_t jitter)
} }
#define APPLY_JITTER(l) l.rekey = apply_jitter(l.rekey, l.jitter) #define APPLY_JITTER(l) l.rekey = apply_jitter(l.rekey, l.jitter)
/** METHOD(child_cfg_t, get_lifetime, lifetime_cfg_t*,
* Implementation of child_cfg_t.get_lifetime. private_child_cfg_t *this)
*/
static lifetime_cfg_t *get_lifetime(private_child_cfg_t *this)
{ {
lifetime_cfg_t *lft = malloc_thing(lifetime_cfg_t); lifetime_cfg_t *lft = malloc_thing(lifetime_cfg_t);
memcpy(lft, &this->lifetime, sizeof(lifetime_cfg_t)); memcpy(lft, &this->lifetime, sizeof(lifetime_cfg_t));
@@ -391,34 +369,26 @@ static lifetime_cfg_t *get_lifetime(private_child_cfg_t *this)
return lft; return lft;
} }
/** METHOD(child_cfg_t, get_mode, ipsec_mode_t,
* Implementation of child_cfg_t.get_mode. private_child_cfg_t *this)
*/
static ipsec_mode_t get_mode(private_child_cfg_t *this)
{ {
return this->mode; return this->mode;
} }
/** METHOD(child_cfg_t, get_dpd_action, action_t,
* Implementation of child_cfg_t.get_dpd_action. private_child_cfg_t *this)
*/
static action_t get_dpd_action(private_child_cfg_t *this)
{ {
return this->dpd_action; return this->dpd_action;
} }
/** METHOD(child_cfg_t, get_close_action, action_t,
* Implementation of child_cfg_t.get_close_action. private_child_cfg_t *this)
*/
static action_t get_close_action(private_child_cfg_t *this)
{ {
return this->close_action; return this->close_action;
} }
/** METHOD(child_cfg_t, get_dh_group, diffie_hellman_group_t,
* Implementation of child_cfg_t.get_dh_group. private_child_cfg_t *this)
*/
static diffie_hellman_group_t get_dh_group(private_child_cfg_t *this)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
proposal_t *proposal; proposal_t *proposal;
@@ -436,77 +406,58 @@ static diffie_hellman_group_t get_dh_group(private_child_cfg_t *this)
return dh_group; return dh_group;
} }
/** METHOD(child_cfg_t, use_ipcomp, bool,
* Implementation of child_cfg_t.use_ipcomp. private_child_cfg_t *this)
*/
static bool use_ipcomp(private_child_cfg_t *this)
{ {
return this->use_ipcomp; return this->use_ipcomp;
} }
/** METHOD(child_cfg_t, get_inactivity, u_int32_t,
* Implementation of child_cfg_t.get_inactivity. private_child_cfg_t *this)
*/
static u_int32_t get_inactivity(private_child_cfg_t *this)
{ {
return this->inactivity; return this->inactivity;
} }
/** METHOD(child_cfg_t, get_reqid, u_int32_t,
* Implementation of child_cfg_t.get_reqid. private_child_cfg_t *this)
*/
static u_int32_t get_reqid(private_child_cfg_t *this)
{ {
return this->reqid; return this->reqid;
} }
/** METHOD(child_cfg_t, get_mark, mark_t,
* Implementation of child_cfg_t.get_mark. private_child_cfg_t *this, bool inbound)
*/
static mark_t get_mark(private_child_cfg_t *this, bool inbound)
{ {
return inbound ? this->mark_in : this->mark_out; return inbound ? this->mark_in : this->mark_out;
} }
/** METHOD(child_cfg_t, set_mipv6_options, void,
* Implementation of child_cfg_t.set_mipv6_options. private_child_cfg_t *this, bool proxy_mode, bool install_policy)
*/
static void set_mipv6_options(private_child_cfg_t *this, bool proxy_mode,
bool install_policy)
{ {
this->proxy_mode = proxy_mode; this->proxy_mode = proxy_mode;
this->install_policy = install_policy; this->install_policy = install_policy;
} }
/** METHOD(child_cfg_t, use_proxy_mode, bool,
* Implementation of child_cfg_t.use_proxy_mode. private_child_cfg_t *this)
*/
static bool use_proxy_mode(private_child_cfg_t *this)
{ {
return this->proxy_mode; return this->proxy_mode;
} }
/** METHOD(child_cfg_t, install_policy, bool,
* Implementation of child_cfg_t.install_policy. private_child_cfg_t *this)
*/
static bool install_policy(private_child_cfg_t *this)
{ {
return this->install_policy; return this->install_policy;
} }
/** METHOD(child_cfg_t, get_ref, child_cfg_t*,
* Implementation of child_cfg_t.get_ref. private_child_cfg_t *this)
*/
static child_cfg_t* get_ref(private_child_cfg_t *this)
{ {
ref_get(&this->refcount); ref_get(&this->refcount);
return &this->public; return &this->public;
} }
/** METHOD(child_cfg_t, destroy, void,
* Implements child_cfg_t.destroy. private_child_cfg_t *this)
*/
static void destroy(private_child_cfg_t *this)
{ {
if (ref_put(&this->refcount)) if (ref_put(&this->refcount))
{ {
@@ -532,66 +483,59 @@ child_cfg_t *child_cfg_create(char *name, lifetime_cfg_t *lifetime,
u_int32_t inactivity, u_int32_t reqid, u_int32_t inactivity, u_int32_t reqid,
mark_t *mark_in, mark_t *mark_out) mark_t *mark_in, mark_t *mark_out)
{ {
private_child_cfg_t *this = malloc_thing(private_child_cfg_t); private_child_cfg_t *this;
this->public.get_name = (char* (*) (child_cfg_t*))get_name; INIT(this,
this->public.add_traffic_selector = (void (*)(child_cfg_t*,bool,traffic_selector_t*))add_traffic_selector; .public = {
this->public.get_traffic_selectors = (linked_list_t*(*)(child_cfg_t*,bool,linked_list_t*,host_t*))get_traffic_selectors; .get_name = _get_name,
this->public.add_proposal = (void (*) (child_cfg_t*,proposal_t*))add_proposal; .add_traffic_selector = _add_traffic_selector,
this->public.get_proposals = (linked_list_t* (*) (child_cfg_t*,bool))get_proposals; .get_traffic_selectors = _get_traffic_selectors,
this->public.select_proposal = (proposal_t* (*) (child_cfg_t*,linked_list_t*,bool,bool))select_proposal; .add_proposal = _add_proposal,
this->public.get_updown = (char* (*) (child_cfg_t*))get_updown; .get_proposals = _get_proposals,
this->public.get_hostaccess = (bool (*) (child_cfg_t*))get_hostaccess; .select_proposal = _select_proposal,
this->public.get_mode = (ipsec_mode_t (*) (child_cfg_t *))get_mode; .get_updown = _get_updown,
this->public.get_dpd_action = (action_t (*) (child_cfg_t *))get_dpd_action; .get_hostaccess = _get_hostaccess,
this->public.get_close_action = (action_t (*) (child_cfg_t *))get_close_action; .get_mode = _get_mode,
this->public.get_lifetime = (lifetime_cfg_t* (*) (child_cfg_t *))get_lifetime; .get_dpd_action = _get_dpd_action,
this->public.get_dh_group = (diffie_hellman_group_t(*)(child_cfg_t*)) get_dh_group; .get_close_action = _get_close_action,
this->public.set_mipv6_options = (void (*) (child_cfg_t*,bool,bool))set_mipv6_options; .get_lifetime = _get_lifetime,
this->public.use_ipcomp = (bool (*) (child_cfg_t *))use_ipcomp; .get_dh_group = _get_dh_group,
this->public.get_inactivity = (u_int32_t (*) (child_cfg_t *))get_inactivity; .set_mipv6_options = _set_mipv6_options,
this->public.get_reqid = (u_int32_t (*) (child_cfg_t *))get_reqid; .use_ipcomp = _use_ipcomp,
this->public.get_mark = (mark_t (*) (child_cfg_t *,bool))get_mark; .get_inactivity = _get_inactivity,
this->public.use_proxy_mode = (bool (*) (child_cfg_t *))use_proxy_mode; .get_reqid = _get_reqid,
this->public.install_policy = (bool (*) (child_cfg_t *))install_policy; .get_mark = _get_mark,
this->public.get_ref = (child_cfg_t* (*) (child_cfg_t*))get_ref; .use_proxy_mode = _use_proxy_mode,
this->public.destroy = (void (*) (child_cfg_t*))destroy; .install_policy = _install_policy,
.get_ref = _get_ref,
this->name = strdup(name); .destroy = _destroy,
this->updown = updown ? strdup(updown) : NULL; },
this->hostaccess = hostaccess; .name = strdup(name),
this->mode = mode; .updown = updown ? strdup(updown) : NULL,
this->dpd_action = dpd_action; .hostaccess = hostaccess,
this->close_action = close_action; .mode = mode,
this->use_ipcomp = ipcomp; .start_action = start_action,
this->inactivity = inactivity; .dpd_action = dpd_action,
this->reqid = reqid; .close_action = close_action,
.use_ipcomp = ipcomp,
.inactivity = inactivity,
.reqid = reqid,
.proxy_mode = FALSE,
.install_policy = TRUE,
.refcount = 1,
.proposals = linked_list_create(),
.my_ts = linked_list_create(),
.other_ts = linked_list_create(),
);
if (mark_in) if (mark_in)
{ {
this->mark_in = *mark_in; this->mark_in = *mark_in;
} }
else
{
this->mark_in.value = 0;
this->mark_in.mask = 0;
}
if (mark_out) if (mark_out)
{ {
this->mark_out = *mark_out; this->mark_out = *mark_out;
} }
else
{
this->mark_out.value = 0;
this->mark_out.mask = 0;
}
this->proxy_mode = FALSE;
this->install_policy = TRUE;
this->refcount = 1;
this->proposals = linked_list_create();
this->my_ts = linked_list_create();
this->other_ts = linked_list_create();
memcpy(&this->lifetime, lifetime, sizeof(lifetime_cfg_t)); memcpy(&this->lifetime, lifetime, sizeof(lifetime_cfg_t));
return &this->public; return &this->public;