-
- struct GNUNET_ATS_Properties prop;
- struct GNUNET_TIME_Relative delay;
-
- delay.rel_value_us = 1000 * 1000LL;
- memset (&prop, 0, sizeof (prop));
- prop.distance = 10;
- GNUNET_TRANSPORT_set_traffic_metric (p1->th,
- &p2->id,
- &prop,
- delay,
- GNUNET_TIME_UNIT_ZERO);
- send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
- }
- if (2 == messages_recv)
- {
- /* Received manipulated message */
- dur_delayed = GNUNET_TIME_absolute_get_duration(start_delayed);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received delayed message %u after %s\n",
- messages_recv,
- GNUNET_STRINGS_relative_time_to_string (dur_delayed,
- GNUNET_YES));
- if (dur_delayed.rel_value_us < 1000 * 1000LL)
- {
- GNUNET_break (0);
- ok += 1;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Delayed message was not delayed correctly: took only %s\n",
- GNUNET_STRINGS_relative_time_to_string (dur_delayed,
- GNUNET_YES));
- }
- /* shutdown */
- end ();
- }
-
- messages_recv ++;
-}
-
-
-static size_t
-notify_ready (void *cls, size_t size, void *buf)
-{
- struct PeerContext *p = cls;
- struct GNUNET_MessageHeader *hdr;
-
- th = NULL;
-
- if (buf == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Timeout occurred while waiting for transmit_ready\n");
- if (NULL != die_task)
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
- ok = 42;
- return 0;
- }
-
- GNUNET_assert (size >= TEST_MESSAGE_SIZE);
- if (buf != NULL)
- {
- memset (buf, '\0', TEST_MESSAGE_SIZE);
- hdr = buf;
- hdr->size = htons (TEST_MESSAGE_SIZE);
- hdr->type = htons (TEST_MESSAGE_TYPE);
- }
-
- char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
- p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
- GNUNET_i2s (&p->id));
- GNUNET_free (ps);
-
- return TEST_MESSAGE_SIZE;
-}
-
-
-static void
-sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- send_task = NULL;
-
- if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)