- fixes, new message
authorBart Polot <bart@net.in.tum.de>
Fri, 20 Jul 2012 17:59:58 +0000 (17:59 +0000)
committerBart Polot <bart@net.in.tum.de>
Fri, 20 Jul 2012 17:59:58 +0000 (17:59 +0000)
src/mesh/gnunet-service-mesh.c
src/mesh/mesh_protocol.h

index 8d4f70e34048d469e76cedf02e1b4bc3a5b6baa6..4a323b7f7871f39f9306339470a7e30c72df0d87 100644 (file)
@@ -1966,6 +1966,13 @@ send_message (const struct GNUNET_MessageHeader *message,
   info->mesh_data = GNUNET_malloc (sizeof (struct MeshData));
   info->mesh_data->data = GNUNET_malloc (size);
   memcpy (info->mesh_data->data, message, size);
+  if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_MESH_UNICAST)
+  {
+    struct GNUNET_MESH_Unicast *m;
+
+    m = (struct GNUNET_MESH_Unicast *) info->mesh_data->data;
+    m->ttl--;
+  }
   info->mesh_data->data_len = size;
   info->mesh_data->reference_counter = GNUNET_malloc (sizeof (unsigned int));
   *info->mesh_data->reference_counter = 1;
@@ -3958,7 +3965,8 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
 {
   struct GNUNET_MESH_Unicast *msg;
   struct MeshTunnel *t;
-  GNUNET_PEER_Id pid;
+  uint32_t pid;
+  uint32_t ttl;
   size_t size;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got a unicast packet from %s\n",
@@ -4005,6 +4013,14 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
     send_subscribed_clients (message, (struct GNUNET_MessageHeader *) &msg[1]);
     return GNUNET_OK;
   }
+  ttl = ntohl (msg->ttl);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "   ttl: %u\n", ttl);
+  if (ttl == 0)
+  {
+    /* FIXME: ttl is 0, log dropping */
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " TTL is 0, DROPPING!\n");
+    return GNUNET_OK;
+  }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "  not for us, retransmitting...\n");
   send_message (message, tree_get_first_hop (t->tree, pid), t);
index f01cb7d982a4a965b69ccca63ba5ed744f6cec75..c09efe669aaebddfca2ac0510cb2f69e645b9e6a 100644 (file)
@@ -175,6 +175,36 @@ struct GNUNET_MESH_ToOrigin
 };
 
 
+/**
+ * Message to acknowledte mesh data traffic.
+ */
+struct GNUNET_MESH_ACK
+{
+    /**
+     * Type: GNUNET_MESSAGE_TYPE_MESH_ACK
+     */
+  struct GNUNET_MessageHeader header;
+
+    /**
+     * TID of the tunnel
+     */
+  uint32_t tid GNUNET_PACKED;
+
+    /**
+     * OID of the tunnel
+     */
+  struct GNUNET_PeerIdentity oid;
+
+    /**
+     * Sender of the message.
+     */
+  struct GNUNET_PeerIdentity sender;
+
+    /**
+     * Payload follows
+     */
+};
+
 /**
  * Message for ack'ing a path
  */