Migrated ha plugin to INIT/METHOD macros

This commit is contained in:
Martin Willi 2010-07-22 11:42:22 +02:00
parent c74c4c2a20
commit 00c1bd0606
10 changed files with 198 additions and 253 deletions

View File

@ -38,12 +38,9 @@ struct private_ha_child_t {
ha_tunnel_t *tunnel;
};
/**
* Implementation of listener_t.child_keys
*/
static bool child_keys(private_ha_child_t *this, ike_sa_t *ike_sa,
child_sa_t *child_sa, diffie_hellman_t *dh,
chunk_t nonce_i, chunk_t nonce_r)
METHOD(listener_t, child_keys, bool,
private_ha_child_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r)
{
ha_message_t *m;
chunk_t secret;
@ -110,11 +107,9 @@ static bool child_keys(private_ha_child_t *this, ike_sa_t *ike_sa,
return TRUE;
}
/**
* Implementation of listener_t.child_state_change
*/
static bool child_state_change(private_ha_child_t *this, ike_sa_t *ike_sa,
child_sa_t *child_sa, child_sa_state_t state)
METHOD(listener_t, child_state_change, bool,
private_ha_child_t *this, ike_sa_t *ike_sa,
child_sa_t *child_sa, child_sa_state_t state)
{
if (!ike_sa ||
ike_sa->get_state(ike_sa) == IKE_PASSIVE ||
@ -142,10 +137,8 @@ static bool child_state_change(private_ha_child_t *this, ike_sa_t *ike_sa,
return TRUE;
}
/**
* Implementation of ha_child_t.destroy.
*/
static void destroy(private_ha_child_t *this)
METHOD(ha_child_t, destroy, void,
private_ha_child_t *this)
{
free(this);
}
@ -155,15 +148,19 @@ static void destroy(private_ha_child_t *this)
*/
ha_child_t *ha_child_create(ha_socket_t *socket, ha_tunnel_t *tunnel)
{
private_ha_child_t *this = malloc_thing(private_ha_child_t);
private_ha_child_t *this;
memset(&this->public.listener, 0, sizeof(listener_t));
this->public.listener.child_keys = (bool(*)(listener_t*, ike_sa_t *ike_sa, child_sa_t *child_sa, diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r))child_keys;
this->public.listener.child_state_change = (bool(*)(listener_t*,ike_sa_t *ike_sa, child_sa_t *child_sa, child_sa_state_t state))child_state_change;
this->public.destroy = (void(*)(ha_child_t*))destroy;
this->socket = socket;
this->tunnel = tunnel;
INIT(this,
.public = {
.listener = {
.child_keys = _child_keys,
.child_state_change = _child_state_change,
},
.destroy = _destroy,
},
.socket = socket,
.tunnel = tunnel,
);
return &this->public;
}

View File

@ -96,10 +96,8 @@ static job_requeue_t dispatch_fifo(private_ha_ctl_t *this)
return JOB_REQUEUE_DIRECT;
}
/**
* Implementation of ha_ctl_t.destroy.
*/
static void destroy(private_ha_ctl_t *this)
METHOD(ha_ctl_t, destroy, void,
private_ha_ctl_t *this)
{
this->job->cancel(this->job);
free(this);
@ -110,9 +108,14 @@ static void destroy(private_ha_ctl_t *this)
*/
ha_ctl_t *ha_ctl_create(ha_segments_t *segments)
{
private_ha_ctl_t *this = malloc_thing(private_ha_ctl_t);
private_ha_ctl_t *this;
this->public.destroy = (void(*)(ha_ctl_t*))destroy;
INIT(this,
.public = {
.destroy = _destroy,
},
.segments = segments,
);
if (access(HA_FIFO, R_OK|W_OK) != 0)
{
@ -123,7 +126,6 @@ ha_ctl_t *ha_ctl_create(ha_segments_t *segments)
}
}
this->segments = segments;
this->job = callback_job_create((callback_job_cb_t)dispatch_fifo,
this, NULL, NULL);
charon->processor->queue_job(charon->processor, (job_t*)this->job);

View File

@ -707,10 +707,8 @@ static job_requeue_t dispatch(private_ha_dispatcher_t *this)
return JOB_REQUEUE_DIRECT;
}
/**
* Implementation of ha_dispatcher_t.destroy.
*/
static void destroy(private_ha_dispatcher_t *this)
METHOD(ha_dispatcher_t, destroy, void,
private_ha_dispatcher_t *this)
{
this->job->cancel(this->job);
free(this);
@ -722,12 +720,16 @@ static void destroy(private_ha_dispatcher_t *this)
ha_dispatcher_t *ha_dispatcher_create(ha_socket_t *socket,
ha_segments_t *segments)
{
private_ha_dispatcher_t *this = malloc_thing(private_ha_dispatcher_t);
private_ha_dispatcher_t *this;
this->public.destroy = (void(*)(ha_dispatcher_t*))destroy;
this->socket = socket;
this->segments = segments;
INIT(this,
.public = {
.destroy = _destroy,
},
.socket = socket,
.segments = segments,
);
this->job = callback_job_create((callback_job_cb_t)dispatch,
this, NULL, NULL);
charon->processor->queue_job(charon->processor, (job_t*)this->job);

View File

@ -62,12 +62,9 @@ static ike_extension_t copy_extension(ike_sa_t *ike_sa, ike_extension_t ext)
return 0;
}
/**
* Implementation of listener_t.ike_keys
*/
static bool ike_keys(private_ha_ike_t *this, ike_sa_t *ike_sa,
diffie_hellman_t *dh, chunk_t nonce_i, chunk_t nonce_r,
ike_sa_t *rekey)
METHOD(listener_t, ike_keys, bool,
private_ha_ike_t *this, ike_sa_t *ike_sa, diffie_hellman_t *dh,
chunk_t nonce_i, chunk_t nonce_r, ike_sa_t *rekey)
{
ha_message_t *m;
chunk_t secret;
@ -124,10 +121,8 @@ static bool ike_keys(private_ha_ike_t *this, ike_sa_t *ike_sa,
return TRUE;
}
/**
* Implementation of listener_t.ike_updown
*/
static bool ike_updown(private_ha_ike_t *this, ike_sa_t *ike_sa, bool up)
METHOD(listener_t, ike_updown, bool,
private_ha_ike_t *this, ike_sa_t *ike_sa, bool up)
{
ha_message_t *m;
@ -189,21 +184,16 @@ static bool ike_updown(private_ha_ike_t *this, ike_sa_t *ike_sa, bool up)
return TRUE;
}
/**
* Implementation of listener_t.ike_rekey
*/
static bool ike_rekey(private_ha_ike_t *this, ike_sa_t *old, ike_sa_t *new)
METHOD(listener_t, ike_rekey, bool,
private_ha_ike_t *this, ike_sa_t *old, ike_sa_t *new)
{
ike_updown(this, old, FALSE);
ike_updown(this, new, TRUE);
return TRUE;
}
/**
* Implementation of listener_t.message
*/
static bool message_hook(private_ha_ike_t *this, ike_sa_t *ike_sa,
message_t *message, bool incoming)
METHOD(listener_t, message_hook, bool,
private_ha_ike_t *this, ike_sa_t *ike_sa, message_t *message, bool incoming)
{
if (this->tunnel && this->tunnel->is_sa(this->tunnel, ike_sa))
{ /* do not sync SA between nodes */
@ -250,10 +240,8 @@ static bool message_hook(private_ha_ike_t *this, ike_sa_t *ike_sa,
return TRUE;
}
/**
* Implementation of ha_ike_t.destroy.
*/
static void destroy(private_ha_ike_t *this)
METHOD(ha_ike_t, destroy, void,
private_ha_ike_t *this)
{
free(this);
}
@ -263,17 +251,21 @@ static void destroy(private_ha_ike_t *this)
*/
ha_ike_t *ha_ike_create(ha_socket_t *socket, ha_tunnel_t *tunnel)
{
private_ha_ike_t *this = malloc_thing(private_ha_ike_t);
private_ha_ike_t *this;
memset(&this->public.listener, 0, sizeof(listener_t));
this->public.listener.ike_keys = (bool(*)(listener_t*, ike_sa_t *ike_sa, diffie_hellman_t *dh,chunk_t nonce_i, chunk_t nonce_r, ike_sa_t *rekey))ike_keys;
this->public.listener.ike_updown = (bool(*)(listener_t*,ike_sa_t *ike_sa, bool up))ike_updown;
this->public.listener.ike_rekey = (bool(*)(listener_t*,ike_sa_t *old, ike_sa_t *new))ike_rekey;
this->public.listener.message = (bool(*)(listener_t*, ike_sa_t *, message_t *,bool))message_hook;
this->public.destroy = (void(*)(ha_ike_t*))destroy;
this->socket = socket;
this->tunnel = tunnel;
INIT(this,
.public = {
.listener = {
.ike_keys = _ike_keys,
.ike_updown = _ike_updown,
.ike_rekey = _ike_rekey,
.message = _message_hook,
},
.destroy = _destroy,
},
.socket = socket,
.tunnel = tunnel,
);
return &this->public;
}

View File

@ -51,10 +51,8 @@ struct private_ha_kernel_t {
u_int count;
};
/**
* Implementation of ha_kernel_t.in_segment
*/
static bool in_segment(private_ha_kernel_t *this, host_t *host, u_int segment)
METHOD(ha_kernel_t, in_segment, bool,
private_ha_kernel_t *this, host_t *host, u_int segment)
{
if (host->get_family(host) == AF_INET)
{
@ -142,10 +140,8 @@ static segment_mask_t get_active(private_ha_kernel_t *this, char *file)
return mask;
}
/**
* Implementation of ha_kernel_t.activate
*/
static void activate(private_ha_kernel_t *this, u_int segment)
METHOD(ha_kernel_t, activate, void,
private_ha_kernel_t *this, u_int segment)
{
enumerator_t *enumerator;
char *file;
@ -158,10 +154,8 @@ static void activate(private_ha_kernel_t *this, u_int segment)
enumerator->destroy(enumerator);
}
/**
* Implementation of ha_kernel_t.deactivate
*/
static void deactivate(private_ha_kernel_t *this, u_int segment)
METHOD(ha_kernel_t, deactivate, void,
private_ha_kernel_t *this, u_int segment)
{
enumerator_t *enumerator;
char *file;
@ -199,10 +193,8 @@ static void disable_all(private_ha_kernel_t *this)
enumerator->destroy(enumerator);
}
/**
* Implementation of ha_kernel_t.destroy.
*/
static void destroy(private_ha_kernel_t *this)
METHOD(ha_kernel_t, destroy, void,
private_ha_kernel_t *this)
{
free(this);
}
@ -212,15 +204,18 @@ static void destroy(private_ha_kernel_t *this)
*/
ha_kernel_t *ha_kernel_create(u_int count)
{
private_ha_kernel_t *this = malloc_thing(private_ha_kernel_t);
private_ha_kernel_t *this;
this->public.in_segment = (bool(*)(ha_kernel_t*, host_t *host, u_int segment))in_segment;
this->public.activate = (void(*)(ha_kernel_t*, u_int segment))activate;
this->public.deactivate = (void(*)(ha_kernel_t*, u_int segment))deactivate;
this->public.destroy = (void(*)(ha_kernel_t*))destroy;
this->initval = 0;
this->count = count;
INIT(this,
.public = {
.in_segment = _in_segment,
.activate = _activate,
.deactivate = _deactivate,
.destroy = _destroy,
},
.initval = 0,
.count = count,
);
disable_all(this);

View File

@ -93,10 +93,8 @@ struct ts_encoding_t {
char encoding[];
} __attribute__((packed));
/**
* Implementation of ha_message_t.get_type
*/
static ha_message_type_t get_type(private_ha_message_t *this)
METHOD(ha_message_t, get_type, ha_message_type_t,
private_ha_message_t *this)
{
return this->buf.ptr[1];
}
@ -119,11 +117,8 @@ static void check_buf(private_ha_message_t *this, size_t len)
}
}
/**
* Implementation of ha_message_t.add_attribute
*/
static void add_attribute(private_ha_message_t *this,
ha_message_attribute_t attribute, ...)
METHOD(ha_message_t, add_attribute, void,
private_ha_message_t *this, ha_message_attribute_t attribute, ...)
{
size_t len;
va_list args;
@ -310,12 +305,9 @@ typedef struct {
void *cleanup_data;
} attribute_enumerator_t;
/**
* Implementation of create_attribute_enumerator().enumerate
*/
static bool attribute_enumerate(attribute_enumerator_t *this,
ha_message_attribute_t *attr_out,
ha_message_value_t *value)
METHOD(enumerator_t, attribute_enumerate, bool,
attribute_enumerator_t *this, ha_message_attribute_t *attr_out,
ha_message_value_t *value)
{
ha_message_attribute_t attr;
@ -559,10 +551,8 @@ static bool attribute_enumerate(attribute_enumerator_t *this,
}
}
/**
* Implementation of create_attribute_enumerator().destroy
*/
static void enum_destroy(attribute_enumerator_t *this)
METHOD(enumerator_t, enum_destroy, void,
attribute_enumerator_t *this)
{
if (this->cleanup)
{
@ -571,35 +561,30 @@ static void enum_destroy(attribute_enumerator_t *this)
free(this);
}
/**
* Implementation of ha_message_t.create_attribute_enumerator
*/
static enumerator_t* create_attribute_enumerator(private_ha_message_t *this)
METHOD(ha_message_t, create_attribute_enumerator, enumerator_t*,
private_ha_message_t *this)
{
attribute_enumerator_t *e = malloc_thing(attribute_enumerator_t);
attribute_enumerator_t *e;
e->public.enumerate = (void*)attribute_enumerate;
e->public.destroy = (void*)enum_destroy;
e->buf = chunk_skip(this->buf, 2);
e->cleanup = NULL;
e->cleanup_data = NULL;
INIT(e,
.public = {
.enumerate = (void*)_attribute_enumerate,
.destroy = _enum_destroy,
},
.buf = chunk_skip(this->buf, 2),
);
return &e->public;
}
/**
* Implementation of ha_message_t.get_encoding
*/
static chunk_t get_encoding(private_ha_message_t *this)
METHOD(ha_message_t, get_encoding, chunk_t,
private_ha_message_t *this)
{
return this->buf;
}
/**
* Implementation of ha_message_t.destroy.
*/
static void destroy(private_ha_message_t *this)
METHOD(ha_message_t, destroy, void,
private_ha_message_t *this)
{
free(this->buf.ptr);
free(this);
@ -608,14 +593,17 @@ static void destroy(private_ha_message_t *this)
static private_ha_message_t *ha_message_create_generic()
{
private_ha_message_t *this = malloc_thing(private_ha_message_t);
this->public.get_type = (ha_message_type_t(*)(ha_message_t*))get_type;
this->public.add_attribute = (void(*)(ha_message_t*, ha_message_attribute_t attribute, ...))add_attribute;
this->public.create_attribute_enumerator = (enumerator_t*(*)(ha_message_t*))create_attribute_enumerator;
this->public.get_encoding = (chunk_t(*)(ha_message_t*))get_encoding;
this->public.destroy = (void(*)(ha_message_t*))destroy;
private_ha_message_t *this;
INIT(this,
.public = {
.get_type = _get_type,
.add_attribute = _add_attribute,
.create_attribute_enumerator = _create_attribute_enumerator,
.get_encoding = _get_encoding,
.destroy = _destroy,
},
);
return this;
}

View File

@ -78,10 +78,8 @@ struct private_ha_plugin_t {
ha_ctl_t *ctl;
};
/**
* Implementation of plugin_t.destroy
*/
static void destroy(private_ha_plugin_t *this)
METHOD(plugin_t, destroy, void,
private_ha_plugin_t *this)
{
DESTROY_IF(this->ctl);
charon->bus->remove_listener(charon->bus, &this->segments->listener);
@ -127,11 +125,9 @@ plugin_t *ha_plugin_create()
return NULL;
}
this = malloc_thing(private_ha_plugin_t);
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
this->tunnel = NULL;
this->ctl = NULL;
INIT(this,
.public.plugin.destroy = _destroy,
);
if (secret)
{

View File

@ -209,18 +209,14 @@ static void enable_disable_all(private_ha_segments_t *this, u_int segment,
this->mutex->unlock(this->mutex);
}
/**
* Implementation of ha_segments_t.activate
*/
static void activate(private_ha_segments_t *this, u_int segment, bool notify)
METHOD(ha_segments_t, activate, void,
private_ha_segments_t *this, u_int segment, bool notify)
{
enable_disable_all(this, segment, TRUE, notify);
}
/**
* Implementation of ha_segments_t.deactivate
*/
static void deactivate(private_ha_segments_t *this, u_int segment, bool notify)
METHOD(ha_segments_t, deactivate, void,
private_ha_segments_t *this, u_int segment, bool notify)
{
enable_disable_all(this, segment, FALSE, notify);
}
@ -249,10 +245,8 @@ static status_t rekey_children(ike_sa_t *ike_sa)
return status;
}
/**
* Implementation of ha_segments_t.resync
*/
static void resync(private_ha_segments_t *this, u_int segment)
METHOD(ha_segments_t, resync, void,
private_ha_segments_t *this, u_int segment)
{
ike_sa_t *ike_sa;
enumerator_t *enumerator;
@ -307,11 +301,8 @@ static void resync(private_ha_segments_t *this, u_int segment)
list->destroy(list);
}
/**
* Implementation of listener_t.alert
*/
static bool alert_hook(private_ha_segments_t *this, ike_sa_t *ike_sa,
alert_t alert, va_list args)
METHOD(listener_t, alert_hook, bool,
private_ha_segments_t *this, ike_sa_t *ike_sa, alert_t alert, va_list args)
{
if (alert == ALERT_SHUTDOWN_SIGNAL)
{
@ -373,10 +364,8 @@ static void start_watchdog(private_ha_segments_t *this)
charon->processor->queue_job(charon->processor, (job_t*)this->job);
}
/**
* Implementation of ha_segments_t.handle_status
*/
static void handle_status(private_ha_segments_t *this, segment_mask_t mask)
METHOD(ha_segments_t, handle_status, void,
private_ha_segments_t *this, segment_mask_t mask)
{
segment_mask_t missing;
int i;
@ -441,10 +430,8 @@ static job_requeue_t send_status(private_ha_segments_t *this)
return JOB_REQUEUE_NONE;
}
/**
* Implementation of ha_segments_t.destroy.
*/
static void destroy(private_ha_segments_t *this)
METHOD(ha_segments_t, destroy, void,
private_ha_segments_t *this)
{
if (this->job)
{
@ -462,27 +449,25 @@ ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
ha_tunnel_t *tunnel, u_int count, u_int node,
bool monitor, bool sync)
{
private_ha_segments_t *this = malloc_thing(private_ha_segments_t);
private_ha_segments_t *this;
memset(&this->public.listener, 0, sizeof(listener_t));
this->public.listener.alert = (bool(*)(listener_t*, ike_sa_t *, alert_t, va_list))alert_hook;
this->public.activate = (void(*)(ha_segments_t*, u_int segment,bool))activate;
this->public.deactivate = (void(*)(ha_segments_t*, u_int segment,bool))deactivate;
this->public.resync = (void(*)(ha_segments_t*, u_int segment))resync;
this->public.handle_status = (void(*)(ha_segments_t*, segment_mask_t mask))handle_status;
this->public.destroy = (void(*)(ha_segments_t*))destroy;
this->socket = socket;
this->tunnel = tunnel;
this->kernel = kernel;
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
this->count = count;
this->node = node;
this->job = NULL;
/* initially all segments are deactivated */
this->active = 0;
INIT(this,
.public = {
.listener.alert = _alert_hook,
.activate = _activate,
.deactivate = _deactivate,
.resync = _resync,
.handle_status = _handle_status,
.destroy = _destroy,
},
.socket = socket,
.tunnel = tunnel,
.kernel = kernel,
.count = count,
.node = node,
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
.condvar = condvar_create(CONDVAR_TYPE_DEFAULT),
);
if (monitor)
{

View File

@ -88,10 +88,8 @@ static job_requeue_t send_message(job_data_t *data)
return JOB_REQUEUE_NONE;
}
/**
* Implementation of ha_socket_t.push
*/
static void push(private_ha_socket_t *this, ha_message_t *message)
METHOD(ha_socket_t, push, void,
private_ha_socket_t *this, ha_message_t *message)
{
chunk_t chunk;
@ -121,10 +119,8 @@ static void push(private_ha_socket_t *this, ha_message_t *message)
message->destroy(message);
}
/**
* Implementation of ha_socket_t.pull
*/
static ha_message_t *pull(private_ha_socket_t *this)
METHOD(ha_socket_t, pull, ha_message_t*,
private_ha_socket_t *this)
{
while (TRUE)
{
@ -189,10 +185,8 @@ static bool open_socket(private_ha_socket_t *this)
return TRUE;
}
/**
* Implementation of ha_socket_t.destroy.
*/
static void destroy(private_ha_socket_t *this)
METHOD(ha_socket_t, destroy, void,
private_ha_socket_t *this)
{
if (this->fd != -1)
{
@ -208,15 +202,18 @@ static void destroy(private_ha_socket_t *this)
*/
ha_socket_t *ha_socket_create(char *local, char *remote)
{
private_ha_socket_t *this = malloc_thing(private_ha_socket_t);
private_ha_socket_t *this;
this->public.push = (void(*)(ha_socket_t*, ha_message_t*))push;
this->public.pull = (ha_message_t*(*)(ha_socket_t*))pull;
this->public.destroy = (void(*)(ha_socket_t*))destroy;
this->local = host_create_from_dns(local, 0, HA_PORT);
this->remote = host_create_from_dns(remote, 0, HA_PORT);
this->fd = -1;
INIT(this,
.public = {
.push = _push,
.pull = _pull,
.destroy = _destroy,
},
.local = host_create_from_dns(local, 0, HA_PORT),
.remote = host_create_from_dns(remote, 0, HA_PORT),
.fd = -1,
);
if (!this->local || !this->remote)
{

View File

@ -92,10 +92,8 @@ struct private_ha_tunnel_t {
ha_creds_t creds;
};
/**
* Implementation of ha_tunnel_t.is_sa
*/
static bool is_sa(private_ha_tunnel_t *this, ike_sa_t *ike_sa)
METHOD(ha_tunnel_t, is_sa, bool,
private_ha_tunnel_t *this, ike_sa_t *ike_sa)
{
peer_cfg_t *cfg = this->backend.cfg;
@ -112,11 +110,8 @@ typedef struct {
shared_key_t *key;
} shared_enum_t;
/**
* Implementation of shared_enum_t.enumerate
*/
static bool shared_enumerate(shared_enum_t *this, shared_key_t **key,
id_match_t *me, id_match_t *other)
METHOD(enumerator_t, shared_enumerate, bool,
shared_enum_t *this, shared_key_t **key, id_match_t *me, id_match_t *other)
{
if (this->key)
{
@ -135,12 +130,9 @@ static bool shared_enumerate(shared_enum_t *this, shared_key_t **key,
return FALSE;
}
/**
* Implements ha_creds_t.create_shared_enumerator
*/
static enumerator_t* create_shared_enumerator(ha_creds_t *this,
shared_key_type_t type, identification_t *me,
identification_t *other)
METHOD(ha_creds_t, create_shared_enumerator, enumerator_t*,
ha_creds_t *this, shared_key_type_t type,
identification_t *me, identification_t *other)
{
shared_enum_t *enumerator;
@ -157,28 +149,25 @@ static enumerator_t* create_shared_enumerator(ha_creds_t *this,
return NULL;
}
enumerator = malloc_thing(shared_enum_t);
enumerator->public.enumerate = (void*)shared_enumerate;
enumerator->public.destroy = (void*)free;
enumerator->key = this->key;
INIT(enumerator,
.public = {
.enumerate = (void*)_shared_enumerate,
.destroy = (void*)free,
},
.key = this->key,
);
return &enumerator->public;
}
/**
* Implementation of backend_t.create_peer_cfg_enumerator.
*/
static enumerator_t* create_peer_cfg_enumerator(ha_backend_t *this,
identification_t *me, identification_t *other)
METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
ha_backend_t *this, identification_t *me, identification_t *other)
{
return enumerator_create_single(this->cfg, NULL);
}
/**
* Implementation of backend_t.create_ike_cfg_enumerator.
*/
static enumerator_t* create_ike_cfg_enumerator(ha_backend_t *this,
host_t *me, host_t *other)
METHOD(backend_t, create_ike_cfg_enumerator, enumerator_t*,
ha_backend_t *this, host_t *me, host_t *other)
{
return enumerator_create_single(this->cfg->get_ike_cfg(this->cfg), NULL);
}
@ -207,7 +196,7 @@ static void setup_tunnel(private_ha_tunnel_t *this,
chunk_clone(chunk_create(secret, strlen(secret))));
this->creds.public.create_private_enumerator = (void*)return_null;
this->creds.public.create_cert_enumerator = (void*)return_null;
this->creds.public.create_shared_enumerator = (void*)create_shared_enumerator;
this->creds.public.create_shared_enumerator = (void*)_create_shared_enumerator;
this->creds.public.create_cdp_enumerator = (void*)return_null;
this->creds.public.cache_cert = (void*)nop;
@ -248,8 +237,8 @@ static void setup_tunnel(private_ha_tunnel_t *this,
peer_cfg->add_child_cfg(peer_cfg, child_cfg);
this->backend.cfg = peer_cfg;
this->backend.public.create_peer_cfg_enumerator = (void*)create_peer_cfg_enumerator;
this->backend.public.create_ike_cfg_enumerator = (void*)create_ike_cfg_enumerator;
this->backend.public.create_peer_cfg_enumerator = (void*)_create_peer_cfg_enumerator;
this->backend.public.create_ike_cfg_enumerator = (void*)_create_ike_cfg_enumerator;
this->backend.public.get_peer_cfg_by_name = (void*)return_null;
charon->backends->add_backend(charon->backends, &this->backend.public);
@ -258,10 +247,8 @@ static void setup_tunnel(private_ha_tunnel_t *this,
this->trap = charon->traps->install(charon->traps, peer_cfg, child_cfg);
}
/**
* Implementation of ha_tunnel_t.destroy.
*/
static void destroy(private_ha_tunnel_t *this)
METHOD(ha_tunnel_t, destroy, void,
private_ha_tunnel_t *this)
{
if (this->backend.cfg)
{
@ -287,10 +274,14 @@ static void destroy(private_ha_tunnel_t *this)
*/
ha_tunnel_t *ha_tunnel_create(char *local, char *remote, char *secret)
{
private_ha_tunnel_t *this = malloc_thing(private_ha_tunnel_t);
private_ha_tunnel_t *this;
this->public.is_sa = (bool(*)(ha_tunnel_t*, ike_sa_t *ike_sa))is_sa;
this->public.destroy = (void(*)(ha_tunnel_t*))destroy;
INIT(this,
.public = {
.is_sa = _is_sa,
.destroy = _destroy,
},
);
setup_tunnel(this, local, remote, secret);