[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r15730 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r15730 - gnunet/src/mesh |
Date: |
Tue, 21 Jun 2011 14:46:43 +0200 |
Author: bartpolot
Date: 2011-06-21 14:46:43 +0200 (Tue, 21 Jun 2011)
New Revision: 15730
Modified:
gnunet/src/mesh/gnunet-service-mesh.c
Log:
WiP
Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c 2011-06-21 11:43:46 UTC (rev
15729)
+++ gnunet/src/mesh/gnunet-service-mesh.c 2011-06-21 12:46:43 UTC (rev
15730)
@@ -350,7 +350,7 @@
* @return Existing or newly created peer info
*/
static struct MeshPeerInfo *
-retireve_peer_info (const struct GNUNET_PeerIdentity *peer)
+get_peer_info (const struct GNUNET_PeerIdentity *peer)
{
struct MeshPeerInfo * peer_info;
@@ -377,7 +377,7 @@
* or 0 in case of error
*/
static GNUNET_PEER_Id
-retrieve_first_hop (struct MeshPath *path)
+get_first_hop (struct MeshPath *path)
{
unsigned int i;
@@ -399,6 +399,7 @@
static void
add_path_to_peer(struct MeshPeerInfo *peer_info, struct MeshPath *path)
{
+
return;
}
@@ -497,14 +498,20 @@
* @param pi the peer_info to destroy
* @return GNUNET_OK on success
*/
-// static int
-// destroy_peer_info(struct MeshTunnel *t, struct MeshPeerInfo *pi)
-// {
-// GNUNET_PEER_change_rc(pi->id, -1);
-// /* FIXME delete from list */
-// GNUNET_free(pi);
-// return GNUNET_OK;
-// }
+static int
+destroy_peer_info(struct MeshPeerInfo *pi)
+{
+ GNUNET_HashCode hash;
+ struct GNUNET_PeerIdentity id;
+
+ GNUNET_PEER_resolve(pi->id, &id);
+ GNUNET_PEER_change_rc(pi->id, -1);
+ GNUNET_CRYPTO_hash(&id, sizeof(struct GNUNET_PeerIdentity), &hash);
+
+ GNUNET_CONTAINER_multihashmap_remove(peers, &hash, pi);
+ GNUNET_free(pi);
+ return GNUNET_OK;
+}
#endif
@@ -523,11 +530,6 @@
if (NULL == t) return GNUNET_OK;
- // FIXME
-// for (path = t->paths_head; path != NULL; path = t->paths_head) {
-// if(GNUNET_OK != destroy_path(t, path)) r = GNUNET_SYSERR;
-// }
-
GNUNET_CRYPTO_hash(&t->id, sizeof(struct MESH_TunnelID), &hash);
if(GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove(tunnels, &hash, t)) {
r = GNUNET_SYSERR;
@@ -571,7 +573,7 @@
if (0 == size && NULL == buf) {
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Retransmitting create path\n");
- GNUNET_PEER_resolve(retrieve_first_hop(peer_info->path), &id);
+ GNUNET_PEER_resolve(get_first_hop(peer_info->path), &id);
GNUNET_CORE_notify_transmit_ready(core_handle,
0,
0,
@@ -770,7 +772,37 @@
}
#endif
+
/**
+ * Send keepalive packets for a peer
+ *
+ * @param cls unused
+ * @param tc unused
+ */
+static void
+path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct MeshPeerInfo *peer_info = cls;
+ struct GNUNET_PeerIdentity id;
+
+ if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) return;
+ GNUNET_PEER_resolve(get_first_hop(peer_info->path), &id);
+ GNUNET_CORE_notify_transmit_ready(core_handle,
+ 0,
+ 0,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &id,
+ sizeof(struct GNUNET_MESH_ManipulatePath)
+ + (peer_info->path->length
+ * sizeof (struct GNUNET_PeerIdentity)),
+ &send_core_create_path_for_peer,
+ peer_info);
+
+ return;
+}
+
+
+/**
* Function to process paths received for a new peer addition. The recorded
* paths form the initial tunnel, which can be optimized later.
* Called on each result obtained for the DHT search.
@@ -845,6 +877,7 @@
* sizeof (struct GNUNET_PeerIdentity)),
&send_core_create_path_for_peer,
peer_info);
+ GNUNET_SCHEDULER_add_delayed(REFRESH_PATH_TIME, &path_refresh, peer_info);
return;
}
@@ -1140,7 +1173,7 @@
}
t->peers_total++;
- peer_info = retireve_peer_info(&peer_msg->peer);
+ peer_info = get_peer_info(&peer_msg->peer);
/* Start DHT search if needed */
if(MESH_PEER_READY != peer_info->state && NULL == peer_info->dhtget) {
@@ -1463,7 +1496,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer connected\n");
- peer_info = retireve_peer_info(peer);
+ peer_info = get_peer_info(peer);
if (myid == peer_info->id) {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" (self)\n");
@@ -1502,63 +1535,6 @@
/******************************************************************************/
-/********************** PERIODIC FUNCTIONS
**************************/
-/******************************************************************************/
-
-/**
- * Iterator over peers to send keepalive packets when needed.
- *
- * @param cls unused
- * @param key current key code
- * @param value value in the hash map
- * @return GNUNET_YES if we should continue to iterate, GNUNET_NO if not.
- */
-int
-path_refresh_peer (void *cls, const GNUNET_HashCode * key, void *value)
-{
- struct MeshPeerInfo *pi = cls;
- struct GNUNET_TIME_Absolute threshold;
- struct GNUNET_PeerIdentity id;
-
- threshold = GNUNET_TIME_absolute_subtract(GNUNET_TIME_absolute_get(),
- REFRESH_PATH_TIME);
-
- if (pi->last_contact.abs_value < threshold.abs_value) {
- GNUNET_PEER_resolve(pi->path->peers[1], &id);
- GNUNET_CORE_notify_transmit_ready(core_handle,
- 0,
- 0,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &id,
- sizeof(struct GNUNET_MESH_ManipulatePath)
- + (pi->path->length
- * sizeof (struct GNUNET_PeerIdentity)),
- &send_core_create_path_for_peer,
- pi);
- }
- return GNUNET_YES;
-}
-
-
-/**
- * Send keepalive packets for all routes
- *
- * @param cls unused
- * @param tc unused
- */
-static void
-path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) return;
- GNUNET_CONTAINER_multihashmap_iterate(peers, path_refresh_peer, NULL);
- GNUNET_SCHEDULER_add_delayed(REFRESH_PATH_TIME,
- &path_refresh,
- NULL);
- return;
-}
-
-
-/******************************************************************************/
/************************ MAIN FUNCTIONS
****************************/
/******************************************************************************/
@@ -1627,11 +1603,6 @@
clients = NULL;
clients_tail = NULL;
- /* Path keepalive */
- GNUNET_SCHEDULER_add_delayed(REFRESH_PATH_TIME,
- &path_refresh,
- NULL);
-
/* Scheduled the task to clean up when shutdown is called */
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
&shutdown_task, NULL);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r15730 - gnunet/src/mesh,
gnunet <=