- char *cbuf = buf;
- struct TestMessage hdr;
- unsigned int ret;
-
- p1.nth = NULL;
- GNUNET_assert (size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE);
- if (buf == NULL)
- {
- if ((p1.ch != NULL) && (p1.connect_status == 1))
- GNUNET_break (NULL !=
- (p1.nth =
- GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO,
- GNUNET_CORE_PRIO_BEST_EFFORT,
- FAST_TIMEOUT, &p2.id,
- MESSAGESIZE,
- &transmit_ready, &p1)));
- return 0;
- }
- GNUNET_assert (tr_n < TOTAL_MSGS);
- ret = 0;
- GNUNET_assert (size >= MESSAGESIZE);
- GNUNET_assert (buf != NULL);
- cbuf = buf;
- do
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending message %u of size %u at offset %u\n", tr_n,
- MESSAGESIZE, ret);
- hdr.header.size = htons (MESSAGESIZE);
- hdr.header.type = htons (MTYPE);
- hdr.num = htonl (tr_n);
- GNUNET_memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage));
- ret += sizeof (struct TestMessage);
- memset (&cbuf[ret], tr_n, MESSAGESIZE - sizeof (struct TestMessage));
- ret += MESSAGESIZE - sizeof (struct TestMessage);
- tr_n++;
- if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16))
- break; /* sometimes pack buffer full, sometimes not */
- }
- while (size - ret >= MESSAGESIZE);
+ struct TestMessage *hdr;
+ struct GNUNET_MQ_Envelope *env;
+
+ env = GNUNET_MQ_msg (hdr,
+ MTYPE);
+ hdr->num = htonl (tr_n);
+ memset (&hdr->pad,
+ tr_n,
+ MESSAGESIZE);
+ tr_n++;