*
* @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;
-
- 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;
-}
+path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
/**
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,
if (NULL == pi)
{
/* TODO maybe feedback, log to statistics */
+ GNUNET_break_op (0);
return GNUNET_OK;
}
if (pi->id == myid)
#endif
+/**
+ * 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.
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;
}
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;
}
int ret;
#if MESH_DEBUG
- fprintf (stderr, "main ()\n");
+// fprintf (stderr, "main ()\n");
#endif
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: main()\n");
ret =
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;
}