-/**
- * Function called to transfer a message to another peer
- * via core.
- *
- * @param cls closure with the direct neighbor
- * @param size number of bytes available in buf
- * @param buf where the callee should write the message
- * @return number of bytes written to buf
- */
-static size_t
-core_transmit_notify (void *cls, size_t size, void *buf)
-{
- struct DirectNeighbor *dn = cls;
- char *cbuf = buf;
- struct PendingMessage *pending;
- size_t off;
- size_t msize;
-
- dn->cth = NULL;
- if (NULL == buf)
- {
- /* client disconnected */
- return 0;
- }
- off = 0;
- while ( (NULL != (pending = dn->pm_head)) &&
- (size >= off + (msize = ntohs (pending->msg->size))))
- {
- dn->pm_queue_size--;
- GNUNET_CONTAINER_DLL_remove (dn->pm_head,
- dn->pm_tail,
- pending);
- memcpy (&cbuf[off], pending->msg, msize);
- if (0 != pending->uid)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Acking transmission of %u bytes to %s with plugin\n",
- msize,
- GNUNET_i2s (&pending->next_target));
- send_ack_to_plugin (&pending->next_target,
- pending->uid,
- GNUNET_NO);
- }
- GNUNET_free (pending);
- off += msize;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitting total of %u bytes to %s\n",
- off,
- GNUNET_i2s (&dn->peer));
- GNUNET_assert (NULL != core_api);
- if (NULL != dn->pm_head)
- dn->cth =
- GNUNET_CORE_notify_transmit_ready (core_api,
- GNUNET_YES /* cork */,
- 0 /* priority */,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &dn->peer,
- msize,
- &core_transmit_notify, dn);
- return off;
-}
-
-