update = "";
nidlen = strlen (update) + 1;
mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
-
size = sizeof (struct SBlock) + slen + nidlen + mdsize;
if (size > MAX_SBLOCK_SIZE)
{
return;
}
size = sizeof (struct SBlock) + mdsize + slen + nidlen;
- sb_enc = GNUNET_malloc (sizeof (struct SBlock) + size);
+ sb_enc = GNUNET_malloc (size);
GNUNET_CRYPTO_hash (identifier, idlen, &key);
GNUNET_CRYPTO_hash (&key, sizeof (GNUNET_HashCode), &id);
sks_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
strlen (identifier),
&key);
GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
- GNUNET_CRYPTO_aes_encrypt (&sb[1],
+ GNUNET_CRYPTO_aes_decrypt (&sb[1],
len,
&skey,
&iv,
uri = GNUNET_FS_uri_parse (uris, &emsg);
if (uri == NULL)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to parse URI `%s': %s\n",
+ uris, emsg);
GNUNET_break_op (0); /* sblock malformed */
GNUNET_free_non_null (emsg);
GNUNET_CONTAINER_meta_data_destroy (meta);
size_t size)
{
if (GNUNET_TIME_absolute_get_duration (expiration).value > 0)
- return; /* result expired */
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Result received has already expired.\n");
+ return; /* result expired */
+ }
switch (type)
{
case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
process_kblock (sc, data, size);
break;
case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
- if (! GNUNET_FS_uri_test_ksk (sc->uri))
+ if (! GNUNET_FS_uri_test_sks (sc->uri))
{
GNUNET_break (0);
return;
return;
}
msize = ntohs (msg->size);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Receiving %u bytes of result from fs service\n",
+ msize);
cm = (const struct PutMessage*) msg;
process_result (sc,
ntohl (cm->type),
sm[i].header.size = htons (sizeof (struct SearchMessage));
sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
sm[i].type = htonl (GNUNET_DATASTORE_BLOCKTYPE_KBLOCK);
- sm[i].anonymity_level = htonl (sc->anonymity);
+ sm[i].anonymity_level = htonl (sc->anonymity);
sm[i].query = sc->requests[i].query;
}
}
if (NULL != sc->client)
GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map);
- for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
- GNUNET_CONTAINER_multihashmap_destroy (sc->requests[i].results);
+ if (sc->requests != NULL)
+ {
+ GNUNET_assert (GNUNET_FS_uri_test_ksk (sc->uri));
+ for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
+ GNUNET_CONTAINER_multihashmap_destroy (sc->requests[i].results);
+ }
GNUNET_free_non_null (sc->requests);
GNUNET_FS_uri_destroy (sc->uri);
GNUNET_free (sc);
(0 != strncmp (s, GNUNET_FS_URI_PREFIX GNUNET_FS_URI_SKS_INFIX,
pos) ) )
return NULL; /* not an SKS URI */
- if ( (slen < pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) + 1) ||
+ if ( (slen < pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) ||
(s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] != '/') )
{
*emsg = GNUNET_strdup (_("Malformed SKS URI"));
* @brief gnunet anonymity protocol implementation
* @author Christian Grothoff
*
+ * FIXME:
+ * - code not clear in terms of which function initializes bloomfilter when!
* TODO:
* - have non-zero preference / priority for requests we initiate!
* - track stats for hot-path routing
if (0 != memcmp (pr->namespace,
&prq->namespace,
sizeof (GNUNET_HashCode)))
- return GNUNET_YES; /* wrong namespace */
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Reply mismatched in terms of namespace. Discarded.\n"));
+ return GNUNET_YES; /* wrong namespace */
+ }
/* then: fall-through! */
case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
if (pr->bf != NULL)
mingle_hash (&chash, pr->mingle, &mhash);
if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (pr->bf,
&mhash))
- return GNUNET_YES; /* duplicate */
+ {
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# duplicate replies discarded (bloomfilter)"),
+ 1,
+ GNUNET_NO);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Duplicate response `%s', discarding.\n",
+ GNUNET_h2s (&mhash));
+ return GNUNET_YES; /* duplicate */
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "New response `%s', adding to filter.\n",
+ GNUNET_h2s (&mhash));
GNUNET_CONTAINER_bloomfilter_add (pr->bf,
&mhash);
}
&pr->bf_size,
pr->replies_seen);
}
- pr->replies_seen[pr->replies_seen_off++] = chash;
-
+ pr->replies_seen[pr->replies_seen_off++] = chash;
}
break;
case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK:
pm->expiration = GNUNET_TIME_absolute_hton (prq->expiration);
memcpy (&pm[1], prq->data, prq->size);
if (NULL == cl->th)
- cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client,
- msize,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &transmit_to_client,
- cl);
+ {
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting result for query `%s' to client\n",
+ GNUNET_h2s (key));
+#endif
+ cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client,
+ msize,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &transmit_to_client,
+ cl);
+ }
GNUNET_break (cl->th != NULL);
}
else
GNUNET_CONTAINER_multihashmap_remove (query_request_map,
key,
pr));
- // FIXME: request somehow does not fully
- // disappear; how to fix?
+ // FIXME: request somehow does not fully disappear; how to fix?
// destroy_pending_request (pr); (not like this!)
}
-
// FIXME: implement hot-path routing statistics keeping!
return GNUNET_YES;
}
pr);
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "New local response to `%s' of type %u.\n",
+ GNUNET_h2s (key),
+ type);
if (type == GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND)
{
#if DEBUG_FS
pr->bf_size,
BLOOMFILTER_K);
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "New local response `%s', adding to filter.\n",
+ GNUNET_h2s (&mhash));
+#if 0
GNUNET_CONTAINER_bloomfilter_add (pr->bf,
&mhash);
+#endif
}
memset (&prq, 0, sizeof (prq));
prq.data = data;
* @brief Test for fs_namespace.c
* @author Christian Grothoff
*
+ *
+ * FIXME:
+ * - child search of "sks" search (the "next" identifier) is not stopped => no termination!
* TODO:
* - add timeout task
*/
GNUNET_FS_search_stop (ksk_search);
ksk_search = NULL;
if (sks_search == NULL)
- GNUNET_FS_stop (fs);
+ {
+ fprintf (stderr, "initiating shutdown\n");
+ GNUNET_FS_stop (fs);
+ }
}
}
{
struct GNUNET_FS_Namespace *ns;
- if (sks_search != NULL)
+ if (sks_search == NULL)
+ return;
+ GNUNET_FS_search_stop (sks_search);
+ sks_search = NULL;
+ ns = GNUNET_FS_namespace_create (fs,
+ "testNamespace");
+ GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_YES));
+ if (ksk_search == NULL)
{
- GNUNET_FS_search_stop (sks_search);
- sks_search = NULL;
- ns = GNUNET_FS_namespace_create (fs,
- "testNamespace");
- GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_YES));
- if (ksk_search == NULL)
- GNUNET_FS_stop (fs);
- }
+ fprintf (stderr, "initiating shutdown\n");
+ GNUNET_FS_stop (fs);
+ }
}
(0 == strcmp ("ksk_search", event->value.search.cctx)));
if (NULL == event->value.search.cctx)
{
- GNUNET_assert (sks_search == event->value.search.pctx);
+ GNUNET_assert (0 == strcmp ("sks_search", event->value.search.pctx));
update_started = GNUNET_YES;
}
GNUNET_assert (1 == event->value.search.anonymity);
break;
case GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED:
- break;
+ return NULL;
case GNUNET_FS_STATUS_SEARCH_STOPPED:
fprintf (stderr,
"Search stop event received\n");
GNUNET_assert ( (ksk_search == event->value.search.sc) ||
(sks_search == event->value.search.sc));
- break;
+ return NULL;
default:
fprintf (stderr,
"Unexpected event: %d\n",
event->status);
break;
}
- return NULL;
+ return event->value.search.cctx;
}
#include "gnunet_arm_service.h"
#include "gnunet_fs_service.h"
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
#define START_ARM GNUNET_YES
DEFAULTSERVICES = resolver datastore transport core fs
[datastore]
-#DEBUG = YES
+DEBUG = YES
[statistics]
PORT = 42467
[fs]
PORT = 42471
HOSTNAME = localhost
-#DEBUG = YES
+DEBUG = YES
[testing]
WEAKRANDOM = YES