Use a CALLBACK feature to create charon's sender and receiver
This commit is contained in:
+31
-12
@@ -102,7 +102,6 @@ static void destroy(private_daemon_t *this)
|
|||||||
/* cancel all threads and wait for their termination */
|
/* cancel all threads and wait for their termination */
|
||||||
lib->processor->cancel(lib->processor);
|
lib->processor->cancel(lib->processor);
|
||||||
|
|
||||||
DESTROY_IF(this->public.receiver);
|
|
||||||
#ifdef ME
|
#ifdef ME
|
||||||
DESTROY_IF(this->public.connect_manager);
|
DESTROY_IF(this->public.connect_manager);
|
||||||
DESTROY_IF(this->public.mediation_manager);
|
DESTROY_IF(this->public.mediation_manager);
|
||||||
@@ -118,7 +117,6 @@ static void destroy(private_daemon_t *this)
|
|||||||
DESTROY_IF(this->public.eap);
|
DESTROY_IF(this->public.eap);
|
||||||
DESTROY_IF(this->public.xauth);
|
DESTROY_IF(this->public.xauth);
|
||||||
DESTROY_IF(this->public.backends);
|
DESTROY_IF(this->public.backends);
|
||||||
DESTROY_IF(this->public.sender);
|
|
||||||
DESTROY_IF(this->public.socket);
|
DESTROY_IF(this->public.socket);
|
||||||
DESTROY_IF(this->public.caps);
|
DESTROY_IF(this->public.caps);
|
||||||
|
|
||||||
@@ -142,17 +140,44 @@ METHOD(daemon_t, start, void,
|
|||||||
DEFAULT_THREADS, charon->name));
|
DEFAULT_THREADS, charon->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize/deinitialize sender and receiver
|
||||||
|
*/
|
||||||
|
static bool sender_receiver_cb(void *plugin, plugin_feature_t *feature,
|
||||||
|
bool reg, private_daemon_t *this)
|
||||||
|
{
|
||||||
|
if (reg)
|
||||||
|
{
|
||||||
|
this->public.receiver = receiver_create();
|
||||||
|
if (!this->public.receiver)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
this->public.sender = sender_create();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DESTROY_IF(this->public.receiver);
|
||||||
|
DESTROY_IF(this->public.sender);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
METHOD(daemon_t, initialize, bool,
|
METHOD(daemon_t, initialize, bool,
|
||||||
private_daemon_t *this, char *plugins)
|
private_daemon_t *this, char *plugins)
|
||||||
{
|
{
|
||||||
static plugin_feature_t features[] = {
|
plugin_feature_t features[] = {
|
||||||
PLUGIN_PROVIDE(CUSTOM, "libcharon"),
|
PLUGIN_PROVIDE(CUSTOM, "libcharon"),
|
||||||
PLUGIN_DEPENDS(HASHER, HASH_SHA1),
|
|
||||||
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
|
||||||
PLUGIN_DEPENDS(NONCE_GEN),
|
PLUGIN_DEPENDS(NONCE_GEN),
|
||||||
|
PLUGIN_DEPENDS(CUSTOM, "libcharon-receiver"),
|
||||||
PLUGIN_DEPENDS(CUSTOM, "kernel-ipsec"),
|
PLUGIN_DEPENDS(CUSTOM, "kernel-ipsec"),
|
||||||
PLUGIN_DEPENDS(CUSTOM, "kernel-net"),
|
PLUGIN_DEPENDS(CUSTOM, "kernel-net"),
|
||||||
PLUGIN_DEPENDS(CUSTOM, "socket"),
|
PLUGIN_CALLBACK((plugin_feature_callback_t)sender_receiver_cb, this),
|
||||||
|
PLUGIN_PROVIDE(CUSTOM, "libcharon-receiver"),
|
||||||
|
PLUGIN_DEPENDS(HASHER, HASH_SHA1),
|
||||||
|
PLUGIN_DEPENDS(RNG, RNG_STRONG),
|
||||||
|
PLUGIN_DEPENDS(CUSTOM, "socket"),
|
||||||
};
|
};
|
||||||
lib->plugins->add_static_features(lib->plugins, charon->name, features,
|
lib->plugins->add_static_features(lib->plugins, charon->name, features,
|
||||||
countof(features), TRUE);
|
countof(features), TRUE);
|
||||||
@@ -170,12 +195,6 @@ METHOD(daemon_t, initialize, bool,
|
|||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
this->public.sender = sender_create();
|
|
||||||
this->public.receiver = receiver_create();
|
|
||||||
if (this->public.receiver == NULL)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Queue start_action job */
|
/* Queue start_action job */
|
||||||
lib->processor->queue_job(lib->processor, (job_t*)start_action_job_create());
|
lib->processor->queue_job(lib->processor, (job_t*)start_action_job_create());
|
||||||
|
|||||||
Reference in New Issue
Block a user