#include "gnunet_statistics_service.h"
-#include "mesh_enc.h"
-#include "mesh_protocol_enc.h" // GNUNET_MESH_Data is shared
+#include "mesh.h"
+#include "mesh_protocol.h" /* GNUNET_MESH_Data is shared */
#include "gnunet-service-mesh_local.h"
{
struct MeshClient *c;
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "client connected: %p\n", client);
if (NULL == client)
return;
c = GNUNET_new (struct MeshClient);
return;
}
- /* If client is root, the ACK is going FWD, therefore this is "BCK". */
- /* If client is dest, the ACK is going BCK, therefore this is "FWD" */
+ /* If client is root, the ACK is going FWD, therefore this is "BCK ACK". */
+ /* If client is dest, the ACK is going BCK, therefore this is "FWD ACK" */
fwd = chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
GMCH_handle_local_ack (ch, fwd);
* @param key Key (hashed tunnel ID, unused).
* @param value Tunnel info.
*
- * @return GNUNET_YES, to keep iterating.
+ * @return #GNUNET_YES, to keep iterating.
*/
// static int
// monitor_all_tunnels_iterator (void *cls,
/**
- * Get a chennel from a client
+ * Get a channel from a client.
*
- * @param c the client to check
- * @param chid Channel ID, must be local (> 0x800...)
+ * @param c Client to check.
+ * @param chid Channel ID, must be local (> 0x800...).
*
* @return non-NULL if channel exists in the clients lists
*/
/**
- * Remove a channel from a client
+ * Remove a channel from a client.
*
* @param client Client.
* @param chid Channel ID.
struct MeshChannel *ch)
{
if (GNUNET_MESH_LOCAL_CHANNEL_ID_SERV <= chid)
- GNUNET_CONTAINER_multihashmap32_remove (client->incoming_channels, chid, ch);
+ GNUNET_break (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap32_remove (client->incoming_channels,
+ chid, ch));
else if (GNUNET_MESH_LOCAL_CHANNEL_ID_CLI <= chid)
- GNUNET_CONTAINER_multihashmap32_remove (client->own_channels, chid, ch);
+ GNUNET_break (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap32_remove (client->own_channels,
+ chid, ch));
else
GNUNET_break (0);
}
}
+/**
+ * Build a local channel NACK message and send it to a local client.
+ *
+ * @param c Client to whom send the NACK.
+ * @param id Channel ID to use
+ */
+void
+GML_send_nack (struct MeshClient *c, MESH_ChannelNumber id)
+{
+ struct GNUNET_MESH_LocalAck msg;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "send local nack on %X towards %p\n",
+ id, c);
+
+ msg.header.size = htons (sizeof (msg));
+ msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_NACK);
+ msg.channel_id = htonl (id);
+ GNUNET_SERVER_notification_context_unicast (nc,
+ c->handle,
+ &msg.header,
+ GNUNET_NO);
+
+}
+
+
/**
* Notify the client that a new incoming channel was created.
*
- * @param ch Channel that was created.
+ * @param c Client to notify.
+ * @param id Channel ID.
+ * @param port Channel's destination port.
+ * @param opt Options (bit array).
+ * @param peer Origin peer.
*/
void
GML_send_channel_create (struct MeshClient *c,