+/**
+ * Get the current ack value for a tunnel, taking in account the tunnel
+ * mode and the status of all children nodes.
+ *
+ * @param t Tunnel.
+ *
+ * @return Maximum PID allowed.
+ */
+static uint32_t
+tunnel_get_ack (struct MeshTunnel *t)
+{
+ uint32_t count;
+ uint32_t buffer_free;
+ uint32_t child_ack;
+ uint32_t ack;
+
+ count = t->pid - t->skip;
+ buffer_free = t->queue_max - t->queue_n;
+ ack = count + buffer_free;
+ child_ack = tunnel_get_children_ack (t);
+
+ if (GNUNET_YES == t->speed_min)
+ {
+ ack = child_ack > ack ? ack : child_ack;
+ }
+ else
+ {
+ ack = child_ack > ack ? child_ack : ack;
+ }
+ return ack;
+}
+
+