*/
struct GNUNET_PEERINFO_Handle *GST_peerinfo;
-
-/**
- * Hostkey generation context
- */
-struct GNUNET_CRYPTO_RsaKeyGenerationContext *GST_keygen;
-
-/**
- * Closure for hostkey generation
- */
-
-struct KeyGenerationContext *GST_keygen_cls;
-
-
/**
* 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.
*
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
GST_neighbours_handle_session_ack (message, peer, &address, session, ats,
- ats_count);
+ ats_count);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT:
GST_neighbours_handle_disconnect_message (peer, message);
static void
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- if (NULL != GST_keygen)
- {
- 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 ();
}
}
+
/**
- * Callback for hostkey read/generation
- * @param cls NULL
- * @param pk the privatekey
- * @param emsg error message
+ * Initiate transport service.
+ *
+ * @param cls closure
+ * @param server the initialized server
+ * @param c configuration to use
*/
static void
-key_generation_cb (void *cls,
- struct GNUNET_CRYPTO_RsaPrivateKey *pk,
- const char *emsg)
+run (void *cls, struct GNUNET_SERVER_Handle *server,
+ const struct GNUNET_CONFIGURATION_Handle *c)
{
+ char *keyfile;
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded tmp;
- GNUNET_assert (NULL != GST_keygen_cls);
- GST_keygen = NULL;
- if (NULL == pk)
+ /* setup globals */
+ GST_cfg = c;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY",
+ &keyfile))
{
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;
+ _
+ ("Transport service is lacking key configuration settings. Exiting.\n"));
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_my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ GNUNET_free (keyfile);
+ if (GST_my_private_key == NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Transport service could not access hostkey. Exiting.\n"));
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ GST_stats = GNUNET_STATISTICS_create ("transport", c);
+ GST_peerinfo = GNUNET_PEERINFO_connect (c);
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);
/* 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 (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 (server);
GST_validation_start ();
- GNUNET_free (GST_keygen_cls);
- GST_keygen_cls = NULL;
-}
-
-
-/**
- * Initiate transport service.
- *
- * @param cls closure
- * @param server the initialized server
- * @param c configuration to use
- */
-static void
-run (void *cls, struct GNUNET_SERVER_Handle *server,
- const struct GNUNET_CONFIGURATION_Handle *c)
-{
- char *keyfile;
-
- /* setup globals */
- GST_cfg = c;
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY",
- &keyfile))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _
- ("Transport service is lacking key configuration settings. Exiting.\n"));
- 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);
- GNUNET_free (keyfile);
- if (NULL == GST_keygen)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Transport service is unable to access hostkey. Exiting.\n"));
- GNUNET_SCHEDULER_shutdown ();
- }
}