tc = lookup_client (client);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
"Client %p sent START\n", tc);
if (tc != NULL)
{
*
* @param cls the transmission context used ('struct GNUNET_SERVER_TransmitContext*')
* @param buf text to transmit
+ * @param res GNUNET_OK if conversion was successful, GNUNET_SYSERR on error
*/
static void
-transmit_address_to_client (void *cls, const char *buf)
+transmit_address_to_client (void *cls, const char *buf, int res)
{
struct AddressToStringContext *actx = cls;
+ struct AddressToStringResultMessage *atsm;
+ size_t len;
+
if (NULL == buf)
{
- GNUNET_SERVER_transmit_context_append_data (actx->tc, NULL, 0,
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY);
- GNUNET_SERVER_transmit_context_run (actx->tc, GNUNET_TIME_UNIT_FOREVER_REL);
- GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, actx);
- GNUNET_free (actx);
- return;
+ GNUNET_assert ((res == GNUNET_OK) || (res == GNUNET_SYSERR));
+
+ len = sizeof (struct AddressToStringResultMessage);
+ atsm = GNUNET_malloc (len);
+ atsm->header.size = ntohs (len);
+ atsm->header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY);
+
+ if (GNUNET_OK == res)
+ {
+ /* done, transmit */
+ atsm->res = htonl (GNUNET_YES);
+ atsm->addr_len = htonl (0);
+ GNUNET_SERVER_transmit_context_append_message (actx->tc,
+ (const struct GNUNET_MessageHeader *) atsm);
+
+ GNUNET_SERVER_transmit_context_run (actx->tc, GNUNET_TIME_UNIT_FOREVER_REL);
+ GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, actx);
+ GNUNET_free (actx);
+ }
+ if (GNUNET_SYSERR == res)
+ {
+ /* address conversion failed */
+
+ atsm->res = htonl (GNUNET_NO);
+ atsm->addr_len = htonl (0);
+ GNUNET_SERVER_transmit_context_append_message (actx->tc,
+ (const struct GNUNET_MessageHeader *) atsm);
+ GNUNET_free (atsm);
+ }
+ }
+ else
+ {
+ GNUNET_assert (res == GNUNET_OK);
+ /* succesful conversion, append*/
+ len = sizeof (struct AddressToStringResultMessage) + strlen (buf) + 1;
+ atsm = GNUNET_malloc (len);
+ atsm->header.size = ntohs (len);
+ atsm->header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY);
+ atsm->res = htonl (GNUNET_YES);
+ atsm->addr_len = htonl (strlen (buf) + 1);
+ memcpy (&atsm[1], buf, strlen (buf) + 1);
+ GNUNET_SERVER_transmit_context_append_message (actx->tc,
+ (const struct GNUNET_MessageHeader *) atsm);
+ GNUNET_free (atsm);
}
- GNUNET_SERVER_transmit_context_append_data (actx->tc, buf, strlen (buf) + 1,
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY);
}
uint16_t size;
struct GNUNET_SERVER_TransmitContext *tc;
struct AddressToStringContext *actx;
+ struct AddressToStringResultMessage atsm;
struct GNUNET_TIME_Relative rtimeout;
int32_t numeric;
papi = GST_plugins_printer_find (plugin_name);
if (NULL == papi)
{
- GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY);
+ atsm.header.size = ntohs (sizeof (struct AddressToStringResultMessage));
+ atsm.header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY);
+ atsm.res = htonl (GNUNET_NO);
+ atsm.addr_len = htonl (0);
+ GNUNET_SERVER_transmit_context_append_message (tc,
+ (const struct GNUNET_MessageHeader *) &atsm);
GNUNET_SERVER_transmit_context_run (tc, rtimeout);
return;
}