const char *guard;
guard = va_arg (va, const char *);
- if (0 == memcmp (guard,
- "seen-set-size",
- strlen ("seen-set-size")))
+ if (0 == strcmp (guard,
+ "seen-set-size"))
bf_size = compute_bloomfilter_size (va_arg (va, unsigned int));
- else if (0 == memcmp (guard,
- "filter-size",
- strlen ("filter-size")))
+ else if (0 == strcmp (guard,
+ "filter-size"))
bf_size = va_arg (va, unsigned int);
else
{
const char *guard;
guard = va_arg (va, const char *);
- if (0 == memcmp (guard,
- "seen-set-size",
- strlen ("seen-set-size")))
+ if (0 == strcmp (guard,
+ "seen-set-size"))
bf_size = compute_bloomfilter_size (va_arg (va, unsigned int));
- else if (0 == memcmp (guard,
- "filter-size",
- strlen ("filter-size")))
+ else if (0 == strcmp (guard,
+ "filter-size"))
bf_size = va_arg (va, unsigned int);
else
{
meta_length =
sizeof (struct GNUNET_PeerIdentity) * (get_path_length + put_path_length);
data_length = msize - meta_length;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Giving %u byte reply for %s to application\n",
- (unsigned int) data_length,
- GNUNET_h2s (key));
put_path = (const struct GNUNET_PeerIdentity *) &crm[1];
get_path = &put_path[put_path_length];
+ {
+ char *pp;
+ char *gp;
+
+ gp = GNUNET_STRINGS_pp2s (get_path,
+ get_path_length);
+ pp = GNUNET_STRINGS_pp2s (put_path,
+ put_path_length);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Giving %u byte reply for %s to application (GP: %s, PP: %s)\n",
+ (unsigned int) data_length,
+ GNUNET_h2s (key),
+ gp,
+ pp);
+ GNUNET_free (gp);
+ GNUNET_free (pp);
+ }
data = &get_path[get_path_length];
/* remember that we've seen this result */
GNUNET_CRYPTO_hash (data,
if (GNUNET_YES == log_route_details_stderr)
{
char *tmp;
+ char *pp;
+ pp = GNUNET_STRINGS_pp2s (put_path,
+ putlen);
tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
- "R5N PUT %s: %s->%s (%u, %u=>%u)\n",
+ "R5N PUT %s: %s->%s (%u, %u=>%u, PP: %s)\n",
GNUNET_h2s (&put->key),
GNUNET_i2s (peer->id),
tmp,
GNUNET_CRYPTO_hash_matching_bits (&peer->phash,
&put->key),
GNUNET_CRYPTO_hash_matching_bits (&my_identity_hash,
- &put->key)
- );
+ &put->key),
+ pp);
+ GNUNET_free (pp);
GNUNET_free (tmp);
}
switch (GNUNET_BLOCK_get_key
const void *data,
size_t data_size)
{
+ char *pp;
+
+ pp = GNUNET_STRINGS_pp2s (put_path,
+ put_path_length);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Found local result for %s (PP: %s)\n",
+ GNUNET_h2s (key),
+ pp);
+ GNUNET_free (pp);
// FIXME: we can probably do better here by
// passing the peer that did the query in the closure...
GDS_ROUTING_process (NULL,
if (GNUNET_YES == log_route_details_stderr)
{
char *tmp;
+ char *pp;
+ char *gp;
+ gp = GNUNET_STRINGS_pp2s (get_path,
+ get_path_length);
+ pp = GNUNET_STRINGS_pp2s (put_path,
+ put_path_length);
tmp = GNUNET_strdup (GNUNET_i2s (&my_identity));
LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
- "R5N RESULT %s: %s->%s (%u)\n",
+ "R5N RESULT %s: %s->%s (GP: %s, PP: %s)\n",
GNUNET_h2s (&prm->key),
GNUNET_i2s (peer->id),
tmp,
- get_path_length + 1);
+ gp,
+ pp);
+ GNUNET_free (gp);
+ GNUNET_free (pp);
GNUNET_free (tmp);
}
/* if we got a HELLO, consider it for our own routing table */
const char *guard;
guard = va_arg (va, const char *);
- if (0 == memcmp (guard,
- "seen-set-size",
- strlen ("seen-set-size")))
+ if (0 == strcmp (guard,
+ "seen-set-size"))
bf_size = compute_bloomfilter_size (va_arg (va, unsigned int));
- else if (0 == memcmp (guard,
- "filter-size",
- strlen ("filter-size")))
+ else if (0 == strcmp (guard,
+ "filter-size"))
bf_size = va_arg (va, unsigned int);
else
{
return NULL;
case GNUNET_BLOCK_TYPE_FS_UBLOCK:
guard = va_arg (va, const char *);
- if (0 != memcmp (guard,
- "seen-set-size",
- strlen ("seen-set-size")))
+ if (0 != strcmp (guard,
+ "seen-set-size"))
{
/* va-args invalid! bad bug, complain! */
GNUNET_break (0);
char **output);
+/**
+ * Convert a peer path to a human-readable string.
+ *
+ * @param pids array of PIDs to convert to a string
+ * @param num_pids length of the @a pids array
+ * @return string representing the array of @a pids
+ */
+char *
+GNUNET_STRINGS_pp2s (const struct GNUNET_PeerIdentity *pids,
+ unsigned int num_pids);
+
+
/**
* Parse a path that might be an URI.
*
/**
- * Parse an address given as a string into a
+ * Parse an address given as a string into a
* `struct sockaddr`.
*
* @param addr the address
const char *guard;
guard = va_arg (va, const char *);
- if (0 == memcmp (guard,
- "seen-set-size",
- strlen ("seen-set-size")))
+ if (0 == strcmp (guard,
+ "seen-set-size"))
bf_size = compute_bloomfilter_size (va_arg (va, unsigned int));
- else if (0 == memcmp (guard,
- "filter-size",
- strlen ("filter-size")))
+ else if (0 == strcmp (guard,
+ "filter-size"))
bf_size = va_arg (va, unsigned int);
else
{
/*
This file is part of GNUnet.
- Copyright (C) 2005-2013 GNUnet e.V.
+ Copyright (C) 2005-2017 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
-
/**
* @file util/strings.c
* @brief string functions
}
+/**
+ * Convert a peer path to a human-readable string.
+ *
+ * @param pids array of PIDs to convert to a string
+ * @param num_pids length of the @a pids array
+ * @return string representing the array of @a pids
+ */
+char *
+GNUNET_STRINGS_pp2s (const struct GNUNET_PeerIdentity *pids,
+ unsigned int num_pids)
+{
+ char *buf;
+ size_t off;
+ size_t plen = num_pids * 5 + 1;
+
+ off = 0;
+ buf = GNUNET_malloc (plen);
+ for (unsigned int i = 0;
+ i < num_pids;
+ i++)
+ {
+ off += GNUNET_snprintf (&buf[off],
+ plen - off,
+ "%s%s",
+ GNUNET_i2s (&pids[i]),
+ (i == num_pids -1) ? "" : "-");
+ }
+ return buf;
+}
+
+
/**
* Given a buffer of a given size, find "count"
* 0-terminated strings in the buffer and assign