+ struct GNUNET_TIME_Relative ret;
+ int do_forward;
+ struct InboundMessage *im;
+ size_t msg_size = ntohs (message->size);
+ size_t size =
+ sizeof (struct InboundMessage) + msg_size +
+ sizeof (struct GNUNET_ATS_Information) * (ats_count + 1);
+ char buf[size];
+ struct GNUNET_ATS_Information *ap;
+
+ ret = GNUNET_TIME_UNIT_ZERO;
+ do_forward = GNUNET_SYSERR;
+ ret = GST_neighbours_calculate_receive_delay (peer, msg_size, &do_forward);
+
+ if (!GST_neighbours_test_connected (peer))
+ {
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Discarded %u bytes type %u payload from peer `%s'\n", msg_size,
+ ntohs (message->type), GNUNET_i2s (peer));
+
+ GNUNET_STATISTICS_update (GST_stats,
+ gettext_noop
+ ("# bytes payload discarded due to not connected peer "),
+ msg_size, GNUNET_NO);
+ return ret;
+ }
+
+ if (do_forward != GNUNET_YES)
+ return ret;
+ im = (struct InboundMessage *) buf;
+ im->header.size = htons (size);
+ im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
+ im->ats_count = htonl (ats_count + 1);
+ im->peer = *peer;
+ ap = (struct GNUNET_ATS_Information *) &im[1];
+ memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
+ ap[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
+ ap[ats_count].value =
+ htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value);
+ memcpy (&ap[ats_count + 1], message, ntohs (message->size));
+
+ GNUNET_ATS_address_update (GST_ats, address, session, ap, ats_count + 1);
+ GST_clients_broadcast (&im->header, GNUNET_YES);
+
+ return ret;