summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-15 10:06:46 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-15 10:06:46 +0000
commit4cdb439de274aee9c25c71e629b2002745b49199 (patch)
treecbddc8e2e2d474a83f2bd622a105a35d6e5bbba1 /src
parent35885b75d0d876cb20a68706d909ad2657be2c2b (diff)
towards fixing #1786
Diffstat (limited to 'src')
-rw-r--r--src/fs/fs.h28
-rw-r--r--src/fs/fs_download.c4
-rw-r--r--src/fs/fs_search.c14
-rw-r--r--src/fs/gnunet-service-fs_lc.c5
4 files changed, 37 insertions, 14 deletions
diff --git a/src/fs/fs.h b/src/fs/fs.h
index bbe4e8660..90d32f4a7 100644
--- a/src/fs/fs.h
+++ b/src/fs/fs.h
@@ -178,6 +178,25 @@ struct UnindexMessage
/**
+ * No options.
+ */
+#define SEARCH_MESSAGE_OPTION_NONE 0
+
+/**
+ * Only search the local datastore (no network)
+ */
+#define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY 1
+
+/**
+ * Request is too large to fit in 64k format. The list of
+ * already-known search results will be continued in another message
+ * for the same type/query/target and additional already-known results
+ * following this one).
+ */
+#define SEARCH_MESSAGE_OPTION_CONTINUED 2
+
+
+/**
* Message sent from a GNUnet (fs) search activity to the
* gnunet-service-fs to start a search.
*/
@@ -191,10 +210,15 @@ struct SearchMessage
struct GNUNET_MessageHeader header;
/**
- * Bitmask with options. Zero for no options, one for loopback-only.
+ * Bitmask with options. Zero for no options, one for
+ * loopback-only, two for 'to be continued' (with a second search
+ * message for the same type/query/target and additional
+ * already-known results following this one). See
+ * SEARCH_MESSAGE_OPTION_ defines.
+ *
* Other bits are currently not defined.
*/
- int32_t options GNUNET_PACKED;
+ uint32_t options GNUNET_PACKED;
/**
* Type of the content that we're looking for.
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 09785f6dd..e4e015e88 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -1284,9 +1284,9 @@ transmit_download_request (void *cls, size_t size, void *buf)
sm->header.size = htons (sizeof (struct SearchMessage));
sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
if (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY))
- sm->options = htonl (1);
+ sm->options = htonl (GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY);
else
- sm->options = htonl (0);
+ sm->options = htonl (GNUNET_FS_SEARCH_OPTION_NONE);
if (dr->depth == 0)
sm->type = htonl (GNUNET_BLOCK_TYPE_FS_DBLOCK);
else
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index b5152cc66..18e03ab61 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -968,6 +968,7 @@ transmit_search_request (void *cls, size_t size, void *buf)
GNUNET_HashCode key;
GNUNET_HashCode idh;
unsigned int sqms;
+ uint32_t options;
if (NULL == buf)
{
@@ -979,6 +980,9 @@ transmit_search_request (void *cls, size_t size, void *buf)
sm = buf;
sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
mbc.xoff = (GNUNET_HashCode *) & sm[1];
+ options = SEARCH_MESSAGE_OPTION_NONE;
+ if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY))
+ options |= SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY;
if (GNUNET_FS_uri_test_ksk (sc->uri))
{
msize = sizeof (struct SearchMessage);
@@ -994,10 +998,7 @@ transmit_search_request (void *cls, size_t size, void *buf)
GNUNET_assert (mbc.put_cnt > 0);
sm->header.size = htons (msize);
- if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY))
- sm->options = htonl (1);
- else
- sm->options = htonl (0);
+ sm->options = htonl (options);
sm->type = htonl (GNUNET_BLOCK_TYPE_ANY);
sm->anonymity_level = htonl (sc->anonymity);
memset (&sm->target, 0, sizeof (GNUNET_HashCode));
@@ -1025,10 +1026,7 @@ transmit_search_request (void *cls, size_t size, void *buf)
GNUNET_assert (GNUNET_FS_uri_test_sks (sc->uri));
msize = sizeof (struct SearchMessage);
GNUNET_assert (size >= msize);
- if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY))
- sm->options = htonl (1);
- else
- sm->options = htonl (0);
+ sm->options = htonl (options);
sm->type = htonl (GNUNET_BLOCK_TYPE_FS_SBLOCK);
sm->anonymity_level = htonl (sc->anonymity);
sm->target = sc->uri->data.sks.namespace;
diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c
index 30a7f57d6..e2a6856fa 100644
--- a/src/fs/gnunet-service-fs_lc.c
+++ b/src/fs/gnunet-service-fs_lc.c
@@ -362,9 +362,10 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
cr->lc = lc;
GNUNET_CONTAINER_DLL_insert (lc->cr_head, lc->cr_tail, cr);
options = GSF_PRO_LOCAL_REQUEST;
- if (0 != (1 & ntohl (sm->options)))
+ if (0 != (GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY & ntohl (sm->options)))
options |= GSF_PRO_LOCAL_ONLY;
- cr->pr = GSF_pending_request_create_ (options, type, &sm->query, (type == GNUNET_BLOCK_TYPE_FS_SBLOCK) ? &sm->target /* namespace */
+ cr->pr = GSF_pending_request_create_ (options, type, &sm->query,
+ (type == GNUNET_BLOCK_TYPE_FS_SBLOCK) ? &sm->target /* namespace */
: NULL,
(0 !=
memcmp (&sm->target, &all_zeros,