diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-08-10 11:46:22 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-08-10 11:46:22 +0000 |
commit | 6d5959b29aa3ff47605aa91550d90fc28597d0de (patch) | |
tree | a1a6b2815d0f8ff1ab145196283d8b31097cb045 /src/scalarproduct | |
parent | 189e703a007d7950842e71399526a3b11ef5a6ac (diff) | |
download | gnunet-6d5959b29aa3ff47605aa91550d90fc28597d0de.tar.gz gnunet-6d5959b29aa3ff47605aa91550d90fc28597d0de.zip |
use non-constant ports for CADET with scalarproduct
Diffstat (limited to 'src/scalarproduct')
5 files changed, 54 insertions, 21 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c index 43a25a08d..fe27067e8 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c | |||
@@ -850,7 +850,11 @@ client_request_complete_alice (struct AliceServiceSession *s) | |||
850 | { | 850 | { |
851 | struct EccServiceRequestMessage *msg; | 851 | struct EccServiceRequestMessage *msg; |
852 | struct GNUNET_MQ_Envelope *e; | 852 | struct GNUNET_MQ_Envelope *e; |
853 | struct GNUNET_HashCode set_sid; | ||
853 | 854 | ||
855 | GNUNET_CRYPTO_hash (&s->session_id, | ||
856 | sizeof (struct GNUNET_HashCode), | ||
857 | &set_sid); | ||
854 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 858 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
855 | "Creating new channel for session with key %s.\n", | 859 | "Creating new channel for session with key %s.\n", |
856 | GNUNET_h2s (&s->session_id)); | 860 | GNUNET_h2s (&s->session_id)); |
@@ -858,7 +862,7 @@ client_request_complete_alice (struct AliceServiceSession *s) | |||
858 | = GNUNET_CADET_channel_create (my_cadet, | 862 | = GNUNET_CADET_channel_create (my_cadet, |
859 | s, | 863 | s, |
860 | &s->peer, | 864 | &s->peer, |
861 | GC_u2h (GNUNET_APPLICATION_TYPE_SCALARPRODUCT_ECC), | 865 | &s->session_id, |
862 | GNUNET_CADET_OPTION_RELIABLE); | 866 | GNUNET_CADET_OPTION_RELIABLE); |
863 | if (NULL == s->channel) | 867 | if (NULL == s->channel) |
864 | { | 868 | { |
@@ -870,7 +874,7 @@ client_request_complete_alice (struct AliceServiceSession *s) | |||
870 | s->intersection_listen | 874 | s->intersection_listen |
871 | = GNUNET_SET_listen (cfg, | 875 | = GNUNET_SET_listen (cfg, |
872 | GNUNET_SET_OPERATION_INTERSECTION, | 876 | GNUNET_SET_OPERATION_INTERSECTION, |
873 | &s->session_id, | 877 | &set_sid, |
874 | &cb_intersection_request_alice, | 878 | &cb_intersection_request_alice, |
875 | s); | 879 | s); |
876 | if (NULL == s->intersection_listen) | 880 | if (NULL == s->intersection_listen) |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c index 7246fa6a0..db656d39b 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c +++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c | |||
@@ -104,6 +104,11 @@ struct BobServiceSession | |||
104 | struct GNUNET_SET_OperationHandle *intersection_op; | 104 | struct GNUNET_SET_OperationHandle *intersection_op; |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * Our open port. | ||
108 | */ | ||
109 | struct GNUNET_CADET_Port *port; | ||
110 | |||
111 | /** | ||
107 | * b(Bob) | 112 | * b(Bob) |
108 | */ | 113 | */ |
109 | struct MpiElement *sorted_elements; | 114 | struct MpiElement *sorted_elements; |
@@ -362,6 +367,7 @@ destroy_service_session (struct BobServiceSession *s) | |||
362 | gcry_mpi_point_release (s->prod_h_i_b_i); | 367 | gcry_mpi_point_release (s->prod_h_i_b_i); |
363 | s->prod_h_i_b_i = NULL; | 368 | s->prod_h_i_b_i = NULL; |
364 | } | 369 | } |
370 | GNUNET_CADET_close_port (s->port); | ||
365 | GNUNET_free (s); | 371 | GNUNET_free (s); |
366 | } | 372 | } |
367 | 373 | ||
@@ -795,6 +801,11 @@ cb_intersection_element_removed (void *cls, | |||
795 | static void | 801 | static void |
796 | start_intersection (struct BobServiceSession *s) | 802 | start_intersection (struct BobServiceSession *s) |
797 | { | 803 | { |
804 | struct GNUNET_HashCode set_sid; | ||
805 | |||
806 | GNUNET_CRYPTO_hash (&s->session_id, | ||
807 | sizeof (struct GNUNET_HashCode), | ||
808 | &set_sid); | ||
798 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 809 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
799 | "Got session with key %s and %u elements, starting intersection.\n", | 810 | "Got session with key %s and %u elements, starting intersection.\n", |
800 | GNUNET_h2s (&s->session_id), | 811 | GNUNET_h2s (&s->session_id), |
@@ -802,7 +813,7 @@ start_intersection (struct BobServiceSession *s) | |||
802 | 813 | ||
803 | s->intersection_op | 814 | s->intersection_op |
804 | = GNUNET_SET_prepare (&s->cadet->peer, | 815 | = GNUNET_SET_prepare (&s->cadet->peer, |
805 | &s->session_id, | 816 | &set_sid, |
806 | NULL, | 817 | NULL, |
807 | GNUNET_SET_RESULT_REMOVED, | 818 | GNUNET_SET_RESULT_REMOVED, |
808 | &cb_intersection_element_removed, | 819 | &cb_intersection_element_removed, |
@@ -1076,6 +1087,18 @@ GSS_handle_bob_client_message (void *cls, | |||
1076 | s->total = total_count; | 1087 | s->total = total_count; |
1077 | s->client_received_element_count = contained_count; | 1088 | s->client_received_element_count = contained_count; |
1078 | s->session_id = msg->session_key; | 1089 | s->session_id = msg->session_key; |
1090 | s->port = GNUNET_CADET_open_port (my_cadet, | ||
1091 | &msg->session_key, | ||
1092 | &cb_channel_incoming, | ||
1093 | s); | ||
1094 | if (NULL == s->port) | ||
1095 | { | ||
1096 | GNUNET_break (0); | ||
1097 | GNUNET_SERVER_receive_done (client, | ||
1098 | GNUNET_SYSERR); | ||
1099 | GNUNET_free (s); | ||
1100 | return; | ||
1101 | } | ||
1079 | GNUNET_break (GNUNET_YES == | 1102 | GNUNET_break (GNUNET_YES == |
1080 | GNUNET_CONTAINER_multihashmap_put (client_sessions, | 1103 | GNUNET_CONTAINER_multihashmap_put (client_sessions, |
1081 | &s->session_id, | 1104 | &s->session_id, |
@@ -1246,9 +1269,6 @@ run (void *cls, | |||
1246 | GNUNET_SCHEDULER_shutdown (); | 1269 | GNUNET_SCHEDULER_shutdown (); |
1247 | return; | 1270 | return; |
1248 | } | 1271 | } |
1249 | GNUNET_CADET_open_port (my_cadet, | ||
1250 | GC_u2h (GNUNET_APPLICATION_TYPE_SCALARPRODUCT_ECC), | ||
1251 | &cb_channel_incoming, NULL); | ||
1252 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 1272 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1253 | NULL); | 1273 | NULL); |
1254 | } | 1274 | } |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c index 8c3b1ed24..0df7da00c 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_alice.c | |||
@@ -1081,7 +1081,7 @@ client_request_complete_alice (struct AliceServiceSession *s) | |||
1081 | = GNUNET_CADET_channel_create (my_cadet, | 1081 | = GNUNET_CADET_channel_create (my_cadet, |
1082 | s, | 1082 | s, |
1083 | &s->peer, | 1083 | &s->peer, |
1084 | GC_u2h (GNUNET_APPLICATION_TYPE_SCALARPRODUCT), | 1084 | &s->session_id, |
1085 | GNUNET_CADET_OPTION_RELIABLE); | 1085 | GNUNET_CADET_OPTION_RELIABLE); |
1086 | if (NULL == s->channel) | 1086 | if (NULL == s->channel) |
1087 | { | 1087 | { |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_bob.c b/src/scalarproduct/gnunet-service-scalarproduct_bob.c index 84c831c82..1136f1e00 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_bob.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_bob.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2013, 2014 GNUnet e.V. | 3 | Copyright (C) 2013, 2014, 2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -104,6 +104,11 @@ struct BobServiceSession | |||
104 | struct GNUNET_SET_OperationHandle *intersection_op; | 104 | struct GNUNET_SET_OperationHandle *intersection_op; |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * CADET port we are listening on. | ||
108 | */ | ||
109 | struct GNUNET_CADET_Port *port; | ||
110 | |||
111 | /** | ||
107 | * a(Alice) | 112 | * a(Alice) |
108 | */ | 113 | */ |
109 | struct MpiElement *sorted_elements; | 114 | struct MpiElement *sorted_elements; |
@@ -403,6 +408,7 @@ destroy_service_session (struct BobServiceSession *s) | |||
403 | GNUNET_free (s->r_prime); | 408 | GNUNET_free (s->r_prime); |
404 | s->r_prime = NULL; | 409 | s->r_prime = NULL; |
405 | } | 410 | } |
411 | GNUNET_CADET_close_port (s->port); | ||
406 | GNUNET_free (s); | 412 | GNUNET_free (s); |
407 | } | 413 | } |
408 | 414 | ||
@@ -1176,7 +1182,7 @@ handle_alices_computation_request (void *cls, | |||
1176 | * preliminary initialization, more happens after we get Alice's first | 1182 | * preliminary initialization, more happens after we get Alice's first |
1177 | * message. | 1183 | * message. |
1178 | * | 1184 | * |
1179 | * @param cls closure | 1185 | * @param cls closure with the `struct BobServiceSession` |
1180 | * @param channel new handle to the channel | 1186 | * @param channel new handle to the channel |
1181 | * @param initiator peer that started the channel | 1187 | * @param initiator peer that started the channel |
1182 | * @param port unused | 1188 | * @param port unused |
@@ -1357,13 +1363,6 @@ GSS_handle_bob_client_message (void *cls, | |||
1357 | GNUNET_SYSERR); | 1363 | GNUNET_SYSERR); |
1358 | return; | 1364 | return; |
1359 | } | 1365 | } |
1360 | if (NULL != find_matching_client_session (&msg->session_key)) | ||
1361 | { | ||
1362 | GNUNET_break (0); | ||
1363 | GNUNET_SERVER_receive_done (client, | ||
1364 | GNUNET_SYSERR); | ||
1365 | return; | ||
1366 | } | ||
1367 | 1366 | ||
1368 | s = GNUNET_new (struct BobServiceSession); | 1367 | s = GNUNET_new (struct BobServiceSession); |
1369 | s->status = GNUNET_SCALARPRODUCT_STATUS_ACTIVE; | 1368 | s->status = GNUNET_SCALARPRODUCT_STATUS_ACTIVE; |
@@ -1372,6 +1371,19 @@ GSS_handle_bob_client_message (void *cls, | |||
1372 | s->total = total_count; | 1371 | s->total = total_count; |
1373 | s->client_received_element_count = contained_count; | 1372 | s->client_received_element_count = contained_count; |
1374 | s->session_id = msg->session_key; | 1373 | s->session_id = msg->session_key; |
1374 | s->port = GNUNET_CADET_open_port (my_cadet, | ||
1375 | &msg->session_key, | ||
1376 | &cb_channel_incoming, | ||
1377 | s); | ||
1378 | if (NULL == s->port) | ||
1379 | { | ||
1380 | GNUNET_break (0); | ||
1381 | GNUNET_SERVER_receive_done (client, | ||
1382 | GNUNET_SYSERR); | ||
1383 | GNUNET_free (s); | ||
1384 | return; | ||
1385 | } | ||
1386 | |||
1375 | GNUNET_break (GNUNET_YES == | 1387 | GNUNET_break (GNUNET_YES == |
1376 | GNUNET_CONTAINER_multihashmap_put (client_sessions, | 1388 | GNUNET_CONTAINER_multihashmap_put (client_sessions, |
1377 | &s->session_id, | 1389 | &s->session_id, |
@@ -1543,9 +1555,6 @@ run (void *cls, | |||
1543 | GNUNET_SCHEDULER_shutdown (); | 1555 | GNUNET_SCHEDULER_shutdown (); |
1544 | return; | 1556 | return; |
1545 | } | 1557 | } |
1546 | GNUNET_CADET_open_port (my_cadet, | ||
1547 | GC_u2h (GNUNET_APPLICATION_TYPE_SCALARPRODUCT), | ||
1548 | &cb_channel_incoming, NULL); | ||
1549 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 1558 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1550 | NULL); | 1559 | NULL); |
1551 | } | 1560 | } |
diff --git a/src/scalarproduct/scalarproduct.conf.in b/src/scalarproduct/scalarproduct.conf.in index c5149eeaf..e2a0c7ad7 100644 --- a/src/scalarproduct/scalarproduct.conf.in +++ b/src/scalarproduct/scalarproduct.conf.in | |||
@@ -1,6 +1,6 @@ | |||
1 | [scalarproduct-alice] | 1 | [scalarproduct-alice] |
2 | AUTOSTART = @AUTOSTART@ | 2 | AUTOSTART = @AUTOSTART@ |
3 | BINARY = gnunet-service-scalarproduct-alice | 3 | BINARY = gnunet-service-scalarproduct-ecc-alice |
4 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-scalarproduct-alice.sock | 4 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-scalarproduct-alice.sock |
5 | @UNIXONLY@ PORT = 2117 | 5 | @UNIXONLY@ PORT = 2117 |
6 | #ACCEPT_FROM = 127.0.0.1; | 6 | #ACCEPT_FROM = 127.0.0.1; |
@@ -14,7 +14,7 @@ UNIX_MATCH_GID = YES | |||
14 | [scalarproduct-bob] | 14 | [scalarproduct-bob] |
15 | AUTOSTART = @AUTOSTART@ | 15 | AUTOSTART = @AUTOSTART@ |
16 | HOSTNAME = localhost | 16 | HOSTNAME = localhost |
17 | BINARY = gnunet-service-scalarproduct-bob | 17 | BINARY = gnunet-service-scalarproduct-ecc-bob |
18 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-scalarproduct-bob.sock | 18 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-scalarproduct-bob.sock |
19 | @UNIXONLY@ PORT = 2118 | 19 | @UNIXONLY@ PORT = 2118 |
20 | 20 | ||