+ {
+ GNUNET_break (0);
+ GNUNET_free (r->friend_only_hello);
+ r->friend_only_hello = hello_clean;
+ }
+ }
+ read_pos += size_hello;
+ }
+
+ if (0 == left)
+ {
+ /* no addresses left, remove from disk */
+ if ( (GNUNET_YES == unlink_garbage) &&
+ (0 != UNLINK (fn)) )
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+ "unlink",
+ fn);
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Found `%s' and `%s' HELLO message in file\n",
+ (NULL != r->hello) ? "public" : "NON-public",
+ (NULL != r->friend_only_hello) ? "friend only" : "NO friend only");
+}
+
+
+/**
+ * Add a host to the list and notify clients about this event
+ *
+ * @param identity the identity of the host
+ * @return the HostEntry
+ */
+static struct HostEntry *
+add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
+{
+ struct HostEntry *entry;
+ struct ReadHostFileContext r;
+ char *fn;
+
+ entry = GNUNET_CONTAINER_multipeermap_get (hostmap, identity);
+ if (NULL == entry)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding new peer `%s'\n", GNUNET_i2s (identity));
+ GNUNET_STATISTICS_update (stats, gettext_noop ("# peers known"), 1,
+ GNUNET_NO);
+ entry = GNUNET_new (struct HostEntry);
+ entry->identity = *identity;
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONTAINER_multipeermap_put (hostmap, &entry->identity, entry,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ notify_all (entry);
+ fn = get_host_filename (identity);
+ if (NULL != fn)
+ {
+ read_host_file (fn, GNUNET_YES, &r);
+ if (NULL != r.hello)
+ update_hello (identity, r.hello);
+ if (NULL != r.friend_only_hello)
+ update_hello (identity, r.friend_only_hello);
+ GNUNET_free_non_null (r.hello);
+ GNUNET_free_non_null (r.friend_only_hello);
+ GNUNET_free (fn);