From: Bart Polot Date: Thu, 10 Oct 2013 14:44:22 +0000 (+0000) Subject: - share ID X-Git-Tag: initial-import-from-subversion-38251~6619 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5235a1f6c285d14b96fa2b3f16b617445b092d7b;p=oweals%2Fgnunet.git - share ID --- diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c index 0a3aeaf35..8a2b60da7 100644 --- a/src/mesh/gnunet-service-mesh-enc.c +++ b/src/mesh/gnunet-service-mesh-enc.c @@ -79,17 +79,17 @@ */ struct GNUNET_STATISTICS_Handle *stats; -/*************************** Static global variables **************************/ - /** * 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. diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 9a58bf843..8f598b2b5 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c @@ -211,6 +211,11 @@ struct MeshConnection */ extern struct GNUNET_STATISTICS_Handle *stats; +/** + * Local peer own ID (memory efficient handle). + */ +extern GNUNET_PEER_Id myid; + /** * Connections known, indexed by cid (MeshConnection). */ @@ -1046,7 +1051,7 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer, if (path->peers[i] == my_short_id) own_pos = i; } - if (own_pos == 0 && path->peers[own_pos] != myid) + if (own_pos == 0 && path->peers[own_pos] != my_short_id) { /* create path: self not found in path through self */ GNUNET_break_op (0); @@ -1055,7 +1060,7 @@ GMC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer, return GNUNET_OK; } LOG (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos); - path_add_to_peers (path, GNUNET_NO); + GMP_add_path_to_all (path, GNUNET_NO); LOG (GNUNET_ERROR_TYPE_DEBUG, " Creating connection\n"); c = GMC_new (cid, NULL, path_duplicate (path), own_pos); if (NULL == c) diff --git a/src/mesh/gnunet-service-mesh_dht.c b/src/mesh/gnunet-service-mesh_dht.c index 00dfb9d46..4587041a4 100644 --- a/src/mesh/gnunet-service-mesh_dht.c +++ b/src/mesh/gnunet-service-mesh_dht.c @@ -61,6 +61,16 @@ struct GMD_search_handle */ extern struct GNUNET_STATISTICS_Handle *stats; +/** + * Own ID (short value). + */ +extern GNUNET_PEER_Id myid; + +/** + * Own ID (full value). + */ +extern struct GNUNET_PeerIdentity my_full_id; + /** * Handle to use DHT. */ @@ -81,16 +91,6 @@ static unsigned long long dht_replication_level; */ static GNUNET_SCHEDULER_TaskIdentifier announce_id_task; -/** - * Own ID (short value). - */ -static GNUNET_PEER_Id short_id; - -/** - * Own ID (full value). - */ -static struct GNUNET_PeerIdentity *full_id; - /** * Own private key. */ @@ -248,8 +248,8 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * - Set data expiration in function of X * - Adapt X to churn */ - block.id = *full_id; - GNUNET_CRYPTO_hash (full_id, sizeof (struct GNUNET_PeerIdentity), &phash); + block.id = my_full_id; + GNUNET_CRYPTO_hash (&my_full_id, sizeof (struct GNUNET_PeerIdentity), &phash); GNUNET_DHT_put (dht_handle, /* DHT handle */ &phash, /* Key to use */ dht_replication_level, /* Replication level */ @@ -277,15 +277,14 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param peer_id Local peer ID (must remain valid during all execution time). */ void -GMD_init (const struct GNUNET_CONFIGURATION_Handle *c, - struct GNUNET_PeerIdentity *peer_id) +GMD_init (const struct GNUNET_CONFIGURATION_Handle *c) { - full_id = peer_id; + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (c, "MESH", "DHT_REPLICATION_LEVEL", &dht_replication_level)) { - LOG_config_invalid (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, "MESH", "DHT_REPLICATION_LEVEL", "USING DEFAULT"); dht_replication_level = 3; } @@ -294,7 +293,7 @@ GMD_init (const struct GNUNET_CONFIGURATION_Handle *c, GNUNET_CONFIGURATION_get_value_time (c, "MESH", "ID_ANNOUNCE_TIME", &id_announce_time)) { - LOG_config_invalid (GNUNET_ERROR_TYPE_ERROR, + GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "MESH", "ID_ANNOUNCE_TIME", "MISSING"); GNUNET_SCHEDULER_shutdown (); return; diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index a4e17cefc..48d5eda7c 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c @@ -177,6 +177,16 @@ struct MeshPeer */ extern struct GNUNET_STATISTICS_Handle *stats; +/** + * Local peer own ID (full value). + */ +extern struct GNUNET_PeerIdentity my_full_id; + +/** + * Local peer own ID (short) + */ +extern GNUNET_PEER_Id myid; + /** * Peers known, indexed by PeerIdentity (MeshPeer). */ @@ -197,15 +207,6 @@ static unsigned long long drop_percent; */ static struct GNUNET_CORE_Handle *core_handle; -/** - * Local peer own ID (full value). - */ -const static struct GNUNET_PeerIdentity *my_full_id; - -/** - * Local peer own ID (short) - */ -static GNUNET_PEER_Id my_short_id; /******************************************************************************/ /***************************** CORE CALLBACKS *********************************/ @@ -231,7 +232,7 @@ notify_broken (void *cls, struct MeshPeer *peer = cls; struct MeshConnection *c = value; - GMC_notify_broken (c, peer, my_full_id); + GMC_notify_broken (c, peer, &my_full_id); return GNUNET_YES; } @@ -1319,18 +1320,14 @@ GMP_queue_cancel (struct MeshPeer *peer, struct MeshConnection *c) * @param id Peer identity */ void -GMP_init (const struct GNUNET_CONFIGURATION_Handle *c, - const struct GNUNET_PeerIdentity *id) +GMP_init (const struct GNUNET_CONFIGURATION_Handle *c) { - my_full_id = id; - my_short_id = GNUNET_PEER_intern (id); - peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_PEERS", &max_peers)) { - LOG_config_invalid (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, "MESH", "MAX_PEERS", "USING DEFAULT"); max_peers = 1000; } @@ -1382,7 +1379,7 @@ GMP_shutdown (void) GNUNET_CORE_disconnect (core_handle); core_handle = NULL; } - GNUNET_PEER_change_rc (my_short_id, -1); + GNUNET_PEER_change_rc (myid, -1); } @@ -1652,7 +1649,7 @@ GMP_add_path_to_all (struct MeshPeerPath *p, int confirmed) unsigned int i; /* TODO: invert and add */ - for (i = 0; i < p->length && p->peers[i] != my_short_id; i++) /* skip'em */ ; + for (i = 0; i < p->length && p->peers[i] != myid; i++) /* skip'em */ ; for (i++; i < p->length; i++) { struct MeshPeer *aux;