/**
- * 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,
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;
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");
" 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;
}
return;
}
+
/**
* Functions to handle messages from clients
*/
return;
}
+
/**
* Method called whenever a given peer connects.
*
return;
}
+
/**
* Method called whenever a peer disconnects.
*