[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33611 - in gnunet/src: include peerinfo util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33611 - in gnunet/src: include peerinfo util |
Date: |
Mon, 9 Jun 2014 10:54:49 +0200 |
Author: grothoff
Date: 2014-06-09 10:54:49 +0200 (Mon, 09 Jun 2014)
New Revision: 33611
Modified:
gnunet/src/include/gnunet_strings_lib.h
gnunet/src/peerinfo/gnunet-service-peerinfo.c
gnunet/src/peerinfo/peerinfo_api.c
gnunet/src/util/strings.c
Log:
-fixing doxygen, indentation
Modified: gnunet/src/include/gnunet_strings_lib.h
===================================================================
--- gnunet/src/include/gnunet_strings_lib.h 2014-06-09 06:58:07 UTC (rev
33610)
+++ gnunet/src/include/gnunet_strings_lib.h 2014-06-09 08:54:49 UTC (rev
33611)
@@ -278,10 +278,7 @@
/**
- * Convert binary data to ASCII encoding. The ASCII encoding is rather
- * GNUnet specific. It was chosen such that it only uses characters
- * in [0-9A-V], can be produced without complex arithmetics and uses a
- * small number of characters. The GNUnet encoding uses 103 characters.
+ * Convert binary data to ASCII encoding using Base32Hex (RFC 4648).
* Does not append 0-terminator, but returns a pointer to the place where
* it should be placed, if needed.
*
@@ -300,8 +297,8 @@
/**
- * Convert ASCII encoding back to data
- * out_size must match exactly the size of the data before it was encoded.
+ * Convert Base32hex encoding back to data.
+ * @a out_size must match exactly the size of the data before it was encoded.
*
* @param enc the encoding
* @param enclen number of characters in 'enc' (without 0-terminator, which
can be missing)
Modified: gnunet/src/peerinfo/gnunet-service-peerinfo.c
===================================================================
--- gnunet/src/peerinfo/gnunet-service-peerinfo.c 2014-06-09 06:58:07 UTC
(rev 33610)
+++ gnunet/src/peerinfo/gnunet-service-peerinfo.c 2014-06-09 08:54:49 UTC
(rev 33611)
@@ -462,13 +462,17 @@
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_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_multipeermap_put (hostmap,
+ &entry->identity,
+ entry,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
notify_all (entry);
fn = get_host_filename (identity);
@@ -499,17 +503,18 @@
{
if (0 == UNLINK (fullname))
GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
- _
- ("File `%s' in directory `%s' does not match naming
convention. "
- "Removed.\n"), fullname, networkIdDirectory);
+ _("File `%s' in directory `%s' does not match naming
convention. Removed.\n"),
+ fullname,
+ networkIdDirectory);
else
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "unlink", fullname);
+ "unlink",
+ fullname);
}
/**
- * Closure for 'hosts_directory_scan_callback'.
+ * Closure for #hosts_directory_scan_callback().
*/
struct DirScanContext
{
@@ -538,7 +543,8 @@
* @return #GNUNET_OK (continue iteration)
*/
static int
-hosts_directory_scan_callback (void *cls, const char *fullname)
+hosts_directory_scan_callback (void *cls,
+ const char *fullname)
{
struct DirScanContext *dsc = cls;
struct GNUNET_PeerIdentity identity;
@@ -590,9 +596,10 @@
remove_garbage (fullname);
return GNUNET_OK;
}
- if (GNUNET_OK == GNUNET_CRYPTO_eddsa_public_key_from_string (filename,
- strlen
(filename),
-
&identity.public_key))
+ if (GNUNET_OK ==
+ GNUNET_CRYPTO_eddsa_public_key_from_string (filename,
+ strlen (filename),
+ &identity.public_key))
{
if (0 != memcmp (&id, &identity, sizeof (id_friend)))
{
@@ -608,14 +615,16 @@
add_host_to_known_hosts (&id);
if (NULL != r.hello)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating peer `%s' public HELLO \n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Updating peer `%s' public HELLO \n",
GNUNET_i2s (&id));
update_hello (&id, r.hello);
GNUNET_free (r.hello);
}
if (NULL != r.friend_only_hello)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating peer `%s' friend only HELLO
\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Updating peer `%s' friend only HELLO \n",
GNUNET_i2s (&id));
update_hello (&id, r.friend_only_hello);
GNUNET_free (r.friend_only_hello);
@@ -650,12 +659,14 @@
dsc.matched = 0;
dsc.remove_files = GNUNET_YES;
GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
- _("Scanning directory `%s'\n"), networkIdDirectory);
+ _("Scanning directory `%s'\n"),
+ networkIdDirectory);
GNUNET_DISK_directory_scan (networkIdDirectory,
&hosts_directory_scan_callback, &dsc);
if ((0 == dsc.matched) && (0 == (++retries & 31)))
GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
- _("Still no peers found in `%s'!\n"), networkIdDirectory);
+ _("Still no peers found in `%s'!\n"),
+ networkIdDirectory);
GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ,
GNUNET_SCHEDULER_PRIORITY_IDLE,
&cron_scan_directory_data_hosts,
@@ -663,6 +674,13 @@
}
+/**
+ * Update the HELLO of a friend by merging the addresses.
+ *
+ * @param hello original hello
+ * @param friend_hello hello with additional addresses
+ * @return merged HELLO
+ */
static struct GNUNET_HELLO_Message *
update_friend_hello (const struct GNUNET_HELLO_Message *hello,
const struct GNUNET_HELLO_Message *friend_hello)
@@ -719,9 +737,10 @@
GNUNET_assert (NULL != host);
friend_hello_type = GNUNET_HELLO_is_friend_only (hello);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating %s HELLO for `%s'\n",
- (GNUNET_YES == friend_hello_type) ? "friend-only" :
"public",
- GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Updating %s HELLO for `%s'\n",
+ (GNUNET_YES == friend_hello_type) ? "friend-only" : "public",
+ GNUNET_i2s (peer));
dest = NULL;
if (GNUNET_YES == friend_hello_type)
@@ -745,9 +764,10 @@
if (delta.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us)
{
/* no differences, just ignore the update */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No change in %s HELLO for `%s'\n",
- (GNUNET_YES == friend_hello_type) ? "friend-only" :
"public",
- GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "No change in %s HELLO for `%s'\n",
+ (GNUNET_YES == friend_hello_type) ? "friend-only" : "public",
+ GNUNET_i2s (peer));
GNUNET_free (mrg);
return;
}
@@ -755,7 +775,8 @@
(*dest) = mrg;
}
- if ((NULL != (host->hello)) && (GNUNET_NO == friend_hello_type))
+ if ( (NULL != (host->hello)) &&
+ (GNUNET_NO == friend_hello_type) )
{
/* Update friend only hello */
mrg = update_friend_hello (host->hello, host->friend_only_hello);
@@ -765,20 +786,25 @@
}
if (NULL != host->hello)
- GNUNET_assert ((GNUNET_NO == GNUNET_HELLO_is_friend_only (host->hello)));
+ GNUNET_assert ((GNUNET_NO ==
+ GNUNET_HELLO_is_friend_only (host->hello)));
if (NULL != host->friend_only_hello)
- GNUNET_assert ((GNUNET_YES ==
GNUNET_HELLO_is_friend_only(host->friend_only_hello)));
+ GNUNET_assert ((GNUNET_YES ==
+ GNUNET_HELLO_is_friend_only (host->friend_only_hello)));
fn = get_host_filename (peer);
if ( (NULL != fn) &&
- (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn)) )
+ (GNUNET_OK ==
+ GNUNET_DISK_directory_create_for_file (fn)) )
{
store_hello = GNUNET_NO;
size = 0;
cnt = 0;
if (NULL != host->hello)
(void) GNUNET_HELLO_iterate_addresses (host->hello,
- GNUNET_NO, &count_addresses, &cnt);
+ GNUNET_NO,
+ &count_addresses,
+ &cnt);
if (cnt > 0)
{
store_hello = GNUNET_YES;
@@ -786,8 +812,10 @@
}
cnt = 0;
if (NULL != host->friend_only_hello)
- (void) GNUNET_HELLO_iterate_addresses (host->friend_only_hello,
GNUNET_NO,
- &count_addresses, &cnt);
+ (void) GNUNET_HELLO_iterate_addresses (host->friend_only_hello,
+ GNUNET_NO,
+ &count_addresses,
+ &cnt);
store_friend_hello = GNUNET_NO;
if (0 < cnt)
{
@@ -795,7 +823,8 @@
size += GNUNET_HELLO_size (host->friend_only_hello);
}
- if ((GNUNET_NO == store_hello) && (GNUNET_NO == store_friend_hello))
+ if ( (GNUNET_NO == store_hello) &&
+ (GNUNET_NO == store_friend_hello) )
{
/* no valid addresses, don't put HELLO on disk; in fact,
if one exists on disk, remove it */
@@ -808,7 +837,8 @@
if (GNUNET_YES == store_hello)
{
- memcpy (buffer, host->hello, GNUNET_HELLO_size (host->hello));
+ memcpy (buffer, host->hello,
+ GNUNET_HELLO_size (host->hello));
pos += GNUNET_HELLO_size (host->hello);
}
if (GNUNET_YES == store_friend_hello)
@@ -825,7 +855,8 @@
GNUNET_DISK_PERM_OTHER_READ))
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn);
else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stored %s %s HELLO in %s with
total size %u\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Stored %s %s HELLO in %s with total size %u\n",
(GNUNET_YES == store_friend_hello) ? "friend-only": "",
(GNUNET_YES == store_hello) ? "public": "",
fn, size);
@@ -846,7 +877,9 @@
* @return #GNUNET_YES (continue to iterate)
*/
static int
-add_to_tc (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
+add_to_tc (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
{
struct TransmitContext *tc = cls;
struct HostEntry *pos = value;
@@ -857,7 +890,8 @@
hs = 0;
im = (struct InfoMessage *) buf;
- if ((pos->hello != NULL) && (GNUNET_NO == tc->friend_only))
+ if ( (NULL != pos->hello) &&
+ (GNUNET_NO == tc->friend_only) )
{
/* Copy public HELLO */
hs = GNUNET_HELLO_size (pos->hello);
@@ -868,7 +902,8 @@
"Sending public HELLO with size %u for peer `%4s'\n",
hs, GNUNET_i2s (key));
}
- else if ((pos->friend_only_hello != NULL) && (GNUNET_YES == tc->friend_only))
+ else if ( (NULL != pos->friend_only_hello) &&
+ (GNUNET_YES == tc->friend_only) )
{
/* Copy friend only HELLO */
hs = GNUNET_HELLO_size (pos->friend_only_hello);
@@ -877,13 +912,14 @@
memcpy (&im[1], pos->friend_only_hello, hs);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending friend-only HELLO with size %u for peer `%4s'\n",
- hs, GNUNET_i2s (key));
+ hs,
+ GNUNET_i2s (key));
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding no HELLO for peer `%s'\n",
- GNUNET_i2s (key));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding no HELLO for peer `%s'\n",
+ GNUNET_i2s (key));
}
im->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
@@ -898,12 +934,13 @@
/**
* @brief delete expired HELLO entries in directory
*
- * @param cls pointer to current time (struct GNUNET_TIME_Absolute)
+ * @param cls pointer to current time (`struct GNUNET_TIME_Absolute *`)
* @param fn filename to test to see if the HELLO expired
* @return #GNUNET_OK (continue iteration)
*/
static int
-discard_hosts_helper (void *cls, const char *fn)
+discard_hosts_helper (void *cls,
+ const char *fn)
{
struct GNUNET_TIME_Absolute *now = cls;
char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN;
@@ -917,7 +954,6 @@
unsigned int cnt;
char *writebuffer;
-
read_size = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer));
if (read_size < sizeof (struct GNUNET_MessageHeader))
{
@@ -940,13 +976,18 @@
/* Invalid data, discard */
if (0 != UNLINK (fn))
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
- GNUNET_ERROR_TYPE_BULK, "unlink", fn);
+ GNUNET_ERROR_TYPE_BULK,
+ "unlink", fn);
return GNUNET_OK;
}
- new_hello = GNUNET_HELLO_iterate_addresses (hello, GNUNET_YES,
&discard_expired, now);
+ new_hello = GNUNET_HELLO_iterate_addresses (hello,
+ GNUNET_YES,
+ &discard_expired, now);
cnt = 0;
if (NULL != new_hello)
- (void) GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO,
&count_addresses, &cnt);
+ (void) GNUNET_HELLO_iterate_addresses (hello,
+ GNUNET_NO,
+ &count_addresses, &cnt);
if ( (NULL != new_hello) && (0 < cnt) )
{
/* Store new HELLO to write it when done */
@@ -968,7 +1009,8 @@
}
else if (0 != UNLINK (fn))
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
- GNUNET_ERROR_TYPE_BULK, "unlink", fn);
+ GNUNET_ERROR_TYPE_BULK,
+ "unlink", fn);
GNUNET_free (writebuffer);
return GNUNET_OK;
@@ -983,7 +1025,8 @@
* @param tc scheduler context, aborted if reason is shutdown
*/
static void
-cron_clean_data_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext
*tc)
+cron_clean_data_hosts (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_TIME_Absolute now;
@@ -991,9 +1034,13 @@
return;
now = GNUNET_TIME_absolute_get ();
GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
- _("Cleaning up directory `%s'\n"), networkIdDirectory);
- GNUNET_DISK_directory_scan (networkIdDirectory, &discard_hosts_helper, &now);
- GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, &cron_clean_data_hosts,
+ _("Cleaning up directory `%s'\n"),
+ networkIdDirectory);
+ GNUNET_DISK_directory_scan (networkIdDirectory,
+ &discard_hosts_helper,
+ &now);
+ GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ,
+ &cron_clean_data_hosts,
NULL);
}
@@ -1006,7 +1053,8 @@
* @param message the actual message
*/
static void
-handle_hello (void *cls, struct GNUNET_SERVER_Client *client,
+handle_hello (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_HELLO_Message *hello;
@@ -1019,8 +1067,10 @@
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received for peer
`%4s'\n",
- "HELLO", GNUNET_i2s (&pid));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "`%s' message received for peer `%4s'\n",
+ "HELLO",
+ GNUNET_i2s (&pid));
add_host_to_known_hosts (&pid);
update_hello (&pid, hello);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -1035,15 +1085,18 @@
* @param message the actual message
*/
static void
-handle_get (void *cls, struct GNUNET_SERVER_Client *client,
+handle_get (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct ListPeerMessage *lpm;
struct TransmitContext tcx;
lpm = (const struct ListPeerMessage *) message;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received for peer
`%4s'\n",
- "GET", GNUNET_i2s (&lpm->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "`%s' message received for peer `%4s'\n",
+ "GET",
+ GNUNET_i2s (&lpm->peer));
tcx.friend_only = ntohl (lpm->include_friend_only);
tcx.tc = GNUNET_SERVER_transmit_context_create (client);
GNUNET_CONTAINER_multipeermap_get_multiple (hostmap, &lpm->peer,
@@ -1070,10 +1123,14 @@
lapm = (const struct ListAllPeersMessage *) message;
tcx.friend_only = ntohl (lapm->include_friend_only);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received\n", "GET_ALL");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "`%s' message received\n",
+ "GET_ALL");
GNUNET_SERVER_disable_receive_done_warning (client);
tcx.tc = GNUNET_SERVER_transmit_context_create (client);
- GNUNET_CONTAINER_multipeermap_iterate (hostmap, &add_to_tc, &tcx);
+ GNUNET_CONTAINER_multipeermap_iterate (hostmap,
+ &add_to_tc,
+ &tcx);
GNUNET_SERVER_transmit_context_append_data (tcx.tc, NULL, 0,
GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END);
GNUNET_SERVER_transmit_context_run (tcx.tc, GNUNET_TIME_UNIT_FOREVER_REL);
@@ -1091,13 +1148,16 @@
* @return #GNUNET_YES (always, continue to iterate)
*/
static int
-do_notify_entry (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
+do_notify_entry (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
{
struct NotificationContext *nc = cls;
struct HostEntry *he = value;
struct InfoMessage *msg;
- if ((NULL == he->hello) && (GNUNET_NO == nc->include_friend_only))
+ if ( (NULL == he->hello) &&
+ (GNUNET_NO == nc->include_friend_only) )
{
/* We have no public hello */
return GNUNET_YES;
@@ -1128,7 +1188,8 @@
* @param message the actual message
*/
static void
-handle_notify (void *cls, struct GNUNET_SERVER_Client *client,
+handle_notify (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
struct NotifyMessage *nm = (struct NotifyMessage *) message;
@@ -1156,7 +1217,8 @@
* @param client server client
*/
static void
-disconnect_cb (void *cls,struct GNUNET_SERVER_Client *client)
+disconnect_cb (void *cls,
+ struct GNUNET_SERVER_Client *client)
{
struct NotificationContext *cur;
@@ -1214,7 +1276,9 @@
GNUNET_CONTAINER_DLL_remove (nc_head, nc_tail, cur);
GNUNET_free (cur);
}
- GNUNET_CONTAINER_multipeermap_iterate (hostmap, &free_host_entry, NULL);
+ GNUNET_CONTAINER_multipeermap_iterate (hostmap,
+ &free_host_entry,
+ NULL);
GNUNET_CONTAINER_multipeermap_destroy (hostmap);
if (NULL != stats)
{
@@ -1232,7 +1296,8 @@
* @param cfg configuration to use
*/
static void
-run (void *cls, struct GNUNET_SERVER_Handle *server,
+run (void *cls,
+ struct GNUNET_SERVER_Handle *server,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
static const struct GNUNET_SERVER_MessageHandler handlers[] = {
@@ -1255,10 +1320,13 @@
stats = GNUNET_STATISTICS_create ("peerinfo", cfg);
notify_list = GNUNET_SERVER_notification_context_create (server, 0);
noio = GNUNET_CONFIGURATION_get_value_yesno (cfg, "peerinfo", "NO_IO");
- use_included = GNUNET_CONFIGURATION_get_value_yesno (cfg, "peerinfo",
"USE_INCLUDED_HELLOS");
+ use_included = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "peerinfo",
+ "USE_INCLUDED_HELLOS");
if (GNUNET_SYSERR == use_included)
use_included = GNUNET_NO;
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+ &shutdown_task,
NULL);
if (GNUNET_YES != noio)
{
@@ -1281,25 +1349,32 @@
if (GNUNET_YES == use_included)
{
ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
- GNUNET_asprintf (&peerdir, "%shellos", ip);
+ GNUNET_asprintf (&peerdir,
+ "%shellos",
+ ip);
GNUNET_free(ip);
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Importing HELLOs from `%s'\n"),
- peerdir);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Importing HELLOs from `%s'\n"),
+ peerdir);
dsc.matched = 0;
dsc.remove_files = GNUNET_NO;
- GNUNET_DISK_directory_scan (peerdir, &hosts_directory_scan_callback,
- &dsc);
+ GNUNET_DISK_directory_scan (peerdir,
+ &hosts_directory_scan_callback,
+ &dsc);
GNUNET_free (peerdir);
}
else
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Skipping import of included
HELLOs\n"));
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ _("Skipping import of included HELLOs\n"));
}
}
GNUNET_SERVER_add_handlers (server, handlers);
- GNUNET_SERVER_disconnect_notify (server, &disconnect_cb, NULL) ;
+ GNUNET_SERVER_disconnect_notify (server,
+ &disconnect_cb,
+ NULL);
}
@@ -1311,13 +1386,16 @@
* @return 0 ok, 1 on error
*/
int
-main (int argc, char *const *argv)
+main (int argc,
+ char *const *argv)
{
int ret;
ret =
(GNUNET_OK ==
- GNUNET_SERVICE_run (argc, argv, "peerinfo", GNUNET_SERVICE_OPTION_NONE,
+ GNUNET_SERVICE_run (argc, argv,
+ "peerinfo",
+ GNUNET_SERVICE_OPTION_NONE,
&run, NULL)) ? 0 : 1;
GNUNET_free_non_null (networkIdDirectory);
return ret;
Modified: gnunet/src/peerinfo/peerinfo_api.c
===================================================================
--- gnunet/src/peerinfo/peerinfo_api.c 2014-06-09 06:58:07 UTC (rev 33610)
+++ gnunet/src/peerinfo/peerinfo_api.c 2014-06-09 08:54:49 UTC (rev 33611)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2004, 2005, 2007, 2009, 2010, 2012 Christian Grothoff
(and other contributing authors)
+ (C) 2001-2014 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -98,7 +98,7 @@
GNUNET_PEERINFO_Processor callback;
/**
- * Closure for 'callback'.
+ * Closure for @e callback.
*/
void *callback_cls;
@@ -123,12 +123,12 @@
struct GNUNET_PeerIdentity peer;
/**
- * Is 'peer' set?
+ * Is @e peer set?
*/
int have_peer;
/**
- * Set to GNUNET_YES if we are currently receiving replies from the
+ * Set to #GNUNET_YES if we are currently receiving replies from the
* service.
*/
int request_transmitted;
@@ -212,7 +212,7 @@
* Disconnect from the peerinfo service. Note that all iterators must
* have completed or have been cancelled by the time this function is
* called (otherwise, calling this function is a serious error).
- * Furthermore, if 'GNUNET_PEERINFO_add_peer' operations are still
+ * Furthermore, if #GNUNET_PEERINFO_add_peer() operations are still
* pending, they will be cancelled silently on disconnect.
*
* @param h handle to disconnect
@@ -233,7 +233,8 @@
{
GNUNET_CONTAINER_DLL_remove (h->ac_head, h->ac_tail, ac);
if (NULL != ac->cont)
- ac->cont (ac->cont_cls, _("aborted due to explicit disconnect request"));
+ ac->cont (ac->cont_cls,
+ _("aborted due to explicit disconnect request"));
GNUNET_free (ac);
}
if (NULL != h->th)
@@ -277,11 +278,12 @@
/**
* Task scheduled to re-try connecting to the peerinfo service.
*
- * @param cls the 'struct GNUNET_PEERINFO_Handle'
+ * @param cls the `struct GNUNET_PEERINFO_Handle *`
* @param tc scheduler context
*/
static void
-reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+reconnect_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_PEERINFO_Handle *h = cls;
@@ -318,7 +320,8 @@
if (NULL == h->client)
{
h->r_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
&reconnect_task,
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &reconnect_task,
h);
return;
}
@@ -330,13 +333,15 @@
* Transmit the request at the head of the transmission queue
* and trigger continuation (if any).
*
- * @param cls the 'struct GNUNET_PEERINFO_Handle' (with the queue)
- * @param size size of the buffer (0 on error)
+ * @param cls the `struct GNUNET_PEERINFO_Handle *` (with the queue)
+ * @param size size of @a buf (0 on error)
* @param buf where to copy the message
- * @return number of bytes copied to buf
+ * @return number of bytes copied to @a buf
*/
static size_t
-do_transmit (void *cls, size_t size, void *buf)
+do_transmit (void *cls,
+ size_t size,
+ void *buf)
{
struct GNUNET_PEERINFO_Handle *h = cls;
struct GNUNET_PEERINFO_AddContext *ac = h->ac_head;
@@ -349,11 +354,13 @@
{
/* peerinfo service died */
LOG (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
- "Failed to transmit message to `%s' service.\n", "PEERINFO");
+ "Failed to transmit message to `%s' service.\n",
+ "PEERINFO");
GNUNET_CONTAINER_DLL_remove (h->ac_head, h->ac_tail, ac);
reconnect (h);
if (NULL != ac->cont)
- ac->cont (ac->cont_cls, _("failed to transmit request (service down?)"));
+ ac->cont (ac->cont_cls,
+ _("failed to transmit request (service down?)"));
GNUNET_free (ac);
return 0;
}
@@ -365,7 +372,9 @@
return 0;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitting request of size %u to `%s' service.\n", ret, "PEERINFO");
+ "Transmitting request of size %u to `%s' service.\n",
+ ret,
+ "PEERINFO");
memcpy (buf, &ac[1], ret);
GNUNET_CONTAINER_DLL_remove (h->ac_head, h->ac_tail, ac);
trigger_transmit (h);
@@ -398,7 +407,8 @@
return;
}
h->th =
- GNUNET_CLIENT_notify_transmit_ready (h->client, ac->size,
+ GNUNET_CLIENT_notify_transmit_ready (h->client,
+ ac->size,
GNUNET_TIME_UNIT_FOREVER_REL,
GNUNET_YES,
&do_transmit, h);
@@ -408,7 +418,7 @@
/**
* Add a host to the persistent list. This method operates in
* semi-reliable mode: if the transmission is not completed by
- * the time 'GNUNET_PEERINFO_disconnect' is called, it will be
+ * the time #GNUNET_PEERINFO_disconnect() is called, it will be
* aborted. Furthermore, if a second HELLO is added for the
* same peer before the first one was transmitted, PEERINFO may
* merge the two HELLOs prior to transmission to the service.
@@ -416,7 +426,7 @@
* @param h handle to the peerinfo service
* @param hello the verified (!) HELLO message
* @param cont continuation to call when done, NULL is allowed
- * @param cont_cls closure for 'cont'
+ * @param cont_cls closure for @a cont
* @return handle to cancel add operation; all pending
* 'add' operations will be cancelled automatically
* on disconnect, so it is not necessary to keep this
@@ -436,7 +446,9 @@
GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_id (hello, &peer));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Adding peer `%s' to PEERINFO database (%u bytes of `%s')\n",
- GNUNET_i2s (&peer), hs, "HELLO");
+ GNUNET_i2s (&peer),
+ hs,
+ "HELLO");
ac = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_AddContext) + hs);
ac->h = h;
ac->size = hs;
@@ -451,7 +463,7 @@
/**
* Cancel pending 'add' operation. Must only be called before
- * either 'cont' or 'GNUNET_PEERINFO_disconnect' are invoked.
+ * either 'cont' or #GNUNET_PEERINFO_disconnect() are invoked.
*
* @param ac handle for the add operation to cancel
*/
@@ -475,7 +487,8 @@
* @param msg message received, NULL on timeout or fatal error
*/
static void
-peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
+peerinfo_handler (void *cls,
+ const struct GNUNET_MessageHeader *msg)
{
struct GNUNET_PEERINFO_Handle *h = cls;
struct GNUNET_PEERINFO_IteratorContext *ic = h->ic_head;
@@ -519,14 +532,17 @@
{
/* normal end of list of peers, signal end, process next pending request */
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received end of list of peers from `%s' service\n", "PEERINFO");
+ "Received end of list of peers from `%s' service\n",
+ "PEERINFO");
GNUNET_PEERINFO_iterate_cancel (ic);
trigger_transmit (h);
if ( (GNUNET_NO == h->in_receive) &&
(NULL != h->ic_head) )
{
h->in_receive = GNUNET_YES;
- GNUNET_CLIENT_receive (h->client, &peerinfo_handler, h,
+ GNUNET_CLIENT_receive (h->client,
+ &peerinfo_handler,
+ h,
GNUNET_TIME_absolute_get_remaining
(h->ic_head->timeout));
}
if (NULL != cb)
@@ -550,7 +566,9 @@
im = (const struct InfoMessage *) msg;
GNUNET_break (0 == ntohl (im->reserved));
if ( (GNUNET_YES == ic->have_peer) &&
- (0 != memcmp (&ic->peer, &im->peer, sizeof (struct
GNUNET_PeerIdentity))) )
+ (0 != memcmp (&ic->peer,
+ &im->peer,
+ sizeof (struct GNUNET_PeerIdentity))) )
{
/* bogus message (from a different iteration call?); out of sequence! */
LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -562,7 +580,9 @@
GNUNET_PEERINFO_iterate_cancel (ic);
reconnect (h);
if (NULL != cb)
- cb (cb_cls, NULL, NULL,
+ cb (cb_cls,
+ NULL,
+ NULL,
_("Received invalid message from `PEERINFO' service."));
return;
}
@@ -577,7 +597,9 @@
GNUNET_PEERINFO_iterate_cancel (ic);
reconnect (h);
if (NULL != cb)
- cb (cb_cls, NULL, NULL,
+ cb (cb_cls,
+ NULL,
+ NULL,
_("Received invalid message from `PEERINFO' service."));
return;
}
@@ -588,18 +610,24 @@
GNUNET_PEERINFO_iterate_cancel (ic);
reconnect (h);
if (NULL != cb)
- cb (cb_cls, NULL, NULL,
+ cb (cb_cls,
+ NULL,
+ NULL,
_("Received invalid message from `PEERINFO' service."));
return;
}
- if (0 != memcmp (&im->peer, &id, sizeof (struct GNUNET_PeerIdentity)))
+ if (0 != memcmp (&im->peer,
+ &id,
+ sizeof (struct GNUNET_PeerIdentity)))
{
/* malformed message */
GNUNET_break (0);
GNUNET_PEERINFO_iterate_cancel (ic);
reconnect (h);
if (NULL != cb)
- cb (cb_cls, NULL, NULL,
+ cb (cb_cls,
+ NULL,
+ NULL,
_("Received invalid message from `PEERINFO' service."));
return;
}
@@ -608,13 +636,20 @@
/* normal data message */
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received %u bytes of `%s' information about peer `%s' from `%s'
service\n",
- (hello == NULL) ? 0 : (unsigned int) GNUNET_HELLO_size (hello), "HELLO",
- GNUNET_i2s (&im->peer), "PEERINFO");
+ (hello == NULL) ? 0 : (unsigned int) GNUNET_HELLO_size (hello),
+ "HELLO",
+ GNUNET_i2s (&im->peer),
+ "PEERINFO");
h->in_receive = GNUNET_YES;
- GNUNET_CLIENT_receive (h->client, &peerinfo_handler, h,
+ GNUNET_CLIENT_receive (h->client,
+ &peerinfo_handler,
+ h,
GNUNET_TIME_absolute_get_remaining (ic->timeout));
if (NULL != cb)
- cb (cb_cls, &im->peer, hello, NULL);
+ cb (cb_cls,
+ &im->peer,
+ hello,
+ NULL);
}
@@ -622,11 +657,12 @@
* We've transmitted the iteration request. Now get ready to process
* the results (or handle transmission error).
*
- * @param cls the 'struct GNUNET_PEERINFO_IteratorContext'
+ * @param cls the `struct GNUNET_PEERINFO_IteratorContext *`
* @param emsg error message, NULL if transmission worked
*/
static void
-iterator_start_receive (void *cls, const char *emsg)
+iterator_start_receive (void *cls,
+ const char *emsg)
{
struct GNUNET_PEERINFO_IteratorContext *ic = cls;
struct GNUNET_PEERINFO_Handle *h = ic->h;
@@ -644,13 +680,16 @@
cb (cb_cls, NULL, NULL, emsg);
return;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Waiting for response from `%s' service.\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Waiting for response from `%s' service.\n",
"PEERINFO");
ic->request_transmitted = GNUNET_YES;
if (GNUNET_NO == h->in_receive)
{
h->in_receive = GNUNET_YES;
- GNUNET_CLIENT_receive (h->client, &peerinfo_handler, h,
+ GNUNET_CLIENT_receive (h->client,
+ &peerinfo_handler,
+ h,
GNUNET_TIME_absolute_get_remaining (ic->timeout));
}
}
@@ -659,11 +698,12 @@
/**
* Peerinfo iteration request has timed out.
*
- * @param cls the 'struct GNUNET_PEERINFO_IteratorContext*'
+ * @param cls the `struct GNUNET_PEERINFO_IteratorContext *`
* @param tc scheduler context
*/
static void
-signal_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+signal_timeout (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_PEERINFO_IteratorContext *ic = cls;
GNUNET_PEERINFO_Processor cb;
@@ -674,7 +714,9 @@
cb_cls = ic->callback_cls;
GNUNET_PEERINFO_iterate_cancel (ic);
if (NULL != cb)
- cb (cb_cls, NULL, NULL,
+ cb (cb_cls,
+ NULL,
+ NULL,
_("Timeout transmitting iteration request to `PEERINFO' service."));
}
@@ -685,23 +727,24 @@
* with a NULL pointer. After that final invocation, the iterator
* context must no longer be used.
*
- * Instead of calling this function with 'peer == NULL' it is often
- * better to use 'GNUNET_PEERINFO_notify'.
+ * Instead of calling this function with `peer == NULL` it is often
+ * better to use #GNUNET_PEERINFO_notify().
*
* @param h handle to the peerinfo service
* @param include_friend_only include HELLO messages for friends only
* @param peer restrict iteration to this peer only (can be NULL)
* @param timeout how long to wait until timing out
* @param callback the method to call for each peer
- * @param callback_cls closure for callback
+ * @param callback_cls closure for @a callback
* @return iterator context
*/
struct GNUNET_PEERINFO_IteratorContext *
GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
-
int include_friend_only,
+ int include_friend_only,
const struct GNUNET_PeerIdentity *peer,
struct GNUNET_TIME_Relative timeout,
- GNUNET_PEERINFO_Processor callback, void
*callback_cls)
+ GNUNET_PEERINFO_Processor callback,
+ void *callback_cls)
{
struct ListAllPeersMessage *lapm;
struct ListPeerMessage *lpm;
@@ -781,7 +824,9 @@
ic);
if (NULL != ic->ac)
{
- GNUNET_CONTAINER_DLL_remove (h->ac_head, h->ac_tail, ic->ac);
+ GNUNET_CONTAINER_DLL_remove (h->ac_head,
+ h->ac_tail,
+ ic->ac);
GNUNET_free (ic->ac);
}
GNUNET_free (ic);
Modified: gnunet/src/util/strings.c
===================================================================
--- gnunet/src/util/strings.c 2014-06-09 06:58:07 UTC (rev 33610)
+++ gnunet/src/util/strings.c 2014-06-09 08:54:49 UTC (rev 33611)
@@ -801,10 +801,7 @@
/**
- * Convert binary data to ASCII encoding. The ASCII encoding is rather
- * GNUnet specific. It was chosen such that it only uses characters
- * in [0-9A-V], can be produced without complex arithmetics and uses a
- * small number of characters.
+ * Convert binary data to ASCII encoding using Base32Hex (RFC 4648).
* Does not append 0-terminator, but returns a pointer to the place where
* it should be placed, if needed.
*
@@ -869,8 +866,8 @@
/**
- * Convert ASCII encoding back to data
- * out_size must match exactly the size of the data before it was encoded.
+ * Convert Base32hex encoding back to data.
+ * @a out_size must match exactly the size of the data before it was encoded.
*
* @param enc the encoding
* @param enclen number of characters in @a enc (without 0-terminator, which
can be missing)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33611 - in gnunet/src: include peerinfo util,
gnunet <=