2 This file is part of GNUnet.
3 (C) 2001, 2002, 2004, 2005, 2007, 2009, 2010, 2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file peerinfo/gnunet-service-peerinfo.c
23 * @brief maintains list of known peers
25 * Code to maintain the list of currently known hosts (in memory
26 * structure of data/hosts/).
28 * @author Christian Grothoff
31 * - notify clients when addresses in HELLO expire (#1933)
35 #include "gnunet_util_lib.h"
36 #include "gnunet_hello_lib.h"
37 #include "gnunet_protocols.h"
38 #include "gnunet_statistics_service.h"
42 * How often do we scan the HOST_DIR for new entries?
44 #define DATA_HOST_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15)
47 * How often do we discard old entries in data/hosts/?
49 #define DATA_HOST_CLEAN_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 60)
53 * In-memory cache of known hosts.
59 * Identity of the peer.
61 struct GNUNET_PeerIdentity identity;
64 * Hello for the peer (can be NULL)
66 struct GNUNET_HELLO_Message *hello;
72 * The in-memory list of known hosts, mapping of
73 * host IDs to 'struct HostEntry*' values.
75 static struct GNUNET_CONTAINER_MultiHashMap *hostmap;
78 * Clients to immediately notify about all changes.
80 static struct GNUNET_SERVER_NotificationContext *notify_list;
83 * Directory where the hellos are stored in (data/hosts)
85 static char *networkIdDirectory;
88 * Handle for reporting statistics.
90 static struct GNUNET_STATISTICS_Handle *stats;
94 * Notify all clients in the notify list about the
95 * given host entry changing.
97 * @param he entry of the host for which we generate a notification
98 * @return generated notification message
100 static struct InfoMessage *
101 make_info_message (const struct HostEntry *he)
103 struct InfoMessage *im;
106 hs = (NULL == he->hello) ? 0 : GNUNET_HELLO_size (he->hello);
107 im = GNUNET_malloc (sizeof (struct InfoMessage) + hs);
108 im->header.size = htons (hs + sizeof (struct InfoMessage));
109 im->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
110 im->peer = he->identity;
111 if (he->hello != NULL)
112 memcpy (&im[1], he->hello, hs);
118 * Address iterator that causes expired entries to be discarded.
120 * @param cls pointer to the current time
121 * @param address the address
122 * @param expiration expiration time for the address
123 * @return GNUNET_NO if expiration smaller than the current time
126 discard_expired (void *cls, const struct GNUNET_HELLO_Address *address,
127 struct GNUNET_TIME_Absolute expiration)
129 const struct GNUNET_TIME_Absolute *now = cls;
131 if (now->abs_value > expiration.abs_value)
133 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
134 _("Removing expired address of transport `%s'\n"),
135 address->transport_name);
143 * Address iterator that counts the remaining addresses.
145 * @param cls pointer to the counter
146 * @param address the address
147 * @param expiration expiration time for the address
148 * @return GNUNET_OK (always)
151 count_addresses (void *cls, const struct GNUNET_HELLO_Address *address,
152 struct GNUNET_TIME_Absolute expiration)
154 unsigned int *cnt = cls;
162 * Get the filename under which we would store the GNUNET_HELLO_Message
163 * for the given host and protocol.
165 * @param id peer for which we need the filename for the HELLO
166 * @return filename of the form DIRECTORY/HOSTID
169 get_host_filename (const struct GNUNET_PeerIdentity *id)
171 struct GNUNET_CRYPTO_HashAsciiEncoded fil;
174 GNUNET_CRYPTO_hash_to_enc (&id->hashPubKey, &fil);
175 GNUNET_asprintf (&fn, "%s%s%s", networkIdDirectory, DIR_SEPARATOR_STR, &fil);
181 * Broadcast information about the given entry to all
184 * @param entry entry to broadcast about
187 notify_all (struct HostEntry *entry)
189 struct InfoMessage *msg;
191 msg = make_info_message (entry);
192 GNUNET_SERVER_notification_context_broadcast (notify_list, &msg->header,
199 * Try to read the HELLO in the given filename and discard expired
200 * addresses. Removes the file if the HELLO is mal-formed. If all
201 * addresses are expired, the HELLO is also removed (but the HELLO
202 * with the public key is still returned if it was found and valid).
204 * @param fn name of the file
205 * @param unlink_garbage if GNUNET_YES, try to remove useless files
206 * @return HELLO of the file, NULL on error
208 static struct GNUNET_HELLO_Message *
209 read_host_file (const char *fn,
212 char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN;
213 const struct GNUNET_HELLO_Message *hello;
214 struct GNUNET_HELLO_Message *hello_clean;
216 struct GNUNET_TIME_Absolute now;
219 if (GNUNET_YES != GNUNET_DISK_file_test (fn))
221 size = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer));
222 hello = (const struct GNUNET_HELLO_Message *) buffer;
223 if ((size < sizeof (struct GNUNET_MessageHeader)) ||
224 (size != ntohs ((((const struct GNUNET_MessageHeader *) hello)->size)))
225 || (size != GNUNET_HELLO_size (hello)))
227 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
228 _("Failed to parse HELLO in file `%s'\n"),
230 if ( (GNUNET_YES == unlink_garbage) &&
232 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
235 now = GNUNET_TIME_absolute_get ();
237 GNUNET_HELLO_iterate_addresses (hello, GNUNET_YES, &discard_expired,
240 (void) GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &count_addresses,
244 /* no addresses left, remove from disk */
245 if ( (GNUNET_YES == unlink_garbage) &&
247 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
254 * Add a host to the list.
256 * @param identity the identity of the host
259 add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
261 struct HostEntry *entry;
264 entry = GNUNET_CONTAINER_multihashmap_get (hostmap, &identity->hashPubKey);
267 GNUNET_STATISTICS_update (stats, gettext_noop ("# peers known"), 1,
269 entry = GNUNET_malloc (sizeof (struct HostEntry));
270 entry->identity = *identity;
271 GNUNET_CONTAINER_multihashmap_put (hostmap, &entry->identity.hashPubKey, entry,
272 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
273 fn = get_host_filename (identity);
274 entry->hello = read_host_file (fn, GNUNET_YES);
281 * Remove a file that should not be there. LOG
282 * success or failure.
284 * @param fullname name of the file to remove
287 remove_garbage (const char *fullname)
289 if (0 == UNLINK (fullname))
290 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
292 ("File `%s' in directory `%s' does not match naming convention. "
293 "Removed.\n"), fullname, networkIdDirectory);
295 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
301 * Closure for 'hosts_directory_scan_callback'.
303 struct DirScanContext
306 * GNUNET_YES if we should remove files that are broken,
307 * GNUNET_NO if the directory we are iterating over should
308 * be treated as read-only by us.
313 * Counter for the number of (valid) entries found, incremented
314 * by one for each match.
316 unsigned int matched;
321 * Function that is called on each HELLO file in a particular directory.
322 * Try to parse the file and add the HELLO to our list.
324 * @param cls pointer to 'unsigned int' to increment for each file, or NULL
325 * if the file is from a read-only, read-once resource directory
326 * @param fullname name of the file to parse
327 * @return GNUNET_OK (continue iteration)
330 hosts_directory_scan_callback (void *cls, const char *fullname)
332 struct DirScanContext *dsc = cls;
333 struct GNUNET_PeerIdentity identity;
334 const char *filename;
335 struct HostEntry *entry;
336 struct GNUNET_HELLO_Message *hello;
337 struct GNUNET_PeerIdentity id;
339 if (GNUNET_YES != GNUNET_DISK_file_test (fullname))
340 return GNUNET_OK; /* ignore non-files */
341 if (strlen (fullname) < sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded))
343 if (GNUNET_YES == dsc->remove_files)
344 remove_garbage (fullname);
348 &fullname[strlen (fullname) -
349 sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) + 1];
350 if (DIR_SEPARATOR != filename[-1])
352 if (GNUNET_YES == dsc->remove_files)
353 remove_garbage (fullname);
357 GNUNET_CRYPTO_hash_from_string (filename, &identity.hashPubKey))
359 /* odd filename, but might still be valid, try getting identity from HELLO */
360 if ( (NULL != (hello = read_host_file (filename,
361 dsc->remove_files))) &&
363 GNUNET_HELLO_get_id (hello,
366 /* ok, found something valid, remember HELLO */
367 entry = GNUNET_malloc (sizeof (struct HostEntry));
368 entry->identity = id;
369 GNUNET_CONTAINER_multihashmap_put (hostmap, &entry->identity.hashPubKey, entry,
370 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
371 entry->hello = hello;
376 if (GNUNET_YES == dsc->remove_files)
377 remove_garbage (fullname);
381 add_host_to_known_hosts (&identity);
387 * Call this method periodically to scan data/hosts for new hosts.
390 * @param tc scheduler context, aborted if reason is shutdown
393 cron_scan_directory_data_hosts (void *cls,
394 const struct GNUNET_SCHEDULER_TaskContext *tc)
396 static unsigned int retries;
397 struct DirScanContext dsc;
399 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
401 if (GNUNET_SYSERR == GNUNET_DISK_directory_create (networkIdDirectory))
403 GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ,
404 GNUNET_SCHEDULER_PRIORITY_IDLE,
405 &cron_scan_directory_data_hosts, NULL);
409 dsc.remove_files = GNUNET_YES;
410 GNUNET_DISK_directory_scan (networkIdDirectory,
411 &hosts_directory_scan_callback, &dsc);
412 if ((0 == dsc.matched) && (0 == (++retries & 31)))
413 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
414 _("Still no peers found in `%s'!\n"), networkIdDirectory);
415 GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ,
416 GNUNET_SCHEDULER_PRIORITY_IDLE,
417 &cron_scan_directory_data_hosts,
423 * Bind a host address (hello) to a hostId.
425 * @param peer the peer for which this is a hello
426 * @param hello the verified (!) hello message
429 bind_address (const struct GNUNET_PeerIdentity *peer,
430 const struct GNUNET_HELLO_Message *hello)
433 struct HostEntry *host;
434 struct GNUNET_HELLO_Message *mrg;
435 struct GNUNET_TIME_Absolute delta;
438 add_host_to_known_hosts (peer);
439 host = GNUNET_CONTAINER_multihashmap_get (hostmap, &peer->hashPubKey);
440 GNUNET_assert (NULL != host);
441 if (NULL == host->hello)
443 host->hello = GNUNET_malloc (GNUNET_HELLO_size (hello));
444 memcpy (host->hello, hello, GNUNET_HELLO_size (hello));
448 mrg = GNUNET_HELLO_merge (host->hello, hello);
449 delta = GNUNET_HELLO_equals (mrg, host->hello, GNUNET_TIME_absolute_get ());
450 if (delta.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value)
452 /* no differences, just ignore the update */
456 GNUNET_free (host->hello);
459 fn = get_host_filename (peer);
460 if (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn))
463 (void) GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &count_addresses,
467 /* no valid addresses, don't put HELLO on disk; in fact,
468 if one exists on disk, remove it */
474 GNUNET_DISK_fn_write (fn, host->hello, GNUNET_HELLO_size (host->hello),
475 GNUNET_DISK_PERM_USER_READ |
476 GNUNET_DISK_PERM_USER_WRITE |
477 GNUNET_DISK_PERM_GROUP_READ |
478 GNUNET_DISK_PERM_OTHER_READ))
479 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn);
488 * Do transmit info about peer to given host.
490 * @param cls NULL to hit all hosts, otherwise specifies a particular target
492 * @param value information to transmit
493 * @return GNUNET_YES (continue to iterate)
496 add_to_tc (void *cls, const struct GNUNET_HashCode * key, void *value)
498 struct GNUNET_SERVER_TransmitContext *tc = cls;
499 struct HostEntry *pos = value;
500 struct InfoMessage *im;
502 char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN;
505 im = (struct InfoMessage *) buf;
506 if (pos->hello != NULL)
508 hs = GNUNET_HELLO_size (pos->hello);
510 GNUNET_SERVER_MAX_MESSAGE_SIZE -
511 sizeof (struct InfoMessage));
512 memcpy (&im[1], pos->hello, hs);
514 im->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
515 im->header.size = htons (sizeof (struct InfoMessage) + hs);
516 im->reserved = htonl (0);
517 im->peer = pos->identity;
518 GNUNET_SERVER_transmit_context_append_message (tc, &im->header);
524 * @brief delete expired HELLO entries in data/hosts/
526 * @param cls pointer to current time (struct GNUNET_TIME_Absolute)
527 * @param fn filename to test to see if the HELLO expired
528 * @return GNUNET_OK (continue iteration)
531 discard_hosts_helper (void *cls, const char *fn)
533 struct GNUNET_TIME_Absolute *now = cls;
534 char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN;
535 const struct GNUNET_HELLO_Message *hello;
536 struct GNUNET_HELLO_Message *new_hello;
540 size = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer));
541 if (size < sizeof (struct GNUNET_MessageHeader))
543 if (0 != UNLINK (fn))
544 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
545 GNUNET_ERROR_TYPE_BULK, "unlink", fn);
548 hello = (const struct GNUNET_HELLO_Message *) buffer;
550 GNUNET_HELLO_iterate_addresses (hello, GNUNET_YES, &discard_expired, now);
552 if (NULL != new_hello)
553 (void) GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &count_addresses, &cnt);
554 if ( (NULL != new_hello) && (0 < cnt) )
556 GNUNET_DISK_fn_write (fn, new_hello, GNUNET_HELLO_size (new_hello),
557 GNUNET_DISK_PERM_USER_READ |
558 GNUNET_DISK_PERM_USER_WRITE |
559 GNUNET_DISK_PERM_GROUP_READ |
560 GNUNET_DISK_PERM_OTHER_READ);
564 if (0 != UNLINK (fn))
565 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
566 GNUNET_ERROR_TYPE_BULK, "unlink", fn);
568 GNUNET_free_non_null (new_hello);
574 * Call this method periodically to scan data/hosts for ancient
578 * @param tc scheduler context, aborted if reason is shutdown
581 cron_clean_data_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
583 struct GNUNET_TIME_Absolute now;
585 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
587 now = GNUNET_TIME_absolute_get ();
588 GNUNET_DISK_directory_scan (networkIdDirectory, &discard_hosts_helper, &now);
589 GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, &cron_clean_data_hosts,
595 * Handle HELLO-message.
598 * @param client identification of the client
599 * @param message the actual message
602 handle_hello (void *cls, struct GNUNET_SERVER_Client *client,
603 const struct GNUNET_MessageHeader *message)
605 const struct GNUNET_HELLO_Message *hello;
606 struct GNUNET_PeerIdentity pid;
608 hello = (const struct GNUNET_HELLO_Message *) message;
609 if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid))
612 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
615 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received for peer `%4s'\n",
616 "HELLO", GNUNET_i2s (&pid));
617 bind_address (&pid, hello);
618 GNUNET_SERVER_receive_done (client, GNUNET_OK);
623 * Handle GET-message.
626 * @param client identification of the client
627 * @param message the actual message
630 handle_get (void *cls, struct GNUNET_SERVER_Client *client,
631 const struct GNUNET_MessageHeader *message)
633 const struct ListPeerMessage *lpm;
634 struct GNUNET_SERVER_TransmitContext *tc;
636 lpm = (const struct ListPeerMessage *) message;
637 GNUNET_break (0 == ntohl (lpm->reserved));
638 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received for peer `%4s'\n",
639 "GET", GNUNET_i2s (&lpm->peer));
640 tc = GNUNET_SERVER_transmit_context_create (client);
641 GNUNET_CONTAINER_multihashmap_get_multiple (hostmap, &lpm->peer.hashPubKey,
643 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
644 GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END);
645 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
650 * Handle GET-ALL-message.
653 * @param client identification of the client
654 * @param message the actual message
657 handle_get_all (void *cls, struct GNUNET_SERVER_Client *client,
658 const struct GNUNET_MessageHeader *message)
660 struct GNUNET_SERVER_TransmitContext *tc;
662 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received\n", "GET_ALL");
663 tc = GNUNET_SERVER_transmit_context_create (client);
664 GNUNET_CONTAINER_multihashmap_iterate (hostmap, &add_to_tc, tc);
665 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
666 GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END);
667 GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
672 * Pass the given client the information we have in the respective
673 * host entry; the client is already in the notification context.
675 * @param cls the 'struct GNUNET_SERVER_Client' to notify
676 * @param key key for the value (unused)
677 * @param value the 'struct HostEntry' to notify the client about
678 * @return GNUNET_YES (always, continue to iterate)
681 do_notify_entry (void *cls, const struct GNUNET_HashCode * key, void *value)
683 struct GNUNET_SERVER_Client *client = cls;
684 struct HostEntry *he = value;
685 struct InfoMessage *msg;
687 msg = make_info_message (he);
688 GNUNET_SERVER_notification_context_unicast (notify_list, client, &msg->header,
696 * Handle NOTIFY-message.
699 * @param client identification of the client
700 * @param message the actual message
703 handle_notify (void *cls, struct GNUNET_SERVER_Client *client,
704 const struct GNUNET_MessageHeader *message)
706 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received\n", "NOTIFY");
707 GNUNET_SERVER_client_mark_monitor (client);
708 GNUNET_SERVER_notification_context_add (notify_list, client);
709 GNUNET_CONTAINER_multihashmap_iterate (hostmap, &do_notify_entry, client);
710 GNUNET_SERVER_receive_done (client, GNUNET_OK);
715 * Release memory taken by a host entry.
718 * @param key key of the host entry
719 * @param value the 'struct HostEntry' to free
720 * @return GNUNET_YES (continue to iterate)
723 free_host_entry (void *cls, const struct GNUNET_HashCode * key, void *value)
725 struct HostEntry *he = value;
727 GNUNET_free_non_null (he->hello);
734 * Clean up our state. Called during shutdown.
737 * @param tc scheduler task context, unused
740 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
742 GNUNET_SERVER_notification_context_destroy (notify_list);
744 GNUNET_CONTAINER_multihashmap_iterate (hostmap, &free_host_entry, NULL);
745 GNUNET_CONTAINER_multihashmap_destroy (hostmap);
748 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
755 * Start up peerinfo service.
758 * @param server the initialized server
759 * @param cfg configuration to use
762 run (void *cls, struct GNUNET_SERVER_Handle *server,
763 const struct GNUNET_CONFIGURATION_Handle *cfg)
765 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
766 {&handle_hello, NULL, GNUNET_MESSAGE_TYPE_HELLO, 0},
767 {&handle_get, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET,
768 sizeof (struct ListPeerMessage)},
769 {&handle_get_all, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL,
770 sizeof (struct GNUNET_MessageHeader)},
771 {&handle_notify, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY,
772 sizeof (struct GNUNET_MessageHeader)},
777 struct DirScanContext dsc;
779 hostmap = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_YES);
780 stats = GNUNET_STATISTICS_create ("peerinfo", cfg);
781 notify_list = GNUNET_SERVER_notification_context_create (server, 0);
782 GNUNET_assert (GNUNET_OK ==
783 GNUNET_CONFIGURATION_get_value_filename (cfg, "peerinfo",
785 &networkIdDirectory));
786 GNUNET_DISK_directory_create (networkIdDirectory);
787 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
788 &cron_scan_directory_data_hosts, NULL);
789 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
790 &cron_clean_data_hosts, NULL);
791 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
793 GNUNET_SERVER_add_handlers (server, handlers);
794 ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
795 GNUNET_asprintf (&peerdir,
799 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
800 _("Importing HELLOs from `%s'\n"),
803 dsc.remove_files = GNUNET_NO;
804 GNUNET_DISK_directory_scan (peerdir,
805 &hosts_directory_scan_callback, &dsc);
806 GNUNET_free (peerdir);
811 * The main function for the peerinfo service.
813 * @param argc number of arguments from the command line
814 * @param argv command line arguments
815 * @return 0 ok, 1 on error
818 main (int argc, char *const *argv)
824 GNUNET_SERVICE_run (argc, argv, "peerinfo", GNUNET_SERVICE_OPTION_NONE,
825 &run, NULL)) ? 0 : 1;
826 GNUNET_free_non_null (networkIdDirectory);
831 /* end of gnunet-service-peerinfo.c */