diff options
Diffstat (limited to 'src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c')
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c | 75 |
1 files changed, 33 insertions, 42 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c index 20ab292cf..447451aef 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.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 | ||
@@ -114,18 +114,18 @@ struct AliceServiceSession | |||
114 | * Set of elements for which will conduction an intersection. | 114 | * Set of elements for which will conduction an intersection. |
115 | * the resulting elements are then used for computing the scalar product. | 115 | * the resulting elements are then used for computing the scalar product. |
116 | */ | 116 | */ |
117 | struct GNUNET_SET_Handle *intersection_set; | 117 | struct GNUNET_SETI_Handle *intersection_set; |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * Set of elements for which will conduction an intersection. | 120 | * Set of elements for which will conduction an intersection. |
121 | * the resulting elements are then used for computing the scalar product. | 121 | * the resulting elements are then used for computing the scalar product. |
122 | */ | 122 | */ |
123 | struct GNUNET_SET_OperationHandle *intersection_op; | 123 | struct GNUNET_SETI_OperationHandle *intersection_op; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * Handle to Alice's Intersection operation listening for Bob | 126 | * Handle to Alice's Intersection operation listening for Bob |
127 | */ | 127 | */ |
128 | struct GNUNET_SET_ListenHandle *intersection_listen; | 128 | struct GNUNET_SETI_ListenHandle *intersection_listen; |
129 | 129 | ||
130 | /** | 130 | /** |
131 | * channel-handle associated with our cadet handle | 131 | * channel-handle associated with our cadet handle |
@@ -256,18 +256,18 @@ destroy_service_session (struct AliceServiceSession *s) | |||
256 | } | 256 | } |
257 | if (NULL != s->intersection_listen) | 257 | if (NULL != s->intersection_listen) |
258 | { | 258 | { |
259 | GNUNET_SET_listen_cancel (s->intersection_listen); | 259 | GNUNET_SETI_listen_cancel (s->intersection_listen); |
260 | s->intersection_listen = NULL; | 260 | s->intersection_listen = NULL; |
261 | } | 261 | } |
262 | if (NULL != s->intersection_op) | 262 | if (NULL != s->intersection_op) |
263 | { | 263 | { |
264 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Set intersection, op still ongoing!\n"); | 264 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Set intersection, op still ongoing!\n"); |
265 | GNUNET_SET_operation_cancel (s->intersection_op); | 265 | GNUNET_SETI_operation_cancel (s->intersection_op); |
266 | s->intersection_op = NULL; | 266 | s->intersection_op = NULL; |
267 | } | 267 | } |
268 | if (NULL != s->intersection_set) | 268 | if (NULL != s->intersection_set) |
269 | { | 269 | { |
270 | GNUNET_SET_destroy (s->intersection_set); | 270 | GNUNET_SETI_destroy (s->intersection_set); |
271 | s->intersection_set = NULL; | 271 | s->intersection_set = NULL; |
272 | } | 272 | } |
273 | if (NULL != s->sorted_elements) | 273 | if (NULL != s->sorted_elements) |
@@ -649,22 +649,22 @@ send_alices_cryptodata_message (struct AliceServiceSession *s) | |||
649 | * to indicate that the set intersection operation is done. | 649 | * to indicate that the set intersection operation is done. |
650 | * | 650 | * |
651 | * @param cls closure with the `struct AliceServiceSession` | 651 | * @param cls closure with the `struct AliceServiceSession` |
652 | * @param element a result element, only valid if status is #GNUNET_SET_STATUS_OK | 652 | * @param element a result element, only valid if status is #GNUNET_SETI_STATUS_OK |
653 | * @param current_size current set size | 653 | * @param current_size current set size |
654 | * @param status what has happened with the set intersection? | 654 | * @param status what has happened with the set intersection? |
655 | */ | 655 | */ |
656 | static void | 656 | static void |
657 | cb_intersection_element_removed (void *cls, | 657 | cb_intersection_element_removed (void *cls, |
658 | const struct GNUNET_SET_Element *element, | 658 | const struct GNUNET_SETI_Element *element, |
659 | uint64_t current_size, | 659 | uint64_t current_size, |
660 | enum GNUNET_SET_Status status) | 660 | enum GNUNET_SETI_Status status) |
661 | { | 661 | { |
662 | struct AliceServiceSession *s = cls; | 662 | struct AliceServiceSession *s = cls; |
663 | struct GNUNET_SCALARPRODUCT_Element *se; | 663 | struct GNUNET_SCALARPRODUCT_Element *se; |
664 | 664 | ||
665 | switch (status) | 665 | switch (status) |
666 | { | 666 | { |
667 | case GNUNET_SET_STATUS_OK: | 667 | case GNUNET_SETI_STATUS_DEL_LOCAL: |
668 | /* this element has been removed from the set */ | 668 | /* this element has been removed from the set */ |
669 | se = GNUNET_CONTAINER_multihashmap_get (s->intersected_elements, | 669 | se = GNUNET_CONTAINER_multihashmap_get (s->intersected_elements, |
670 | element->data); | 670 | element->data); |
@@ -680,34 +680,27 @@ cb_intersection_element_removed (void *cls, | |||
680 | se)); | 680 | se)); |
681 | GNUNET_free (se); | 681 | GNUNET_free (se); |
682 | return; | 682 | return; |
683 | 683 | case GNUNET_SETI_STATUS_DONE: | |
684 | case GNUNET_SET_STATUS_DONE: | ||
685 | s->intersection_op = NULL; | 684 | s->intersection_op = NULL; |
686 | if (NULL != s->intersection_set) | 685 | if (NULL != s->intersection_set) |
687 | { | 686 | { |
688 | GNUNET_SET_destroy (s->intersection_set); | 687 | GNUNET_SETI_destroy (s->intersection_set); |
689 | s->intersection_set = NULL; | 688 | s->intersection_set = NULL; |
690 | } | 689 | } |
691 | send_alices_cryptodata_message (s); | 690 | send_alices_cryptodata_message (s); |
692 | return; | 691 | return; |
693 | 692 | case GNUNET_SETI_STATUS_FAILURE: | |
694 | case GNUNET_SET_STATUS_HALF_DONE: | ||
695 | /* unexpected for intersection */ | ||
696 | GNUNET_break (0); | ||
697 | return; | ||
698 | |||
699 | case GNUNET_SET_STATUS_FAILURE: | ||
700 | /* unhandled status code */ | 693 | /* unhandled status code */ |
701 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Set intersection failed!\n"); | 694 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Set intersection failed!\n"); |
702 | if (NULL != s->intersection_listen) | 695 | if (NULL != s->intersection_listen) |
703 | { | 696 | { |
704 | GNUNET_SET_listen_cancel (s->intersection_listen); | 697 | GNUNET_SETI_listen_cancel (s->intersection_listen); |
705 | s->intersection_listen = NULL; | 698 | s->intersection_listen = NULL; |
706 | } | 699 | } |
707 | s->intersection_op = NULL; | 700 | s->intersection_op = NULL; |
708 | if (NULL != s->intersection_set) | 701 | if (NULL != s->intersection_set) |
709 | { | 702 | { |
710 | GNUNET_SET_destroy (s->intersection_set); | 703 | GNUNET_SETI_destroy (s->intersection_set); |
711 | s->intersection_set = NULL; | 704 | s->intersection_set = NULL; |
712 | } | 705 | } |
713 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; | 706 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; |
@@ -729,7 +722,7 @@ cb_intersection_element_removed (void *cls, | |||
729 | * @param other_peer the other peer | 722 | * @param other_peer the other peer |
730 | * @param context_msg message with application specific information from | 723 | * @param context_msg message with application specific information from |
731 | * the other peer | 724 | * the other peer |
732 | * @param request request from the other peer (never NULL), use GNUNET_SET_accept() | 725 | * @param request request from the other peer (never NULL), use GNUNET_SETI_accept() |
733 | * to accept it, otherwise the request will be refused | 726 | * to accept it, otherwise the request will be refused |
734 | * Note that we can't just return value from the listen callback, | 727 | * Note that we can't just return value from the listen callback, |
735 | * as it is also necessary to specify the set we want to do the | 728 | * as it is also necessary to specify the set we want to do the |
@@ -740,7 +733,7 @@ static void | |||
740 | cb_intersection_request_alice (void *cls, | 733 | cb_intersection_request_alice (void *cls, |
741 | const struct GNUNET_PeerIdentity *other_peer, | 734 | const struct GNUNET_PeerIdentity *other_peer, |
742 | const struct GNUNET_MessageHeader *context_msg, | 735 | const struct GNUNET_MessageHeader *context_msg, |
743 | struct GNUNET_SET_Request *request) | 736 | struct GNUNET_SETI_Request *request) |
744 | { | 737 | { |
745 | struct AliceServiceSession *s = cls; | 738 | struct AliceServiceSession *s = cls; |
746 | 739 | ||
@@ -752,11 +745,11 @@ cb_intersection_request_alice (void *cls, | |||
752 | GNUNET_break_op (0); | 745 | GNUNET_break_op (0); |
753 | return; | 746 | return; |
754 | } | 747 | } |
755 | s->intersection_op = GNUNET_SET_accept (request, | 748 | s->intersection_op = GNUNET_SETI_accept (request, |
756 | GNUNET_SET_RESULT_REMOVED, | 749 | (struct |
757 | (struct GNUNET_SET_Option[]){ { 0 } }, | 750 | GNUNET_SETI_Option[]){ { 0 } }, |
758 | &cb_intersection_element_removed, | 751 | &cb_intersection_element_removed, |
759 | s); | 752 | s); |
760 | if (NULL == s->intersection_op) | 753 | if (NULL == s->intersection_op) |
761 | { | 754 | { |
762 | GNUNET_break (0); | 755 | GNUNET_break (0); |
@@ -764,7 +757,7 @@ cb_intersection_request_alice (void *cls, | |||
764 | prepare_client_end_notification (s); | 757 | prepare_client_end_notification (s); |
765 | return; | 758 | return; |
766 | } | 759 | } |
767 | if (GNUNET_OK != GNUNET_SET_commit (s->intersection_op, s->intersection_set)) | 760 | if (GNUNET_OK != GNUNET_SETI_commit (s->intersection_op, s->intersection_set)) |
768 | { | 761 | { |
769 | GNUNET_break (0); | 762 | GNUNET_break (0); |
770 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; | 763 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; |
@@ -812,11 +805,10 @@ client_request_complete_alice (struct AliceServiceSession *s) | |||
812 | return; | 805 | return; |
813 | } | 806 | } |
814 | s->cadet_mq = GNUNET_CADET_get_mq (s->channel); | 807 | s->cadet_mq = GNUNET_CADET_get_mq (s->channel); |
815 | s->intersection_listen = GNUNET_SET_listen (cfg, | 808 | s->intersection_listen = GNUNET_SETI_listen (cfg, |
816 | GNUNET_SET_OPERATION_INTERSECTION, | 809 | &set_sid, |
817 | &set_sid, | 810 | &cb_intersection_request_alice, |
818 | &cb_intersection_request_alice, | 811 | s); |
819 | s); | ||
820 | if (NULL == s->intersection_listen) | 812 | if (NULL == s->intersection_listen) |
821 | { | 813 | { |
822 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; | 814 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; |
@@ -883,7 +875,7 @@ handle_alice_client_message_multipart ( | |||
883 | struct AliceServiceSession *s = cls; | 875 | struct AliceServiceSession *s = cls; |
884 | uint32_t contained_count; | 876 | uint32_t contained_count; |
885 | const struct GNUNET_SCALARPRODUCT_Element *elements; | 877 | const struct GNUNET_SCALARPRODUCT_Element *elements; |
886 | struct GNUNET_SET_Element set_elem; | 878 | struct GNUNET_SETI_Element set_elem; |
887 | struct GNUNET_SCALARPRODUCT_Element *elem; | 879 | struct GNUNET_SCALARPRODUCT_Element *elem; |
888 | 880 | ||
889 | contained_count = ntohl (msg->element_count_contained); | 881 | contained_count = ntohl (msg->element_count_contained); |
@@ -908,7 +900,7 @@ handle_alice_client_message_multipart ( | |||
908 | set_elem.data = &elem->key; | 900 | set_elem.data = &elem->key; |
909 | set_elem.size = sizeof(elem->key); | 901 | set_elem.size = sizeof(elem->key); |
910 | set_elem.element_type = 0; | 902 | set_elem.element_type = 0; |
911 | GNUNET_SET_add_element (s->intersection_set, &set_elem, NULL, NULL); | 903 | GNUNET_SETI_add_element (s->intersection_set, &set_elem, NULL, NULL); |
912 | s->used_element_count++; | 904 | s->used_element_count++; |
913 | } | 905 | } |
914 | GNUNET_SERVICE_client_continue (s->client); | 906 | GNUNET_SERVICE_client_continue (s->client); |
@@ -978,7 +970,7 @@ handle_alice_client_message (void *cls, | |||
978 | uint32_t contained_count; | 970 | uint32_t contained_count; |
979 | uint32_t total_count; | 971 | uint32_t total_count; |
980 | const struct GNUNET_SCALARPRODUCT_Element *elements; | 972 | const struct GNUNET_SCALARPRODUCT_Element *elements; |
981 | struct GNUNET_SET_Element set_elem; | 973 | struct GNUNET_SETI_Element set_elem; |
982 | struct GNUNET_SCALARPRODUCT_Element *elem; | 974 | struct GNUNET_SCALARPRODUCT_Element *elem; |
983 | 975 | ||
984 | total_count = ntohl (msg->element_count_total); | 976 | total_count = ntohl (msg->element_count_total); |
@@ -991,8 +983,7 @@ handle_alice_client_message (void *cls, | |||
991 | elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1]; | 983 | elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1]; |
992 | s->intersected_elements = | 984 | s->intersected_elements = |
993 | GNUNET_CONTAINER_multihashmap_create (s->total, GNUNET_YES); | 985 | GNUNET_CONTAINER_multihashmap_create (s->total, GNUNET_YES); |
994 | s->intersection_set = | 986 | s->intersection_set = GNUNET_SETI_create (cfg); |
995 | GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_INTERSECTION); | ||
996 | for (uint32_t i = 0; i < contained_count; i++) | 987 | for (uint32_t i = 0; i < contained_count; i++) |
997 | { | 988 | { |
998 | if (0 == GNUNET_ntohll (elements[i].value)) | 989 | if (0 == GNUNET_ntohll (elements[i].value)) |
@@ -1015,7 +1006,7 @@ handle_alice_client_message (void *cls, | |||
1015 | set_elem.data = &elem->key; | 1006 | set_elem.data = &elem->key; |
1016 | set_elem.size = sizeof(elem->key); | 1007 | set_elem.size = sizeof(elem->key); |
1017 | set_elem.element_type = 0; | 1008 | set_elem.element_type = 0; |
1018 | GNUNET_SET_add_element (s->intersection_set, &set_elem, NULL, NULL); | 1009 | GNUNET_SETI_add_element (s->intersection_set, &set_elem, NULL, NULL); |
1019 | s->used_element_count++; | 1010 | s->used_element_count++; |
1020 | } | 1011 | } |
1021 | GNUNET_SERVICE_client_continue (s->client); | 1012 | GNUNET_SERVICE_client_continue (s->client); |