+
+/**
+ * Handler called by core when core is ready to transmit message
+ * @param cls closure
+ * @param size size of buffer to copy message to
+ * @param buf buffer to copy message to
+ */
+static size_t
+adv_transmit_ready ( void *cls, size_t size, void *buf)
+{
+ static uint64_t hostlist_adv_count;
+
+ size_t transmission_size;
+ size_t uri_size; /* Including \0 termination! */
+ struct GNUNET_MessageHeader header;
+ char *cbuf;
+
+ if (buf == NULL)
+ {
+ GNUNET_log ( GNUNET_ERROR_TYPE_DEBUG,
+ "Transmission failed, buffer invalid!\n" );
+ return 0;
+ }
+ uri_size = strlen ( hostlist_uri ) + 1;
+ transmission_size = sizeof (struct GNUNET_MessageHeader) + uri_size;
+ header.type = htons (GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT);
+ header.size = htons (transmission_size);
+ GNUNET_assert (size >= transmission_size);
+ memcpy (buf, &header, sizeof (struct GNUNET_MessageHeader));
+ cbuf = buf;
+ memcpy (&cbuf[sizeof (struct GNUNET_MessageHeader)],
+ hostlist_uri, uri_size);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sent advertisement message: Copied %u bytes into buffer!\n",
+ (unsigned int) transmission_size);
+ hostlist_adv_count++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ " # Sent advertisement message: %u\n",
+ hostlist_adv_count);
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop("# hostlist advertisements send"),
+ 1,
+ GNUNET_NO);
+ return transmission_size;
+}
+
+