+/**
+ * Iterator over all paths of a peer to build an InfoPeer message.
+ *
+ * Message contains blocks of peers, first not included.
+ *
+ * @param cls Closure (message to build).
+ * @param peer Peer this path is towards.
+ * @param path Path itself
+ * @return #GNUNET_YES if should keep iterating.
+ * #GNUNET_NO otherwise.
+ */
+static int
+path_info_iterator (void *cls,
+ struct CadetPeer *peer,
+ struct CadetPeerPath *path)
+{
+ struct GNUNET_CADET_LocalInfoPeer *resp = cls;
+ struct GNUNET_PeerIdentity *id;
+ uint16_t msg_size;
+ uint16_t path_size;
+ unsigned int i;
+
+ msg_size = ntohs (resp->header.size);
+ path_size = sizeof (struct GNUNET_PeerIdentity) * (path->length - 1);
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Info Path %u\n", path->length);
+ if (msg_size + path_size > UINT16_MAX)
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING, "path too long for info message\n");
+ return GNUNET_NO;
+ }
+
+ i = msg_size - sizeof (struct GNUNET_CADET_LocalInfoPeer);
+ i = i / sizeof (struct GNUNET_PeerIdentity);
+
+ /* Set id to the address of the first free peer slot. */
+ id = (struct GNUNET_PeerIdentity *) &resp[1];
+ id = &id[i];
+
+ /* Don't copy first peers.
+ * First peer is always the local one.
+ * Last peer is always the destination (leave as 0, EOL).
+ */
+ for (i = 0; i < path->length - 1; i++)
+ {
+ GNUNET_PEER_resolve (path->peers[i + 1], &id[i]);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " %s\n", GNUNET_i2s (&id[i]));
+ }
+
+ resp->header.size = htons (msg_size + path_size);
+
+ return GNUNET_YES;
+}
+
+