aboutsummaryrefslogtreecommitdiff
path: root/src/fs
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/fs
parent35885b75d0d876cb20a68706d909ad2657be2c2b (diff)
downloadgnunet-4cdb439de274aee9c25c71e629b2002745b49199.tar.gz
gnunet-4cdb439de274aee9c25c71e629b2002745b49199.zip
towards fixing #1786
Diffstat (limited to 'src/fs')
-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
178 178
179 179
180/** 180/**
181 * No options.
182 */
183#define SEARCH_MESSAGE_OPTION_NONE 0
184
185/**
186 * Only search the local datastore (no network)
187 */
188#define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY 1
189
190/**
191 * Request is too large to fit in 64k format. The list of
192 * already-known search results will be continued in another message
193 * for the same type/query/target and additional already-known results
194 * following this one).
195 */
196#define SEARCH_MESSAGE_OPTION_CONTINUED 2
197
198
199/**
181 * Message sent from a GNUnet (fs) search activity to the 200 * Message sent from a GNUnet (fs) search activity to the
182 * gnunet-service-fs to start a search. 201 * gnunet-service-fs to start a search.
183 */ 202 */
@@ -191,10 +210,15 @@ struct SearchMessage
191 struct GNUNET_MessageHeader header; 210 struct GNUNET_MessageHeader header;
192 211
193 /** 212 /**
194 * Bitmask with options. Zero for no options, one for loopback-only. 213 * Bitmask with options. Zero for no options, one for
214 * loopback-only, two for 'to be continued' (with a second search
215 * message for the same type/query/target and additional
216 * already-known results following this one). See
217 * SEARCH_MESSAGE_OPTION_ defines.
218 *
195 * Other bits are currently not defined. 219 * Other bits are currently not defined.
196 */ 220 */
197 int32_t options GNUNET_PACKED; 221 uint32_t options GNUNET_PACKED;
198 222
199 /** 223 /**
200 * Type of the content that we're looking for. 224 * 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)
1284 sm->header.size = htons (sizeof (struct SearchMessage)); 1284 sm->header.size = htons (sizeof (struct SearchMessage));
1285 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); 1285 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
1286 if (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY)) 1286 if (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY))
1287 sm->options = htonl (1); 1287 sm->options = htonl (GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY);
1288 else 1288 else
1289 sm->options = htonl (0); 1289 sm->options = htonl (GNUNET_FS_SEARCH_OPTION_NONE);
1290 if (dr->depth == 0) 1290 if (dr->depth == 0)
1291 sm->type = htonl (GNUNET_BLOCK_TYPE_FS_DBLOCK); 1291 sm->type = htonl (GNUNET_BLOCK_TYPE_FS_DBLOCK);
1292 else 1292 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)
968 GNUNET_HashCode key; 968 GNUNET_HashCode key;
969 GNUNET_HashCode idh; 969 GNUNET_HashCode idh;
970 unsigned int sqms; 970 unsigned int sqms;
971 uint32_t options;
971 972
972 if (NULL == buf) 973 if (NULL == buf)
973 { 974 {
@@ -979,6 +980,9 @@ transmit_search_request (void *cls, size_t size, void *buf)
979 sm = buf; 980 sm = buf;
980 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); 981 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
981 mbc.xoff = (GNUNET_HashCode *) & sm[1]; 982 mbc.xoff = (GNUNET_HashCode *) & sm[1];
983 options = SEARCH_MESSAGE_OPTION_NONE;
984 if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY))
985 options |= SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY;
982 if (GNUNET_FS_uri_test_ksk (sc->uri)) 986 if (GNUNET_FS_uri_test_ksk (sc->uri))
983 { 987 {
984 msize = sizeof (struct SearchMessage); 988 msize = sizeof (struct SearchMessage);
@@ -994,10 +998,7 @@ transmit_search_request (void *cls, size_t size, void *buf)
994 GNUNET_assert (mbc.put_cnt > 0); 998 GNUNET_assert (mbc.put_cnt > 0);
995 999
996 sm->header.size = htons (msize); 1000 sm->header.size = htons (msize);
997 if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY)) 1001 sm->options = htonl (options);
998 sm->options = htonl (1);
999 else
1000 sm->options = htonl (0);
1001 sm->type = htonl (GNUNET_BLOCK_TYPE_ANY); 1002 sm->type = htonl (GNUNET_BLOCK_TYPE_ANY);
1002 sm->anonymity_level = htonl (sc->anonymity); 1003 sm->anonymity_level = htonl (sc->anonymity);
1003 memset (&sm->target, 0, sizeof (GNUNET_HashCode)); 1004 memset (&sm->target, 0, sizeof (GNUNET_HashCode));
@@ -1025,10 +1026,7 @@ transmit_search_request (void *cls, size_t size, void *buf)
1025 GNUNET_assert (GNUNET_FS_uri_test_sks (sc->uri)); 1026 GNUNET_assert (GNUNET_FS_uri_test_sks (sc->uri));
1026 msize = sizeof (struct SearchMessage); 1027 msize = sizeof (struct SearchMessage);
1027 GNUNET_assert (size >= msize); 1028 GNUNET_assert (size >= msize);
1028 if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY)) 1029 sm->options = htonl (options);
1029 sm->options = htonl (1);
1030 else
1031 sm->options = htonl (0);
1032 sm->type = htonl (GNUNET_BLOCK_TYPE_FS_SBLOCK); 1030 sm->type = htonl (GNUNET_BLOCK_TYPE_FS_SBLOCK);
1033 sm->anonymity_level = htonl (sc->anonymity); 1031 sm->anonymity_level = htonl (sc->anonymity);
1034 sm->target = sc->uri->data.sks.namespace; 1032 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,
362 cr->lc = lc; 362 cr->lc = lc;
363 GNUNET_CONTAINER_DLL_insert (lc->cr_head, lc->cr_tail, cr); 363 GNUNET_CONTAINER_DLL_insert (lc->cr_head, lc->cr_tail, cr);
364 options = GSF_PRO_LOCAL_REQUEST; 364 options = GSF_PRO_LOCAL_REQUEST;
365 if (0 != (1 & ntohl (sm->options))) 365 if (0 != (GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY & ntohl (sm->options)))
366 options |= GSF_PRO_LOCAL_ONLY; 366 options |= GSF_PRO_LOCAL_ONLY;
367 cr->pr = GSF_pending_request_create_ (options, type, &sm->query, (type == GNUNET_BLOCK_TYPE_FS_SBLOCK) ? &sm->target /* namespace */ 367 cr->pr = GSF_pending_request_create_ (options, type, &sm->query,
368 (type == GNUNET_BLOCK_TYPE_FS_SBLOCK) ? &sm->target /* namespace */
368 : NULL, 369 : NULL,
369 (0 != 370 (0 !=
370 memcmp (&sm->target, &all_zeros, 371 memcmp (&sm->target, &all_zeros,