diff options
-rw-r--r-- | src/include/gnunet_protocols.h | 4 | ||||
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c | 272 | ||||
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c | 2 | ||||
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct_alice.c | 2 | ||||
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct_bob.c | 2 | ||||
-rw-r--r-- | src/scalarproduct/scalarproduct_api.c | 4 |
6 files changed, 141 insertions, 145 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 392a4d761..1d2a87691 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -1903,12 +1903,12 @@ extern "C" | |||
1903 | /** | 1903 | /** |
1904 | * Client -> Alice multipart | 1904 | * Client -> Alice multipart |
1905 | */ | 1905 | */ |
1906 | #define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_ALICE 642 | 1906 | #define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_ALICE 642 |
1907 | 1907 | ||
1908 | /** | 1908 | /** |
1909 | * Client -> Bob multipart | 1909 | * Client -> Bob multipart |
1910 | */ | 1910 | */ |
1911 | #define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_BOB 643 | 1911 | #define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_BOB 643 |
1912 | 1912 | ||
1913 | /** | 1913 | /** |
1914 | * Alice -> Bob session initialization | 1914 | * Alice -> Bob session initialization |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c index fe27067e8..ba8b4b796 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.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-2015 GNUnet e.V. | 3 | Copyright (C) 2013-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 |
@@ -93,7 +93,7 @@ struct AliceServiceSession | |||
93 | /** | 93 | /** |
94 | * The client this request is related to. | 94 | * The client this request is related to. |
95 | */ | 95 | */ |
96 | struct GNUNET_SERVER_Client *client; | 96 | struct GNUNET_SERVICE_Client *client; |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * The message queue for the client. | 99 | * The message queue for the client. |
@@ -238,11 +238,6 @@ destroy_service_session (struct AliceServiceSession *s) | |||
238 | if (GNUNET_YES == s->in_destroy) | 238 | if (GNUNET_YES == s->in_destroy) |
239 | return; | 239 | return; |
240 | s->in_destroy = GNUNET_YES; | 240 | s->in_destroy = GNUNET_YES; |
241 | if (NULL != s->client_mq) | ||
242 | { | ||
243 | GNUNET_MQ_destroy (s->client_mq); | ||
244 | s->client_mq = NULL; | ||
245 | } | ||
246 | if (NULL != s->cadet_mq) | 241 | if (NULL != s->cadet_mq) |
247 | { | 242 | { |
248 | GNUNET_MQ_destroy (s->cadet_mq); | 243 | GNUNET_MQ_destroy (s->cadet_mq); |
@@ -250,9 +245,7 @@ destroy_service_session (struct AliceServiceSession *s) | |||
250 | } | 245 | } |
251 | if (NULL != s->client) | 246 | if (NULL != s->client) |
252 | { | 247 | { |
253 | GNUNET_SERVER_client_set_user_context (s->client, | 248 | GNUNET_SERVICE_client_drop (s->client); |
254 | NULL); | ||
255 | GNUNET_SERVER_client_disconnect (s->client); | ||
256 | s->client = NULL; | 249 | s->client = NULL; |
257 | } | 250 | } |
258 | if (NULL != s->channel) | 251 | if (NULL != s->channel) |
@@ -895,48 +888,23 @@ client_request_complete_alice (struct AliceServiceSession *s) | |||
895 | 888 | ||
896 | 889 | ||
897 | /** | 890 | /** |
898 | * We're receiving additional set data. Add it to our | 891 | * We're receiving additional set data. Check if |
899 | * set and if we are done, initiate the transaction. | 892 | * @a msg is well-formed. |
900 | * | 893 | * |
901 | * @param cls closure | 894 | * @param cls client identification of the client |
902 | * @param client identification of the client | 895 | * @param msg the actual message |
903 | * @param message the actual message | 896 | * @return #GNUNET_OK if @a msg is well-formed |
904 | */ | 897 | */ |
905 | static void | 898 | static int |
906 | GSS_handle_alice_client_message_multipart (void *cls, | 899 | check_alice_client_message_multipart (void *cls, |
907 | struct GNUNET_SERVER_Client *client, | 900 | const struct ComputationBobCryptodataMultipartMessage *msg) |
908 | const struct GNUNET_MessageHeader *message) | ||
909 | { | 901 | { |
910 | const struct ComputationBobCryptodataMultipartMessage * msg; | 902 | struct AliceServiceSession *s = cls; |
911 | struct AliceServiceSession *s; | ||
912 | uint32_t contained_count; | 903 | uint32_t contained_count; |
913 | const struct GNUNET_SCALARPRODUCT_Element *elements; | ||
914 | uint32_t i; | ||
915 | uint16_t msize; | 904 | uint16_t msize; |
916 | struct GNUNET_SET_Element set_elem; | ||
917 | struct GNUNET_SCALARPRODUCT_Element *elem; | ||
918 | 905 | ||
919 | s = GNUNET_SERVER_client_get_user_context (client, | 906 | msize = ntohs (msg->header.size); |
920 | struct AliceServiceSession); | ||
921 | if (NULL == s) | ||
922 | { | ||
923 | /* session needs to already exist */ | ||
924 | GNUNET_break (0); | ||
925 | GNUNET_SERVER_receive_done (client, | ||
926 | GNUNET_SYSERR); | ||
927 | return; | ||
928 | } | ||
929 | msize = ntohs (message->size); | ||
930 | if (msize < sizeof (struct ComputationBobCryptodataMultipartMessage)) | ||
931 | { | ||
932 | GNUNET_break (0); | ||
933 | GNUNET_SERVER_receive_done (client, | ||
934 | GNUNET_SYSERR); | ||
935 | return; | ||
936 | } | ||
937 | msg = (const struct ComputationBobCryptodataMultipartMessage *) message; | ||
938 | contained_count = ntohl (msg->element_count_contained); | 907 | contained_count = ntohl (msg->element_count_contained); |
939 | |||
940 | if ( (msize != (sizeof (struct ComputationBobCryptodataMultipartMessage) + | 908 | if ( (msize != (sizeof (struct ComputationBobCryptodataMultipartMessage) + |
941 | contained_count * sizeof (struct GNUNET_SCALARPRODUCT_Element))) || | 909 | contained_count * sizeof (struct GNUNET_SCALARPRODUCT_Element))) || |
942 | (0 == contained_count) || | 910 | (0 == contained_count) || |
@@ -944,18 +912,38 @@ GSS_handle_alice_client_message_multipart (void *cls, | |||
944 | (s->total < s->client_received_element_count + contained_count) ) | 912 | (s->total < s->client_received_element_count + contained_count) ) |
945 | { | 913 | { |
946 | GNUNET_break_op (0); | 914 | GNUNET_break_op (0); |
947 | GNUNET_SERVER_receive_done (client, | 915 | return GNUNET_SYSERR; |
948 | GNUNET_SYSERR); | ||
949 | return; | ||
950 | } | 916 | } |
917 | return GNUNET_OK; | ||
918 | } | ||
919 | |||
920 | |||
921 | /** | ||
922 | * We're receiving additional set data. Add it to our | ||
923 | * set and if we are done, initiate the transaction. | ||
924 | * | ||
925 | * @param cls client identification of the client | ||
926 | * @param msg the actual message | ||
927 | */ | ||
928 | static void | ||
929 | handle_alice_client_message_multipart (void *cls, | ||
930 | const struct ComputationBobCryptodataMultipartMessage *msg) | ||
931 | { | ||
932 | struct AliceServiceSession *s = cls; | ||
933 | uint32_t contained_count; | ||
934 | const struct GNUNET_SCALARPRODUCT_Element *elements; | ||
935 | struct GNUNET_SET_Element set_elem; | ||
936 | struct GNUNET_SCALARPRODUCT_Element *elem; | ||
937 | |||
938 | contained_count = ntohl (msg->element_count_contained); | ||
951 | s->client_received_element_count += contained_count; | 939 | s->client_received_element_count += contained_count; |
952 | elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1]; | 940 | elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1]; |
953 | for (i = 0; i < contained_count; i++) | 941 | for (uint32_t i = 0; i < contained_count; i++) |
954 | { | 942 | { |
955 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); | 943 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); |
956 | GNUNET_memcpy (elem, | 944 | GNUNET_memcpy (elem, |
957 | &elements[i], | 945 | &elements[i], |
958 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); | 946 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); |
959 | if (GNUNET_SYSERR == | 947 | if (GNUNET_SYSERR == |
960 | GNUNET_CONTAINER_multihashmap_put (s->intersected_elements, | 948 | GNUNET_CONTAINER_multihashmap_put (s->intersected_elements, |
961 | &elem->key, | 949 | &elem->key, |
@@ -974,8 +962,7 @@ GSS_handle_alice_client_message_multipart (void *cls, | |||
974 | NULL, NULL); | 962 | NULL, NULL); |
975 | s->used_element_count++; | 963 | s->used_element_count++; |
976 | } | 964 | } |
977 | GNUNET_SERVER_receive_done (client, | 965 | GNUNET_SERVICE_client_continue (s->client); |
978 | GNUNET_OK); | ||
979 | if (s->total != s->client_received_element_count) | 966 | if (s->total != s->client_received_element_count) |
980 | { | 967 | { |
981 | /* more to come */ | 968 | /* more to come */ |
@@ -987,45 +974,29 @@ GSS_handle_alice_client_message_multipart (void *cls, | |||
987 | 974 | ||
988 | /** | 975 | /** |
989 | * Handler for Alice's client request message. | 976 | * Handler for Alice's client request message. |
990 | * We are doing request-initiation to compute a scalar product with a peer. | 977 | * Check that @a msg is well-formed. |
991 | * | 978 | * |
992 | * @param cls closure | 979 | * @param cls identification of the client |
993 | * @param client identification of the client | 980 | * @param msg the actual message |
994 | * @param message the actual message | 981 | * @return #GNUNET_OK if @a msg is well-formed |
995 | */ | 982 | */ |
996 | static void | 983 | static int |
997 | GSS_handle_alice_client_message (void *cls, | 984 | check_alice_client_message (void *cls, |
998 | struct GNUNET_SERVER_Client *client, | 985 | const struct AliceComputationMessage *msg) |
999 | const struct GNUNET_MessageHeader *message) | ||
1000 | { | 986 | { |
1001 | const struct AliceComputationMessage *msg; | 987 | struct AliceServiceSession *s = cls; |
1002 | struct AliceServiceSession *s; | ||
1003 | uint32_t contained_count; | ||
1004 | uint32_t total_count; | ||
1005 | const struct GNUNET_SCALARPRODUCT_Element *elements; | ||
1006 | uint32_t i; | ||
1007 | uint16_t msize; | 988 | uint16_t msize; |
1008 | struct GNUNET_SET_Element set_elem; | 989 | uint32_t total_count; |
1009 | struct GNUNET_SCALARPRODUCT_Element *elem; | 990 | uint32_t contained_count; |
1010 | 991 | ||
1011 | s = GNUNET_SERVER_client_get_user_context (client, | 992 | if (NULL != s->intersected_elements) |
1012 | struct AliceServiceSession); | ||
1013 | if (NULL != s) | ||
1014 | { | 993 | { |
1015 | /* only one concurrent session per client connection allowed, | 994 | /* only one concurrent session per client connection allowed, |
1016 | simplifies logic a lot... */ | 995 | simplifies logic a lot... */ |
1017 | GNUNET_break (0); | 996 | GNUNET_break (0); |
1018 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 997 | return GNUNET_SYSERR; |
1019 | return; | ||
1020 | } | ||
1021 | msize = ntohs (message->size); | ||
1022 | if (msize < sizeof (struct AliceComputationMessage)) | ||
1023 | { | ||
1024 | GNUNET_break (0); | ||
1025 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1026 | return; | ||
1027 | } | 998 | } |
1028 | msg = (const struct AliceComputationMessage *) message; | 999 | msize = ntohs (msg->header.size); |
1029 | total_count = ntohl (msg->element_count_total); | 1000 | total_count = ntohl (msg->element_count_total); |
1030 | contained_count = ntohl (msg->element_count_contained); | 1001 | contained_count = ntohl (msg->element_count_contained); |
1031 | if ( (0 == total_count) || | 1002 | if ( (0 == total_count) || |
@@ -1034,15 +1005,34 @@ GSS_handle_alice_client_message (void *cls, | |||
1034 | contained_count * sizeof (struct GNUNET_SCALARPRODUCT_Element))) ) | 1005 | contained_count * sizeof (struct GNUNET_SCALARPRODUCT_Element))) ) |
1035 | { | 1006 | { |
1036 | GNUNET_break_op (0); | 1007 | GNUNET_break_op (0); |
1037 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1008 | return GNUNET_SYSERR; |
1038 | return; | ||
1039 | } | 1009 | } |
1010 | return GNUNET_OK; | ||
1011 | } | ||
1040 | 1012 | ||
1041 | s = GNUNET_new (struct AliceServiceSession); | 1013 | |
1014 | /** | ||
1015 | * Handler for Alice's client request message. | ||
1016 | * We are doing request-initiation to compute a scalar product with a peer. | ||
1017 | * | ||
1018 | * @param cls identification of the client | ||
1019 | * @param msg the actual message | ||
1020 | */ | ||
1021 | static void | ||
1022 | handle_alice_client_message (void *cls, | ||
1023 | const struct AliceComputationMessage *msg) | ||
1024 | { | ||
1025 | struct AliceServiceSession *s = cls; | ||
1026 | uint32_t contained_count; | ||
1027 | uint32_t total_count; | ||
1028 | const struct GNUNET_SCALARPRODUCT_Element *elements; | ||
1029 | struct GNUNET_SET_Element set_elem; | ||
1030 | struct GNUNET_SCALARPRODUCT_Element *elem; | ||
1031 | |||
1032 | total_count = ntohl (msg->element_count_total); | ||
1033 | contained_count = ntohl (msg->element_count_contained); | ||
1042 | s->peer = msg->peer; | 1034 | s->peer = msg->peer; |
1043 | s->status = GNUNET_SCALARPRODUCT_STATUS_ACTIVE; | 1035 | s->status = GNUNET_SCALARPRODUCT_STATUS_ACTIVE; |
1044 | s->client = client; | ||
1045 | s->client_mq = GNUNET_MQ_queue_for_server_client (client); | ||
1046 | s->total = total_count; | 1036 | s->total = total_count; |
1047 | s->client_received_element_count = contained_count; | 1037 | s->client_received_element_count = contained_count; |
1048 | s->session_id = msg->session_key; | 1038 | s->session_id = msg->session_key; |
@@ -1051,14 +1041,14 @@ GSS_handle_alice_client_message (void *cls, | |||
1051 | GNUNET_YES); | 1041 | GNUNET_YES); |
1052 | s->intersection_set = GNUNET_SET_create (cfg, | 1042 | s->intersection_set = GNUNET_SET_create (cfg, |
1053 | GNUNET_SET_OPERATION_INTERSECTION); | 1043 | GNUNET_SET_OPERATION_INTERSECTION); |
1054 | for (i = 0; i < contained_count; i++) | 1044 | for (uint32_t i = 0; i < contained_count; i++) |
1055 | { | 1045 | { |
1056 | if (0 == GNUNET_ntohll (elements[i].value)) | 1046 | if (0 == GNUNET_ntohll (elements[i].value)) |
1057 | continue; | 1047 | continue; |
1058 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); | 1048 | elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element); |
1059 | GNUNET_memcpy (elem, | 1049 | GNUNET_memcpy (elem, |
1060 | &elements[i], | 1050 | &elements[i], |
1061 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); | 1051 | sizeof (struct GNUNET_SCALARPRODUCT_Element)); |
1062 | if (GNUNET_SYSERR == | 1052 | if (GNUNET_SYSERR == |
1063 | GNUNET_CONTAINER_multihashmap_put (s->intersected_elements, | 1053 | GNUNET_CONTAINER_multihashmap_put (s->intersected_elements, |
1064 | &elem->key, | 1054 | &elem->key, |
@@ -1078,10 +1068,7 @@ GSS_handle_alice_client_message (void *cls, | |||
1078 | NULL, NULL); | 1068 | NULL, NULL); |
1079 | s->used_element_count++; | 1069 | s->used_element_count++; |
1080 | } | 1070 | } |
1081 | GNUNET_SERVER_client_set_user_context (client, | 1071 | GNUNET_SERVICE_client_continue (s->client); |
1082 | s); | ||
1083 | GNUNET_SERVER_receive_done (client, | ||
1084 | GNUNET_OK); | ||
1085 | if (s->total != s->client_received_element_count) | 1072 | if (s->total != s->client_received_element_count) |
1086 | { | 1073 | { |
1087 | /* wait for multipart msg */ | 1074 | /* wait for multipart msg */ |
@@ -1117,6 +1104,30 @@ shutdown_task (void *cls) | |||
1117 | 1104 | ||
1118 | 1105 | ||
1119 | /** | 1106 | /** |
1107 | * A client connected. | ||
1108 | * | ||
1109 | * Setup the associated data structure. | ||
1110 | * | ||
1111 | * @param cls closure, NULL | ||
1112 | * @param client identification of the client | ||
1113 | * @param mq message queue to communicate with @a client | ||
1114 | * @return our `struct AliceServiceSession` | ||
1115 | */ | ||
1116 | static void * | ||
1117 | client_connect_cb (void *cls, | ||
1118 | struct GNUNET_SERVICE_Client *client, | ||
1119 | struct GNUNET_MQ_Handle *mq) | ||
1120 | { | ||
1121 | struct AliceServiceSession *s; | ||
1122 | |||
1123 | s = GNUNET_new (struct AliceServiceSession); | ||
1124 | s->client = client; | ||
1125 | s->client_mq = mq; | ||
1126 | return s; | ||
1127 | } | ||
1128 | |||
1129 | |||
1130 | /** | ||
1120 | * A client disconnected. | 1131 | * A client disconnected. |
1121 | * | 1132 | * |
1122 | * Remove the associated session(s), release data structures | 1133 | * Remove the associated session(s), release data structures |
@@ -1124,25 +1135,20 @@ shutdown_task (void *cls) | |||
1124 | * | 1135 | * |
1125 | * @param cls closure, NULL | 1136 | * @param cls closure, NULL |
1126 | * @param client identification of the client | 1137 | * @param client identification of the client |
1138 | * @param app_cls our `struct AliceServiceSession` | ||
1127 | */ | 1139 | */ |
1128 | static void | 1140 | static void |
1129 | handle_client_disconnect (void *cls, | 1141 | client_disconnect_cb (void *cls, |
1130 | struct GNUNET_SERVER_Client *client) | 1142 | struct GNUNET_SERVICE_Client *client, |
1143 | void *app_cls) | ||
1131 | { | 1144 | { |
1132 | struct AliceServiceSession *s; | 1145 | struct AliceServiceSession *s = app_cls; |
1133 | 1146 | ||
1134 | if (NULL == client) | ||
1135 | return; | ||
1136 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1137 | "Client %p disconnected from us.\n", | 1148 | "Client %p disconnected from us.\n", |
1138 | client); | 1149 | client); |
1139 | s = GNUNET_SERVER_client_get_user_context (client, | ||
1140 | struct AliceServiceSession); | ||
1141 | if (NULL == s) | ||
1142 | return; | ||
1143 | s->client = NULL; | 1150 | s->client = NULL; |
1144 | GNUNET_SERVER_client_set_user_context (client, | 1151 | s->client_mq = NULL; |
1145 | NULL); | ||
1146 | destroy_service_session (s); | 1152 | destroy_service_session (s); |
1147 | } | 1153 | } |
1148 | 1154 | ||
@@ -1151,13 +1157,13 @@ handle_client_disconnect (void *cls, | |||
1151 | * Initialization of the program and message handlers | 1157 | * Initialization of the program and message handlers |
1152 | * | 1158 | * |
1153 | * @param cls closure | 1159 | * @param cls closure |
1154 | * @param server the initialized server | ||
1155 | * @param c configuration to use | 1160 | * @param c configuration to use |
1161 | * @param service the initialized service | ||
1156 | */ | 1162 | */ |
1157 | static void | 1163 | static void |
1158 | run (void *cls, | 1164 | run (void *cls, |
1159 | struct GNUNET_SERVER_Handle *server, | 1165 | const struct GNUNET_CONFIGURATION_Handle *c, |
1160 | const struct GNUNET_CONFIGURATION_Handle *c) | 1166 | struct GNUNET_SERVICE_Handle *service) |
1161 | { | 1167 | { |
1162 | static const struct GNUNET_CADET_MessageHandler cadet_handlers[] = { | 1168 | static const struct GNUNET_CADET_MessageHandler cadet_handlers[] = { |
1163 | { &handle_bobs_cryptodata_message, | 1169 | { &handle_bobs_cryptodata_message, |
@@ -1165,15 +1171,6 @@ run (void *cls, | |||
1165 | 0}, | 1171 | 0}, |
1166 | { NULL, 0, 0} | 1172 | { NULL, 0, 0} |
1167 | }; | 1173 | }; |
1168 | static const struct GNUNET_SERVER_MessageHandler server_handlers[] = { | ||
1169 | { &GSS_handle_alice_client_message, NULL, | ||
1170 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE, | ||
1171 | 0}, | ||
1172 | { &GSS_handle_alice_client_message_multipart, NULL, | ||
1173 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_ALICE, | ||
1174 | 0}, | ||
1175 | { NULL, NULL, 0, 0} | ||
1176 | }; | ||
1177 | 1174 | ||
1178 | cfg = c; | 1175 | cfg = c; |
1179 | edc = GNUNET_CRYPTO_ecc_dlog_prepare (MAX_RESULT, | 1176 | edc = GNUNET_CRYPTO_ecc_dlog_prepare (MAX_RESULT, |
@@ -1182,12 +1179,8 @@ run (void *cls, | |||
1182 | GNUNET_CRYPTO_ecc_rnd_mpi (edc, | 1179 | GNUNET_CRYPTO_ecc_rnd_mpi (edc, |
1183 | &my_privkey, | 1180 | &my_privkey, |
1184 | &my_privkey_inv); | 1181 | &my_privkey_inv); |
1185 | GNUNET_SERVER_add_handlers (server, | 1182 | my_cadet = GNUNET_CADET_connect (cfg, |
1186 | server_handlers); | 1183 | NULL, |
1187 | GNUNET_SERVER_disconnect_notify (server, | ||
1188 | &handle_client_disconnect, | ||
1189 | NULL); | ||
1190 | my_cadet = GNUNET_CADET_connect (cfg, NULL, | ||
1191 | &cb_channel_destruction, | 1184 | &cb_channel_destruction, |
1192 | cadet_handlers); | 1185 | cadet_handlers); |
1193 | if (NULL == my_cadet) | 1186 | if (NULL == my_cadet) |
@@ -1204,21 +1197,24 @@ run (void *cls, | |||
1204 | 1197 | ||
1205 | 1198 | ||
1206 | /** | 1199 | /** |
1207 | * The main function for the scalarproduct service. | 1200 | * Define "main" method using service macro. |
1208 | * | ||
1209 | * @param argc number of arguments from the command line | ||
1210 | * @param argv command line arguments | ||
1211 | * @return 0 ok, 1 on error | ||
1212 | */ | 1201 | */ |
1213 | int | 1202 | GNUNET_SERVICE_MAIN |
1214 | main (int argc, | 1203 | ("scalarproduct-alice", |
1215 | char *const *argv) | 1204 | GNUNET_SERVICE_OPTION_NONE, |
1216 | { | 1205 | &run, |
1217 | return (GNUNET_OK == | 1206 | &client_connect_cb, |
1218 | GNUNET_SERVICE_run (argc, argv, | 1207 | &client_disconnect_cb, |
1219 | "scalarproduct-alice", | 1208 | NULL, |
1220 | GNUNET_SERVICE_OPTION_NONE, | 1209 | GNUNET_MQ_hd_var_size (alice_client_message, |
1221 | &run, NULL)) ? 0 : 1; | 1210 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE, |
1222 | } | 1211 | struct AliceComputationMessage, |
1212 | NULL), | ||
1213 | GNUNET_MQ_hd_var_size (alice_client_message_multipart, | ||
1214 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_ALICE, | ||
1215 | struct ComputationBobCryptodataMultipartMessage, | ||
1216 | NULL), | ||
1217 | GNUNET_MQ_handler_end ()); | ||
1218 | |||
1223 | 1219 | ||
1224 | /* end of gnunet-service-scalarproduct-ecc_alice.c */ | 1220 | /* end of gnunet-service-scalarproduct-ecc_alice.c */ |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c index db656d39b..7942c0b3d 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c +++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c | |||
@@ -1231,7 +1231,7 @@ run (void *cls, | |||
1231 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB, | 1231 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB, |
1232 | 0}, | 1232 | 0}, |
1233 | { &GSS_handle_bob_client_message_multipart, NULL, | 1233 | { &GSS_handle_bob_client_message_multipart, NULL, |
1234 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_BOB, | 1234 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_BOB, |
1235 | 0}, | 1235 | 0}, |
1236 | { NULL, NULL, 0, 0} | 1236 | { NULL, NULL, 0, 0} |
1237 | }; | 1237 | }; |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c index 0df7da00c..51bfcb80f 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_alice.c | |||
@@ -1387,7 +1387,7 @@ run (void *cls, | |||
1387 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE, | 1387 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE, |
1388 | 0}, | 1388 | 0}, |
1389 | { &GSS_handle_alice_client_message_multipart, NULL, | 1389 | { &GSS_handle_alice_client_message_multipart, NULL, |
1390 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_ALICE, | 1390 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_ALICE, |
1391 | 0}, | 1391 | 0}, |
1392 | { NULL, NULL, 0, 0} | 1392 | { NULL, NULL, 0, 0} |
1393 | }; | 1393 | }; |
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_bob.c b/src/scalarproduct/gnunet-service-scalarproduct_bob.c index 1136f1e00..a19c909e1 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_bob.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_bob.c | |||
@@ -1511,7 +1511,7 @@ run (void *cls, | |||
1511 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB, | 1511 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB, |
1512 | 0}, | 1512 | 0}, |
1513 | { &GSS_handle_bob_client_message_multipart, NULL, | 1513 | { &GSS_handle_bob_client_message_multipart, NULL, |
1514 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_BOB, | 1514 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_BOB, |
1515 | 0}, | 1515 | 0}, |
1516 | { NULL, NULL, 0, 0} | 1516 | { NULL, NULL, 0, 0} |
1517 | }; | 1517 | }; |
diff --git a/src/scalarproduct/scalarproduct_api.c b/src/scalarproduct/scalarproduct_api.c index 5ad64f4be..9606851c8 100644 --- a/src/scalarproduct/scalarproduct_api.c +++ b/src/scalarproduct/scalarproduct_api.c | |||
@@ -294,7 +294,7 @@ GNUNET_SCALARPRODUCT_accept_computation (const struct GNUNET_CONFIGURATION_Handl | |||
294 | size = todo * sizeof (struct GNUNET_SCALARPRODUCT_Element); | 294 | size = todo * sizeof (struct GNUNET_SCALARPRODUCT_Element); |
295 | env = GNUNET_MQ_msg_extra (mmsg, | 295 | env = GNUNET_MQ_msg_extra (mmsg, |
296 | size, | 296 | size, |
297 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_BOB); | 297 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_BOB); |
298 | mmsg->element_count_contained = htonl (todo); | 298 | mmsg->element_count_contained = htonl (todo); |
299 | GNUNET_memcpy (&mmsg[1], | 299 | GNUNET_memcpy (&mmsg[1], |
300 | &elements[element_count_transfered], | 300 | &elements[element_count_transfered], |
@@ -454,7 +454,7 @@ GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle | |||
454 | size = todo * sizeof (struct GNUNET_SCALARPRODUCT_Element); | 454 | size = todo * sizeof (struct GNUNET_SCALARPRODUCT_Element); |
455 | env = GNUNET_MQ_msg_extra (mmsg, | 455 | env = GNUNET_MQ_msg_extra (mmsg, |
456 | size, | 456 | size, |
457 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_ALICE); | 457 | GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_ALICE); |
458 | mmsg->element_count_contained = htonl (todo); | 458 | mmsg->element_count_contained = htonl (todo); |
459 | GNUNET_memcpy (&mmsg[1], | 459 | GNUNET_memcpy (&mmsg[1], |
460 | &elements[element_count_transfered], | 460 | &elements[element_count_transfered], |