- GNUNET_assert(ntohs(msg->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_DV_RECEIVE);
-
- if (ntohs(msg->size) < sizeof(struct GNUNET_DV_MessageReceived))
- return;
-
- received_msg = (struct GNUNET_DV_MessageReceived *)msg;
- GNUNET_assert(ntohs(msg->size) == (sizeof(struct GNUNET_DV_MessageReceived) + ntohs(received_msg->msg->size) + ntohs(received_msg->sender_address_len)));
-
- sender_address = GNUNET_malloc(ntohs(received_msg->sender_address_len));
- sender_address = memcpy(sender_address, &received_msg[1], ntohs(received_msg->sender_address_len));
-
- handle->receive_handler(handle->receive_cls,
- received_msg->sender,
- received_msg->msg,
- ntohl(received_msg->distance),
- sender_address,
- ntohs(received_msg->sender_address_len));
+ received_msg = (struct GNUNET_DV_MessageReceived *)msg;
+ packed_msg_len = ntohl(received_msg->msg_len);
+ sender_address_len = ntohl(received_msg->sender_address_len);
+
+ GNUNET_assert(ntohs(msg->size) == (sizeof(struct GNUNET_DV_MessageReceived) + packed_msg_len + sender_address_len));
+ sender_address = GNUNET_malloc(sender_address_len);
+ memcpy(sender_address, &received_msg[1], sender_address_len);
+ packed_msg_start = (char *)&received_msg[1];
+ packed_msg = GNUNET_malloc(packed_msg_len);
+ memcpy(packed_msg, &packed_msg_start[sender_address_len], packed_msg_len);
+
+#if DEBUG_DV
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: packed message type: %d or %d\n", ntohs(((struct GNUNET_MessageHeader *)packed_msg)->type), ((struct GNUNET_MessageHeader *)packed_msg)->type);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: message sender reported as %s\n", GNUNET_i2s(&received_msg->sender));
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: distance is %u\n", ntohl(received_msg->distance));
+#endif