diff options
Diffstat (limited to 'src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c')
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c | 70 |
1 files changed, 30 insertions, 40 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c index 2da79f845..4c835d52a 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c +++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include "gnunet_applications.h" | 32 | #include "gnunet_applications.h" |
33 | #include "gnunet_protocols.h" | 33 | #include "gnunet_protocols.h" |
34 | #include "gnunet_scalarproduct_service.h" | 34 | #include "gnunet_scalarproduct_service.h" |
35 | #include "gnunet_set_service.h" | 35 | #include "gnunet_seti_service.h" |
36 | #include "scalarproduct.h" | 36 | #include "scalarproduct.h" |
37 | #include "gnunet-service-scalarproduct-ecc.h" | 37 | #include "gnunet-service-scalarproduct-ecc.h" |
38 | 38 | ||
@@ -83,13 +83,13 @@ struct BobServiceSession | |||
83 | * Set of elements for which we will be conducting an intersection. | 83 | * Set of elements for which we will be conducting an intersection. |
84 | * The resulting elements are then used for computing the scalar product. | 84 | * The resulting elements are then used for computing the scalar product. |
85 | */ | 85 | */ |
86 | struct GNUNET_SET_Handle *intersection_set; | 86 | struct GNUNET_SETI_Handle *intersection_set; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Set of elements for which will conduction an intersection. | 89 | * Set of elements for which will conduction an intersection. |
90 | * the resulting elements are then used for computing the scalar product. | 90 | * the resulting elements are then used for computing the scalar product. |
91 | */ | 91 | */ |
92 | struct GNUNET_SET_OperationHandle *intersection_op; | 92 | struct GNUNET_SETI_OperationHandle *intersection_op; |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * Our open port. | 95 | * Our open port. |
@@ -235,12 +235,12 @@ destroy_service_session (struct BobServiceSession *s) | |||
235 | } | 235 | } |
236 | if (NULL != s->intersection_op) | 236 | if (NULL != s->intersection_op) |
237 | { | 237 | { |
238 | GNUNET_SET_operation_cancel (s->intersection_op); | 238 | GNUNET_SETI_operation_cancel (s->intersection_op); |
239 | s->intersection_op = NULL; | 239 | s->intersection_op = NULL; |
240 | } | 240 | } |
241 | if (NULL != s->intersection_set) | 241 | if (NULL != s->intersection_set) |
242 | { | 242 | { |
243 | GNUNET_SET_destroy (s->intersection_set); | 243 | GNUNET_SETI_destroy (s->intersection_set); |
244 | s->intersection_set = NULL; | 244 | s->intersection_set = NULL; |
245 | } | 245 | } |
246 | if (NULL != s->sorted_elements) | 246 | if (NULL != s->sorted_elements) |
@@ -578,22 +578,22 @@ handle_alices_cryptodata_message (void *cls, | |||
578 | * that needs to be removed from the result set. | 578 | * that needs to be removed from the result set. |
579 | * | 579 | * |
580 | * @param cls closure with the `struct BobServiceSession` | 580 | * @param cls closure with the `struct BobServiceSession` |
581 | * @param element a result element, only valid if status is #GNUNET_SET_STATUS_OK | 581 | * @param element a result element, only valid if status is #GNUNET_SETI_STATUS_OK |
582 | * @param current_size current set size | 582 | * @param current_size current set size |
583 | * @param status what has happened with the set intersection? | 583 | * @param status what has happened with the set intersection? |
584 | */ | 584 | */ |
585 | static void | 585 | static void |
586 | cb_intersection_element_removed (void *cls, | 586 | cb_intersection_element_removed (void *cls, |
587 | const struct GNUNET_SET_Element *element, | 587 | const struct GNUNET_SETI_Element *element, |
588 | uint64_t current_size, | 588 | uint64_t current_size, |
589 | enum GNUNET_SET_Status status) | 589 | enum GNUNET_SETI_Status status) |
590 | { | 590 | { |
591 | struct BobServiceSession *s = cls; | 591 | struct BobServiceSession *s = cls; |
592 | struct GNUNET_SCALARPRODUCT_Element *se; | 592 | struct GNUNET_SCALARPRODUCT_Element *se; |
593 | 593 | ||
594 | switch (status) | 594 | switch (status) |
595 | { | 595 | { |
596 | case GNUNET_SET_STATUS_OK: | 596 | case GNUNET_SETI_STATUS_DEL_LOCAL: |
597 | /* this element has been removed from the set */ | 597 | /* this element has been removed from the set */ |
598 | se = GNUNET_CONTAINER_multihashmap_get (s->intersected_elements, | 598 | se = GNUNET_CONTAINER_multihashmap_get (s->intersected_elements, |
599 | element->data); | 599 | element->data); |
@@ -609,8 +609,7 @@ cb_intersection_element_removed (void *cls, | |||
609 | se)); | 609 | se)); |
610 | GNUNET_free (se); | 610 | GNUNET_free (se); |
611 | return; | 611 | return; |
612 | 612 | case GNUNET_SETI_STATUS_DONE: | |
613 | case GNUNET_SET_STATUS_DONE: | ||
614 | s->intersection_op = NULL; | 613 | s->intersection_op = NULL; |
615 | GNUNET_break (NULL == s->intersection_set); | 614 | GNUNET_break (NULL == s->intersection_set); |
616 | GNUNET_CADET_receive_done (s->channel); | 615 | GNUNET_CADET_receive_done (s->channel); |
@@ -625,20 +624,14 @@ cb_intersection_element_removed (void *cls, | |||
625 | transmit_bobs_cryptodata_message (s); | 624 | transmit_bobs_cryptodata_message (s); |
626 | } | 625 | } |
627 | return; | 626 | return; |
628 | 627 | case GNUNET_SETI_STATUS_FAILURE: | |
629 | case GNUNET_SET_STATUS_HALF_DONE: | ||
630 | /* unexpected for intersection */ | ||
631 | GNUNET_break (0); | ||
632 | return; | ||
633 | |||
634 | case GNUNET_SET_STATUS_FAILURE: | ||
635 | /* unhandled status code */ | 628 | /* unhandled status code */ |
636 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 629 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
637 | "Set intersection failed!\n"); | 630 | "Set intersection failed!\n"); |
638 | s->intersection_op = NULL; | 631 | s->intersection_op = NULL; |
639 | if (NULL != s->intersection_set) | 632 | if (NULL != s->intersection_set) |
640 | { | 633 | { |
641 | GNUNET_SET_destroy (s->intersection_set); | 634 | GNUNET_SETI_destroy (s->intersection_set); |
642 | s->intersection_set = NULL; | 635 | s->intersection_set = NULL; |
643 | } | 636 | } |
644 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; | 637 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; |
@@ -672,23 +665,22 @@ start_intersection (struct BobServiceSession *s) | |||
672 | (unsigned int) s->total); | 665 | (unsigned int) s->total); |
673 | 666 | ||
674 | s->intersection_op | 667 | s->intersection_op |
675 | = GNUNET_SET_prepare (&s->peer, | 668 | = GNUNET_SETI_prepare (&s->peer, |
676 | &set_sid, | 669 | &set_sid, |
677 | NULL, | 670 | NULL, |
678 | GNUNET_SET_RESULT_REMOVED, | 671 | (struct GNUNET_SETI_Option[]) { { 0 } }, |
679 | (struct GNUNET_SET_Option[]) { { 0 } }, | 672 | &cb_intersection_element_removed, |
680 | &cb_intersection_element_removed, | 673 | s); |
681 | s); | ||
682 | if (GNUNET_OK != | 674 | if (GNUNET_OK != |
683 | GNUNET_SET_commit (s->intersection_op, | 675 | GNUNET_SETI_commit (s->intersection_op, |
684 | s->intersection_set)) | 676 | s->intersection_set)) |
685 | { | 677 | { |
686 | GNUNET_break (0); | 678 | GNUNET_break (0); |
687 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; | 679 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; |
688 | prepare_client_end_notification (s); | 680 | prepare_client_end_notification (s); |
689 | return; | 681 | return; |
690 | } | 682 | } |
691 | GNUNET_SET_destroy (s->intersection_set); | 683 | GNUNET_SETI_destroy (s->intersection_set); |
692 | s->intersection_set = NULL; | 684 | s->intersection_set = NULL; |
693 | } | 685 | } |
694 | 686 | ||
@@ -797,7 +789,7 @@ handle_bob_client_message_multipart (void *cls, | |||
797 | struct BobServiceSession *s = cls; | 789 | struct BobServiceSession *s = cls; |
798 | uint32_t contained_count; | 790 | uint32_t contained_count; |
799 | const struct GNUNET_SCALARPRODUCT_Element *elements; | 791 | const struct GNUNET_SCALARPRODUCT_Element *elements; |
800 | struct GNUNET_SET_Element set_elem; | 792 | struct GNUNET_SETI_Element set_elem; |
801 | struct GNUNET_SCALARPRODUCT_Element *elem; | 793 | struct GNUNET_SCALARPRODUCT_Element *elem; |
802 | 794 | ||
803 | contained_count = ntohl (msg->element_count_contained); | 795 | contained_count = ntohl (msg->element_count_contained); |
@@ -821,9 +813,9 @@ handle_bob_client_message_multipart (void *cls, | |||
821 | set_elem.data = &elem->key; | 813 | set_elem.data = &elem->key; |
822 | set_elem.size = sizeof(elem->key); | 814 | set_elem.size = sizeof(elem->key); |
823 | set_elem.element_type = 0; | 815 | set_elem.element_type = 0; |
824 | GNUNET_SET_add_element (s->intersection_set, | 816 | GNUNET_SETI_add_element (s->intersection_set, |
825 | &set_elem, | 817 | &set_elem, |
826 | NULL, NULL); | 818 | NULL, NULL); |
827 | } | 819 | } |
828 | s->client_received_element_count += contained_count; | 820 | s->client_received_element_count += contained_count; |
829 | GNUNET_SERVICE_client_continue (s->client); | 821 | GNUNET_SERVICE_client_continue (s->client); |
@@ -913,7 +905,7 @@ handle_bob_client_message (void *cls, | |||
913 | uint32_t contained_count; | 905 | uint32_t contained_count; |
914 | uint32_t total_count; | 906 | uint32_t total_count; |
915 | const struct GNUNET_SCALARPRODUCT_Element *elements; | 907 | const struct GNUNET_SCALARPRODUCT_Element *elements; |
916 | struct GNUNET_SET_Element set_elem; | 908 | struct GNUNET_SETI_Element set_elem; |
917 | struct GNUNET_SCALARPRODUCT_Element *elem; | 909 | struct GNUNET_SCALARPRODUCT_Element *elem; |
918 | 910 | ||
919 | total_count = ntohl (msg->element_count_total); | 911 | total_count = ntohl (msg->element_count_total); |
@@ -927,9 +919,7 @@ handle_bob_client_message (void *cls, | |||
927 | s->intersected_elements | 919 | s->intersected_elements |
928 | = GNUNET_CONTAINER_multihashmap_create (s->total, | 920 | = GNUNET_CONTAINER_multihashmap_create (s->total, |
929 | GNUNET_YES); | 921 | GNUNET_YES); |
930 | s->intersection_set | 922 | s->intersection_set = GNUNET_SETI_create (cfg); |
931 | = GNUNET_SET_create (cfg, | ||
932 | GNUNET_SET_OPERATION_INTERSECTION); | ||
933 | for (uint32_t i = 0; i < contained_count; i++) | 923 | for (uint32_t i = 0; i < contained_count; i++) |
934 | { | 924 | { |
935 | if (0 == GNUNET_ntohll (elements[i].value)) | 925 | if (0 == GNUNET_ntohll (elements[i].value)) |
@@ -951,9 +941,9 @@ handle_bob_client_message (void *cls, | |||
951 | set_elem.data = &elem->key; | 941 | set_elem.data = &elem->key; |
952 | set_elem.size = sizeof(elem->key); | 942 | set_elem.size = sizeof(elem->key); |
953 | set_elem.element_type = 0; | 943 | set_elem.element_type = 0; |
954 | GNUNET_SET_add_element (s->intersection_set, | 944 | GNUNET_SETI_add_element (s->intersection_set, |
955 | &set_elem, | 945 | &set_elem, |
956 | NULL, NULL); | 946 | NULL, NULL); |
957 | s->used_element_count++; | 947 | s->used_element_count++; |
958 | } | 948 | } |
959 | GNUNET_SERVICE_client_continue (s->client); | 949 | GNUNET_SERVICE_client_continue (s->client); |