[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17089 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17089 - gnunet/src/mesh |
Date: |
Wed, 28 Sep 2011 11:22:26 +0200 |
Author: bartpolot
Date: 2011-09-28 11:22:26 +0200 (Wed, 28 Sep 2011)
New Revision: 17089
Modified:
gnunet/src/mesh/gnunet-service-mesh.c
Log:
Added multicast route keeplive
Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c 2011-09-28 08:57:33 UTC (rev
17088)
+++ gnunet/src/mesh/gnunet-service-mesh.c 2011-09-28 09:22:26 UTC (rev
17089)
@@ -904,29 +904,13 @@
*
* @param cls Closure (tunnel for which to send the keepalive).
* @param tc Notification context.
+ *
+ * TODO: implement explicit multicast keepalive?
*/
void
-path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct MeshTunnel *t = cls;
+path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
- if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
- {
- return;
- }
- /* FIXME path
- * TODO: implement explicit multicast keepalive? */
- GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0,
- GNUNET_TIME_UNIT_FOREVER_REL, NULL,
- sizeof (struct
GNUNET_MESH_ManipulatePath),
- NULL, //&send_core_data_multicast,
- t);
- t->path_refresh_task =
- GNUNET_SCHEDULER_add_delayed (t->tree->refresh, &path_refresh, t);
- return;
-}
-
/**
* Check if client has registered with the service and has not disconnected
*
@@ -1699,6 +1683,7 @@
if (NULL == t)
{
/* TODO notify back: we don't know this tunnel */
+ GNUNET_break_op (0);
return GNUNET_OK;
}
pi = GNUNET_CONTAINER_multihashmap_get (t->peers,
@@ -1706,6 +1691,7 @@
if (NULL == pi)
{
/* TODO maybe feedback, log to statistics */
+ GNUNET_break_op (0);
return GNUNET_OK;
}
if (pi->id == myid)
@@ -2032,6 +2018,51 @@
/**
+ * Send keepalive packets for a peer
+ *
+ * @param cls Closure (tunnel for which to send the keepalive).
+ * @param tc Notification context.
+ *
+ * TODO: implement explicit multicast keepalive?
+ */
+void
+path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct MeshTunnel *t = cls;
+ struct GNUNET_MessageHeader *payload;
+ struct GNUNET_MESH_Multicast *msg;
+ size_t size;
+
+ t->path_refresh_task = GNUNET_SCHEDULER_NO_TASK;
+ if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
+ {
+ return;
+ }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "MESH: sending keepalive for tunnel %d\n",
+ t->id.tid);
+
+ size = sizeof(struct GNUNET_MESH_Multicast) +
+ sizeof(struct GNUNET_MessageHeader);
+ msg = GNUNET_malloc (size);
+ msg->header.size = htons (size);
+ msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_MULTICAST);
+ msg->oid = my_full_id;
+ msg->tid = htonl(t->id.tid);
+ payload = (struct GNUNET_MessageHeader *) &msg[1];
+ payload->size = htons (sizeof(struct GNUNET_MessageHeader));
+ payload->type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE);
+ handle_mesh_data_multicast (NULL, &my_full_id, &msg->header, NULL);
+
+ GNUNET_free (msg);
+ t->path_refresh_task =
+ GNUNET_SCHEDULER_add_delayed (t->tree->refresh, &path_refresh, t);
+ 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.
@@ -2830,8 +2861,8 @@
copy->oid = my_full_id;
copy->tid = htonl (t->id.tid);
handle_mesh_data_unicast (NULL, &my_full_id, ©->header, NULL);
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
@@ -2885,9 +2916,18 @@
return;
}
- /* TODO */
+ {
+ char buf[ntohs(message->size)];
+ struct GNUNET_MESH_Multicast *copy;
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ copy = (struct GNUNET_MESH_Multicast *)buf;
+ memcpy(buf, message, ntohs(message->size));
+ copy->oid = my_full_id;
+ copy->tid = htonl(t->id.tid);
+ handle_mesh_data_multicast(client, &my_full_id, ©->header, NULL);
+ }
+
+ /* receive done gets called when last copy is sent */
return;
}
@@ -3172,7 +3212,7 @@
int ret;
#if MESH_DEBUG
- fprintf (stderr, "main ()\n");
+// fprintf (stderr, "main ()\n");
#endif
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: main()\n");
ret =
@@ -3181,7 +3221,7 @@
NULL)) ? 0 : 1;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: main() END\n");
#if MESH_DEBUG
- fprintf (stderr, "main () END\n");
+// fprintf (stderr, "main () END\n");
#endif
return ret;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17089 - gnunet/src/mesh,
gnunet <=