diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-10-07 17:10:19 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-10-07 17:10:19 +0000 |
commit | e85c90bbd1f2ac05da8d77ecc850d8657b6eeda7 (patch) | |
tree | 0e72d2dc924b2628996a24f3ea38b11c9eec7900 /src/scalarproduct | |
parent | 5e8acfff954e7d5b39f9c3451d4674368871615e (diff) | |
download | gnunet-e85c90bbd1f2ac05da8d77ecc850d8657b6eeda7.tar.gz gnunet-e85c90bbd1f2ac05da8d77ecc850d8657b6eeda7.zip |
finished service request multipart message sending
Diffstat (limited to 'src/scalarproduct')
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c index dafcde3a4..91f4d45c6 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct.c +++ b/src/scalarproduct/gnunet-service-scalarproduct.c | |||
@@ -1173,7 +1173,7 @@ prepare_service_request_multipart (void *cls, | |||
1173 | struct ServiceSession * session = cls; | 1173 | struct ServiceSession * session = cls; |
1174 | unsigned char * current; | 1174 | unsigned char * current; |
1175 | unsigned char * element_exported; | 1175 | unsigned char * element_exported; |
1176 | struct GNUNET_SCALARPRODUCT_service_request * msg; | 1176 | struct GNUNET_SCALARPRODUCT_multipart_message * msg; |
1177 | unsigned int i; | 1177 | unsigned int i; |
1178 | unsigned int j; | 1178 | unsigned int j; |
1179 | uint32_t msg_length; | 1179 | uint32_t msg_length; |
@@ -1185,12 +1185,15 @@ prepare_service_request_multipart (void *cls, | |||
1185 | msg_length = sizeof (struct GNUNET_SCALARPRODUCT_multipart_message); | 1185 | msg_length = sizeof (struct GNUNET_SCALARPRODUCT_multipart_message); |
1186 | todo_count = session->used_element_count - session->transferred_element_count; | 1186 | todo_count = session->used_element_count - session->transferred_element_count; |
1187 | 1187 | ||
1188 | if (todo_count > MULTIPART_ELEMENT_CAPACITY){ | 1188 | if (todo_count > MULTIPART_ELEMENT_CAPACITY) |
1189 | // send the currently possible maximum chunk, else send all remaining | 1189 | // send the currently possible maximum chunk |
1190 | todo_count = MULTIPART_ELEMENT_CAPACITY; | 1190 | todo_count = MULTIPART_ELEMENT_CAPACITY; |
1191 | } | 1191 | |
1192 | msg_length += todo_count * PAILLIER_ELEMENT_LENGTH; | 1192 | msg_length += todo_count * PAILLIER_ELEMENT_LENGTH; |
1193 | msg = GNUNET_malloc (msg_length); | 1193 | msg = GNUNET_malloc (msg_length); |
1194 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_TO_BOB_MULTIPART); | ||
1195 | msg->header.size = htons (msg_length); | ||
1196 | msg->multipart_element_count = htonl (todo_count); | ||
1194 | 1197 | ||
1195 | element_exported = GNUNET_malloc (PAILLIER_ELEMENT_LENGTH); | 1198 | element_exported = GNUNET_malloc (PAILLIER_ELEMENT_LENGTH); |
1196 | a = gcry_mpi_new (KEYBITS * 2); | 1199 | a = gcry_mpi_new (KEYBITS * 2); |
@@ -1235,7 +1238,33 @@ prepare_service_request_multipart (void *cls, | |||
1235 | } | 1238 | } |
1236 | gcry_mpi_release (a); | 1239 | gcry_mpi_release (a); |
1237 | GNUNET_free(element_exported); | 1240 | GNUNET_free(element_exported); |
1241 | session->transferred_element_count+=todo_count; | ||
1238 | 1242 | ||
1243 | session->msg = (struct GNUNET_MessageHeader *) msg; | ||
1244 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Transmitting service request.\n")); | ||
1245 | |||
1246 | //transmit via mesh messaging | ||
1247 | session->service_transmit_handle = GNUNET_MESH_notify_transmit_ready (session->tunnel, GNUNET_YES, | ||
1248 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1249 | msg_length, | ||
1250 | &do_send_message, | ||
1251 | session); | ||
1252 | if (!session->service_transmit_handle) | ||
1253 | { | ||
1254 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send service-request multipart message to tunnel!\n")); | ||
1255 | GNUNET_free (msg); | ||
1256 | session->msg = NULL; | ||
1257 | session->client_notification_task = | ||
1258 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, | ||
1259 | session); | ||
1260 | return; | ||
1261 | } | ||
1262 | if (session->transferred_element_count != session->used_element_count){ | ||
1263 | session->last_processed_element = i; | ||
1264 | } | ||
1265 | else | ||
1266 | //final part | ||
1267 | session->state = WAITING_FOR_SERVICE_RESPONSE; | ||
1239 | } | 1268 | } |
1240 | /** | 1269 | /** |
1241 | * Executed by Alice, fills in a service-request message and sends it to the given peer | 1270 | * Executed by Alice, fills in a service-request message and sends it to the given peer |
@@ -1352,7 +1381,7 @@ prepare_service_request (void *cls, | |||
1352 | session); | 1381 | session); |
1353 | if (!session->service_transmit_handle) | 1382 | if (!session->service_transmit_handle) |
1354 | { | 1383 | { |
1355 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send mutlicast message to tunnel!\n")); | 1384 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send message to tunnel!\n")); |
1356 | GNUNET_free (msg); | 1385 | GNUNET_free (msg); |
1357 | session->msg = NULL; | 1386 | session->msg = NULL; |
1358 | session->client_notification_task = | 1387 | session->client_notification_task = |