aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-13 13:44:18 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-13 13:44:18 +0000
commit2e9731ebda48bf2549aed64ca9cdfea5b298f9d7 (patch)
tree299c800975b74b4036dcda3168c352799e7c89e2 /src/mesh/gnunet-service-mesh.c
parent8c61ac28c875a62ed8f3a51bfbd7359fdd581d0b (diff)
downloadgnunet-2e9731ebda48bf2549aed64ca9cdfea5b298f9d7.tar.gz
gnunet-2e9731ebda48bf2549aed64ca9cdfea5b298f9d7.zip
Extended testcase, fixed bugs in client -> service data traffic handling
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r--src/mesh/gnunet-service-mesh.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index cff27272c..a19aa268d 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -1427,10 +1427,14 @@ tunnel_add_path (struct MeshTunnel *t,
1427 struct MeshPeerPath *p, 1427 struct MeshPeerPath *p,
1428 unsigned int own_pos) 1428 unsigned int own_pos)
1429{ 1429{
1430 struct GNUNET_PeerIdentity id;
1431
1430 GNUNET_assert (0 != own_pos); 1432 GNUNET_assert (0 != own_pos);
1431 tree_add_path(t->tree, p, NULL); 1433 tree_add_path(t->tree, p, NULL);
1432 if (NULL == t->tree->me) 1434 if (NULL == t->tree->me)
1433 t->tree->me = tree_find_peer(t->tree->root, p->peers[own_pos]); 1435 t->tree->me = tree_find_peer(t->tree->root, p->peers[own_pos]);
1436 GNUNET_PEER_resolve (p->peers[own_pos + 1], &id);
1437 tree_update_first_hops(t->tree, t->tree->me, &id);
1434} 1438}
1435 1439
1436 1440
@@ -2028,9 +2032,12 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
2028{ 2032{
2029 struct GNUNET_MESH_Unicast *msg; 2033 struct GNUNET_MESH_Unicast *msg;
2030 struct MeshTunnel *t; 2034 struct MeshTunnel *t;
2031 struct MeshPeerInfo *pi; 2035 GNUNET_PEER_Id pid;
2032 size_t size; 2036 size_t size;
2033 2037
2038 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2039 "MESH: got a unicast packet from %s\n",
2040 GNUNET_i2s (peer));
2034 size = ntohs (message->size); 2041 size = ntohs (message->size);
2035 if (size < 2042 if (size <
2036 sizeof (struct GNUNET_MESH_Unicast) + 2043 sizeof (struct GNUNET_MESH_Unicast) +
@@ -2047,24 +2054,21 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
2047 GNUNET_break_op (0); 2054 GNUNET_break_op (0);
2048 return GNUNET_OK; 2055 return GNUNET_OK;
2049 } 2056 }
2050 pi = GNUNET_CONTAINER_multihashmap_get (t->peers, 2057 pid = GNUNET_PEER_search(&msg->destination);
2051 &msg->destination.hashPubKey); 2058 if (pid == myid)
2052 if (NULL == pi)
2053 {
2054 /* TODO maybe feedback, log to statistics */
2055 GNUNET_break_op (0);
2056 return GNUNET_OK;
2057 }
2058 if (pi->id == myid)
2059 { 2059 {
2060 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2061 "MESH: it's for us! sending to clients...\n");
2060 send_subscribed_clients ((struct GNUNET_MessageHeader *) &msg[1]); 2062 send_subscribed_clients ((struct GNUNET_MessageHeader *) &msg[1]);
2061 return GNUNET_OK; 2063 return GNUNET_OK;
2062 } 2064 }
2065 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2066 "MESH: not for us, retransmitting...\n");
2063 msg = GNUNET_malloc (size); 2067 msg = GNUNET_malloc (size);
2064 memcpy (msg, message, size); 2068 memcpy (msg, message, size);
2065 GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, 2069 GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0,
2066 GNUNET_TIME_UNIT_FOREVER_REL, 2070 GNUNET_TIME_UNIT_FOREVER_REL,
2067 path_get_first_hop (t->tree, pi->id), 2071 path_get_first_hop (t->tree, pid),
2068 size, 2072 size,
2069 &send_core_data_raw, msg); 2073 &send_core_data_raw, msg);
2070 return GNUNET_OK; 2074 return GNUNET_OK;
@@ -3125,6 +3129,9 @@ handle_local_unicast (void *cls, struct GNUNET_SERVER_Client *client,
3125 MESH_TunnelNumber tid; 3129 MESH_TunnelNumber tid;
3126 size_t size; 3130 size_t size;
3127 3131
3132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3133 "MESH: Got a unicast request from a client!\n");
3134
3128 /* Sanity check for client registration */ 3135 /* Sanity check for client registration */
3129 if (NULL == (c = client_get (client))) 3136 if (NULL == (c = client_get (client)))
3130 { 3137 {
@@ -3183,6 +3190,8 @@ handle_local_unicast (void *cls, struct GNUNET_SERVER_Client *client,
3183 memcpy (buf, data_msg, size); 3190 memcpy (buf, data_msg, size);
3184 copy->oid = my_full_id; 3191 copy->oid = my_full_id;
3185 copy->tid = htonl (t->id.tid); 3192 copy->tid = htonl (t->id.tid);
3193 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3194 "MESH: calling generic handler...\n");
3186 handle_mesh_data_unicast (NULL, &my_full_id, &copy->header, NULL); 3195 handle_mesh_data_unicast (NULL, &my_full_id, &copy->header, NULL);
3187 } 3196 }
3188 GNUNET_SERVER_receive_done (client, GNUNET_OK); 3197 GNUNET_SERVER_receive_done (client, GNUNET_OK);