diff options
Diffstat (limited to 'src/scalarproduct/gnunet-service-scalarproduct_alice.c')
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct_alice.c | 77 |
1 files changed, 36 insertions, 41 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c index 44534c850..1ca7f61da 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_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.h" | 37 | #include "gnunet-service-scalarproduct.h" |
38 | 38 | ||
@@ -99,18 +99,18 @@ struct AliceServiceSession | |||
99 | * Set of elements for which will conduction an intersection. | 99 | * Set of elements for which will conduction an intersection. |
100 | * the resulting elements are then used for computing the scalar product. | 100 | * the resulting elements are then used for computing the scalar product. |
101 | */ | 101 | */ |
102 | struct GNUNET_SET_Handle *intersection_set; | 102 | struct GNUNET_SETI_Handle *intersection_set; |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * Set of elements for which will conduction an intersection. | 105 | * Set of elements for which will conduction an intersection. |
106 | * the resulting elements are then used for computing the scalar product. | 106 | * the resulting elements are then used for computing the scalar product. |
107 | */ | 107 | */ |
108 | struct GNUNET_SET_OperationHandle *intersection_op; | 108 | struct GNUNET_SETI_OperationHandle *intersection_op; |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * Handle to Alice's Intersection operation listening for Bob | 111 | * Handle to Alice's Intersection operation listening for Bob |
112 | */ | 112 | */ |
113 | struct GNUNET_SET_ListenHandle *intersection_listen; | 113 | struct GNUNET_SETI_ListenHandle *intersection_listen; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * channel-handle associated with our cadet handle | 116 | * channel-handle associated with our cadet handle |
@@ -265,17 +265,17 @@ destroy_service_session (struct AliceServiceSession *s) | |||
265 | } | 265 | } |
266 | if (NULL != s->intersection_listen) | 266 | if (NULL != s->intersection_listen) |
267 | { | 267 | { |
268 | GNUNET_SET_listen_cancel (s->intersection_listen); | 268 | GNUNET_SETI_listen_cancel (s->intersection_listen); |
269 | s->intersection_listen = NULL; | 269 | s->intersection_listen = NULL; |
270 | } | 270 | } |
271 | if (NULL != s->intersection_op) | 271 | if (NULL != s->intersection_op) |
272 | { | 272 | { |
273 | GNUNET_SET_operation_cancel (s->intersection_op); | 273 | GNUNET_SETI_operation_cancel (s->intersection_op); |
274 | s->intersection_op = NULL; | 274 | s->intersection_op = NULL; |
275 | } | 275 | } |
276 | if (NULL != s->intersection_set) | 276 | if (NULL != s->intersection_set) |
277 | { | 277 | { |
278 | GNUNET_SET_destroy (s->intersection_set); | 278 | GNUNET_SETI_destroy (s->intersection_set); |
279 | s->intersection_set = NULL; | 279 | s->intersection_set = NULL; |
280 | } | 280 | } |
281 | if (NULL != s->sorted_elements) | 281 | if (NULL != s->sorted_elements) |
@@ -894,22 +894,22 @@ send_alices_cryptodata_message (struct AliceServiceSession *s) | |||
894 | * to indicate that the set intersection operation is done. | 894 | * to indicate that the set intersection operation is done. |
895 | * | 895 | * |
896 | * @param cls closure with the `struct AliceServiceSession` | 896 | * @param cls closure with the `struct AliceServiceSession` |
897 | * @param element a result element, only valid if status is #GNUNET_SET_STATUS_OK | 897 | * @param element a result element, only valid if status is #GNUNET_SETI_STATUS_OK |
898 | * @param current_size current set size | 898 | * @param current_size current set size |
899 | * @param status what has happened with the set intersection? | 899 | * @param status what has happened with the set intersection? |
900 | */ | 900 | */ |
901 | static void | 901 | static void |
902 | cb_intersection_element_removed (void *cls, | 902 | cb_intersection_element_removed (void *cls, |
903 | const struct GNUNET_SET_Element *element, | 903 | const struct GNUNET_SETI_Element *element, |
904 | uint64_t current_size, | 904 | uint64_t current_size, |
905 | enum GNUNET_SET_Status status) | 905 | enum GNUNET_SETI_Status status) |
906 | { | 906 | { |
907 | struct AliceServiceSession *s = cls; | 907 | struct AliceServiceSession *s = cls; |
908 | struct GNUNET_SCALARPRODUCT_Element *se; | 908 | struct GNUNET_SCALARPRODUCT_Element *se; |
909 | 909 | ||
910 | switch (status) | 910 | switch (status) |
911 | { | 911 | { |
912 | case GNUNET_SET_STATUS_OK: | 912 | case GNUNET_SETI_STATUS_DEL_LOCAL: |
913 | /* this element has been removed from the set */ | 913 | /* this element has been removed from the set */ |
914 | se = GNUNET_CONTAINER_multihashmap_get (s->intersected_elements, | 914 | se = GNUNET_CONTAINER_multihashmap_get (s->intersected_elements, |
915 | element->data); | 915 | element->data); |
@@ -926,33 +926,27 @@ cb_intersection_element_removed (void *cls, | |||
926 | GNUNET_free (se); | 926 | GNUNET_free (se); |
927 | return; | 927 | return; |
928 | 928 | ||
929 | case GNUNET_SET_STATUS_DONE: | 929 | case GNUNET_SETI_STATUS_DONE: |
930 | s->intersection_op = NULL; | 930 | s->intersection_op = NULL; |
931 | if (NULL != s->intersection_set) | 931 | if (NULL != s->intersection_set) |
932 | { | 932 | { |
933 | GNUNET_SET_destroy (s->intersection_set); | 933 | GNUNET_SETI_destroy (s->intersection_set); |
934 | s->intersection_set = NULL; | 934 | s->intersection_set = NULL; |
935 | } | 935 | } |
936 | send_alices_cryptodata_message (s); | 936 | send_alices_cryptodata_message (s); |
937 | return; | 937 | return; |
938 | 938 | case GNUNET_SETI_STATUS_FAILURE: | |
939 | case GNUNET_SET_STATUS_HALF_DONE: | ||
940 | /* unexpected for intersection */ | ||
941 | GNUNET_break (0); | ||
942 | return; | ||
943 | |||
944 | case GNUNET_SET_STATUS_FAILURE: | ||
945 | /* unhandled status code */ | 939 | /* unhandled status code */ |
946 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Set intersection failed!\n"); | 940 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Set intersection failed!\n"); |
947 | if (NULL != s->intersection_listen) | 941 | if (NULL != s->intersection_listen) |
948 | { | 942 | { |
949 | GNUNET_SET_listen_cancel (s->intersection_listen); | 943 | GNUNET_SETI_listen_cancel (s->intersection_listen); |
950 | s->intersection_listen = NULL; | 944 | s->intersection_listen = NULL; |
951 | } | 945 | } |
952 | s->intersection_op = NULL; | 946 | s->intersection_op = NULL; |
953 | if (NULL != s->intersection_set) | 947 | if (NULL != s->intersection_set) |
954 | { | 948 | { |
955 | GNUNET_SET_destroy (s->intersection_set); | 949 | GNUNET_SETI_destroy (s->intersection_set); |
956 | s->intersection_set = NULL; | 950 | s->intersection_set = NULL; |
957 | } | 951 | } |
958 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; | 952 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; |
@@ -974,7 +968,7 @@ cb_intersection_element_removed (void *cls, | |||
974 | * @param other_peer the other peer | 968 | * @param other_peer the other peer |
975 | * @param context_msg message with application specific information from | 969 | * @param context_msg message with application specific information from |
976 | * the other peer | 970 | * the other peer |
977 | * @param request request from the other peer (never NULL), use GNUNET_SET_accept() | 971 | * @param request request from the other peer (never NULL), use GNUNET_SETI_accept() |
978 | * to accept it, otherwise the request will be refused | 972 | * to accept it, otherwise the request will be refused |
979 | * Note that we can't just return value from the listen callback, | 973 | * Note that we can't just return value from the listen callback, |
980 | * as it is also necessary to specify the set we want to do the | 974 | * as it is also necessary to specify the set we want to do the |
@@ -985,7 +979,7 @@ static void | |||
985 | cb_intersection_request_alice (void *cls, | 979 | cb_intersection_request_alice (void *cls, |
986 | const struct GNUNET_PeerIdentity *other_peer, | 980 | const struct GNUNET_PeerIdentity *other_peer, |
987 | const struct GNUNET_MessageHeader *context_msg, | 981 | const struct GNUNET_MessageHeader *context_msg, |
988 | struct GNUNET_SET_Request *request) | 982 | struct GNUNET_SETI_Request *request) |
989 | { | 983 | { |
990 | struct AliceServiceSession *s = cls; | 984 | struct AliceServiceSession *s = cls; |
991 | 985 | ||
@@ -994,11 +988,11 @@ cb_intersection_request_alice (void *cls, | |||
994 | GNUNET_break_op (0); | 988 | GNUNET_break_op (0); |
995 | return; | 989 | return; |
996 | } | 990 | } |
997 | s->intersection_op = GNUNET_SET_accept (request, | 991 | s->intersection_op = GNUNET_SETI_accept (request, |
998 | GNUNET_SET_RESULT_REMOVED, | 992 | (struct |
999 | (struct GNUNET_SET_Option[]){ { 0 } }, | 993 | GNUNET_SETI_Option[]){ { 0 } }, |
1000 | &cb_intersection_element_removed, | 994 | &cb_intersection_element_removed, |
1001 | s); | 995 | s); |
1002 | if (NULL == s->intersection_op) | 996 | if (NULL == s->intersection_op) |
1003 | { | 997 | { |
1004 | GNUNET_break (0); | 998 | GNUNET_break (0); |
@@ -1006,7 +1000,7 @@ cb_intersection_request_alice (void *cls, | |||
1006 | prepare_client_end_notification (s); | 1000 | prepare_client_end_notification (s); |
1007 | return; | 1001 | return; |
1008 | } | 1002 | } |
1009 | if (GNUNET_OK != GNUNET_SET_commit (s->intersection_op, s->intersection_set)) | 1003 | if (GNUNET_OK != GNUNET_SETI_commit (s->intersection_op, s->intersection_set)) |
1010 | { | 1004 | { |
1011 | GNUNET_break (0); | 1005 | GNUNET_break (0); |
1012 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; | 1006 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; |
@@ -1055,11 +1049,10 @@ client_request_complete_alice (struct AliceServiceSession *s) | |||
1055 | return; | 1049 | return; |
1056 | } | 1050 | } |
1057 | s->cadet_mq = GNUNET_CADET_get_mq (s->channel); | 1051 | s->cadet_mq = GNUNET_CADET_get_mq (s->channel); |
1058 | s->intersection_listen = GNUNET_SET_listen (cfg, | 1052 | s->intersection_listen = GNUNET_SETI_listen (cfg, |
1059 | GNUNET_SET_OPERATION_INTERSECTION, | 1053 | &s->session_id, |
1060 | &s->session_id, | 1054 | &cb_intersection_request_alice, |
1061 | &cb_intersection_request_alice, | 1055 | s); |
1062 | s); | ||
1063 | if (NULL == s->intersection_listen) | 1056 | if (NULL == s->intersection_listen) |
1064 | { | 1057 | { |
1065 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; | 1058 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; |
@@ -1125,7 +1118,7 @@ handle_alice_client_message_multipart ( | |||
1125 | struct AliceServiceSession *s = cls; | 1118 | struct AliceServiceSession *s = cls; |
1126 | uint32_t contained_count; | 1119 | uint32_t contained_count; |
1127 | const struct GNUNET_SCALARPRODUCT_Element *elements; | 1120 | const struct GNUNET_SCALARPRODUCT_Element *elements; |
1128 | struct GNUNET_SET_Element set_elem; | 1121 | struct GNUNET_SETI_Element set_elem; |
1129 | struct GNUNET_SCALARPRODUCT_Element *elem; | 1122 | struct GNUNET_SCALARPRODUCT_Element *elem; |
1130 | 1123 | ||
1131 | contained_count = ntohl (msg->element_count_contained); | 1124 | contained_count = ntohl (msg->element_count_contained); |
@@ -1150,7 +1143,7 @@ handle_alice_client_message_multipart ( | |||
1150 | set_elem.data = &elem->key; | 1143 | set_elem.data = &elem->key; |
1151 | set_elem.size = sizeof(elem->key); | 1144 | set_elem.size = sizeof(elem->key); |
1152 | set_elem.element_type = 0; | 1145 | set_elem.element_type = 0; |
1153 | GNUNET_SET_add_element (s->intersection_set, &set_elem, NULL, NULL); | 1146 | GNUNET_SETI_add_element (s->intersection_set, &set_elem, NULL, NULL); |
1154 | s->used_element_count++; | 1147 | s->used_element_count++; |
1155 | } | 1148 | } |
1156 | GNUNET_SERVICE_client_continue (s->client); | 1149 | GNUNET_SERVICE_client_continue (s->client); |
@@ -1217,7 +1210,7 @@ handle_alice_client_message (void *cls, | |||
1217 | uint32_t contained_count; | 1210 | uint32_t contained_count; |
1218 | uint32_t total_count; | 1211 | uint32_t total_count; |
1219 | const struct GNUNET_SCALARPRODUCT_Element *elements; | 1212 | const struct GNUNET_SCALARPRODUCT_Element *elements; |
1220 | struct GNUNET_SET_Element set_elem; | 1213 | struct GNUNET_SETI_Element set_elem; |
1221 | struct GNUNET_SCALARPRODUCT_Element *elem; | 1214 | struct GNUNET_SCALARPRODUCT_Element *elem; |
1222 | 1215 | ||
1223 | total_count = ntohl (msg->element_count_total); | 1216 | total_count = ntohl (msg->element_count_total); |
@@ -1230,8 +1223,7 @@ handle_alice_client_message (void *cls, | |||
1230 | elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1]; | 1223 | elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1]; |
1231 | s->intersected_elements = | 1224 | s->intersected_elements = |
1232 | GNUNET_CONTAINER_multihashmap_create (s->total, GNUNET_YES); | 1225 | GNUNET_CONTAINER_multihashmap_create (s->total, GNUNET_YES); |
1233 | s->intersection_set = | 1226 | s->intersection_set = GNUNET_SETI_create (cfg); |
1234 | GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_INTERSECTION); | ||
1235 | 1227 | ||
1236 | for (uint32_t i = 0; i < contained_count; i++) | 1228 | for (uint32_t i = 0; i < contained_count; i++) |
1237 | { | 1229 | { |
@@ -1255,7 +1247,10 @@ handle_alice_client_message (void *cls, | |||
1255 | set_elem.data = &elem->key; | 1247 | set_elem.data = &elem->key; |
1256 | set_elem.size = sizeof(elem->key); | 1248 | set_elem.size = sizeof(elem->key); |
1257 | set_elem.element_type = 0; | 1249 | set_elem.element_type = 0; |
1258 | GNUNET_SET_add_element (s->intersection_set, &set_elem, NULL, NULL); | 1250 | GNUNET_SETI_add_element (s->intersection_set, |
1251 | &set_elem, | ||
1252 | NULL, | ||
1253 | NULL); | ||
1259 | s->used_element_count++; | 1254 | s->used_element_count++; |
1260 | } | 1255 | } |
1261 | GNUNET_SERVICE_client_continue (s->client); | 1256 | GNUNET_SERVICE_client_continue (s->client); |