diff options
Diffstat (limited to 'src/namestore/namestore_api.c')
-rw-r--r-- | src/namestore/namestore_api.c | 69 |
1 files changed, 62 insertions, 7 deletions
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index 31de00c81..ae9ed1a27 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c | |||
@@ -365,8 +365,6 @@ handle_record_create_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
365 | struct GNUNET_NAMESTORE_Handle *h = qe->nsh; | 365 | struct GNUNET_NAMESTORE_Handle *h = qe->nsh; |
366 | int res = ntohl (msg->op_result); | 366 | int res = ntohl (msg->op_result); |
367 | 367 | ||
368 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' %i\n", | ||
369 | "RECORD_CREATE_RESPONSE", ntohs (msg->op_result)); | ||
370 | if (res == GNUNET_YES) | 368 | if (res == GNUNET_YES) |
371 | { | 369 | { |
372 | if (qe->cont != NULL) | 370 | if (qe->cont != NULL) |
@@ -582,12 +580,66 @@ handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze, | |||
582 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n", | 580 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' \n", |
583 | "ZONE_ITERATION_RESPONSE"); | 581 | "ZONE_ITERATION_RESPONSE"); |
584 | 582 | ||
583 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubdummy; | ||
584 | size_t msg_len = 0; | ||
585 | size_t exp_msg_len = 0; | ||
586 | size_t name_len = 0; | ||
587 | size_t rd_len = 0; | ||
588 | unsigned rd_count = 0; | ||
585 | 589 | ||
586 | if (ze->proc != NULL) | 590 | char *name_tmp; |
591 | char *rd_ser_tmp; | ||
592 | struct GNUNET_TIME_Absolute expire; | ||
593 | |||
594 | msg_len = ntohs (msg->gns_header.header.size); | ||
595 | rd_len = ntohs (msg->rd_len); | ||
596 | rd_count = ntohs (msg->rd_count); | ||
597 | name_len = ntohs (msg->name_len); | ||
598 | expire = GNUNET_TIME_absolute_ntoh (msg->expire); | ||
599 | |||
600 | exp_msg_len = sizeof (struct ZoneIterationResponseMessage) + name_len + rd_len; | ||
601 | if (msg_len != exp_msg_len) | ||
602 | { | ||
603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message size describes with `%u' bytes but calculated size is %u bytes \n", | ||
604 | msg_len, exp_msg_len); | ||
605 | GNUNET_break_op (0); | ||
606 | return; | ||
607 | } | ||
608 | if (0 != ntohs (msg->reserved)) | ||
609 | { | ||
610 | GNUNET_break_op (0); | ||
611 | return; | ||
612 | } | ||
613 | |||
614 | memset (&pubdummy, '\0', sizeof (pubdummy)); | ||
615 | if ((0 == name_len) && (0 == (memcmp (&msg->public_key, &pubdummy, sizeof (pubdummy))))) | ||
616 | { | ||
617 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone iteration is completed!\n"); | ||
618 | |||
619 | if (ze->proc != NULL) | ||
620 | ze->proc(ze->proc_cls, NULL, GNUNET_TIME_absolute_get_zero (), NULL , 0, NULL, NULL); | ||
621 | |||
622 | GNUNET_CONTAINER_DLL_remove(ze->h->z_head, ze->h->z_tail, ze); | ||
623 | GNUNET_free (ze); | ||
624 | return; | ||
625 | } | ||
626 | |||
627 | name_tmp = (char *) &msg[1]; | ||
628 | if ((name_tmp[name_len -1] != '\0') || (name_len > 256)) | ||
629 | { | ||
630 | GNUNET_break_op (0); | ||
631 | return; | ||
632 | } | ||
633 | rd_ser_tmp = (char *) &name_tmp[name_len]; | ||
634 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | ||
635 | if (GNUNET_OK != GNUNET_NAMESTORE_records_deserialize (rd_len, rd_ser_tmp, rd_count, rd)) | ||
587 | { | 636 | { |
588 | // FIXME | 637 | GNUNET_break_op (0); |
589 | ze->proc(ze->proc_cls, NULL, GNUNET_TIME_absolute_get_forever(), "dummy", 0, NULL, NULL); | 638 | return; |
590 | } | 639 | } |
640 | |||
641 | if (ze->proc != NULL) | ||
642 | ze->proc(ze->proc_cls, &msg->public_key, expire, name_tmp, rd_count, rd, &msg->signature); | ||
591 | } | 643 | } |
592 | 644 | ||
593 | 645 | ||
@@ -1425,7 +1477,7 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, | |||
1425 | uint32_t rid = 0; | 1477 | uint32_t rid = 0; |
1426 | 1478 | ||
1427 | GNUNET_assert (NULL != h); | 1479 | GNUNET_assert (NULL != h); |
1428 | GNUNET_assert (NULL != zone); | 1480 | |
1429 | 1481 | ||
1430 | rid = get_op_id(h); | 1482 | rid = get_op_id(h); |
1431 | it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator)); | 1483 | it = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_ZoneIterator)); |
@@ -1448,7 +1500,10 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, | |||
1448 | msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START); | 1500 | msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START); |
1449 | msg->gns_header.header.size = htons (msg_size); | 1501 | msg->gns_header.header.size = htons (msg_size); |
1450 | msg->gns_header.r_id = htonl (rid); | 1502 | msg->gns_header.r_id = htonl (rid); |
1451 | msg->zone = *zone; | 1503 | if (NULL == zone) |
1504 | msg->zone = *zone; | ||
1505 | else | ||
1506 | memset (&msg->zone, '\0', sizeof (msg->zone)); | ||
1452 | msg->must_have_flags = ntohs (must_have_flags); | 1507 | msg->must_have_flags = ntohs (must_have_flags); |
1453 | msg->must_not_have_flags = ntohs (must_not_have_flags); | 1508 | msg->must_not_have_flags = ntohs (must_not_have_flags); |
1454 | 1509 | ||