- make sure to free all memory in possible luibgcrypt leak
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh-enc.c
index 1767f5a1aff7acfdabd33f9cb410ca850bb3c2b6..3d1238a3653dfaa3c8c24eef1459ff0cd41ba491 100644 (file)
@@ -46,7 +46,6 @@
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "mesh_enc.h"
-#include "block_mesh.h"
 #include "gnunet_statistics_service.h"
 
 #include "gnunet-service-mesh_local.h"
 /***********************      GLOBAL VARIABLES     ****************************/
 /******************************************************************************/
 
-/************************** Configuration parameters **************************/
-
-
-
-/*************************** Static global variables **************************/
+/****************************** Global variables ******************************/
 
 /**
  * Handle to the statistics service.
  */
-static struct GNUNET_STATISTICS_Handle *stats;
+struct GNUNET_STATISTICS_Handle *stats;
 
 /**
  * Local peer own ID (memory efficient handle).
  */
-static GNUNET_PEER_Id myid;
+GNUNET_PEER_Id myid;
 
 /**
  * Local peer own ID (full value).
  */
-static struct GNUNET_PeerIdentity my_full_id;
+struct GNUNET_PeerIdentity my_full_id;
+
+/*************************** Static global variables **************************/
 
 /**
  * Own private key.
  */
-static struct GNUNET_CRYPTO_EccPrivateKey *my_private_key;
+static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key;
 
 
 /******************************************************************************/
@@ -158,8 +155,6 @@ static void
 run (void *cls, struct GNUNET_SERVER_Handle *server,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
-  struct GNUNET_CRYPTO_EccPrivateKey *pk;
-
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting to run\n");
 
   stats = GNUNET_STATISTICS_create ("mesh", c);
@@ -168,11 +163,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
                                 NULL);
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "reading key\n");
-  pk = GNUNET_CRYPTO_ecc_key_create_from_configuration (c);
-  GNUNET_assert (NULL != pk);
-  my_private_key = pk;
-  GNUNET_CRYPTO_ecc_key_get_public_for_signature (my_private_key,
-                                                  &my_full_id.public_key);
+  my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (c);
+  GNUNET_assert (NULL != my_private_key);
+  GNUNET_CRYPTO_eddsa_key_get_public (my_private_key, &my_full_id.public_key);
   myid = GNUNET_PEER_intern (&my_full_id);
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Mesh for peer [%s] starting\n",
@@ -181,8 +174,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
   GML_init (server);    /* Local clients */
   GMC_init (c);         /* Connections */
   GMP_init (c);         /* Peers */
-  GMD_init (c, &my_full_id);         /* DHT */
-  GMT_init (c, &my_full_id, my_private_key);
+  GMD_init (c);         /* DHT */
+  GMT_init (c, my_private_key); /* Tunnels */
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Mesh service running\n");
 }
@@ -201,11 +194,12 @@ main (int argc, char *const *argv)
   int ret;
   int r;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "main()\n");
+  fprintf (stderr, "main()\n");
   r = GNUNET_SERVICE_run (argc, argv, "mesh", GNUNET_SERVICE_OPTION_NONE, &run,
                           NULL);
+  GNUNET_free (my_private_key);
   ret = (GNUNET_OK == r) ? 0 : 1;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "main() END\n");
+  fprintf (stderr, "main() END\n");
 
   return ret;
 }