- struct GNUNET_DHT_Handle *handle = cls;
- struct GNUNET_DHT_RouteResultMessage *dht_msg;
- struct GNUNET_MessageHeader *enc_msg;
- struct GNUNET_DHT_RouteHandle *route_handle;
- uint64_t uid;
- GNUNET_HashCode uid_hash;
- size_t enc_size;
-
- if (msg == NULL)
- {
-#if DEBUG_DHT_API
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "`%s': Received NULL from server, connection down!\n",
- "DHT API");
-#endif
- GNUNET_CLIENT_disconnect (handle->client, GNUNET_YES);
- handle->client = GNUNET_CLIENT_connect (handle->sched,
- "dht",
- handle->cfg);
- if (handle->current != NULL)
- {
- finish(handle, GNUNET_SYSERR); /* If there was a current message, kill it! */
- }
-#if RETRANSMIT
- if ((handle->retransmit_stage != DHT_RETRANSMITTING) && (GNUNET_CONTAINER_multihashmap_iterate(handle->outstanding_requests, &retransmit_iterator, handle) > 0))
- {
- handle->retransmit_stage = DHT_RETRANSMITTING;
- handle->current = handle->retransmissions->message;
- process_pending_retransmissions(handle);
- }
-#endif
- return;
- }
-
- switch (ntohs (msg->type))
- {
- case GNUNET_MESSAGE_TYPE_LOCAL_DHT_ROUTE_RESULT:
- {
- dht_msg = (struct GNUNET_DHT_RouteResultMessage *) msg;
- uid = GNUNET_ntohll (dht_msg->unique_id);
-#if DEBUG_DHT_API
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "`%s': Received response to message (uid %llu)\n",
- "DHT API", uid);
-#endif
-
- hash_from_uid (uid, &uid_hash);
- route_handle =
- GNUNET_CONTAINER_multihashmap_get (handle->outstanding_requests,
- &uid_hash);
- if (route_handle == NULL) /* We have no recollection of this request */
- {
-#if DEBUG_DHT_API
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "`%s': Received response to message (uid %llu), but have no recollection of it!\n",
- "DHT API", uid);
-#endif
- }
- else
- {
- enc_size =
- ntohs (dht_msg->header.size) -
- sizeof (struct GNUNET_DHT_RouteResultMessage);
- GNUNET_assert (enc_size > 0);
- enc_msg = (struct GNUNET_MessageHeader *) &dht_msg[1];
- route_handle->iter (route_handle->iter_cls, enc_msg);
- }
-
- break;
- }
- default:
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "`%s': Received unknown message type %d\n", "DHT API",
- ntohs (msg->type));
- }
- }
- GNUNET_CLIENT_receive (handle->client,
- &service_message_handler,
- handle, GNUNET_TIME_UNIT_FOREVER_REL);