From: Bart Polot Date: Wed, 25 Jul 2012 01:15:11 +0000 (+0000) Subject: - add children info update on unicast X-Git-Tag: initial-import-from-subversion-38251~12355 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=64f68a96a48f84ab5b793492fa33286e3d43af19;p=oweals%2Fgnunet.git - add children info update on unicast --- diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 5cbdec5ee..f17c91b25 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -3021,7 +3021,35 @@ tunnel_send_multicast (struct MeshTunnel *t, /** - * Iterator to get the appropiate ACK value from all children nodes + * Increase the SKIP value of all peers that + * have not received a unicast message. + * + * @param cls Closure (Short id of the peer that HAS received the message). + * @param id Short ID of the neighbor. + */ +static int +tunnel_add_skip (void *cls, + const struct GNUNET_HashCode * key, + void *value) +{ + struct GNUNET_PeerIdentity *neighbor = cls; + struct MeshTunnelChildInfo *cinfo = value; + + if (0 == memcmp (&neighbor->hashPubKey, key, sizeof (struct GNUNET_HashCode))) + { + return GNUNET_YES; + } + cinfo->skip++; + return GNUNET_YES; +} + + + +/** + * Iterator to get the appropiate ACK value from all children nodes. + * + * @param cls Closue (tunnel). + * @param id Id of the child node. */ static void tunnel_get_child_ack (void *cls, @@ -4185,7 +4213,10 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer, unsigned int atsi_count) { struct GNUNET_MESH_Unicast *msg; + struct GNUNET_PeerIdentity *neighbor; + struct MeshTunnelChildInfo *cinfo; struct MeshTunnel *t; + GNUNET_PEER_Id dest_id; uint32_t pid; uint32_t ttl; size_t size; @@ -4227,8 +4258,8 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer, t->skip += (pid - t->pid) - 1; t->pid = pid; tunnel_reset_timeout (t); - pid = GNUNET_PEER_search (&msg->destination); - if (pid == myid) + dest_id = GNUNET_PEER_search (&msg->destination); + if (dest_id == myid) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " it's for us! sending to clients...\n"); @@ -4249,7 +4280,27 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer, " not for us, retransmitting...\n"); GNUNET_STATISTICS_update (stats, "# unicast forwarded", 1, GNUNET_NO); - send_message (message, tree_get_first_hop (t->tree, pid), t); + neighbor = tree_get_first_hop (t->tree, dest_id); + cinfo = GNUNET_CONTAINER_multihashmap_get (t->children_fc, + &neighbor->hashPubKey); + if (NULL == cinfo) + { + cinfo = GNUNET_malloc (sizeof (struct MeshTunnelChildInfo)); + cinfo->id = GNUNET_PEER_intern (neighbor); + cinfo->skip = pid; + cinfo->max_pid = pid + t->queue_max - t->queue_n; // FIXME review + + GNUNET_assert (GNUNET_OK == + GNUNET_CONTAINER_multihashmap_put (t->children_fc, + &neighbor->hashPubKey, + cinfo, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); + } + cinfo->pid = pid; + GNUNET_CONTAINER_multihashmap_iterate (t->children_fc, + &tunnel_add_skip, + &neighbor); + send_message (message, neighbor, t); return GNUNET_OK; } @@ -6221,6 +6272,7 @@ handle_local_multicast (void *cls, struct GNUNET_SERVER_Client *client, return; } + /** * Functions to handle messages from clients */ @@ -6296,6 +6348,7 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server, return; } + /** * Method called whenever a given peer connects. * @@ -6334,6 +6387,7 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, return; } + /** * Method called whenever a peer disconnects. *