diff options
author | t3sserakt <t3ss@posteo.de> | 2020-08-28 17:57:44 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2020-08-28 17:57:53 +0200 |
commit | 2b552a5f5e85fab1c14af73735c0de61b46cc3dc (patch) | |
tree | 1ed739ddb116d77a7f2dfcc69c013f0eb9f731e7 /src/scalarproduct/gnunet-service-scalarproduct_bob.c | |
parent | 03f6a0233f72c2c4c3925f0d6f6f7a81987c6530 (diff) | |
parent | bbf9540c93da3c6b950920ee7eaae479c95403c5 (diff) | |
download | gnunet-2b552a5f5e85fab1c14af73735c0de61b46cc3dc.tar.gz gnunet-2b552a5f5e85fab1c14af73735c0de61b46cc3dc.zip |
Merge branch 'master' of ssh://gnunet.org/gnunet
Diffstat (limited to 'src/scalarproduct/gnunet-service-scalarproduct_bob.c')
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct_bob.c | 71 |
1 files changed, 30 insertions, 41 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_bob.c b/src/scalarproduct/gnunet-service-scalarproduct_bob.c index c000749af..b0299779d 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_bob.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_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.h" | 37 | #include "gnunet-service-scalarproduct.h" |
38 | 38 | ||
@@ -88,13 +88,13 @@ struct BobServiceSession | |||
88 | * Set of elements for which we will be conducting an intersection. | 88 | * Set of elements for which we will be conducting an intersection. |
89 | * The resulting elements are then used for computing the scalar product. | 89 | * The resulting elements are then used for computing the scalar product. |
90 | */ | 90 | */ |
91 | struct GNUNET_SET_Handle *intersection_set; | 91 | struct GNUNET_SETI_Handle *intersection_set; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Set of elements for which will conduction an intersection. | 94 | * Set of elements for which will conduction an intersection. |
95 | * the resulting elements are then used for computing the scalar product. | 95 | * the resulting elements are then used for computing the scalar product. |
96 | */ | 96 | */ |
97 | struct GNUNET_SET_OperationHandle *intersection_op; | 97 | struct GNUNET_SETI_OperationHandle *intersection_op; |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * CADET port we are listening on. | 100 | * CADET port we are listening on. |
@@ -277,12 +277,12 @@ destroy_service_session (struct BobServiceSession *s) | |||
277 | } | 277 | } |
278 | if (NULL != s->intersection_op) | 278 | if (NULL != s->intersection_op) |
279 | { | 279 | { |
280 | GNUNET_SET_operation_cancel (s->intersection_op); | 280 | GNUNET_SETI_operation_cancel (s->intersection_op); |
281 | s->intersection_op = NULL; | 281 | s->intersection_op = NULL; |
282 | } | 282 | } |
283 | if (NULL != s->intersection_set) | 283 | if (NULL != s->intersection_set) |
284 | { | 284 | { |
285 | GNUNET_SET_destroy (s->intersection_set); | 285 | GNUNET_SETI_destroy (s->intersection_set); |
286 | s->intersection_set = NULL; | 286 | s->intersection_set = NULL; |
287 | } | 287 | } |
288 | if (NULL != s->e_a) | 288 | if (NULL != s->e_a) |
@@ -888,22 +888,22 @@ handle_alices_cryptodata_message (void *cls, | |||
888 | * that needs to be removed from the result set. | 888 | * that needs to be removed from the result set. |
889 | * | 889 | * |
890 | * @param cls closure with the `struct BobServiceSession` | 890 | * @param cls closure with the `struct BobServiceSession` |
891 | * @param element a result element, only valid if status is #GNUNET_SET_STATUS_OK | 891 | * @param element a result element, only valid if status is #GNUNET_SETI_STATUS_OK |
892 | * @param current_size current set size | 892 | * @param current_size current set size |
893 | * @param status what has happened with the set intersection? | 893 | * @param status what has happened with the set intersection? |
894 | */ | 894 | */ |
895 | static void | 895 | static void |
896 | cb_intersection_element_removed (void *cls, | 896 | cb_intersection_element_removed (void *cls, |
897 | const struct GNUNET_SET_Element *element, | 897 | const struct GNUNET_SETI_Element *element, |
898 | uint64_t current_size, | 898 | uint64_t current_size, |
899 | enum GNUNET_SET_Status status) | 899 | enum GNUNET_SETI_Status status) |
900 | { | 900 | { |
901 | struct BobServiceSession *s = cls; | 901 | struct BobServiceSession *s = cls; |
902 | struct GNUNET_SCALARPRODUCT_Element *se; | 902 | struct GNUNET_SCALARPRODUCT_Element *se; |
903 | 903 | ||
904 | switch (status) | 904 | switch (status) |
905 | { | 905 | { |
906 | case GNUNET_SET_STATUS_OK: | 906 | case GNUNET_SETI_STATUS_DEL_LOCAL: |
907 | /* this element has been removed from the set */ | 907 | /* this element has been removed from the set */ |
908 | se = GNUNET_CONTAINER_multihashmap_get (s->intersected_elements, | 908 | se = GNUNET_CONTAINER_multihashmap_get (s->intersected_elements, |
909 | element->data); | 909 | element->data); |
@@ -919,8 +919,7 @@ cb_intersection_element_removed (void *cls, | |||
919 | se)); | 919 | se)); |
920 | GNUNET_free (se); | 920 | GNUNET_free (se); |
921 | return; | 921 | return; |
922 | 922 | case GNUNET_SETI_STATUS_DONE: | |
923 | case GNUNET_SET_STATUS_DONE: | ||
924 | s->intersection_op = NULL; | 923 | s->intersection_op = NULL; |
925 | GNUNET_break (NULL == s->intersection_set); | 924 | GNUNET_break (NULL == s->intersection_set); |
926 | GNUNET_CADET_receive_done (s->channel); | 925 | GNUNET_CADET_receive_done (s->channel); |
@@ -935,26 +934,19 @@ cb_intersection_element_removed (void *cls, | |||
935 | transmit_cryptographic_reply (s); | 934 | transmit_cryptographic_reply (s); |
936 | } | 935 | } |
937 | return; | 936 | return; |
938 | 937 | 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 */ | 938 | /* unhandled status code */ |
946 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 939 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
947 | "Set intersection failed!\n"); | 940 | "Set intersection failed!\n"); |
948 | s->intersection_op = NULL; | 941 | s->intersection_op = NULL; |
949 | if (NULL != s->intersection_set) | 942 | if (NULL != s->intersection_set) |
950 | { | 943 | { |
951 | GNUNET_SET_destroy (s->intersection_set); | 944 | GNUNET_SETI_destroy (s->intersection_set); |
952 | s->intersection_set = NULL; | 945 | s->intersection_set = NULL; |
953 | } | 946 | } |
954 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; | 947 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; |
955 | prepare_client_end_notification (s); | 948 | prepare_client_end_notification (s); |
956 | return; | 949 | return; |
957 | |||
958 | default: | 950 | default: |
959 | GNUNET_break (0); | 951 | GNUNET_break (0); |
960 | return; | 952 | return; |
@@ -977,23 +969,22 @@ start_intersection (struct BobServiceSession *s) | |||
977 | (unsigned int) s->total); | 969 | (unsigned int) s->total); |
978 | 970 | ||
979 | s->intersection_op | 971 | s->intersection_op |
980 | = GNUNET_SET_prepare (&s->peer, | 972 | = GNUNET_SETI_prepare (&s->peer, |
981 | &s->session_id, | 973 | &s->session_id, |
982 | NULL, | 974 | NULL, |
983 | GNUNET_SET_RESULT_REMOVED, | 975 | (struct GNUNET_SETI_Option[]) { { 0 } }, |
984 | (struct GNUNET_SET_Option[]) { { 0 } }, | 976 | &cb_intersection_element_removed, |
985 | &cb_intersection_element_removed, | 977 | s); |
986 | s); | ||
987 | if (GNUNET_OK != | 978 | if (GNUNET_OK != |
988 | GNUNET_SET_commit (s->intersection_op, | 979 | GNUNET_SETI_commit (s->intersection_op, |
989 | s->intersection_set)) | 980 | s->intersection_set)) |
990 | { | 981 | { |
991 | GNUNET_break (0); | 982 | GNUNET_break (0); |
992 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; | 983 | s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; |
993 | prepare_client_end_notification (s); | 984 | prepare_client_end_notification (s); |
994 | return; | 985 | return; |
995 | } | 986 | } |
996 | GNUNET_SET_destroy (s->intersection_set); | 987 | GNUNET_SETI_destroy (s->intersection_set); |
997 | s->intersection_set = NULL; | 988 | s->intersection_set = NULL; |
998 | } | 989 | } |
999 | 990 | ||
@@ -1096,7 +1087,7 @@ handle_bob_client_message_multipart (void *cls, | |||
1096 | struct BobServiceSession *s = cls; | 1087 | struct BobServiceSession *s = cls; |
1097 | uint32_t contained_count; | 1088 | uint32_t contained_count; |
1098 | const struct GNUNET_SCALARPRODUCT_Element *elements; | 1089 | const struct GNUNET_SCALARPRODUCT_Element *elements; |
1099 | struct GNUNET_SET_Element set_elem; | 1090 | struct GNUNET_SETI_Element set_elem; |
1100 | struct GNUNET_SCALARPRODUCT_Element *elem; | 1091 | struct GNUNET_SCALARPRODUCT_Element *elem; |
1101 | 1092 | ||
1102 | contained_count = ntohl (msg->element_count_contained); | 1093 | contained_count = ntohl (msg->element_count_contained); |
@@ -1120,9 +1111,9 @@ handle_bob_client_message_multipart (void *cls, | |||
1120 | set_elem.data = &elem->key; | 1111 | set_elem.data = &elem->key; |
1121 | set_elem.size = sizeof(elem->key); | 1112 | set_elem.size = sizeof(elem->key); |
1122 | set_elem.element_type = 0; | 1113 | set_elem.element_type = 0; |
1123 | GNUNET_SET_add_element (s->intersection_set, | 1114 | GNUNET_SETI_add_element (s->intersection_set, |
1124 | &set_elem, | 1115 | &set_elem, |
1125 | NULL, NULL); | 1116 | NULL, NULL); |
1126 | } | 1117 | } |
1127 | s->client_received_element_count += contained_count; | 1118 | s->client_received_element_count += contained_count; |
1128 | GNUNET_SERVICE_client_continue (s->client); | 1119 | GNUNET_SERVICE_client_continue (s->client); |
@@ -1206,7 +1197,7 @@ handle_bob_client_message (void *cls, | |||
1206 | uint32_t contained_count; | 1197 | uint32_t contained_count; |
1207 | uint32_t total_count; | 1198 | uint32_t total_count; |
1208 | const struct GNUNET_SCALARPRODUCT_Element *elements; | 1199 | const struct GNUNET_SCALARPRODUCT_Element *elements; |
1209 | struct GNUNET_SET_Element set_elem; | 1200 | struct GNUNET_SETI_Element set_elem; |
1210 | struct GNUNET_SCALARPRODUCT_Element *elem; | 1201 | struct GNUNET_SCALARPRODUCT_Element *elem; |
1211 | 1202 | ||
1212 | total_count = ntohl (msg->element_count_total); | 1203 | total_count = ntohl (msg->element_count_total); |
@@ -1220,9 +1211,7 @@ handle_bob_client_message (void *cls, | |||
1220 | s->intersected_elements | 1211 | s->intersected_elements |
1221 | = GNUNET_CONTAINER_multihashmap_create (s->total, | 1212 | = GNUNET_CONTAINER_multihashmap_create (s->total, |
1222 | GNUNET_YES); | 1213 | GNUNET_YES); |
1223 | s->intersection_set | 1214 | s->intersection_set = GNUNET_SETI_create (cfg); |
1224 | = GNUNET_SET_create (cfg, | ||
1225 | GNUNET_SET_OPERATION_INTERSECTION); | ||
1226 | for (uint32_t i = 0; i < contained_count; i++) | 1215 | for (uint32_t i = 0; i < contained_count; i++) |
1227 | { | 1216 | { |
1228 | if (0 == GNUNET_ntohll (elements[i].value)) | 1217 | if (0 == GNUNET_ntohll (elements[i].value)) |
@@ -1244,9 +1233,9 @@ handle_bob_client_message (void *cls, | |||
1244 | set_elem.data = &elem->key; | 1233 | set_elem.data = &elem->key; |
1245 | set_elem.size = sizeof(elem->key); | 1234 | set_elem.size = sizeof(elem->key); |
1246 | set_elem.element_type = 0; | 1235 | set_elem.element_type = 0; |
1247 | GNUNET_SET_add_element (s->intersection_set, | 1236 | GNUNET_SETI_add_element (s->intersection_set, |
1248 | &set_elem, | 1237 | &set_elem, |
1249 | NULL, NULL); | 1238 | NULL, NULL); |
1250 | s->used_element_count++; | 1239 | s->used_element_count++; |
1251 | } | 1240 | } |
1252 | GNUNET_SERVICE_client_continue (s->client); | 1241 | GNUNET_SERVICE_client_continue (s->client); |