EXP_LIB = \
libgnunetmeshenc.la
-#EXP_LIBEXEC = \
-# gnunet-service-mesh-enc
+EXP_LIBEXEC = \
+ gnunet-service-mesh-enc
libexec_PROGRAMS = \
gnunet-service-mesh $(EXP_LIBEXEC)
fwd ? "FWD" : "BCK", GNUNET_h2s (&c->id));
/* Check if we need to transmit the ACK */
- if (prev_fc->last_ack_sent - prev_fc->last_pid_recv > 3)
+ delta = prev_fc->last_ack_sent - prev_fc->last_pid_recv;
+ if (3 < delta && buffer < delta)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "Not sending ACK, buffer > 3\n");
LOG (GNUNET_ERROR_TYPE_DEBUG,
}
/* Ok, ACK might be necessary, what PID to ACK? */
- delta = next_fc->queue_max - next_fc->queue_n;
- ack = prev_fc->last_pid_recv + delta;
+ ack = prev_fc->last_pid_recv + buffer;
LOG (GNUNET_ERROR_TYPE_DEBUG, " ACK %u\n", ack);
LOG (GNUNET_ERROR_TYPE_DEBUG,
" last pid %u, last ack %u, qmax %u, q %u\n",
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on all connections\n");
GNUNET_assert (NULL != ch);
- channel_send_connections_ack (ch, buffer, fwd);
+ GMT_send_acks (GMCH_get_tunnel (ch), buffer, fwd);
}
else
{
void
GMC_shutdown (void)
{
+ GNUNET_CONTAINER_multihashmap_destroy (connections);
}
}
+/**
+ * Allow the connection to advertise a buffer of the given size.
+ *
+ * The connection will send an @c fwd ACK message (so: in direction !fwd)
+ * allowing up to last_pid_recv + buffer.
+ *
+ * @param c Connection.
+ * @param buffer How many more messages the connection can accept.
+ * @param fwd Is this about FWD traffic? (The ack will go dest->root).
+ */
+void
+GMC_allow (struct MeshConnection *c, unsigned int buffer, int fwd)
+{
+ connection_send_ack (c, buffer, fwd);
+}
+
+
/**
* Send a notification that a connection is broken.
*
unsigned int
GMC_get_qn (struct MeshConnection *c, int fwd);
+/**
+ * Allow the connection to advertise a buffer of the given size.
+ *
+ * The connection will send an @c fwd ACK message (so: in direction !fwd)
+ * allowing up to last_pid_recv + buffer.
+ *
+ * @param c Connection.
+ * @param buffer How many more messages the connection can accept.
+ * @param fwd Is this about FWD traffic? (The ack will go dest->root).
+ */
+void
+GMC_allow (struct MeshConnection *c, unsigned int buffer, int fwd);
+
/**
* Send FWD keepalive packets for a connection.
*
* @param ch Channel which has some free buffer space.
* @param fwd Is this in for FWD traffic? (ACK goes dest->root)
*/
-static void
-GMT_send_acks (struct MeshTunnel3 *t,
- unsigned int buffer,
- int fwd)
+void
+GMT_send_acks (struct MeshTunnel3 *t, unsigned int buffer, int fwd)
{
struct MeshTConnection *iter;
uint32_t allowed;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Tunnel send acks on %s:%X\n",
- fwd ? "FWD" : "BCK", peer2s (ch->t->peer), ch->gid);
+ fwd ? "FWD" : "BCK", GMT_2s (t));
+
+ if (NULL == t)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ if (NULL == t->channel_head ||
+ GNUNET_NO == GMCH_is_origin (t->channel_head->ch, fwd))
+ {
+ GNUNET_break (0);
+ return;
+ }
/* Count connections, how many messages are already allowed */
cs = GMT_count_connections (t);
}
/* Authorize connections to send more data */
- to_allow = buffer - allowed;
+ to_allow = buffer; /* - allowed; */
for (iter = t->connection_head; NULL != iter && to_allow > 0; iter = iter->next)
{
{
continue;
}
- GMC_send_ack (iter->c, NULL, fwd);
- connection_send_ack (iter, allow_per_connection, fwd);
+ GMC_allow (iter->c, buffer, fwd);
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Channel send connection %s ack on %s:%X\n",
- fwd ? "FWD" : "BCK", peer2s (ch->t->peer), ch->gid);
GNUNET_break (to_allow == 0);
}
MESH_ChannelNumber
GMT_get_next_chid (struct MeshTunnel3 *t);
+/**
+ * Send ACK on one or more connections due to buffer space to the client.
+ *
+ * Iterates all connections of the tunnel and sends ACKs appropriately.
+ *
+ * @param ch Channel which has some free buffer space.
+ * @param fwd Is this in for FWD traffic? (ACK goes dest->root)
+ */
+void
+GMT_send_acks (struct MeshTunnel3 *t, unsigned int buffer, int fwd);
+
/**
* Sends an already built message on a tunnel, encrypting it and
* choosing the best connection.