transport service sends wrong message type to transport_api
authorMatthias Wachs <wachs@net.in.tum.de>
Thu, 25 Aug 2011 14:17:53 +0000 (14:17 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Thu, 25 Aug 2011 14:17:53 +0000 (14:17 +0000)
transport api requests GNUNET_MESSAGE_TYPE_TRANSPORT_RECV for payload messages

src/transport/gnunet-service-transport-new.c

index 95f181835a24d7e002b26da7040edb2bdf994814..54af9cadec812850cbf0046284fc1046aa26d1d7 100644 (file)
@@ -156,7 +156,8 @@ static struct GNUNET_TIME_Relative
 plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
                              const struct GNUNET_MessageHeader *message,
                              const struct GNUNET_TRANSPORT_ATS_Information *ats,
-                             uint32_t ats_count, struct Session *session,
+                             uint32_t ats_count,
+                             struct Session *session,
                              const char *sender_address,
                              uint16_t sender_address_len)
 {
@@ -222,7 +223,23 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
                                                   ntohs (message->size),
                                                   &do_forward);
       if (do_forward == GNUNET_YES)
-        GST_clients_broadcast (message, GNUNET_YES);
+      {
+        struct InboundMessage * im;
+        size_t size =
+            sizeof (struct InboundMessage) +
+            ntohs (message->size);
+
+        im = GNUNET_malloc (size);
+        im->header.size = htons (size);
+        im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
+        im->ats_count = htonl (0);
+        memcpy (&(im->peer), peer, sizeof(struct GNUNET_PeerIdentity));
+        memcpy (&im[1], message, ntohs (message->size));
+
+        GST_clients_broadcast ((const struct GNUNET_MessageHeader *) im, GNUNET_YES);
+
+        GNUNET_free(im);
+      }
       break;
     }
   }