+/**
+ * Transmit ready callback.
+ *
+ * @param cls Closure (peer number of peer sending the data).
+ * @param size Buffer size.
+ * @param buf Buffer.
+ */
+static size_t
+tmt_rdy (void *cls, size_t size, void *buf)
+{
+ unsigned int peer_number = *(unsigned int *) cls;
+ struct GNUNET_MessageHeader *m = buf;
+ struct test_traffic_message *msg = buf;
+ size_t msize = sizeof (struct test_traffic_message);
+ unsigned int *sent;
+ unsigned int target;
+
+ if (0 == size || NULL == buf)
+ return 0;
+
+ if (1 == peer_number)
+ {
+ sent = &sent_fwd;
+ target = to_send_fwd;
+ }
+ else if (2 == peer_number)
+ {
+ sent = &sent_bck;
+ target = to_send_bck;
+ }
+ else
+ GNUNET_abort();
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data packet # %u\n",
+ *sent);
+ GNUNET_assert (size >= msize);
+ (*sent)++;
+ if (target > *sent)
+ GNUNET_MESH_notify_transmit_ready (t, GNUNET_NO,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &peer_id, msize, &tmt_rdy, cls);
+ m->size = htons (msize);
+ m->type = htons (1);
+ msg->data = htonl (*sent - 1);
+ return msize;
+}
+
+