+/**
+ * Handler for client's SHOW_PEER request.
+ *
+ * @param cls Closure (unused).
+ * @param client Identification of the client.
+ * @param message The actual message.
+ */
+void
+handle_show_peer (void *cls, struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
+{
+ const struct GNUNET_CADET_LocalInfo *msg;
+ struct GNUNET_CADET_LocalInfoPeer *resp;
+ struct CadetPeer *p;
+ struct CadetClient *c;
+ unsigned char cbuf[64 * 1024];
+
+ /* Sanity check for client registration */
+ if (NULL == (c = GML_client_get (client)))
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+
+ msg = (struct GNUNET_CADET_LocalInfo *) message;
+ resp = (struct GNUNET_CADET_LocalInfoPeer *) cbuf;
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "Received peer info request from client %u for peer %s\n",
+ c->id, GNUNET_i2s_full (&msg->peer));
+
+ resp->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER);
+ resp->header.size = htons (sizeof (struct GNUNET_CADET_LocalInfoPeer));
+ resp->destination = msg->peer;
+ p = GCP_get (&msg->peer, GNUNET_NO);
+ if (NULL == p)
+ {
+ /* We don't know the peer */
+
+ LOG (GNUNET_ERROR_TYPE_INFO, "Peer %s unknown\n",
+ GNUNET_i2s_full (&msg->peer));
+ resp->paths = htons (0);
+ resp->tunnel = htons (NULL != GCP_get_tunnel (p));
+
+ GNUNET_SERVER_notification_context_unicast (nc, client,
+ &resp->header,
+ GNUNET_NO);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
+
+ resp->paths = htons (GCP_count_paths (p));
+ resp->tunnel = htons (NULL != GCP_get_tunnel (p));
+ GCP_iterate_paths (p, &path_info_iterator, resp);
+
+ GNUNET_SERVER_notification_context_unicast (nc, c->handle,
+ &resp->header, GNUNET_NO);
+
+ LOG (GNUNET_ERROR_TYPE_INFO, "Show peer from client %u completed.\n", c->id);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+