aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_search.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-04-28 12:40:41 +0000
committerChristian Grothoff <christian@grothoff.org>2010-04-28 12:40:41 +0000
commitd83a3d2ac2a33d43239bbd5703574872081ba81f (patch)
tree4cf623eeec48634fa1d0ffd6ce31521ee90a3c3c /src/fs/fs_search.c
parent0398c75b95c53ffd109635e5477e8bb3b93217de (diff)
downloadgnunet-d83a3d2ac2a33d43239bbd5703574872081ba81f.tar.gz
gnunet-d83a3d2ac2a33d43239bbd5703574872081ba81f.zip
added option to restrict search to local-only
Diffstat (limited to 'src/fs/fs_search.c')
-rw-r--r--src/fs/fs_search.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index 2c8022237..efe5bf34a 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -458,6 +458,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc,
458 * @param uri specifies the search parameters; can be 458 * @param uri specifies the search parameters; can be
459 * a KSK URI or an SKS URI. 459 * a KSK URI or an SKS URI.
460 * @param anonymity desired level of anonymity 460 * @param anonymity desired level of anonymity
461 * @param options options for the search
461 * @param cctx client context 462 * @param cctx client context
462 * @param parent parent search (for namespace update searches) 463 * @param parent parent search (for namespace update searches)
463 * @return context that can be used to control the search 464 * @return context that can be used to control the search
@@ -466,6 +467,7 @@ static struct GNUNET_FS_SearchContext *
466search_start (struct GNUNET_FS_Handle *h, 467search_start (struct GNUNET_FS_Handle *h,
467 const struct GNUNET_FS_Uri *uri, 468 const struct GNUNET_FS_Uri *uri,
468 uint32_t anonymity, 469 uint32_t anonymity,
470 enum GNUNET_FS_SearchOptions options,
469 void *cctx, 471 void *cctx,
470 struct GNUNET_FS_SearchContext *parent); 472 struct GNUNET_FS_SearchContext *parent);
471 473
@@ -523,6 +525,7 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc,
523 search_start (sc->h, 525 search_start (sc->h,
524 &uu, 526 &uu,
525 sc->anonymity, 527 sc->anonymity,
528 sc->options,
526 NULL, 529 NULL,
527 sc); 530 sc);
528} 531}
@@ -938,6 +941,10 @@ transmit_search_request (void *cls,
938 { 941 {
939 sm[i].header.size = htons (sizeof (struct SearchMessage)); 942 sm[i].header.size = htons (sizeof (struct SearchMessage));
940 sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); 943 sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
944 if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY))
945 sm[i].options = htonl (1);
946 else
947 sm[i].options = htonl (0);
941 sm[i].type = htonl (GNUNET_BLOCK_TYPE_ANY); 948 sm[i].type = htonl (GNUNET_BLOCK_TYPE_ANY);
942 sm[i].anonymity_level = htonl (sc->anonymity); 949 sm[i].anonymity_level = htonl (sc->anonymity);
943 sm[i].query = sc->requests[i].query; 950 sm[i].query = sc->requests[i].query;
@@ -952,6 +959,10 @@ transmit_search_request (void *cls,
952 memset (sm, 0, msize); 959 memset (sm, 0, msize);
953 sm->header.size = htons (sizeof (struct SearchMessage)); 960 sm->header.size = htons (sizeof (struct SearchMessage));
954 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); 961 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
962 if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY))
963 sm->options = htonl (1);
964 else
965 sm->options = htonl (0);
955 sm->type = htonl (GNUNET_BLOCK_TYPE_SBLOCK); 966 sm->type = htonl (GNUNET_BLOCK_TYPE_SBLOCK);
956 sm->anonymity_level = htonl (sc->anonymity); 967 sm->anonymity_level = htonl (sc->anonymity);
957 sm->target = sc->uri->data.sks.namespace; 968 sm->target = sc->uri->data.sks.namespace;
@@ -1042,6 +1053,7 @@ try_reconnect (struct GNUNET_FS_SearchContext *sc)
1042 * @param uri specifies the search parameters; can be 1053 * @param uri specifies the search parameters; can be
1043 * a KSK URI or an SKS URI. 1054 * a KSK URI or an SKS URI.
1044 * @param anonymity desired level of anonymity 1055 * @param anonymity desired level of anonymity
1056 * @param options options for the search
1045 * @param cctx initial value for the client context 1057 * @param cctx initial value for the client context
1046 * @param parent parent search (for namespace update searches) 1058 * @param parent parent search (for namespace update searches)
1047 * @return context that can be used to control the search 1059 * @return context that can be used to control the search
@@ -1050,6 +1062,7 @@ static struct GNUNET_FS_SearchContext *
1050search_start (struct GNUNET_FS_Handle *h, 1062search_start (struct GNUNET_FS_Handle *h,
1051 const struct GNUNET_FS_Uri *uri, 1063 const struct GNUNET_FS_Uri *uri,
1052 uint32_t anonymity, 1064 uint32_t anonymity,
1065 enum GNUNET_FS_SearchOptions options,
1053 void *cctx, 1066 void *cctx,
1054 struct GNUNET_FS_SearchContext *parent) 1067 struct GNUNET_FS_SearchContext *parent)
1055{ 1068{
@@ -1085,6 +1098,7 @@ search_start (struct GNUNET_FS_Handle *h,
1085 return NULL; 1098 return NULL;
1086 sc = GNUNET_malloc (sizeof(struct GNUNET_FS_SearchContext)); 1099 sc = GNUNET_malloc (sizeof(struct GNUNET_FS_SearchContext));
1087 sc->h = h; 1100 sc->h = h;
1101 sc->options = options;
1088 sc->uri = GNUNET_FS_uri_dup (uri); 1102 sc->uri = GNUNET_FS_uri_dup (uri);
1089 sc->anonymity = anonymity; 1103 sc->anonymity = anonymity;
1090 sc->start_time = GNUNET_TIME_absolute_get (); 1104 sc->start_time = GNUNET_TIME_absolute_get ();
@@ -1139,6 +1153,7 @@ search_start (struct GNUNET_FS_Handle *h,
1139 * @param uri specifies the search parameters; can be 1153 * @param uri specifies the search parameters; can be
1140 * a KSK URI or an SKS URI. 1154 * a KSK URI or an SKS URI.
1141 * @param anonymity desired level of anonymity 1155 * @param anonymity desired level of anonymity
1156 * @param options options for the search
1142 * @param cctx initial value for the client context 1157 * @param cctx initial value for the client context
1143 * @return context that can be used to control the search 1158 * @return context that can be used to control the search
1144 */ 1159 */
@@ -1146,9 +1161,10 @@ struct GNUNET_FS_SearchContext *
1146GNUNET_FS_search_start (struct GNUNET_FS_Handle *h, 1161GNUNET_FS_search_start (struct GNUNET_FS_Handle *h,
1147 const struct GNUNET_FS_Uri *uri, 1162 const struct GNUNET_FS_Uri *uri,
1148 uint32_t anonymity, 1163 uint32_t anonymity,
1164 enum GNUNET_FS_SearchOptions options,
1149 void *cctx) 1165 void *cctx)
1150{ 1166{
1151 return search_start (h, uri, anonymity, cctx, NULL); 1167 return search_start (h, uri, anonymity, options, cctx, NULL);
1152} 1168}
1153 1169
1154 1170