#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;
/******************************************************************************/
/******************************************************************************/
-/**
- * Get the static string for a peer ID.
- *
- * @param peer Peer.
- *
- * @return Static string for it's ID.
- */
-static const char *
-peer2s (const struct MeshPeer *peer)
-{
- if (NULL == peer)
- return "(NULL)";
- return GNUNET_i2s (GNUNET_PEER_resolve2 (peer->id));
-}
-
-
-
-/**
- * Send an ACK on the appropriate connection/channel, depending on
- * the direction and the position of the peer.
- *
- * @param c Which connection to send the hop-by-hop ACK.
- * @param ch Channel, if any.
- * @param fwd Is this a fwd ACK? (will go dest->root)
- */
-static void
-send_ack (struct MeshConnection *c, struct MeshChannel *ch, int fwd)
-{
- unsigned int buffer;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "send ack %s on %p %p\n",
- fwd ? "FWD" : "BCK", c, ch);
- if (NULL == c || GMC_is_terminal (c, fwd))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " getting from all connections\n");
- buffer = tunnel_get_buffer (NULL == c ? ch->t : c->t, fwd);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " getting from one connection\n");
- buffer = connection_get_buffer (c, fwd);
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " buffer available: %u\n", buffer);
-
- if ( (NULL != ch && channel_is_origin (ch, fwd)) ||
- (NULL != c && connection_is_origin (c, fwd)) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " sending on channel...\n");
- if (0 < buffer)
- {
- GNUNET_assert (NULL != ch);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " really sending!\n");
- send_local_ack (ch, fwd);
- }
- }
- else if (NULL == c)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " sending on all connections\n");
- GNUNET_assert (NULL != ch);
- channel_send_connections_ack (ch, buffer, fwd);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " sending on connection\n");
- connection_send_ack (c, buffer, fwd);
- }
-}
-
-
-
-
-
-
-
-
-
/******************************************************************************/
/**************** MESH NETWORK HANDLER HELPERS ***********************/
-
-
-
/******************************************************************************/
/******************** MESH NETWORK HANDLERS **************************/
/******************************************************************************/
-
-
/******************************************************************************/
/************************ MAIN FUNCTIONS ****************************/
/******************************************************************************/
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);
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",
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");
}
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;
}