towards fixing #1786
authorChristian Grothoff <christian@grothoff.org>
Tue, 15 Nov 2011 10:06:46 +0000 (10:06 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 15 Nov 2011 10:06:46 +0000 (10:06 +0000)
src/fs/fs.h
src/fs/fs_download.c
src/fs/fs_search.c
src/fs/gnunet-service-fs_lc.c

index bbe4e8660e3c9f5221dfa3ae028884aca71ddcea..90d32f4a7ef99475a308c85da9a0c0cad72cdbdc 100644 (file)
@@ -177,6 +177,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.
index 09785f6dd797adcf8b6975d318582bfbde644704..e4e015e8875efd5e7f465b824fa5eb9ff0c408c1 100644 (file)
@@ -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
index b5152cc66c617ac266bbacd48664e25bfe49db61..18e03ab61fcb0b0f01191072614fdfd3f2fb8337 100644 (file)
@@ -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;
index 30a7f57d60e376f6781471cd1ad0c86562386f28..e2a6856fa01bdfa6db658e9837b55767ac873de1 100644 (file)
@@ -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,