- respond to data on unknown channels with destroy (avoids retransmissions)
authorBart Polot <bart@net.in.tum.de>
Tue, 17 Dec 2013 05:18:16 +0000 (05:18 +0000)
committerBart Polot <bart@net.in.tum.de>
Tue, 17 Dec 2013 05:18:16 +0000 (05:18 +0000)
src/mesh/gnunet-service-mesh_tunnel.c

index a65d85f6617ec0d8ad3ad5b697325842a2b91f3d..b6ff4f2d4cbcf4574f03548158b096ec5079a225 100644 (file)
@@ -541,6 +541,7 @@ t_decrypt (struct MeshTunnel3 *t,
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "WARNING got data on %s without a valid key\n",
          GMT_2s (t));
+    GMT_debug (t);
     return 0;
   }
 
@@ -1132,6 +1133,29 @@ destroy_iterator (void *cls,
 }
 
 
+/**
+ * Notify remote peer that we don't know a channel he is talking about,
+ * probably CHANNEL_DESTROY was missed.
+ *
+ * @param t Tunnel on which to notify.
+ * @param gid ID of the channel.
+ */
+static void
+send_channel_destroy (struct MeshTunnel3 *t, unsigned int gid)
+{
+  struct GNUNET_MESH_ChannelManage msg;
+
+  msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY);
+  msg.header.size = htons (sizeof (msg));
+  msg.chid = htonl (gid);
+
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "WARNING destroying unknown channel %u on tunnel %s\n",
+       gid, GMT_2s (t));
+  send_prebuilt_message (&msg.header, t, GNUNET_YES, NULL, NULL, NULL);
+}
+
+
 /**
  * Demultiplex data per channel and call appropriate channel handler.
  *
@@ -1170,6 +1194,7 @@ handle_data (struct MeshTunnel3 *t,
                               1, GNUNET_NO);
     LOG (GNUNET_ERROR_TYPE_DEBUG, "WARNING channel 0x%X unknown\n",
          ntohl (msg->chid));
+    send_channel_destroy (t, ntohl (msg->chid));
     return;
   }