- struct GNUNET_GNS_Handle *handle = cls;
- struct GNUNET_GNS_QueueEntry *qe;
- const struct GNUNET_GNS_ClientLookupResultMessage *lookup_msg;
- const struct GNUNET_GNS_ClientShortenResultMessage *shorten_msg;
- const struct GNUNET_GNS_ClientGetAuthResultMessage *get_auth_msg;
- uint16_t type;
- uint32_t r_id;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got message\n");
- if (msg == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error receiving data from GNS service, reconnecting\n");
- force_reconnect (handle);
- return;
- }
-
- type = ntohs (msg->type);
-
- if (type == GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got lookup msg\n");
- lookup_msg = (const struct GNUNET_GNS_ClientLookupResultMessage *) msg;
- r_id = ntohl (lookup_msg->id);
-
- if (r_id > handle->r_id)
- {
- /** no request found */
- GNUNET_break_op (0);
- GNUNET_CLIENT_receive (handle->client, &process_message, handle,
- GNUNET_TIME_UNIT_FOREVER_REL);
- return;
- }
-
- for (qe = handle->lookup_head; qe != NULL; qe = qe->next)
- {
- if (qe->r_id == r_id)
- break;
- }
- if (qe)
- process_lookup_reply(qe, lookup_msg);
-
- return;
-
- }
- else if (type == GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got SHORTEN_RESULT msg\n");
- shorten_msg = (struct GNUNET_GNS_ClientShortenResultMessage *) msg;
-
- r_id = ntohl (shorten_msg->id);
-
- if (r_id > handle->r_id)
- {
- /** no request found */
- GNUNET_break_op (0);
- GNUNET_CLIENT_receive (handle->client, &process_message, handle,
- GNUNET_TIME_UNIT_FOREVER_REL);
- return;
- }
-
- for (qe = handle->shorten_head; qe != NULL; qe = qe->next)
- {
- if (qe->r_id == r_id)
- break;
- }
- if (qe)
- process_shorten_reply(qe, shorten_msg);
- return;
- }
- else if (type == GNUNET_MESSAGE_TYPE_GNS_GET_AUTH_RESULT)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got GET_AUTH_RESULT msg\n");
- get_auth_msg = (struct GNUNET_GNS_ClientGetAuthResultMessage *) msg;
-
- r_id = ntohl (get_auth_msg->id);
-
- if (r_id > handle->r_id)
- {
- /** no request found */
- GNUNET_break_op (0);
- GNUNET_CLIENT_receive (handle->client, &process_message, handle,
- GNUNET_TIME_UNIT_FOREVER_REL);
- return;
- }
-
- for (qe = handle->get_auth_head; qe != NULL; qe = qe->next)
- {
- if (qe->r_id == r_id)
- break;
- }
- if (qe)
- process_get_auth_reply(qe, get_auth_msg);
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_var_size (result,
+ GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT,
+ struct LookupResultMessage,
+ handle),
+ GNUNET_MQ_handler_end ()
+ };
+ struct GNUNET_GNS_LookupRequest *lh;
+
+ GNUNET_assert (NULL == handle->mq);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Trying to connect to GNS\n");
+ handle->mq = GNUNET_CLIENT_connect (handle->cfg,
+ "gns",
+ handlers,
+ &mq_error_handler,
+ handle);
+ if (NULL == handle->mq)