aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-05-24 18:06:44 +0000
committerChristian Grothoff <christian@grothoff.org>2014-05-24 18:06:44 +0000
commit152cd13768915399f9e5137d78a2f75296a1b93e (patch)
treedd7c1b41a053991eb64d62746a900b4614ef940d /src/scalarproduct
parentc0d549b6ab07a951380b807f1a1c1a767bfd5be0 (diff)
downloadgnunet-152cd13768915399f9e5137d78a2f75296a1b93e.tar.gz
gnunet-152cd13768915399f9e5137d78a2f75296a1b93e.zip
-doxygen, some additional error checking
Diffstat (limited to 'src/scalarproduct')
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct.c73
1 files changed, 31 insertions, 42 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c
index b133bb325..568f68ffc 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct.c
@@ -60,17 +60,17 @@ struct SortedValue
60 * Sorted Values are kept in a DLL 60 * Sorted Values are kept in a DLL
61 */ 61 */
62 struct SortedValue * next; 62 struct SortedValue * next;
63 63
64 /** 64 /**
65 * Sorted Values are kept in a DLL 65 * Sorted Values are kept in a DLL
66 */ 66 */
67 struct SortedValue * prev; 67 struct SortedValue * prev;
68 68
69 /** 69 /**
70 * The element's id+integer-value 70 * The element's id+integer-value
71 */ 71 */
72 struct GNUNET_SCALARPRODUCT_Element * elem; 72 struct GNUNET_SCALARPRODUCT_Element * elem;
73 73
74 /** 74 /**
75 * the element's value converted to MPI 75 * the element's value converted to MPI
76 */ 76 */
@@ -91,7 +91,7 @@ struct ServiceSession
91 * Is this session active(GNUNET_YES), Concluded(GNUNET_NO), (GNUNET_SYSERR) 91 * Is this session active(GNUNET_YES), Concluded(GNUNET_NO), (GNUNET_SYSERR)
92 */ 92 */
93 int32_t active; 93 int32_t active;
94 94
95 /** 95 /**
96 * the role this peer has 96 * the role this peer has
97 */ 97 */
@@ -116,7 +116,7 @@ struct ServiceSession
116 * Alice or Bob's peerID 116 * Alice or Bob's peerID
117 */ 117 */
118 struct GNUNET_PeerIdentity peer; 118 struct GNUNET_PeerIdentity peer;
119 119
120 /** 120 /**
121 * the client this request is related to 121 * the client this request is related to
122 */ 122 */
@@ -148,13 +148,13 @@ struct ServiceSession
148 uint32_t transferred_element_count; 148 uint32_t transferred_element_count;
149 149
150 /** 150 /**
151 * Set of elements for which will conduction an intersection. 151 * Set of elements for which will conduction an intersection.
152 * the resulting elements are then used for computing the scalar product. 152 * the resulting elements are then used for computing the scalar product.
153 */ 153 */
154 struct GNUNET_SET_Handle * intersection_set; 154 struct GNUNET_SET_Handle * intersection_set;
155 155
156 /** 156 /**
157 * Set of elements for which will conduction an intersection. 157 * Set of elements for which will conduction an intersection.
158 * the resulting elements are then used for computing the scalar product. 158 * the resulting elements are then used for computing the scalar product.
159 */ 159 */
160 struct GNUNET_SET_OperationHandle * intersection_op; 160 struct GNUNET_SET_OperationHandle * intersection_op;
@@ -561,7 +561,7 @@ cb_client_disconnect (void *cls,
561 s = GNUNET_SERVER_client_get_user_context (client, struct ServiceSession); 561 s = GNUNET_SERVER_client_get_user_context (client, struct ServiceSession);
562 if (NULL == s) 562 if (NULL == s)
563 return; 563 return;
564 564
565 GNUNET_CONTAINER_DLL_remove (from_client_head, from_client_tail, s); 565 GNUNET_CONTAINER_DLL_remove (from_client_head, from_client_tail, s);
566 566
567 if (NULL != s->service_transmit_handle){ 567 if (NULL != s->service_transmit_handle){
@@ -751,14 +751,14 @@ prepare_bobs_cryptodata_message_multipart (void *cls)
751 s); 751 s);
752 if (NULL == s->service_transmit_handle) { 752 if (NULL == s->service_transmit_handle) {
753 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send service-response message via cadet!)\n")); 753 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send service-response message via cadet!)\n"));
754 754
755 GNUNET_free (msg); 755 GNUNET_free (msg);
756 s->msg = NULL; 756 s->msg = NULL;
757 GNUNET_CADET_channel_destroy(s->channel); 757 GNUNET_CADET_channel_destroy(s->channel);
758 s->response->active = GNUNET_SYSERR; 758 s->response->active = GNUNET_SYSERR;
759 759
760 GNUNET_CONTAINER_DLL_remove (from_service_head, from_service_tail, s); 760 GNUNET_CONTAINER_DLL_remove (from_service_head, from_service_tail, s);
761 761
762 s->response->client_notification_task = 762 s->response->client_notification_task =
763 GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, 763 GNUNET_SCHEDULER_add_now (&prepare_client_end_notification,
764 s->response); 764 s->response);
@@ -852,7 +852,7 @@ prepare_bobs_cryptodata_message (void *cls,
852 GNUNET_CONTAINER_DLL_remove (from_service_head, from_service_tail, s); 852 GNUNET_CONTAINER_DLL_remove (from_service_head, from_service_tail, s);
853 GNUNET_CADET_channel_destroy(s->channel); 853 GNUNET_CADET_channel_destroy(s->channel);
854 s->response->active = GNUNET_SYSERR; 854 s->response->active = GNUNET_SYSERR;
855 855
856 s->response->client_notification_task = 856 s->response->client_notification_task =
857 GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, 857 GNUNET_SCHEDULER_add_now (&prepare_client_end_notification,
858 s->response); 858 s->response);
@@ -1087,7 +1087,7 @@ cb_intersection_element_removed (void *cls,
1087 1087
1088 case GNUNET_SET_STATUS_DONE: 1088 case GNUNET_SET_STATUS_DONE:
1089 s->intersection_op = NULL; 1089 s->intersection_op = NULL;
1090 1090
1091 if (2 > s->used_element_count) { 1091 if (2 > s->used_element_count) {
1092 // failed! do not leak information about our single remaining element! 1092 // failed! do not leak information about our single remaining element!
1093 // continue after the loop 1093 // continue after the loop
@@ -1102,7 +1102,7 @@ cb_intersection_element_removed (void *cls,
1102 for (i = 0; NULL != s->a_head; i++) { 1102 for (i = 0; NULL != s->a_head; i++) {
1103 struct SortedValue* a = s->a_head; 1103 struct SortedValue* a = s->a_head;
1104 GNUNET_assert (i < s->used_element_count); 1104 GNUNET_assert (i < s->used_element_count);
1105 1105
1106 s->sorted_elements[i] = a->val; 1106 s->sorted_elements[i] = a->val;
1107 GNUNET_CONTAINER_DLL_remove (s->a_head, s->a_tail, a); 1107 GNUNET_CONTAINER_DLL_remove (s->a_head, s->a_tail, a);
1108 GNUNET_free (a->elem); 1108 GNUNET_free (a->elem);
@@ -1129,7 +1129,7 @@ cb_intersection_element_removed (void *cls,
1129 1129
1130 //failed if we go here 1130 //failed if we go here
1131 GNUNET_break_op (0); 1131 GNUNET_break_op (0);
1132 1132
1133 1133
1134 // and notify our client-session that we could not complete the session 1134 // and notify our client-session that we could not complete the session
1135 if (ALICE == s->role) { 1135 if (ALICE == s->role) {
@@ -1262,31 +1262,18 @@ prepare_client_response (void *cls,
1262 msg->header.size = htons (msg_length); 1262 msg->header.size = htons (msg_length);
1263 msg->range = range; 1263 msg->range = range;
1264 msg->product_length = htonl (product_length); 1264 msg->product_length = htonl (product_length);
1265
1266 s->msg = (struct GNUNET_MessageHeader *) msg; 1265 s->msg = (struct GNUNET_MessageHeader *) msg;
1267 //transmit this message to our client
1268 s->client_transmit_handle = 1266 s->client_transmit_handle =
1269 GNUNET_SERVER_notify_transmit_ready (s->client, 1267 GNUNET_SERVER_notify_transmit_ready (s->client,
1270 msg_length, 1268 msg_length,
1271 GNUNET_TIME_UNIT_FOREVER_REL, 1269 GNUNET_TIME_UNIT_FOREVER_REL,
1272 &cb_transfer_message, 1270 &cb_transfer_message,
1273 s); 1271 s);
1274 if (NULL == s->client_transmit_handle) { 1272 GNUNET_break (NULL != s->client_transmit_handle);
1275 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1273 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1276 _ ("Could not send message to client (%p)!\n"), 1274 _ ("Sent result to client (%p), this session (%s) has ended!\n"),
1277 s->client); 1275 s->client,
1278 GNUNET_SERVER_client_disconnect(s->client); 1276 GNUNET_h2s (&s->session_id));
1279 free_session_variables(s);
1280 GNUNET_CONTAINER_DLL_remove (from_client_head, from_client_tail, s);
1281 GNUNET_free(s);
1282 }
1283 else
1284 // gracefully sent message, just terminate session structure
1285 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1286 _ ("Sent result to client (%p), this session (%s) has ended!\n"),
1287 s->client,
1288 GNUNET_h2s (&s->session_id));
1289 free_session_variables (s);
1290} 1277}
1291 1278
1292 1279
@@ -1317,7 +1304,8 @@ prepare_alices_computation_request (struct ServiceSession * s)
1317 &cb_transfer_message, 1304 &cb_transfer_message,
1318 s); 1305 s);
1319 if (!s->service_transmit_handle) { 1306 if (!s->service_transmit_handle) {
1320 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send message to channel!\n")); 1307 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1308 _ ("Could not send message to channel!\n"));
1321 GNUNET_free (msg); 1309 GNUNET_free (msg);
1322 s->msg = NULL; 1310 s->msg = NULL;
1323 s->active = GNUNET_SYSERR; 1311 s->active = GNUNET_SYSERR;
@@ -1383,7 +1371,8 @@ prepare_alices_cyrptodata_message_multipart (void *cls)
1383 &cb_transfer_message, 1371 &cb_transfer_message,
1384 s); 1372 s);
1385 if (!s->service_transmit_handle) { 1373 if (!s->service_transmit_handle) {
1386 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send service-request multipart message to channel!\n")); 1374 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1375 _("Could not send service-request multipart message to channel!\n"));
1387 GNUNET_free (msg); 1376 GNUNET_free (msg);
1388 s->msg = NULL; 1377 s->msg = NULL;
1389 s->active = GNUNET_SYSERR; 1378 s->active = GNUNET_SYSERR;
@@ -1397,7 +1386,7 @@ prepare_alices_cyrptodata_message_multipart (void *cls)
1397 1386
1398/** 1387/**
1399 * Our client has finished sending us its multipart message. 1388 * Our client has finished sending us its multipart message.
1400 * 1389 *
1401 * @param session the service session context 1390 * @param session the service session context
1402 */ 1391 */
1403static void 1392static void
@@ -1442,7 +1431,7 @@ client_request_complete_bob (struct ServiceSession * client_session)
1442 1431
1443/** 1432/**
1444 * Our client has finished sending us its multipart message. 1433 * Our client has finished sending us its multipart message.
1445 * 1434 *
1446 * @param session the service session context 1435 * @param session the service session context
1447 */ 1436 */
1448static void 1437static void
@@ -1719,7 +1708,7 @@ cb_channel_destruction (void *cls,
1719 _ ("Peer disconnected, terminating session %s with peer (%s)\n"), 1708 _ ("Peer disconnected, terminating session %s with peer (%s)\n"),
1720 GNUNET_h2s (&s->session_id), 1709 GNUNET_h2s (&s->session_id),
1721 GNUNET_i2s (&s->peer)); 1710 GNUNET_i2s (&s->peer));
1722 1711
1723 // as we have only one peer connected in each session, just remove the session 1712 // as we have only one peer connected in each session, just remove the session
1724 s->channel = NULL; 1713 s->channel = NULL;
1725 1714
@@ -1881,7 +1870,7 @@ handle_alices_cyrptodata_message_multipart (void *cls,
1881 // are we in the correct state? 1870 // are we in the correct state?
1882 s = (struct ServiceSession *) * channel_ctx; 1871 s = (struct ServiceSession *) * channel_ctx;
1883 //we are not bob 1872 //we are not bob
1884 if ((NULL == s->e_a) || //or we did not expect this message yet 1873 if ((NULL == s->e_a) || //or we did not expect this message yet
1885 (s->used_element_count == s->transferred_element_count)) { //we are not expecting multipart messages 1874 (s->used_element_count == s->transferred_element_count)) { //we are not expecting multipart messages
1886 goto except; 1875 goto except;
1887 } 1876 }
@@ -2265,8 +2254,8 @@ handle_bobs_cryptodata_message (void *cls,
2265 GNUNET_assert (NULL != message); 2254 GNUNET_assert (NULL != message);
2266 s = (struct ServiceSession *) * channel_ctx; 2255 s = (struct ServiceSession *) * channel_ctx;
2267 // are we in the correct state? 2256 // are we in the correct state?
2268 if (NULL == s->sorted_elements 2257 if (NULL == s->sorted_elements
2269 || NULL != s->msg 2258 || NULL != s->msg
2270 || s->used_element_count != s->transferred_element_count) { 2259 || s->used_element_count != s->transferred_element_count) {
2271 goto invalid_msg; 2260 goto invalid_msg;
2272 } 2261 }
@@ -2411,7 +2400,7 @@ run (void *cls,
2411 0 2400 0
2412 }; 2401 };
2413 cfg = c; 2402 cfg = c;
2414 2403
2415 //generate private/public key set 2404 //generate private/public key set
2416 GNUNET_CRYPTO_paillier_create (&my_pubkey, &my_privkey); 2405 GNUNET_CRYPTO_paillier_create (&my_pubkey, &my_privkey);
2417 2406