diff options
author | Tobias Brunner <tobias@strongswan.org> | 2012-07-12 16:56:35 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2012-08-08 15:41:02 +0200 |
commit | 053276e69a182c33dcbac2d7b510d2734cd0bfd3 (patch) | |
tree | 6fdfad013506850e78e359a4f19d480df15c97ce | |
parent | 2dde79aca62315fcbbb64e7ec10d3d8dfaf91a59 (diff) | |
download | strongswan-053276e69a182c33dcbac2d7b510d2734cd0bfd3.tar.bz2 strongswan-053276e69a182c33dcbac2d7b510d2734cd0bfd3.tar.xz |
Use a CALLBACK feature to create charon's sender and receiver
-rw-r--r-- | src/libcharon/daemon.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/libcharon/daemon.c b/src/libcharon/daemon.c index 612796a78..6e977efc4 100644 --- a/src/libcharon/daemon.c +++ b/src/libcharon/daemon.c @@ -102,7 +102,6 @@ static void destroy(private_daemon_t *this) /* cancel all threads and wait for their termination */ lib->processor->cancel(lib->processor); - DESTROY_IF(this->public.receiver); #ifdef ME DESTROY_IF(this->public.connect_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.xauth); DESTROY_IF(this->public.backends); - DESTROY_IF(this->public.sender); DESTROY_IF(this->public.socket); DESTROY_IF(this->public.caps); @@ -142,17 +140,44 @@ METHOD(daemon_t, start, void, 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, private_daemon_t *this, char *plugins) { - static plugin_feature_t features[] = { + plugin_feature_t features[] = { PLUGIN_PROVIDE(CUSTOM, "libcharon"), - PLUGIN_DEPENDS(HASHER, HASH_SHA1), - PLUGIN_DEPENDS(RNG, RNG_STRONG), PLUGIN_DEPENDS(NONCE_GEN), + PLUGIN_DEPENDS(CUSTOM, "libcharon-receiver"), PLUGIN_DEPENDS(CUSTOM, "kernel-ipsec"), 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, countof(features), TRUE); @@ -170,12 +195,6 @@ METHOD(daemon_t, initialize, bool, { return FALSE; } - this->public.sender = sender_create(); - this->public.receiver = receiver_create(); - if (this->public.receiver == NULL) - { - return FALSE; - } /* Queue start_action job */ lib->processor->queue_job(lib->processor, (job_t*)start_action_job_create()); |