+/**
+ * Iterator to get the appropiate ACK value from all children nodes
+ */
+static void
+tunnel_get_child_ack (void *cls,
+ GNUNET_PEER_Id id)
+{
+ struct GNUNET_PeerIdentity peer_id;
+ struct MeshTunnelChildInfo *cinfo;
+ struct MeshTunnel *t = cls;
+ uint32_t ack;
+
+ GNUNET_PEER_resolve (id, &peer_id);
+ cinfo = GNUNET_CONTAINER_multihashmap_get (t->children_fc,
+ &peer_id.hashPubKey);
+ if (NULL == cinfo)
+ {
+ cinfo = GNUNET_malloc (sizeof (struct MeshTunnelChildInfo));
+ cinfo->id = id;
+ cinfo->pid = t->pid;
+ cinfo->skip = t->pid;
+ cinfo->max_pid = ack = t->pid + 1;
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONTAINER_multihashmap_put(t->children_fc,
+ &peer_id.hashPubKey,
+ cinfo,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
+ }
+ else
+ {
+ ack = cinfo->max_pid;
+ }
+
+ if (0 == t->max_child_ack)
+ t->max_child_ack = ack;
+
+ if (GNUNET_YES == t->speed_min)
+ {
+ t->max_child_ack = t->max_child_ack > ack ? ack : t->max_child_ack;
+ }
+ else
+ {
+ t->max_child_ack = t->max_child_ack > ack ? t->max_child_ack : ack;
+ }
+
+}
+
+
+/**
+ * Get the maximum PID allowed to transmit to any
+ * tunnel child of the local peer.
+ *
+ * @param t Tunnel.
+ *
+ * @return Maximum PID allowed.
+ */
+static uint32_t
+tunnel_get_children_ack (struct MeshTunnel *t)
+{
+ t->max_child_ack = 0;
+ tree_iterate_children (t->tree, tunnel_get_child_ack, t);
+ return t->max_child_ack;
+}
+
+