diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-09 09:40:03 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-09 09:40:03 +0000 |
commit | 0b0770065d84c2a6079c2033dd74ee7c751e88f6 (patch) | |
tree | 621e1795013524ff10baddf853ff40995a5349f3 /src/namestore/gnunet-service-namestore.c | |
parent | 5d418f9d2ba7f861388244803d7fb186ca2406ef (diff) | |
download | gnunet-0b0770065d84c2a6079c2033dd74ee7c751e88f6.tar.gz gnunet-0b0770065d84c2a6079c2033dd74ee7c751e88f6.zip |
- fixed lookup
Diffstat (limited to 'src/namestore/gnunet-service-namestore.c')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 55ead3a41..6a7082156 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -237,7 +237,6 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
237 | next = nc->next; | 237 | next = nc->next; |
238 | for (no = nc->op_head; no != NULL; no = tmp) | 238 | for (no = nc->op_head; no != NULL; no = tmp) |
239 | { | 239 | { |
240 | GNUNET_break (0); | ||
241 | GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, no); | 240 | GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, no); |
242 | tmp = no->next; | 241 | tmp = no->next; |
243 | GNUNET_free (no); | 242 | GNUNET_free (no); |
@@ -364,7 +363,6 @@ handle_lookup_name_it (void *cls, | |||
364 | struct GNUNET_NAMESTORE_RecordData *rd_selected = NULL; | 363 | struct GNUNET_NAMESTORE_RecordData *rd_selected = NULL; |
365 | struct GNUNET_NAMESTORE_CryptoContainer *cc; | 364 | struct GNUNET_NAMESTORE_CryptoContainer *cc; |
366 | struct GNUNET_CRYPTO_RsaSignature *signature_new = NULL; | 365 | struct GNUNET_CRYPTO_RsaSignature *signature_new = NULL; |
367 | const struct GNUNET_CRYPTO_RsaSignature *sig_to_use; | ||
368 | GNUNET_HashCode zone_key_hash; | 366 | GNUNET_HashCode zone_key_hash; |
369 | char *rd_tmp; | 367 | char *rd_tmp; |
370 | char *name_tmp; | 368 | char *name_tmp; |
@@ -373,7 +371,8 @@ handle_lookup_name_it (void *cls, | |||
373 | size_t name_len = 0; | 371 | size_t name_len = 0; |
374 | 372 | ||
375 | int copied_elements = 0; | 373 | int copied_elements = 0; |
376 | int contains_signature = 0; | 374 | int contains_signature = GNUNET_NO; |
375 | int authoritative = GNUNET_NO; | ||
377 | int c; | 376 | int c; |
378 | 377 | ||
379 | if (NULL != name) | 378 | if (NULL != name) |
@@ -428,6 +427,7 @@ handle_lookup_name_it (void *cls, | |||
428 | else | 427 | else |
429 | contains_signature = GNUNET_NO; | 428 | contains_signature = GNUNET_NO; |
430 | 429 | ||
430 | |||
431 | if ((NULL != zone_key) && (copied_elements == rd_count)) | 431 | if ((NULL != zone_key) && (copied_elements == rd_count)) |
432 | { | 432 | { |
433 | GNUNET_CRYPTO_hash(zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone_key_hash); | 433 | GNUNET_CRYPTO_hash(zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone_key_hash); |
@@ -436,13 +436,10 @@ handle_lookup_name_it (void *cls, | |||
436 | cc = GNUNET_CONTAINER_multihashmap_get(zonekeys, &zone_key_hash); | 436 | cc = GNUNET_CONTAINER_multihashmap_get(zonekeys, &zone_key_hash); |
437 | signature_new = GNUNET_NAMESTORE_create_signature(cc->privkey, name, rd_selected, copied_elements); | 437 | signature_new = GNUNET_NAMESTORE_create_signature(cc->privkey, name, rd_selected, copied_elements); |
438 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating signature for name `%s' in zone `%s'\n",name, GNUNET_h2s(&zone_key_hash)); | 438 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating signature for name `%s' in zone `%s'\n",name, GNUNET_h2s(&zone_key_hash)); |
439 | sig_to_use = signature_new; | 439 | authoritative = GNUNET_YES; |
440 | contains_signature = GNUNET_YES; | ||
441 | } | 440 | } |
442 | } | 441 | else |
443 | else | 442 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I am not authoritative for name `%s' in zone `%s'\n",name, GNUNET_h2s(&zone_key_hash)); |
444 | { | ||
445 | sig_to_use = signature; | ||
446 | } | 443 | } |
447 | 444 | ||
448 | if (rd_selected != rd) | 445 | if (rd_selected != rd) |
@@ -461,15 +458,24 @@ handle_lookup_name_it (void *cls, | |||
461 | lnr_msg->rd_count = htons (copied_elements); | 458 | lnr_msg->rd_count = htons (copied_elements); |
462 | lnr_msg->rd_len = htons (rd_ser_len); | 459 | lnr_msg->rd_len = htons (rd_ser_len); |
463 | lnr_msg->name_len = htons (name_len); | 460 | lnr_msg->name_len = htons (name_len); |
464 | lnr_msg->contains_sig = htons (contains_signature); | ||
465 | lnr_msg->expire = GNUNET_TIME_absolute_hton(expire); | 461 | lnr_msg->expire = GNUNET_TIME_absolute_hton(expire); |
466 | 462 | ||
467 | if (zone_key != NULL) | 463 | if (zone_key != NULL) |
468 | lnr_msg->public_key = (*zone_key); | 464 | lnr_msg->public_key = (*zone_key); |
469 | else | 465 | else |
470 | memset(&lnr_msg->public_key, '\0', sizeof (lnr_msg->public_key)); | 466 | memset(&lnr_msg->public_key, '\0', sizeof (lnr_msg->public_key)); |
467 | |||
468 | if (GNUNET_YES == authoritative) | ||
469 | { | ||
470 | lnr_msg->contains_sig = htons (GNUNET_YES); | ||
471 | lnr_msg->signature = *signature_new; | ||
472 | GNUNET_free (signature_new); | ||
473 | } | ||
471 | if (GNUNET_YES == contains_signature) | 474 | if (GNUNET_YES == contains_signature) |
472 | lnr_msg->signature = *sig_to_use; | 475 | { |
476 | lnr_msg->contains_sig = htons (GNUNET_YES); | ||
477 | lnr_msg->signature = *signature; | ||
478 | } | ||
473 | else | 479 | else |
474 | memset (&lnr_msg->signature, '\0', sizeof (lnr_msg->signature)); | 480 | memset (&lnr_msg->signature, '\0', sizeof (lnr_msg->signature)); |
475 | 481 | ||