- drop to_orig messages on 0 ttl
authorBart Polot <bart@net.in.tum.de>
Wed, 19 Jun 2013 17:49:39 +0000 (17:49 +0000)
committerBart Polot <bart@net.in.tum.de>
Wed, 19 Jun 2013 17:49:39 +0000 (17:49 +0000)
src/mesh/gnunet-service-mesh-new.c

index 77406d9b0c5e03bb6379d6e7c4f3721f634c7f97..ef04ea25934891a057bf9f05b198c5ec5040d1b0 100644 (file)
@@ -3485,6 +3485,7 @@ handle_mesh_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer,
   struct MeshTunnel *t;
   size_t size;
   uint32_t pid;
+  uint32_t ttl;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got a ToOrigin packet from %s\n",
               GNUNET_i2s (peer));
@@ -3568,6 +3569,15 @@ handle_mesh_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer,
                 GNUNET_i2s (&msg->oid), ntohl(msg->tid));
     return GNUNET_OK;
   }
+  ttl = ntohl (msg->ttl);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "   ttl: %u\n", ttl);
+  if (ttl == 0)
+  {
+    GNUNET_STATISTICS_update (stats, "# TTL drops", 1, GNUNET_NO);
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " TTL is 0, DROPPING!\n");
+    tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_ACK);
+    return GNUNET_OK;
+  }
   send_prebuilt_message (message, t->prev_hop, t);
   GNUNET_STATISTICS_update (stats, "# to origin forwarded", 1, GNUNET_NO);