/**
* Notify a client that the channel is no longer valid.
- * FIXME send on tunnel if some client == NULL?
*
* @param ch Channel that is destroyed.
*/
void
GMCH_send_destroy (struct MeshChannel *ch)
{
+ struct GNUNET_MESH_ChannelManage msg;
+
+ msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY);
+ msg.header.size = htons (sizeof (msg));
+ msg.chid = htonl (ch->gid);
+
+ /* If root is not NULL, notify.
+ * If it's NULL, check lid_root. When a local destroy comes in, root
+ * is set to NULL but lid_root is left untouched. In this case, do nothing,
+ * the client is the one who reuqested the channel to be destroyed.
+ */
if (NULL != ch->root)
GML_send_channel_destroy (ch->root, ch->lid_root);
+ else if (0 == ch->lid_root)
+ GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO);
if (NULL != ch->dest)
GML_send_channel_destroy (ch->dest, ch->lid_dest);
+ else if (0 == ch->lid_dest)
+ GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_YES);
}
}
else
{
+ /* Unexpected peer sending traffic on a connection. */
GNUNET_break_op (0);
return GNUNET_OK;
}
}
- fc = fwd ? &c->bck_fc : &c->fwd_fc;
/* Check PID */
+ fc = fwd ? &c->bck_fc : &c->fwd_fc;
pid = ntohl (msg->pid);
if (GMC_is_pid_bigger (pid, fc->last_ack_sent))
{
pid, fc->last_pid_recv + 1);
return GNUNET_OK;
}
- if (MESH_CONNECTION_SENT == c->state)
+ if (MESH_CONNECTION_SENT == c->state || MESH_CONNECTION_ACK == c->state)
connection_change_state (c, MESH_CONNECTION_READY);
connection_reset_timeout (c, fwd);
fc->last_pid_recv = pid;
* @param fwd Is this message fwd?
*/
static void
-handle_GMT_decrypted (struct MeshTunnel3 *t,
+handle_decrypted (struct MeshTunnel3 *t,
const struct GNUNET_MessageHeader *msgh,
int fwd)
{
while (off < payload_size)
{
msgh = (struct GNUNET_MessageHeader *) &cbuf[off];
- handle_GMT_decrypted (t, msgh, fwd);
+ handle_decrypted (t, msgh, fwd);
off += ntohs (msgh->size);
}
}
unsigned int cs;
unsigned int buffer;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Tunnel send %s ACKs on %s\n",
- fwd ? "FWD" : "BCK", GMT_2s (t));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Tunnel send %s ACKs on %s\n",
+ fwd ? "FWD" : "BCK", GMT_2s (t));
if (NULL == t)
{