diff options
Diffstat (limited to 'src/fs/fs_search.c')
-rw-r--r-- | src/fs/fs_search.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index a03e9becb..746a2f19d 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include "gnunet_protocols.h" | 38 | #include "gnunet_protocols.h" |
39 | #include "fs.h" | 39 | #include "fs.h" |
40 | 40 | ||
41 | #define DEBUG_SEARCH GNUNET_NO | 41 | #define DEBUG_SEARCH GNUNET_YES |
42 | 42 | ||
43 | 43 | ||
44 | 44 | ||
@@ -161,8 +161,8 @@ struct GetResultContext | |||
161 | 161 | ||
162 | 162 | ||
163 | /** | 163 | /** |
164 | * Check if the given result is identical | 164 | * Check if the given result is identical to the given URI and if so |
165 | * to the given URI and if so return it. | 165 | * return it. |
166 | * | 166 | * |
167 | * @param cls a "struct GetResultContext" | 167 | * @param cls a "struct GetResultContext" |
168 | * @param key not used | 168 | * @param key not used |
@@ -186,9 +186,8 @@ get_result_present (void *cls, | |||
186 | 186 | ||
187 | 187 | ||
188 | /** | 188 | /** |
189 | * We have received a KSK result. Check | 189 | * We have received a KSK result. Check how it fits in with the |
190 | * how it fits in with the overall query | 190 | * overall query and notify the client accordingly. |
191 | * and notify the client accordingly. | ||
192 | * | 191 | * |
193 | * @param sc context for the overall query | 192 | * @param sc context for the overall query |
194 | * @param ent entry for the specific keyword | 193 | * @param ent entry for the specific keyword |
@@ -208,14 +207,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc, | |||
208 | int is_new; | 207 | int is_new; |
209 | 208 | ||
210 | /* check if new */ | 209 | /* check if new */ |
211 | if (! GNUNET_FS_uri_test_chk (uri)) | 210 | GNUNET_FS_uri_to_key (uri, &key); |
212 | { | ||
213 | GNUNET_break_op (0); | ||
214 | return; | ||
215 | } | ||
216 | GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key, | ||
217 | &uri->data.chk.chk.query, | ||
218 | &key); | ||
219 | if (GNUNET_SYSERR == | 211 | if (GNUNET_SYSERR == |
220 | GNUNET_CONTAINER_multihashmap_get_multiple (ent->results, | 212 | GNUNET_CONTAINER_multihashmap_get_multiple (ent->results, |
221 | &key, | 213 | &key, |
@@ -281,9 +273,8 @@ search_start (struct GNUNET_FS_Handle *h, | |||
281 | 273 | ||
282 | 274 | ||
283 | /** | 275 | /** |
284 | * We have received an SKS result. Start | 276 | * We have received an SKS result. Start searching for updates and |
285 | * searching for updates and notify the | 277 | * notify the client if it is a new result. |
286 | * client if it is a new result. | ||
287 | * | 278 | * |
288 | * @param sc context for the overall query | 279 | * @param sc context for the overall query |
289 | * @param id_update identifier for updates, NULL for none | 280 | * @param id_update identifier for updates, NULL for none |
@@ -301,11 +292,7 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc, | |||
301 | struct SearchResult *sr; | 292 | struct SearchResult *sr; |
302 | 293 | ||
303 | /* check if new */ | 294 | /* check if new */ |
304 | if (! GNUNET_FS_uri_test_ksk (uri)) | 295 | GNUNET_FS_uri_to_key (uri, &key); |
305 | { | ||
306 | GNUNET_break_op (0); | ||
307 | return; | ||
308 | } | ||
309 | GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key, | 296 | GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key, |
310 | &uri->data.chk.chk.query, | 297 | &uri->data.chk.chk.query, |
311 | &key); | 298 | &key); |
@@ -618,6 +605,7 @@ transmit_search_request (void *cls, | |||
618 | struct SearchMessage *sm; | 605 | struct SearchMessage *sm; |
619 | unsigned int i; | 606 | unsigned int i; |
620 | const char *identifier; | 607 | const char *identifier; |
608 | GNUNET_HashCode key; | ||
621 | GNUNET_HashCode idh; | 609 | GNUNET_HashCode idh; |
622 | 610 | ||
623 | if (NULL == buf) | 611 | if (NULL == buf) |
@@ -635,28 +623,34 @@ transmit_search_request (void *cls, | |||
635 | { | 623 | { |
636 | sm[i].header.size = htons (sizeof (struct SearchMessage)); | 624 | sm[i].header.size = htons (sizeof (struct SearchMessage)); |
637 | sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); | 625 | sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); |
638 | sm[i].anonymity_level = htonl (sc->anonymity); | 626 | sm[i].type = htonl (GNUNET_DATASTORE_BLOCKTYPE_KBLOCK); |
627 | sm[i].anonymity_level = htonl (sc->anonymity); | ||
639 | sm[i].query = sc->requests[i].query; | 628 | sm[i].query = sc->requests[i].query; |
640 | } | 629 | } |
641 | } | 630 | } |
642 | else | 631 | else |
643 | { | 632 | { |
633 | GNUNET_assert (GNUNET_FS_uri_test_sks (sc->uri)); | ||
644 | msize = sizeof (struct SearchMessage); | 634 | msize = sizeof (struct SearchMessage); |
645 | GNUNET_assert (size >= msize); | 635 | GNUNET_assert (size >= msize); |
646 | sm = buf; | 636 | sm = buf; |
647 | memset (sm, 0, msize); | 637 | memset (sm, 0, msize); |
648 | sm->header.size = htons (sizeof (struct SearchMessage)); | 638 | sm->header.size = htons (sizeof (struct SearchMessage)); |
649 | sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); | 639 | sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); |
640 | sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_SBLOCK); | ||
650 | sm->anonymity_level = htonl (sc->anonymity); | 641 | sm->anonymity_level = htonl (sc->anonymity); |
651 | sm->target = sc->uri->data.sks.namespace; | 642 | sm->target = sc->uri->data.sks.namespace; |
652 | identifier = sc->uri->data.sks.identifier; | 643 | identifier = sc->uri->data.sks.identifier; |
653 | GNUNET_CRYPTO_hash (identifier, | 644 | GNUNET_CRYPTO_hash (identifier, |
654 | strlen (identifier), | 645 | strlen (identifier), |
646 | &key); | ||
647 | GNUNET_CRYPTO_hash (&key, | ||
648 | sizeof (GNUNET_HashCode), | ||
655 | &idh); | 649 | &idh); |
656 | GNUNET_CRYPTO_hash_xor (&idh, | 650 | GNUNET_CRYPTO_hash_xor (&idh, |
657 | &sm->target, | 651 | &sm->target, |
658 | &sm->query); | 652 | &sm->query); |
659 | } | 653 | } |
660 | GNUNET_CLIENT_receive (sc->client, | 654 | GNUNET_CLIENT_receive (sc->client, |
661 | &receive_results, | 655 | &receive_results, |
662 | sc, | 656 | sc, |
@@ -785,6 +779,7 @@ search_start (struct GNUNET_FS_Handle *h, | |||
785 | sc->client_info = cctx; | 779 | sc->client_info = cctx; |
786 | if (GNUNET_FS_uri_test_ksk (uri)) | 780 | if (GNUNET_FS_uri_test_ksk (uri)) |
787 | { | 781 | { |
782 | GNUNET_assert (0 != sc->uri->data.ksk.keywordCount); | ||
788 | sc->requests = GNUNET_malloc (sizeof (struct SearchRequestEntry) * | 783 | sc->requests = GNUNET_malloc (sizeof (struct SearchRequestEntry) * |
789 | sc->uri->data.ksk.keywordCount); | 784 | sc->uri->data.ksk.keywordCount); |
790 | for (i=0;i<sc->uri->data.ksk.keywordCount;i++) | 785 | for (i=0;i<sc->uri->data.ksk.keywordCount;i++) |