*/
struct GNUNET_PEERINFO_Handle *GST_peerinfo;
-
/**
* Hostkey generation context
*/
struct GNUNET_CRYPTO_RsaKeyGenerationContext *GST_keygen;
/**
- * Closure for hostkey generation
+ * Handle to our service's server.
*/
-
-struct KeyGenerationContext *GST_keygen_cls;
-
+static struct GNUNET_SERVER_Handle *GST_server;
/**
* Our public key.
static int connections;
-struct KeyGenerationContext
-{
- struct GNUNET_SERVER_Handle *server;
- const struct GNUNET_CONFIGURATION_Handle *c;
-};
-
-
/**
* Transmit our HELLO message to the given (connected) neighbour.
*
* @param addr one of the addresses of the host
* the specific address format depends on the transport
* @param addrlen length of the address
+ * @param dest_plugin destination plugin to use this address with
*/
static void
plugin_env_address_change_notification (void *cls, int add_remove,
- const void *addr, size_t addrlen)
+ const void *addr, size_t addrlen,
+ const char *dest_plugin)
{
- const char *plugin_name = cls;
struct GNUNET_HELLO_Address address;
address.peer = GST_my_identity;
- address.transport_name = plugin_name;
+ address.transport_name = dest_plugin;
address.address = addr;
address.address_length = addrlen;
GST_hello_modify_addresses (add_remove, &address);
GNUNET_CRYPTO_rsa_key_create_stop (GST_keygen);
GST_keygen = NULL;
}
-
- if (NULL != GST_keygen_cls)
- {
- GNUNET_free (GST_keygen_cls);
- GST_keygen_cls = NULL;
- }
-
GST_neighbours_stop ();
GST_validation_stop ();
GST_plugins_unload ();
GST_blacklist_stop ();
GST_hello_stop ();
- if (GST_peerinfo != NULL)
+ if (NULL != GST_peerinfo)
{
GNUNET_PEERINFO_disconnect (GST_peerinfo);
GST_peerinfo = NULL;
}
- if (GST_stats != NULL)
+ if (NULL != GST_stats)
{
GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO);
GST_stats = NULL;
}
- if (GST_my_private_key != NULL)
+ if (NULL != GST_my_private_key)
{
GNUNET_CRYPTO_rsa_key_free (GST_my_private_key);
GST_my_private_key = NULL;
}
+ GST_server = NULL;
}
+
/**
* Callback for hostkey read/generation
+ *
* @param cls NULL
- * @param pk the privatekey
+ * @param pk the private key
* @param emsg error message
*/
static void
const char *emsg)
{
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded tmp;
- GNUNET_assert (NULL != GST_keygen_cls);
+
GST_keygen = NULL;
if (NULL == pk)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Transport service could not access hostkey: %s. Exiting.\n"),
emsg);
- GNUNET_free (GST_keygen_cls);
- GST_keygen_cls = NULL;
GNUNET_SCHEDULER_shutdown ();
return;
}
GST_my_private_key = pk;
- GST_stats = GNUNET_STATISTICS_create ("transport", GST_keygen_cls->c);
- GST_peerinfo = GNUNET_PEERINFO_connect (GST_keygen_cls->c);
+ GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg);
+ GST_peerinfo = GNUNET_PEERINFO_connect (GST_cfg);
memset (&GST_my_public_key, '\0', sizeof (GST_my_public_key));
memset (&tmp, '\0', sizeof (tmp));
GNUNET_CRYPTO_rsa_key_get_public (GST_my_private_key, &GST_my_public_key);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
NULL);
- if (GST_peerinfo == NULL)
+ if (NULL == GST_peerinfo)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Could not access PEERINFO service. Exiting.\n"));
/* start subsystems */
GST_hello_start (&process_hello_update, NULL);
GNUNET_assert (NULL != GST_hello_get());
- GST_blacklist_start (GST_keygen_cls->server);
+ GST_blacklist_start (GST_server);
GST_ats =
GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL);
GST_plugins_load (&plugin_env_receive_callback,
&neighbours_connect_notification,
&neighbours_disconnect_notification,
&neighbours_address_notification);
- GST_clients_start (GST_keygen_cls->server);
+ GST_clients_start (GST_server);
GST_validation_start ();
- GNUNET_free (GST_keygen_cls);
- GST_keygen_cls = NULL;
+ if (NULL != GST_server)
+ GNUNET_SERVER_resume (GST_server);
}
GNUNET_SCHEDULER_shutdown ();
return;
}
- GST_keygen_cls = GNUNET_malloc (sizeof (struct KeyGenerationContext));
- GST_keygen_cls->c = c;
- GST_keygen_cls->server = server;
-
- GST_keygen = GNUNET_CRYPTO_rsa_key_create_start (keyfile, key_generation_cb, GST_keygen_cls);
+ GST_server = server;
+ GNUNET_SERVER_suspend (server);
+ GST_keygen = GNUNET_CRYPTO_rsa_key_create_start (keyfile, &key_generation_cb, NULL);
GNUNET_free (keyfile);
if (NULL == GST_keygen)
{