/*
This file is part of GNUnet.
- (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
* @file core/gnunet-service-core.c
* @brief high-level P2P messaging
* @author Christian Grothoff
- *
- * Not implemented:
- * - peer status changes (PeerStatusNotifyMessage) [needed?]
- * - ATS integration / bw allocation / preferences
*/
#include "platform.h"
+#include <gcrypt.h>
#include "gnunet_util_lib.h"
#include "gnunet-service-core.h"
#include "gnunet-service-core_clients.h"
*/
struct GNUNET_STATISTICS_Handle *GSC_stats;
+/**
+ * Handle to the server of the core service.
+ */
+static struct GNUNET_SERVER_Handle *GSC_server;
+
/**
* Last task run during shutdown. Disconnects us from
* the transport.
+ *
+ * @param cls NULL, unused
+ * @param tc scheduler context, unused
*/
static void
-cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
-#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core service shutting down.\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core service shutting down.\n");
GSC_CLIENTS_done ();
GSC_NEIGHBOURS_done ();
GSC_SESSIONS_done ();
GSC_KX_done ();
GSC_TYPEMAP_done ();
- if (GSC_stats != NULL)
+ if (NULL != GSC_stats)
{
GNUNET_STATISTICS_destroy (GSC_stats, GNUNET_NO);
GSC_stats = NULL;
run (void *cls, struct GNUNET_SERVER_Handle *server,
const struct GNUNET_CONFIGURATION_Handle *c)
{
- GSC_cfg = c;
+ struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
+ char *keyfile;
+
+ GSC_cfg = c;
+ GSC_server = server;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (GSC_cfg, "PEER", "PRIVATE_KEY",
+ &keyfile))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Core service is lacking HOSTKEY configuration setting. Exiting.\n"));
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
GSC_stats = GNUNET_STATISTICS_create ("core", GSC_cfg);
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task,
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+ &shutdown_task,
NULL);
+ GNUNET_SERVER_suspend (server);
GSC_TYPEMAP_init ();
- if ( (GNUNET_OK != GSC_KX_init ()) ||
- (GNUNET_OK != GSC_NEIGHBOURS_init ()) )
+ pk = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile);
+ GNUNET_free (keyfile);
+ GNUNET_assert (NULL != pk);
+ if ((GNUNET_OK != GSC_KX_init (pk,
+ server)) ||
+ (GNUNET_OK != GSC_NEIGHBOURS_init ()))
{
GNUNET_SCHEDULER_shutdown ();
return;
}
GSC_SESSIONS_init ();
- GSC_CLIENTS_init (server);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Core service of `%4s' ready.\n"),
+ GSC_CLIENTS_init (GSC_server);
+ GNUNET_SERVER_resume (GSC_server);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Core service of `%4s' ready.\n"),
GNUNET_i2s (&GSC_my_identity));
}
-
/**
* The main function for the transport service.
*
main (int argc, char *const *argv)
{
return (GNUNET_OK ==
- GNUNET_SERVICE_run (argc, argv, "core", GNUNET_SERVICE_OPTION_NONE,
+ GNUNET_SERVICE_run (argc, argv, "core",
+ GNUNET_SERVICE_OPTION_NONE,
&run, NULL)) ? 0 : 1;
}