diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-12-05 14:15:25 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-12-05 14:15:25 +0000 |
commit | 44d957c38051c6e778595b74f4a831da8ad1a179 (patch) | |
tree | 235e33b27ba570e6e857f306ff4ed27791d21d14 /src/scalarproduct | |
parent | b83fc2e7baf2713881c1ff59971e6dbd4609e771 (diff) | |
download | gnunet-44d957c38051c6e778595b74f4a831da8ad1a179.tar.gz gnunet-44d957c38051c6e778595b74f4a831da8ad1a179.zip |
- change mesh channel creation/notification API
Diffstat (limited to 'src/scalarproduct')
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c index b6c8e6077..5a917b20c 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct.c +++ b/src/scalarproduct/gnunet-service-scalarproduct.c | |||
@@ -226,9 +226,9 @@ struct ServiceSession | |||
226 | * Send a multi part chunk of a service request from alice to bob. | 226 | * Send a multi part chunk of a service request from alice to bob. |
227 | * This element only contains a part of the elements-vector (session->a[]), | 227 | * This element only contains a part of the elements-vector (session->a[]), |
228 | * mask and public key set have to be contained within the first message | 228 | * mask and public key set have to be contained within the first message |
229 | * | 229 | * |
230 | * This allows a ~32kbit key length while using 32000 elements or 62000 elements per request. | 230 | * This allows a ~32kbit key length while using 32000 elements or 62000 elements per request. |
231 | * | 231 | * |
232 | * @param cls the associated service session | 232 | * @param cls the associated service session |
233 | */ | 233 | */ |
234 | static void | 234 | static void |
@@ -237,7 +237,7 @@ prepare_service_request_multipart (void *cls); | |||
237 | /** | 237 | /** |
238 | * Send a multi part chunk of a service response from bob to alice. | 238 | * Send a multi part chunk of a service response from bob to alice. |
239 | * This element only contains the two permutations of R, R'. | 239 | * This element only contains the two permutations of R, R'. |
240 | * | 240 | * |
241 | * @param cls the associated service session | 241 | * @param cls the associated service session |
242 | */ | 242 | */ |
243 | static void | 243 | static void |
@@ -657,7 +657,7 @@ permute_vector (gcry_mpi_t * vector, | |||
657 | /** | 657 | /** |
658 | * Finds a not terminated client/service session in the | 658 | * Finds a not terminated client/service session in the |
659 | * given DLL based on session key, element count and state. | 659 | * given DLL based on session key, element count and state. |
660 | * | 660 | * |
661 | * @param tail - the tail of the DLL | 661 | * @param tail - the tail of the DLL |
662 | * @param key - the key we want to search for | 662 | * @param key - the key we want to search for |
663 | * @param element_count - the total element count of the dataset (session->total) | 663 | * @param element_count - the total element count of the dataset (session->total) |
@@ -694,7 +694,7 @@ find_matching_session (struct ServiceSession * tail, | |||
694 | 694 | ||
695 | /** | 695 | /** |
696 | * Safely frees ALL memory areas referenced by a session. | 696 | * Safely frees ALL memory areas referenced by a session. |
697 | * | 697 | * |
698 | * @param session - the session to free elements from | 698 | * @param session - the session to free elements from |
699 | */ | 699 | */ |
700 | static void | 700 | static void |
@@ -769,7 +769,7 @@ handle_client_disconnect (void *cls, | |||
769 | struct GNUNET_SERVER_Client *client) | 769 | struct GNUNET_SERVER_Client *client) |
770 | { | 770 | { |
771 | struct ServiceSession *session; | 771 | struct ServiceSession *session; |
772 | 772 | ||
773 | if (NULL != client) | 773 | if (NULL != client) |
774 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 774 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
775 | _ ("Client (%p) disconnected from us.\n"), client); | 775 | _ ("Client (%p) disconnected from us.\n"), client); |
@@ -851,7 +851,7 @@ prepare_client_end_notification (void * cls, | |||
851 | } | 851 | } |
852 | else | 852 | else |
853 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Sending session-end notification to client (%p) for session %s\n"), &session->client, GNUNET_h2s (&session->key)); | 853 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Sending session-end notification to client (%p) for session %s\n"), &session->client, GNUNET_h2s (&session->key)); |
854 | 854 | ||
855 | free_session_variables (session); | 855 | free_session_variables (session); |
856 | } | 856 | } |
857 | 857 | ||
@@ -953,7 +953,7 @@ prepare_client_response (void *cls, | |||
953 | /** | 953 | /** |
954 | * Send a multipart chunk of a service response from bob to alice. | 954 | * Send a multipart chunk of a service response from bob to alice. |
955 | * This element only contains the two permutations of R, R'. | 955 | * This element only contains the two permutations of R, R'. |
956 | * | 956 | * |
957 | * @param cls the associated service session | 957 | * @param cls the associated service session |
958 | */ | 958 | */ |
959 | static void | 959 | static void |
@@ -1396,9 +1396,9 @@ except: | |||
1396 | * Send a multi part chunk of a service request from alice to bob. | 1396 | * Send a multi part chunk of a service request from alice to bob. |
1397 | * This element only contains a part of the elements-vector (session->a[]), | 1397 | * This element only contains a part of the elements-vector (session->a[]), |
1398 | * mask and public key set have to be contained within the first message | 1398 | * mask and public key set have to be contained within the first message |
1399 | * | 1399 | * |
1400 | * This allows a ~32kbit key length while using 32000 elements or 62000 elements per request. | 1400 | * This allows a ~32kbit key length while using 32000 elements or 62000 elements per request. |
1401 | * | 1401 | * |
1402 | * @param cls the associated service session | 1402 | * @param cls the associated service session |
1403 | */ | 1403 | */ |
1404 | static void | 1404 | static void |
@@ -1751,8 +1751,7 @@ handle_client_request (void *cls, | |||
1751 | session->channel = GNUNET_MESH_channel_create (my_mesh, session, | 1751 | session->channel = GNUNET_MESH_channel_create (my_mesh, session, |
1752 | &session->peer, | 1752 | &session->peer, |
1753 | GNUNET_APPLICATION_TYPE_SCALARPRODUCT, | 1753 | GNUNET_APPLICATION_TYPE_SCALARPRODUCT, |
1754 | GNUNET_NO, | 1754 | GNUNET_MESH_OPTION_RELIABLE); |
1755 | GNUNET_YES); | ||
1756 | //prepare_service_request, channel_peer_disconnect_handler, | 1755 | //prepare_service_request, channel_peer_disconnect_handler, |
1757 | if (!session->channel) { | 1756 | if (!session->channel) { |
1758 | GNUNET_break (0); | 1757 | GNUNET_break (0); |
@@ -1815,18 +1814,20 @@ handle_client_request (void *cls, | |||
1815 | * @param channel new handle to the channel | 1814 | * @param channel new handle to the channel |
1816 | * @param initiator peer that started the channel | 1815 | * @param initiator peer that started the channel |
1817 | * @param port unused | 1816 | * @param port unused |
1817 | * @param options unused | ||
1818 | * | ||
1818 | * @return session associated with the channel | 1819 | * @return session associated with the channel |
1819 | */ | 1820 | */ |
1820 | static void * | 1821 | static void * |
1821 | channel_incoming_handler (void *cls, | 1822 | channel_incoming_handler (void *cls, |
1822 | struct GNUNET_MESH_Channel *channel, | 1823 | struct GNUNET_MESH_Channel *channel, |
1823 | const struct GNUNET_PeerIdentity *initiator, | 1824 | const struct GNUNET_PeerIdentity *initiator, |
1824 | uint32_t port) | 1825 | uint32_t port, enum MeshOption options) |
1825 | { | 1826 | { |
1826 | struct ServiceSession * c = GNUNET_new (struct ServiceSession); | 1827 | struct ServiceSession * c = GNUNET_new (struct ServiceSession); |
1827 | 1828 | ||
1828 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("New incoming channel from peer %s.\n"), GNUNET_i2s (initiator)); | 1829 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("New incoming channel from peer %s.\n"), GNUNET_i2s (initiator)); |
1829 | 1830 | ||
1830 | c->peer = *initiator; | 1831 | c->peer = *initiator; |
1831 | c->channel = channel; | 1832 | c->channel = channel; |
1832 | c->role = BOB; | 1833 | c->role = BOB; |
@@ -1861,7 +1862,7 @@ channel_destruction_handler (void *cls, | |||
1861 | GNUNET_i2s (&session->peer)); | 1862 | GNUNET_i2s (&session->peer)); |
1862 | if (ALICE == session->role) { | 1863 | if (ALICE == session->role) { |
1863 | // as we have only one peer connected in each session, just remove the session | 1864 | // as we have only one peer connected in each session, just remove the session |
1864 | 1865 | ||
1865 | if ((SERVICE_RESPONSE_RECEIVED > session->state) && (!do_shutdown)) { | 1866 | if ((SERVICE_RESPONSE_RECEIVED > session->state) && (!do_shutdown)) { |
1866 | session->channel = NULL; | 1867 | session->channel = NULL; |
1867 | // if this happened before we received the answer, we must terminate the session | 1868 | // if this happened before we received the answer, we must terminate the session |
@@ -2288,7 +2289,7 @@ handle_service_response_multipart (void *cls, | |||
2288 | return GNUNET_OK; | 2289 | return GNUNET_OK; |
2289 | session->state = SERVICE_RESPONSE_RECEIVED; | 2290 | session->state = SERVICE_RESPONSE_RECEIVED; |
2290 | session->product = compute_scalar_product (session); //never NULL | 2291 | session->product = compute_scalar_product (session); //never NULL |
2291 | 2292 | ||
2292 | invalid_msg: | 2293 | invalid_msg: |
2293 | GNUNET_break_op (NULL != session->product); | 2294 | GNUNET_break_op (NULL != session->product); |
2294 | 2295 | ||
@@ -2342,7 +2343,7 @@ handle_service_response (void *cls, | |||
2342 | //we need at least a full message without elements attached | 2343 | //we need at least a full message without elements attached |
2343 | msg_size = ntohs (msg->header.size); | 2344 | msg_size = ntohs (msg->header.size); |
2344 | required_size = sizeof (struct GNUNET_SCALARPRODUCT_service_response) + 2 * PAILLIER_ELEMENT_LENGTH; | 2345 | required_size = sizeof (struct GNUNET_SCALARPRODUCT_service_response) + 2 * PAILLIER_ELEMENT_LENGTH; |
2345 | 2346 | ||
2346 | if (required_size > msg_size) { | 2347 | if (required_size > msg_size) { |
2347 | goto invalid_msg; | 2348 | goto invalid_msg; |
2348 | } | 2349 | } |
@@ -2393,7 +2394,7 @@ handle_service_response (void *cls, | |||
2393 | 2394 | ||
2394 | session->state = SERVICE_RESPONSE_RECEIVED; | 2395 | session->state = SERVICE_RESPONSE_RECEIVED; |
2395 | session->product = compute_scalar_product (session); //never NULL | 2396 | session->product = compute_scalar_product (session); //never NULL |
2396 | 2397 | ||
2397 | invalid_msg: | 2398 | invalid_msg: |
2398 | GNUNET_break_op (NULL != session->product); | 2399 | GNUNET_break_op (NULL != session->product); |
2399 | // send message with product to client | 2400 | // send message with product to client |