aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-09-28 09:22:26 +0000
committerBart Polot <bart@net.in.tum.de>2011-09-28 09:22:26 +0000
commit99dcbedd2d4bdd256c0b9dd7413a88592fc74bb0 (patch)
treea760f61cb1c4015feb82678018a38aca517ad791 /src/mesh
parent676a03149617636a25d5d9185b24e17b8980bbb1 (diff)
downloadgnunet-99dcbedd2d4bdd256c0b9dd7413a88592fc74bb0.tar.gz
gnunet-99dcbedd2d4bdd256c0b9dd7413a88592fc74bb0.zip
Added multicast route keeplive
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c88
1 files changed, 64 insertions, 24 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index e26cf666e..670c2f973 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -904,27 +904,11 @@ path_build_from_dht (const struct GNUNET_PeerIdentity *get_path,
904 * 904 *
905 * @param cls Closure (tunnel for which to send the keepalive). 905 * @param cls Closure (tunnel for which to send the keepalive).
906 * @param tc Notification context. 906 * @param tc Notification context.
907 *
908 * TODO: implement explicit multicast keepalive?
907 */ 909 */
908void 910void
909path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 911path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
910{
911 struct MeshTunnel *t = cls;
912
913 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
914 {
915 return;
916 }
917 /* FIXME path
918 * TODO: implement explicit multicast keepalive? */
919 GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0,
920 GNUNET_TIME_UNIT_FOREVER_REL, NULL,
921 sizeof (struct GNUNET_MESH_ManipulatePath),
922 NULL, //&send_core_data_multicast,
923 t);
924 t->path_refresh_task =
925 GNUNET_SCHEDULER_add_delayed (t->tree->refresh, &path_refresh, t);
926 return;
927}
928 912
929 913
930/** 914/**
@@ -1699,6 +1683,7 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
1699 if (NULL == t) 1683 if (NULL == t)
1700 { 1684 {
1701 /* TODO notify back: we don't know this tunnel */ 1685 /* TODO notify back: we don't know this tunnel */
1686 GNUNET_break_op (0);
1702 return GNUNET_OK; 1687 return GNUNET_OK;
1703 } 1688 }
1704 pi = GNUNET_CONTAINER_multihashmap_get (t->peers, 1689 pi = GNUNET_CONTAINER_multihashmap_get (t->peers,
@@ -1706,6 +1691,7 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
1706 if (NULL == pi) 1691 if (NULL == pi)
1707 { 1692 {
1708 /* TODO maybe feedback, log to statistics */ 1693 /* TODO maybe feedback, log to statistics */
1694 GNUNET_break_op (0);
1709 return GNUNET_OK; 1695 return GNUNET_OK;
1710 } 1696 }
1711 if (pi->id == myid) 1697 if (pi->id == myid)
@@ -2032,6 +2018,51 @@ notify_client_connection_failure (void *cls, size_t size, void *buf)
2032 2018
2033 2019
2034/** 2020/**
2021 * Send keepalive packets for a peer
2022 *
2023 * @param cls Closure (tunnel for which to send the keepalive).
2024 * @param tc Notification context.
2025 *
2026 * TODO: implement explicit multicast keepalive?
2027 */
2028void
2029path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2030{
2031 struct MeshTunnel *t = cls;
2032 struct GNUNET_MessageHeader *payload;
2033 struct GNUNET_MESH_Multicast *msg;
2034 size_t size;
2035
2036 t->path_refresh_task = GNUNET_SCHEDULER_NO_TASK;
2037 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
2038 {
2039 return;
2040 }
2041
2042 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2043 "MESH: sending keepalive for tunnel %d\n",
2044 t->id.tid);
2045
2046 size = sizeof(struct GNUNET_MESH_Multicast) +
2047 sizeof(struct GNUNET_MessageHeader);
2048 msg = GNUNET_malloc (size);
2049 msg->header.size = htons (size);
2050 msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_MULTICAST);
2051 msg->oid = my_full_id;
2052 msg->tid = htonl(t->id.tid);
2053 payload = (struct GNUNET_MessageHeader *) &msg[1];
2054 payload->size = htons (sizeof(struct GNUNET_MessageHeader));
2055 payload->type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE);
2056 handle_mesh_data_multicast (NULL, &my_full_id, &msg->header, NULL);
2057
2058 GNUNET_free (msg);
2059 t->path_refresh_task =
2060 GNUNET_SCHEDULER_add_delayed (t->tree->refresh, &path_refresh, t);
2061 return;
2062}
2063
2064
2065/**
2035 * Function to process paths received for a new peer addition. The recorded 2066 * Function to process paths received for a new peer addition. The recorded
2036 * paths form the initial tunnel, which can be optimized later. 2067 * paths form the initial tunnel, which can be optimized later.
2037 * Called on each result obtained for the DHT search. 2068 * Called on each result obtained for the DHT search.
@@ -2830,8 +2861,8 @@ handle_local_unicast (void *cls, struct GNUNET_SERVER_Client *client,
2830 copy->oid = my_full_id; 2861 copy->oid = my_full_id;
2831 copy->tid = htonl (t->id.tid); 2862 copy->tid = htonl (t->id.tid);
2832 handle_mesh_data_unicast (NULL, &my_full_id, &copy->header, NULL); 2863 handle_mesh_data_unicast (NULL, &my_full_id, &copy->header, NULL);
2833 GNUNET_SERVER_receive_done (client, GNUNET_OK);
2834 } 2864 }
2865 GNUNET_SERVER_receive_done (client, GNUNET_OK);
2835 return; 2866 return;
2836} 2867}
2837 2868
@@ -2885,9 +2916,18 @@ handle_local_multicast (void *cls, struct GNUNET_SERVER_Client *client,
2885 return; 2916 return;
2886 } 2917 }
2887 2918
2888 /* TODO */ 2919 {
2920 char buf[ntohs(message->size)];
2921 struct GNUNET_MESH_Multicast *copy;
2889 2922
2890 GNUNET_SERVER_receive_done (client, GNUNET_OK); 2923 copy = (struct GNUNET_MESH_Multicast *)buf;
2924 memcpy(buf, message, ntohs(message->size));
2925 copy->oid = my_full_id;
2926 copy->tid = htonl(t->id.tid);
2927 handle_mesh_data_multicast(client, &my_full_id, &copy->header, NULL);
2928 }
2929
2930 /* receive done gets called when last copy is sent */
2891 return; 2931 return;
2892} 2932}
2893 2933
@@ -3172,7 +3212,7 @@ main (int argc, char *const *argv)
3172 int ret; 3212 int ret;
3173 3213
3174#if MESH_DEBUG 3214#if MESH_DEBUG
3175 fprintf (stderr, "main ()\n"); 3215// fprintf (stderr, "main ()\n");
3176#endif 3216#endif
3177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: main()\n"); 3217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: main()\n");
3178 ret = 3218 ret =
@@ -3181,7 +3221,7 @@ main (int argc, char *const *argv)
3181 NULL)) ? 0 : 1; 3221 NULL)) ? 0 : 1;
3182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: main() END\n"); 3222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: main() END\n");
3183#if MESH_DEBUG 3223#if MESH_DEBUG
3184 fprintf (stderr, "main () END\n"); 3224// fprintf (stderr, "main () END\n");
3185#endif 3225#endif
3186 return ret; 3226 return ret;
3187} 3227}