[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r9250 - GNUnet/src/applications/fs/gap
From: |
gnunet |
Subject: |
[GNUnet-SVN] r9250 - GNUnet/src/applications/fs/gap |
Date: |
Thu, 22 Oct 2009 19:17:43 -0600 |
Author: nevans
Date: 2009-10-22 19:17:43 -0600 (Thu, 22 Oct 2009)
New Revision: 9250
Added:
GNUnet/src/applications/fs/gap/gap_test.conf
GNUnet/src/applications/fs/gap/gnunetd_dv_gap.conf
GNUnet/src/applications/fs/gap/test_gap_dv.c
Modified:
GNUnet/src/applications/fs/gap/Makefile.am
GNUnet/src/applications/fs/gap/dv_fs.c
GNUnet/src/applications/fs/gap/dv_querymanager.c
GNUnet/src/applications/fs/gap/dv_querymanager.h
GNUnet/src/applications/fs/gap/fs.c
GNUnet/src/applications/fs/gap/fs_dv_dht.c
GNUnet/src/applications/fs/gap/fs_dv_dht.h
GNUnet/src/applications/fs/gap/test_multi_results_dv.c
GNUnet/src/applications/fs/gap/test_star_topology.c
Log:
changes to allow dv transfer for non-anonymous downloads from dv known peers.
Faster and highly unstable at this point (-:
Modified: GNUnet/src/applications/fs/gap/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/gap/Makefile.am 2009-10-23 01:14:12 UTC (rev
9249)
+++ GNUnet/src/applications/fs/gap/Makefile.am 2009-10-23 01:17:43 UTC (rev
9250)
@@ -8,7 +8,8 @@
plugindir = $(libdir)/GNUnet
plugin_LTLIBRARIES = \
- libgnunetmodule_fs.la
+ libgnunetmodule_fs.la \
+ libgnunetmodule_dv_fs.la
libgnunetmodule_fs_la_SOURCES = \
@@ -29,15 +30,35 @@
$(top_builddir)/src/util/libgnunetutil.la \
-lm \
$(GN_LIBINTL)
+
+libgnunetmodule_dv_fs_la_SOURCES = \
+ anonymity.c anonymity.h \
+ dv_fs.c \
+ fs_dv_dht.c fs_dv_dht.h \
+ gap.c gap.h \
+ migration.c migration.h \
+ ondemand.c ondemand.h \
+ plan.c plan.h \
+ pid_table.c pid_table.h \
+ dv_querymanager.c dv_querymanager.h \
+ shared.c shared.h
+libgnunetmodule_dv_fs_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+libgnunetmodule_dv_fs_la_LIBADD = \
+ $(top_builddir)/src/applications/fs/libgnunetecrscore.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ -lm \
+ $(GN_LIBINTL)
-
check_PROGRAMS = \
test_loopback \
test_linear_topology \
test_multi_results \
- test_star_topology
-
+ test_star_topology \
+ test_multi_results_dv \
+ test_gap_dv
+
TESTS = $(check_PROGRAMS)
test_loopback_SOURCES = \
@@ -65,6 +86,13 @@
$(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
$(top_builddir)/src/util/libgnunetutil.la
+test_multi_results_dv_SOURCES = \
+ test_multi_results_dv.c
+test_multi_results_dv_LDADD = \
+ $(top_builddir)/src/applications/testing/libgnunettestingapi.la \
+ $(top_builddir)/src/applications/stats/libgnunetstatsapi.la \
+ $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
+ $(top_builddir)/src/util/libgnunetutil.la
test_star_topology_SOURCES = \
test_star_topology.c
@@ -75,6 +103,15 @@
$(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
$(top_builddir)/src/util/libgnunetutil.la
+test_gap_dv_SOURCES = \
+ test_gap_dv.c
+test_gap_dv_LDADD = \
+ $(top_builddir)/src/applications/identity/libgnunetidentityapi.la \
+ $(top_builddir)/src/applications/testing/libgnunettestingapi.la \
+ $(top_builddir)/src/applications/testing/libgnunetremoteapi.la \
+ $(top_builddir)/src/applications/stats/libgnunetstatsapi.la \
+ $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
+ $(top_builddir)/src/util/libgnunetutil.la
EXTRA_DIST = \
check.conf
Modified: GNUnet/src/applications/fs/gap/dv_fs.c
===================================================================
--- GNUnet/src/applications/fs/gap/dv_fs.c 2009-10-23 01:14:12 UTC (rev
9249)
+++ GNUnet/src/applications/fs/gap/dv_fs.c 2009-10-23 01:17:43 UTC (rev
9250)
@@ -52,6 +52,7 @@
#include "plan.h"
#include "pid_table.h"
#include "shared.h"
+#include "gnunet_dv_service.h"
#define DEBUG_FS GNUNET_NO
@@ -70,6 +71,8 @@
static GNUNET_Stats_ServiceAPI *stats;
+static GNUNET_DV_ServiceAPI *dv_api;
+
static GNUNET_Datastore_ServiceAPI *datastore;
static int active_migration;
@@ -93,6 +96,11 @@
static unsigned long long hardUpLimit;
+struct DV_send_closure
+{
+ struct RequestList *request;
+ const P2P_gap_query_MESSAGE *message;
+};
/* ********************* CS handlers ********************** */
@@ -509,10 +517,13 @@
sizeof (CS_fs_request_search_MESSAGE)) / sizeof (GNUNET_HashCode);
have_target =
memcmp (&all_zeros, &rs->target, sizeof (GNUNET_PeerIdentity)) != 0;
- GNUNET_DV_FS_QUERYMANAGER_start_query (&rs->query[0], keyCount,
anonymityLevel,
- type, sock,
- have_target ? &rs->target : NULL,
- fpp.seen, fpp.have_more);
+ GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
+ "in dv_fs, have_target is %d", have_target);
+
+ GNUNET_DV_FS_QUERYMANAGER_start_query (&rs->query[0], keyCount,
+ anonymityLevel, type, sock,
+ have_target ? &rs->target : NULL,
+ fpp.seen, fpp.have_more);
CLEANUP:
if (fpp.seen != NULL)
GNUNET_multi_hash_map_destroy (fpp.seen);
@@ -544,8 +555,8 @@
keyCount =
1 + (ntohs (req->size) -
sizeof (CS_fs_request_search_MESSAGE)) / sizeof (GNUNET_HashCode);
- GNUNET_DV_FS_QUERYMANAGER_stop_query (&rs->query[0], keyCount,
anonymityLevel,
- type, sock);
+ GNUNET_DV_FS_QUERYMANAGER_stop_query (&rs->query[0], keyCount,
+ anonymityLevel, type, sock);
return GNUNET_OK;
}
@@ -565,6 +576,73 @@
GNUNET_ND_UPLOAD) >= hardUpLimit));
}
+static int
+send_results_dv (const GNUNET_HashCode * key,
+ const GNUNET_DatastoreValue * value, void *closure,
+ unsigned long long uid)
+{
+ struct DV_send_closure *dvcls = (struct DV_send_closure *) closure;
+ const P2P_gap_query_MESSAGE *original_msg = dvcls->message;
+ P2P_gap_reply_MESSAGE *msg;
+ GNUNET_DatastoreValue *enc;
+ unsigned int size;
+ unsigned long long et;
+ GNUNET_CronTime now;
+ int ret;
+ int want_more;
+
+ want_more = GNUNET_OK;
+
+ enc = NULL;
+ if (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND)
+ {
+ if (GNUNET_OK !=
+ GNUNET_FS_ONDEMAND_get_indexed_content (value, key, &enc))
+ return GNUNET_NO;
+ value = enc;
+ }
+
+ et = GNUNET_ntohll (value->expiration_time);
+ now = GNUNET_get_time ();
+ /* convert to relative expiration time */
+ if (now < et)
+ {
+ et -= now;
+ if (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_KEYWORD)
+ et %= GNUNET_GAP_MAX_MIGRATION_EXP_KSK;
+ else
+ et %= GNUNET_GAP_MAX_MIGRATION_EXP;
+ }
+ else
+ {
+ if (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_KEYWORD)
+ return want_more; /* expired KSK -- ignore! */
+ /* indicate entry has expired */
+ et = -1;
+ }
+ size =
+ sizeof (P2P_gap_reply_MESSAGE) + ntohl (value->size) -
+ sizeof (GNUNET_DatastoreValue);
+ msg = GNUNET_malloc (size);
+ msg->header.type = htons (GNUNET_P2P_PROTO_GAP_RESULT);
+ msg->header.size = htons (size);
+ msg->reserved = htonl (0);
+ msg->expiration = GNUNET_htonll (et);
+ memcpy (&msg[1], &value[1], size - sizeof (P2P_gap_reply_MESSAGE));
+
+ ret =
+ dv_api->dv_send (&original_msg->returnTo, &msg->header,
+ htonl (original_msg->priority), et);
+ if (stats != NULL)
+ {
+ //stats->change (stat_trust_earned, req->value_offered);
+ }
+
+ GNUNET_free_non_null (enc);
+ return ret;
+
+}
+
/**
* Handle P2P query for content.
*/
@@ -580,8 +658,12 @@
unsigned int prio;
unsigned int type;
unsigned int netLoad;
+ int have_peer;
+ int have_data;
+ GNUNET_EncName enc;
enum GNUNET_FS_RoutingPolicy policy;
double preference;
+ struct DV_send_closure *dv_cls;
if (stats != NULL)
stats->change (stat_gap_query_received, 1);
@@ -684,6 +766,72 @@
if (preference < GNUNET_GAP_QUERY_BANDWIDTH_VALUE)
preference = GNUNET_GAP_QUERY_BANDWIDTH_VALUE;
coreAPI->p2p_connection_preference_increase (sender, preference);
+
+ GNUNET_mutex_lock (GNUNET_FS_lock);
+ have_peer = dv_api->have_peer (sender);
+ have_data = datastore->get (&req->queries[0], type, NULL, NULL);
+ GNUNET_hash_to_enc (&req->queries[0], &enc);
+ GNUNET_GE_LOG (ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "have_peer returned %d, get (%s) returned %d results for
query type %d",
+ have_peer, (char *) &enc, have_data, type);
+ if ((dv_api->have_peer (sender) > 0)
+ && (datastore->get (&req->queries[0], type, NULL, NULL) > 0))
+ {
+ GNUNET_GE_LOG (ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "We have the data, we know the return peer intimately
(DV), so we will try and send results thataway!\n");
+
+ dv_cls = GNUNET_malloc (sizeof (struct DV_send_closure));
+ dv_cls->message = (const P2P_gap_query_MESSAGE *) msg;
+ dv_cls->request = NULL; /* Not used for now... */
+ datastore->get (&req->queries[0], type, &send_results_dv, dv_cls);
+ GNUNET_free (dv_cls);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+ return GNUNET_OK;
+ }
+ else if ((dv_api->have_peer (sender) > 0)
+ && (datastore->
+ get (&req->queries[0], GNUNET_ECRS_BLOCKTYPE_DATA, NULL,
+ NULL) > 0))
+ {
+ GNUNET_GE_LOG (ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "We have the data (blocktype_data), we know the return
peer intimately (DV), so we will try and send results thataway!\n");
+
+ dv_cls = GNUNET_malloc (sizeof (struct DV_send_closure));
+ dv_cls->message = (const P2P_gap_query_MESSAGE *) msg;
+ dv_cls->request = NULL; /* Not used for now... */
+ datastore->get (&req->queries[0], GNUNET_ECRS_BLOCKTYPE_DATA,
+ &send_results_dv, dv_cls);
+ GNUNET_free (dv_cls);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+ return GNUNET_OK;
+ }
+ else if ((dv_api->have_peer (sender) > 0)
+ && (datastore->
+ get (&req->queries[0], GNUNET_ECRS_BLOCKTYPE_ANY, NULL,
+ NULL) > 0))
+ {
+ GNUNET_GE_LOG (ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "We have the data (blocktype_any), we know the return
peer intimately (DV), so we will try and send results thataway!\n");
+
+ dv_cls = GNUNET_malloc (sizeof (struct DV_send_closure));
+ dv_cls->message = (const P2P_gap_query_MESSAGE *) msg;
+ dv_cls->request = NULL; /* Not used for now... */
+ datastore->get (&req->queries[0], GNUNET_ECRS_BLOCKTYPE_ANY,
+ &send_results_dv, dv_cls);
+ GNUNET_free (dv_cls);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+ return GNUNET_OK;
+ }
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+
GNUNET_FS_GAP_execute_query (sender,
prio,
ntohl (req->priority),
@@ -764,9 +912,9 @@
}
/* forward to local clients */
prio += GNUNET_DV_FS_QUERYMANAGER_handle_response (sender,
- &query,
- expiration,
- data_size, dblock);
+ &query,
+ expiration,
+ data_size, dblock);
if ((sender != NULL) &&
(active_migration == GNUNET_YES) &&
((prio > 0) || (!test_load_too_high ())))
@@ -823,7 +971,7 @@
= GNUNET_GC_get_configuration_value_yesno (coreAPI->cfg,
"DV_FS",
"ACTIVEMIGRATION", GNUNET_NO);
- stats = capi->service_request ("stats");
+ stats = coreAPI->service_request ("stats");
if (stats != NULL)
{
stat_gap_query_received =
@@ -835,30 +983,31 @@
stat_gap_trust_awarded =
stats->create (gettext_noop ("# gap total trust awarded"));
}
- identity = capi->service_request ("identity");
+ identity = coreAPI->service_request ("identity");
if (identity == NULL)
{
GNUNET_GE_BREAK (ectx, 0);
- capi->service_release (stats);
+ coreAPI->service_release (stats);
return GNUNET_SYSERR;
}
- datastore = capi->service_request ("datastore");
+ datastore = coreAPI->service_request ("datastore");
+ dv_api = coreAPI->service_request ("dv");
if (datastore == NULL)
{
- capi->service_release (identity);
- capi->service_release (stats);
+ coreAPI->service_release (identity);
+ coreAPI->service_release (stats);
GNUNET_GE_BREAK (ectx, 0);
return GNUNET_SYSERR;
}
- GNUNET_FS_lock = capi->global_lock_get (); // GNUNET_mutex_create
(GNUNET_YES);
- GNUNET_FS_ANONYMITY_init (capi);
- GNUNET_FS_PLAN_init (capi);
- GNUNET_FS_ONDEMAND_init (capi);
+ GNUNET_FS_lock = coreAPI->global_lock_get (); // GNUNET_mutex_create
(GNUNET_YES);
+ GNUNET_FS_ANONYMITY_init (coreAPI);
+ GNUNET_FS_PLAN_init (coreAPI);
+ GNUNET_FS_ONDEMAND_init (coreAPI);
GNUNET_FS_PT_init (ectx, stats);
- GNUNET_DV_FS_QUERYMANAGER_init (capi);
- GNUNET_FS_DV_DHT_init (capi);
- GNUNET_FS_GAP_init (capi);
- GNUNET_FS_MIGRATION_init (capi);
+ GNUNET_DV_FS_QUERYMANAGER_init (coreAPI);
+ GNUNET_FS_DV_DHT_init (coreAPI);
+ GNUNET_FS_GAP_init (coreAPI);
+ GNUNET_FS_MIGRATION_init (coreAPI);
GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
_
("`%s' registering client handlers %d %d %d %d %d %d %d %d
and P2P handlers %d %d\n"),
@@ -871,53 +1020,56 @@
GNUNET_P2P_PROTO_GAP_QUERY, GNUNET_P2P_PROTO_GAP_RESULT);
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- capi->p2p_ciphertext_handler_register
+ coreAPI->p2p_ciphertext_handler_register
(GNUNET_P2P_PROTO_GAP_QUERY, &handle_p2p_query));
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- capi->p2p_ciphertext_handler_register
+ coreAPI->p2p_ciphertext_handler_register
(GNUNET_P2P_PROTO_GAP_RESULT, &handle_p2p_content));
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- capi->cs_handler_register
+ coreAPI->cs_handler_register
(GNUNET_CS_PROTO_GAP_QUERY_START,
&handle_cs_query_start_request));
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- capi->cs_handler_register
+ coreAPI->cs_handler_register
(GNUNET_CS_PROTO_GAP_QUERY_STOP,
&handle_cs_query_stop_request));
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- capi->cs_handler_register (GNUNET_CS_PROTO_GAP_INSERT,
- &handle_cs_insert_request));
+ coreAPI->cs_handler_register (GNUNET_CS_PROTO_GAP_INSERT,
+ &handle_cs_insert_request));
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- capi->cs_handler_register (GNUNET_CS_PROTO_GAP_INDEX,
- &handle_cs_index_request));
+ coreAPI->cs_handler_register (GNUNET_CS_PROTO_GAP_INDEX,
+ &handle_cs_index_request));
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- capi->cs_handler_register (GNUNET_CS_PROTO_GAP_INIT_INDEX,
- &handle_cs_init_index_request));
+ coreAPI->
+ cs_handler_register (GNUNET_CS_PROTO_GAP_INIT_INDEX,
+ &handle_cs_init_index_request));
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- capi->cs_handler_register (GNUNET_CS_PROTO_GAP_DELETE,
- &handle_cs_delete_request));
+ coreAPI->cs_handler_register (GNUNET_CS_PROTO_GAP_DELETE,
+ &handle_cs_delete_request));
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- capi->cs_handler_register (GNUNET_CS_PROTO_GAP_UNINDEX,
- &handle_cs_unindex_request));
+ coreAPI->cs_handler_register (GNUNET_CS_PROTO_GAP_UNINDEX,
+ &handle_cs_unindex_request));
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- capi->cs_handler_register (GNUNET_CS_PROTO_GAP_TESTINDEX,
-
&handle_cs_test_indexed_request));
- GNUNET_GE_ASSERT (capi->ectx,
- 0 == GNUNET_GC_set_configuration_value_string (capi->cfg,
- capi->ectx,
- "ABOUT",
- "dv_fs",
- gettext_noop
- ("enables
(anonymous) file-sharing")));
+ coreAPI->
+ cs_handler_register (GNUNET_CS_PROTO_GAP_TESTINDEX,
+ &handle_cs_test_indexed_request));
+ GNUNET_GE_ASSERT (coreAPI->ectx,
+ 0 ==
+ GNUNET_GC_set_configuration_value_string (coreAPI->cfg,
+ coreAPI->ectx,
+ "ABOUT",
+ "dv_fs",
+ gettext_noop
+ ("enables
(anonymous) file-sharing")));
return GNUNET_OK;
}
@@ -982,6 +1134,9 @@
coreAPI->service_release (stats);
stats = NULL;
}
+ if (dv_api != NULL)
+ coreAPI->service_release (dv_api);
+
coreAPI->service_release (datastore);
datastore = NULL;
coreAPI->service_release (identity);
Modified: GNUnet/src/applications/fs/gap/dv_querymanager.c
===================================================================
--- GNUnet/src/applications/fs/gap/dv_querymanager.c 2009-10-23 01:14:12 UTC
(rev 9249)
+++ GNUnet/src/applications/fs/gap/dv_querymanager.c 2009-10-23 01:17:43 UTC
(rev 9250)
@@ -37,6 +37,7 @@
#include "plan.h"
#include "pid_table.h"
#include "shared.h"
+#include "gnunet_dv_service.h"
#define CHECK_REPEAT_FREQUENCY (150 * GNUNET_CRON_MILLISECONDS)
@@ -78,6 +79,8 @@
static GNUNET_CoreAPIForPlugins *coreAPI;
+static GNUNET_DV_ServiceAPI *dv_api;
+
static GNUNET_Stats_ServiceAPI *stats;
static GNUNET_Datastore_ServiceAPI *datastore;
@@ -92,6 +95,7 @@
static int stat_gap_client_bf_updates;
+static int stat_gap_dv_sends;
/**
* How many bytes should a bloomfilter be if
@@ -131,6 +135,66 @@
return GNUNET_OK;
}
+static int
+send_dv_query (struct RequestList *request, const GNUNET_PeerIdentity * peer)
+{
+ P2P_gap_query_MESSAGE *msg;
+ unsigned int size;
+ GNUNET_CronTime now;
+ int ret;
+ ret = GNUNET_SYSERR;
+ int ttl;
+ int prio = GNUNET_FS_GAP_get_average_priority ();
+
+ GNUNET_GE_ASSERT (NULL, request->key_count > 0);
+ size = sizeof (P2P_gap_query_MESSAGE)
+ + request->bloomfilter_size + (request->key_count -
+ 1) * sizeof (GNUNET_HashCode);
+ msg = (P2P_gap_query_MESSAGE *) GNUNET_malloc (size);
+ if ((prio > request->remaining_value) && (request->response_client == NULL))
+ prio = request->remaining_value;
+ now = GNUNET_get_time ();
+ ttl = GNUNET_FS_HELPER_bound_ttl (now + 60 * GNUNET_CRON_SECONDS, prio);
+ msg->header.size = htons (size);
+ msg->header.type = htons (GNUNET_P2P_PROTO_GAP_QUERY);
+ msg->type = htonl (request->type);
+ msg->priority = htonl (prio);
+ msg->ttl = htonl (ttl);
+ msg->filter_mutator = htonl (request->bloomfilter_mutator);
+ msg->number_of_queries = htonl (request->key_count);
+ if (0 != (request->policy & GNUNET_FS_RoutingPolicy_INDIRECT))
+ msg->returnTo = *coreAPI->my_identity;
+ else
+ GNUNET_FS_PT_resolve (request->response_target, &msg->returnTo);
+ memcpy (&msg->queries[0],
+ &request->queries[0],
+ request->key_count * sizeof (GNUNET_HashCode));
+ if (request->bloomfilter != NULL)
+ GNUNET_bloomfilter_get_raw_data (request->bloomfilter,
+ (char *) &msg->queries[request->
+ key_count],
+ request->bloomfilter_size);
+ now = GNUNET_get_time ();
+ if (now + ttl > request->last_request_time + request->last_ttl_used)
+ {
+ request->last_request_time = now;
+ request->last_prio_used = prio;
+ request->last_ttl_used = ttl;
+ }
+ request->remaining_value -= prio;
+ if (stats != NULL)
+ {
+ stats->change (stat_gap_dv_sends, 1);
+ }
+ ret = dv_api->dv_send (peer, &msg->header, prio, ttl);
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "Sending message via DV returned %d, type of request %d
(htonl %d)\n",
+ ret, request->type, htonl (request->type));
+ return ret;
+}
+
/**
* A client is asking us to run a query. The query should be issued
* until either a unique response has been obtained or until the
@@ -140,17 +204,25 @@
*/
void
GNUNET_DV_FS_QUERYMANAGER_start_query (const GNUNET_HashCode * query,
- unsigned int key_count,
- unsigned int anonymityLevel,
- unsigned int type,
- struct GNUNET_ClientHandle *client,
- const GNUNET_PeerIdentity * target,
- const struct GNUNET_MultiHashMap *seen,
- int have_more)
+ unsigned int key_count,
+ unsigned int anonymityLevel,
+ unsigned int type,
+ struct GNUNET_ClientHandle *client,
+ const GNUNET_PeerIdentity * target,
+ const struct GNUNET_MultiHashMap *seen,
+ int have_more)
{
struct ClientDataList *cl;
struct RequestList *request;
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "entered GNUNET_DV_FS_QUERYMANAGER_start_query\n");
+ if (target == NULL)
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, "target is null!\n");
GNUNET_GE_ASSERT (NULL, key_count > 0);
if (stats != NULL)
{
@@ -203,6 +275,29 @@
cl->requests = request;
if (cl->request_tail == NULL)
cl->request_tail = request;
+
+ if ((anonymityLevel == 0) && (target != NULL)
+ && (dv_api->have_peer (target)))
+ {
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "anonymity is zero, target non-null, and we know this
peer. Will attempt to send requests out over DV\n");
+ if (send_dv_query (request, target) > 0)
+ {
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+ request->last_dht_get = GNUNET_get_time ();
+ request->dht_back_off = GNUNET_GAP_MAX_DHT_DELAY;
+ return;
+ }
+ }
+ else if ((anonymityLevel == 0) && (target != NULL))
+ {
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "anonymity is zero, target non-null, but we don't know
this peer\n");
+ }
if ((GNUNET_YES == GNUNET_FS_PLAN_request (client, 0, request)) &&
(stats != NULL))
stats->change (stat_gap_client_query_injected, 1);
@@ -212,7 +307,7 @@
request->dht_back_off = GNUNET_GAP_MAX_DHT_DELAY;
}
GNUNET_mutex_unlock (GNUNET_FS_lock);
- if ((anonymityLevel == 0) && (type == 0)) /* Cannot search the dht with type
0 */
+ if ((anonymityLevel == 0) && (type == 0)) /* Cannot search the dht with
type 0 */
GNUNET_FS_DV_DHT_execute_query (GNUNET_ECRS_BLOCKTYPE_KEYWORD, query);
}
@@ -221,10 +316,10 @@
*/
int
GNUNET_DV_FS_QUERYMANAGER_stop_query (const GNUNET_HashCode * query,
- unsigned int key_count,
- unsigned int anonymityLevel,
- unsigned int type,
- struct GNUNET_ClientHandle *client)
+ unsigned int key_count,
+ unsigned int anonymityLevel,
+ unsigned int type,
+ struct GNUNET_ClientHandle *client)
{
struct ClientDataList *cl;
struct ClientDataList *cprev;
@@ -413,7 +508,7 @@
* Handle the given response (by forwarding it to
* other peers as necessary).
*
- * @param sender who send the response (good too know
+ * @param sender who sent the response (good too know
* for future routing decisions)
* @param primary_query hash code used for lookup
* (note that namespace membership may
@@ -426,10 +521,11 @@
*/
unsigned int
GNUNET_DV_FS_QUERYMANAGER_handle_response (const GNUNET_PeerIdentity * sender,
- const GNUNET_HashCode * primary_query,
- GNUNET_CronTime expirationTime,
- unsigned int size,
- const GNUNET_EC_DBlock * data)
+ const GNUNET_HashCode *
+ primary_query,
+ GNUNET_CronTime expirationTime,
+ unsigned int size,
+ const GNUNET_EC_DBlock * data)
{
struct ClientDataList *cl;
struct RequestList *rl;
@@ -674,10 +770,10 @@
(request->last_ttl_used * GNUNET_CRON_SECONDS +
request->last_request_time < now))
{
- if ((GNUNET_OK ==
- GNUNET_FS_PLAN_request (client->client, 0, request))
- && (stats != NULL))
- stats->change (stat_gap_client_query_injected, 1);
+ /*if ((GNUNET_OK ==
+ GNUNET_FS_PLAN_request (client->client, 0, request))
+ && (stats != NULL))
+ stats->change (stat_gap_client_query_injected, 1); */
}
if ((request->anonymityLevel == 0) &&
@@ -686,7 +782,7 @@
if (request->dht_back_off * 2 > request->dht_back_off)
request->dht_back_off *= 2;
request->last_dht_get = now;
- GNUNET_FS_DV_DHT_execute_query (request->type, &request->queries[0]);
+ /*GNUNET_FS_DV_DHT_execute_query (request->type,
&request->queries[0]); */
}
}
GNUNET_mutex_unlock (GNUNET_FS_lock);
@@ -696,12 +792,13 @@
GNUNET_DV_FS_QUERYMANAGER_init (GNUNET_CoreAPIForPlugins * capi)
{
coreAPI = capi;
- GNUNET_GE_ASSERT (capi->ectx,
+ GNUNET_GE_ASSERT (coreAPI->ectx,
GNUNET_SYSERR !=
- capi->cs_disconnect_handler_register
+ coreAPI->cs_disconnect_handler_register
(&handle_client_exit));
- datastore = capi->service_request ("datastore");
- stats = capi->service_request ("stats");
+ datastore = coreAPI->service_request ("datastore");
+ stats = coreAPI->service_request ("stats");
+ dv_api = coreAPI->service_request ("dv");
if (stats != NULL)
{
stat_gap_client_query_received =
@@ -715,8 +812,10 @@
stat_gap_client_bf_updates =
stats->create (gettext_noop
("# gap query bloomfilter resizing updates"));
+ stat_gap_dv_sends =
+ stats->create (gettext_noop ("# dv gap requests sent"));
}
- GNUNET_cron_add_job (capi->cron,
+ GNUNET_cron_add_job (coreAPI->cron,
&repeat_requests_job,
CHECK_REPEAT_FREQUENCY, CHECK_REPEAT_FREQUENCY, NULL);
return 0;
@@ -735,6 +834,8 @@
handle_client_exit (clients->client);
coreAPI->service_release (datastore);
datastore = NULL;
+ coreAPI->service_release (dv_api);
+ dv_api = NULL;
if (stats != NULL)
{
coreAPI->service_release (stats);
Modified: GNUnet/src/applications/fs/gap/dv_querymanager.h
===================================================================
--- GNUnet/src/applications/fs/gap/dv_querymanager.h 2009-10-23 01:14:12 UTC
(rev 9249)
+++ GNUnet/src/applications/fs/gap/dv_querymanager.h 2009-10-23 01:17:43 UTC
(rev 9250)
@@ -46,23 +46,23 @@
*/
void
GNUNET_DV_FS_QUERYMANAGER_start_query (const GNUNET_HashCode * query,
- unsigned int key_count,
- unsigned int anonymityLevel,
- unsigned int type,
- struct GNUNET_ClientHandle *client,
- const GNUNET_PeerIdentity * target,
- const struct GNUNET_MultiHashMap *seen,
- int have_more);
+ unsigned int key_count,
+ unsigned int anonymityLevel,
+ unsigned int type,
+ struct GNUNET_ClientHandle *client,
+ const GNUNET_PeerIdentity * target,
+ const struct GNUNET_MultiHashMap *seen,
+ int have_more);
/**
* A client is asking us to stop running a query (without disconnect).
*/
int
GNUNET_DV_FS_QUERYMANAGER_stop_query (const GNUNET_HashCode * query,
- unsigned int key_count,
- unsigned int anonymityLevel,
- unsigned int type,
- struct GNUNET_ClientHandle *client);
+ unsigned int key_count,
+ unsigned int anonymityLevel,
+ unsigned int type,
+ struct GNUNET_ClientHandle *client);
/**
* Handle the given response (by forwarding it to
@@ -81,10 +81,11 @@
*/
unsigned int
GNUNET_DV_FS_QUERYMANAGER_handle_response (const GNUNET_PeerIdentity * sender,
- const GNUNET_HashCode * primary_query,
- GNUNET_CronTime expirationTime,
- unsigned int size,
- const GNUNET_EC_DBlock * data);
+ const GNUNET_HashCode *
+ primary_query,
+ GNUNET_CronTime expirationTime,
+ unsigned int size,
+ const GNUNET_EC_DBlock * data);
#endif
Modified: GNUnet/src/applications/fs/gap/fs.c
===================================================================
--- GNUnet/src/applications/fs/gap/fs.c 2009-10-23 01:14:12 UTC (rev 9249)
+++ GNUnet/src/applications/fs/gap/fs.c 2009-10-23 01:17:43 UTC (rev 9250)
@@ -693,8 +693,7 @@
query_count,
&req->queries[0],
ntohl (req->filter_mutator),
- bloomfilter_size,
- &req->queries[query_count]);
+ bloomfilter_size, &req->queries[query_count]);
return GNUNET_OK;
}
Modified: GNUnet/src/applications/fs/gap/fs_dv_dht.c
===================================================================
--- GNUnet/src/applications/fs/gap/fs_dv_dht.c 2009-10-23 01:14:12 UTC (rev
9249)
+++ GNUnet/src/applications/fs/gap/fs_dv_dht.c 2009-10-23 01:17:43 UTC (rev
9250)
@@ -166,7 +166,8 @@
* @param query hash code of the query
*/
void
-GNUNET_FS_DV_DHT_execute_query (unsigned int type, const GNUNET_HashCode *
query)
+GNUNET_FS_DV_DHT_execute_query (unsigned int type,
+ const GNUNET_HashCode * query)
{
struct ActiveRequestRecords *record;
GNUNET_CronTime now;
@@ -178,8 +179,9 @@
record = GNUNET_malloc (sizeof (struct ActiveRequestRecords));
record->end_time = now + GNUNET_GAP_MAX_DHT_DELAY;
record->type = type;
- /*record->type = GNUNET_ECRS_BLOCKTYPE_KEYWORD;*/ /* Anonymous query should
only get this type, right? */
- record->handle = dv_dht->get_start (record->type, query, &response_callback,
record);
+ /*record->type = GNUNET_ECRS_BLOCKTYPE_KEYWORD; *//* Anonymous query should
only get this type, right? */
+ record->handle =
+ dv_dht->get_start (record->type, query, &response_callback, record);
if (record->handle == NULL)
{
GNUNET_free (record);
@@ -217,9 +219,9 @@
return GNUNET_SYSERR;
dv_dht->put (key,
- ntohl (value->type),
- ntohl (value->size) - sizeof (GNUNET_DatastoreValue),
- (const char *) &value[1]);
+ ntohl (value->type),
+ ntohl (value->size) - sizeof (GNUNET_DatastoreValue),
+ (const char *) &value[1]);
if (stats != NULL)
stats->change (stat_push_count, 1);
if (GNUNET_YES == shutdown_requested)
Modified: GNUnet/src/applications/fs/gap/fs_dv_dht.h
===================================================================
--- GNUnet/src/applications/fs/gap/fs_dv_dht.h 2009-10-23 01:14:12 UTC (rev
9249)
+++ GNUnet/src/applications/fs/gap/fs_dv_dht.h 2009-10-23 01:17:43 UTC (rev
9250)
@@ -43,6 +43,6 @@
*/
void
GNUNET_FS_DV_DHT_execute_query (unsigned int type,
- const GNUNET_HashCode * query);
+ const GNUNET_HashCode * query);
#endif
Added: GNUnet/src/applications/fs/gap/gap_test.conf
===================================================================
--- GNUnet/src/applications/fs/gap/gap_test.conf
(rev 0)
+++ GNUnet/src/applications/fs/gap/gap_test.conf 2009-10-23 01:17:43 UTC
(rev 9250)
@@ -0,0 +1,11 @@
+[MULTIPLE_SERVER_TESTING]
+CONTROL_HOST=127.0.0.1;
+HOSTNAMES=localhost
+STARTING_PORT=31387
+PORT_INCREMENT=2
+BASE_CONFIG=gnunetd_dv_gap.conf
+TOPOLOGY=2
+SETTLE_TIME=10
+NUM_PEERS=15
+DOT_OUTPUT=topology.dot
+
Added: GNUnet/src/applications/fs/gap/gnunetd_dv_gap.conf
===================================================================
--- GNUnet/src/applications/fs/gap/gnunetd_dv_gap.conf
(rev 0)
+++ GNUnet/src/applications/fs/gap/gnunetd_dv_gap.conf 2009-10-23 01:17:43 UTC
(rev 9250)
@@ -0,0 +1,97 @@
+[Meta]
+ADVANCED = YES
+EXPERIMENTAL = YES
+
+[PATHS]
+GNUNETD_HOME =
+
+[GNUNETD]
+APPLICATIONS = advertising getoption topology_default stats dv_fs
+TRANSPORTS = udp tcp
+HOSTS = $GNUNETD_HOME/data/hosts/
+HTTP-PROXY =
+FDLIMIT = 1024
+PIDFILE = $GNUNETD_HOME/pid/
+AUTOSTART = NO
+HELLOEXPIRES = 1440
+PRIVATE-NETWORK = NO
+LIMIT-ALLOW =
+LIMIT-DENY =
+KEEPLOG = 3
+LOGFILE = $GNUNETD_HOME/daemon-logs
+
+[MODULES]
+sqstore = sqstore_sqlite
+dstore = dstore_sqlite
+topology = topology_default
+
+[NETWORK]
+PORT = 2087
+TRUSTED = 127.0.0.0/8;
+DISABLE-ADVERTISEMENTS = NO
+HELLOEXCHANGE = YES
+DISABLE-AUTOCONNECT = NO
+INTERFACE = eth1
+
+[F2F]
+FRIENDS-ONLY = YES
+#MINIMUM = 0
+FRIENDS = $GNUNETD_HOME/friends
+
+[FS]
+DIR = $GNUNETD_HOME/data/fs
+INDEX-DIRECTORY = $GNUNETD_HOME/data/shared
+QUOTA = 1024
+ACTIVEMIGRATION = NO
+
+[TCPSERVER]
+DISABLE = NO
+
+[LOGGING]
+DEVELOPER = YES
+ADMIN-LEVEL = DEBUG
+USER-LEVEL = DEBUG
+
+[LOAD]
+MAXNETDOWNBPSTOTAL = 500000
+MAXNETUPBPSTOTAL = 500000
+HARDUPLIMIT = 0
+MAXCPULOAD = 10
+MAXIOLOAD = 50
+HARDCPULIMIT = 0
+BASICLIMITING = YES
+INTERFACES = eth1
+
+[GNUNETD-EXPERIMENTAL]
+PADDING = NO
+
+[NAT]
+LIMITED = AUTO
+
+[TCP]
+PORT = 2086
+UPNP = YES
+BLACKLIST =
+WHITELIST =
+
+[UDP]
+PORT = 2086
+UPNP = YES
+MTU = 1472
+BLACKLIST =
+WHITELIST =
+
+[GAP]
+TABLESIZE = 65536
+
+[DHT]
+TABLESIZE = 1024
+LOGSQLEXTENDED = NO
+DHTLOG_MYSQL = NO
+
+[DSTORE]
+QUOTA = 1
+
+[TESTING]
+WEAKRANDOM = YES
+
Added: GNUnet/src/applications/fs/gap/test_gap_dv.c
===================================================================
--- GNUnet/src/applications/fs/gap/test_gap_dv.c
(rev 0)
+++ GNUnet/src/applications/fs/gap/test_gap_dv.c 2009-10-23 01:17:43 UTC
(rev 9250)
@@ -0,0 +1,221 @@
+/*
+ This file is part of GNUnet.
+ (C) 2007, 2008 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
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file applications/fs/gap/test_gap_dv.c
+ * @brief DV_DHT testcase
+ * @author Christian Grothoff
+ * @author Nathan Evans
+ */
+
+#include "platform.h"
+#include "gnunet_protocols.h"
+#include "gnunet_testing_lib.h"
+#include "gnunet_stats_lib.h"
+#include "gnunet_util.h"
+#include "gnunet_remote_lib.h"
+
+/**
+ * How many peers should the testcase run? Note that
+ * we create a clique topology so the cost is quadratic!
+ */
+#define NUM_PEERS 15
+
+/**
+ * How many times will we try the DV_DHT-GET operation before
+ * giving up for good?
+ */
+#define NUM_ROUNDS 20
+
+/**
+ * How often do we iterate the put-get loop?
+ */
+#define NUM_REPEAT 20
+
+static int ok;
+
+static int
+waitForConnect (const char *name, unsigned long long value, void *cls)
+{
+ if ((value > 0) && (0 == strcmp (_("# dv_dht connections"), name)))
+ {
+ ok = 1;
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+static int
+getPeers (const char *name, unsigned long long value, void *cls)
+{
+ if ((value > 0) && (strstr (name, _("# dv")) != NULL))
+ {
+ fprintf (stderr, "%s : %llu\n", name, value);
+ }
+
+ if ((value > 0) && (0 == strcmp (_("# dv_dht connections"), name)))
+ {
+ ok = 1;
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+#define CHECK(a) do { if (!(a)) { ret = 1; GNUNET_GE_BREAK(ectx, 0); goto
FAILURE; } } while(0)
+
+/**
+ * Testcase to test DV_DHT routing (many peers).
+ * @return 0: ok, -1: error
+ */
+int
+main (int argc, const char **argv)
+{
+ struct GNUNET_REMOTE_TESTING_DaemonContext *peers;
+ struct GNUNET_REMOTE_TESTING_DaemonContext *peer_array[NUM_PEERS];
+ struct GNUNET_REMOTE_TESTING_DaemonContext *pos;
+ int ret = 0;
+ struct GNUNET_GE_Context *ectx;
+ struct GNUNET_GC_Configuration *cfg;
+ struct GNUNET_ClientServerConnection *sock;
+ int left;
+ int i;
+ int r;
+ char buf[128];
+
+ ectx = NULL;
+ cfg = GNUNET_GC_create ();
+ if (-1 == GNUNET_GC_parse_configuration (cfg, "gap_test.conf"))
+ {
+ GNUNET_GC_free (cfg);
+ return -1;
+ }
+ GNUNET_GC_set_configuration_value_string (cfg, NULL,
+ "MULTIPLE_SERVER_TESTING",
+ "DOT_OUTPUT", "topology.dot");
+ printf ("Starting %u peers...\n", NUM_PEERS);
+ GNUNET_REMOTE_start_daemons (&peers, cfg, NUM_PEERS);
+ if (peers == NULL)
+ {
+ GNUNET_GC_free (cfg);
+ return -1;
+ }
+ pos = peers;
+ for (i = 0; i < NUM_PEERS; i++)
+ {
+ peer_array[i] = pos;
+ pos = pos->next;
+ }
+ sleep (30);
+ fprintf (stdout, "Will run for %d minues\n", NUM_REPEAT);
+ for (r = 0; r < NUM_REPEAT; r++)
+ {
+ fprintf (stderr, "After %d minutes\n", r);
+ for (i = 0; i < NUM_PEERS; i++)
+ {
+ if (GNUNET_shutdown_test () == GNUNET_YES)
+ break;
+ fprintf (stderr, "Peer %d: ", i);
+ sock =
+ GNUNET_client_connection_create (NULL, peer_array[i]->config);
+ GNUNET_STATS_get_statistics (NULL, sock, &getPeers, NULL);
+ GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
+ GNUNET_client_connection_destroy (sock);
+
+ }
+ if (GNUNET_shutdown_test () == GNUNET_YES)
+ break;
+ sleep (60);
+ }
+
+ for (r = 0; r < NUM_REPEAT; r++)
+ {
+ for (i = 0; i < NUM_PEERS; i++)
+ {
+ if (GNUNET_shutdown_test () == GNUNET_YES)
+ break;
+ fprintf (stderr, "Peer %d: ", i);
+ sock =
+ GNUNET_client_connection_create (NULL, peer_array[i]->config);
+ GNUNET_STATS_get_statistics (NULL, sock, &getPeers, NULL);
+ GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
+ GNUNET_client_connection_destroy (sock);
+
+ }
+ if (GNUNET_shutdown_test () == GNUNET_YES)
+ break;
+
+ printf ("Waiting for DV_DHT connections of peer");
+ for (i = 0; i < NUM_PEERS; i++)
+ {
+ if (GNUNET_shutdown_test () == GNUNET_YES)
+ break;
+ ok = 0;
+ printf (" %d", i);
+ fflush (stdout);
+ GNUNET_snprintf (buf, sizeof (buf), "localhost:%u", 2087 + i * 10);
+ /* wait for some DV_DHT's to find each other! */
+ sock =
+ GNUNET_client_connection_create (NULL, peer_array[i]->config);
+ left = 30; /* how many iterations should we wait? */
+ while (GNUNET_OK ==
+ GNUNET_STATS_get_statistics (NULL, sock, &waitForConnect,
+ NULL))
+ {
+ if (GNUNET_shutdown_test () == GNUNET_YES)
+ break;
+ if (9 == left % 10)
+ printf (".");
+ fflush (stdout);
+ GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
+ left--;
+ if (left == 0)
+ break;
+ }
+ GNUNET_client_connection_destroy (sock);
+ if (ok == 0)
+ {
+ printf ("ERROR!\n");
+ fflush (stdout);
+ pos = peers;
+ while (pos != NULL)
+ {
+ GNUNET_REMOTE_kill_daemon (pos);
+ pos = pos->next;
+ }
+ fprintf (stderr, "Peers' DV_DHTs failed to DV_DHT-connect!\n");
+ GNUNET_GC_free (cfg);
+ return -1;
+ }
+
+ }
+ }
+ /* end of actual test code */
+
+ pos = peers;
+ while (pos != NULL)
+ {
+ GNUNET_REMOTE_kill_daemon (pos);
+ pos = pos->next;
+ }
+ GNUNET_GC_free (cfg);
+ return ret;
+}
+
+/* end of test_gap_dv.c */
Modified: GNUnet/src/applications/fs/gap/test_multi_results_dv.c
===================================================================
--- GNUnet/src/applications/fs/gap/test_multi_results_dv.c 2009-10-23
01:14:12 UTC (rev 9249)
+++ GNUnet/src/applications/fs/gap/test_multi_results_dv.c 2009-10-23
01:17:43 UTC (rev 9250)
@@ -19,7 +19,7 @@
*/
/**
- * @file applications/gap/test_multi_results.c
+ * @file applications/gap/test_multi_results_dv.c
* @brief GAP routing testcase, linear topology
* @author Christian Grothoff
*/
@@ -32,6 +32,7 @@
#include "gnunet_util.h"
#include "gnunet_stats_lib.h"
#include "../ecrs/ecrs.h"
+#include "gnunet_identity_lib.h"
#define START_PEERS 1
#define DEBUG 1
@@ -80,7 +81,9 @@
int fd;
char *buf;
struct GNUNET_ECRS_URI *uri;
-
+ struct GNUNET_ClientServerConnection *sock;
+ struct GNUNET_ECRS_URI *locURI;
+ GNUNET_MessageHello *hello;
name = makeName (size);
fd =
GNUNET_disk_file_open (ectx, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
@@ -95,10 +98,11 @@
GNUNET_free (buf);
GNUNET_disk_file_close (ectx, name, fd);
ret = GNUNET_ECRS_file_upload (ectx, cfg, name, GNUNET_YES, /* index */
- 1, /* anonymous */
+ 0, /* anonymity */
0, /* priority */
GNUNET_get_time () + 100 *
GNUNET_CRON_MINUTES, /* expire */
NULL, NULL, &testTerminate, NULL, &uri);
+
if (ret != GNUNET_SYSERR)
{
struct GNUNET_MetaData *meta;
@@ -106,6 +110,26 @@
meta = GNUNET_meta_data_create ();
ret = GNUNET_ECRS_publish_under_keyword (ectx, cfg, key, 0, 0,
GNUNET_get_time () + 100 * GNUNET_CRON_MINUTES, /* expire */
uri, meta);
+ sock = GNUNET_client_connection_create (ectx, cfg);
+ if (GNUNET_OK == GNUNET_IDENTITY_get_self (sock, &hello))
+ {
+ locURI = GNUNET_ECRS_location_to_uri (uri,
+ &hello->publicKey,
+ ntohl (hello->
+ expiration_time),
+ (GNUNET_ECRS_SignFunction) &
+ GNUNET_IDENTITY_sign_function,
+ sock);
+ ret = GNUNET_ECRS_publish_under_keyword (ectx, cfg, key, 0, 0,
GNUNET_get_time () + 100 * GNUNET_CRON_MINUTES, /* expire */
+ locURI, meta);
+ if (ret != GNUNET_OK)
+ fprintf (stderr, "Failed to publish locURI\n");
+ GNUNET_free (hello);
+ }
+ else
+ {
+ fprintf (stderr, "failed to create loc\n");
+ }
GNUNET_meta_data_destroy (meta);
GNUNET_free (name);
if (ret == GNUNET_OK)
@@ -128,8 +152,28 @@
int i;
#if DEBUG
+ GNUNET_EncName enc;
+ GNUNET_HashCode hc;
if (fi->uri->type == loc)
- fprintf(stdout, "Got location information from search, great!\n");
+ {
+ fprintf (stdout,
+ "Got location information from search, great, isroot = %d!\n",
+ isRoot);
+/* if (GNUNET_OK == parseLocationURI(ectx, fi->uri, &uri->data.loc))
+ {
+
+ }*/
+ GNUNET_hash (&fi->uri->data.loc.peer, sizeof (GNUNET_RSA_PublicKey),
+ &hc);
+ GNUNET_hash_to_enc (&hc, &enc);
+ fprintf (stdout, "Received locURI putting data at peer %s\n",
+ (char *) &enc);
+ }
+ else
+ {
+ fprintf (stdout, "Got type %d, isroot=%d\n", fi->uri->type, isRoot);
+ }
+
#endif
for (i = 0; i < TOTAL; i++)
@@ -201,11 +245,11 @@
{
uris[i] = uploadFile (i + 1);
CHECK (uris[i] != NULL);
- tmp = GNUNET_ECRS_uri_to_string(uris[i]);
+ tmp = GNUNET_ECRS_uri_to_string (uris[i]);
//fprintf (stderr, "URI is %s\n", tmp);
- GNUNET_free(tmp);
+ GNUNET_free (tmp);
}
- GNUNET_thread_sleep(360 * GNUNET_CRON_SECONDS);
+ GNUNET_thread_sleep (360 * GNUNET_CRON_SECONDS);
fprintf (stderr, "\nSearching...");
GNUNET_snprintf (buf, 128, "localhost:%u", 2077 + PEER_COUNT * 10);
GNUNET_GC_set_configuration_value_string (cfg, ectx, "NETWORK", "HOST",
@@ -214,6 +258,7 @@
GNUNET_ECRS_search (ectx,
cfg, key, 0, &searchCB, NULL, &testTerminate, NULL);
fprintf (stderr, "\n");
+ GNUNET_thread_sleep (120 * GNUNET_CRON_SECONDS);
CHECK (found > (TOTAL * 90) / 100);
FAILURE:
#if START_PEERS
Modified: GNUnet/src/applications/fs/gap/test_star_topology.c
===================================================================
--- GNUnet/src/applications/fs/gap/test_star_topology.c 2009-10-23 01:14:12 UTC
(rev 9249)
+++ GNUnet/src/applications/fs/gap/test_star_topology.c 2009-10-23 01:17:43 UTC
(rev 9250)
@@ -221,8 +221,7 @@
ret = 0;
cfg = GNUNET_GC_create ();
- fprintf(stderr,
- "Setup...\n");
+ fprintf (stderr, "Setup...\n");
if (-1 == GNUNET_GC_parse_configuration (cfg, "check.conf"))
{
GNUNET_GC_free (cfg);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r9250 - GNUnet/src/applications/fs/gap,
gnunet <=