aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-11-27 09:50:41 +0000
committerChristian Grothoff <christian@grothoff.org>2014-11-27 09:50:41 +0000
commit44bb721ef043f99e97d60231438b9e71104d99d7 (patch)
tree476330cbfe2031fa3e3daecf8bf3c45a5156b800 /src/set
parentbf716069e987193e1ee0d06bbc4af245e6ffa821 (diff)
downloadgnunet-44bb721ef043f99e97d60231438b9e71104d99d7.tar.gz
gnunet-44bb721ef043f99e97d60231438b9e71104d99d7.zip
eliminating useless salt argument, salt can be generated inside of gnunet-service-set
Diffstat (limited to 'src/set')
-rw-r--r--src/set/gnunet-service-set.c26
-rw-r--r--src/set/gnunet-service-set.h3
-rw-r--r--src/set/gnunet-set-profiler.c16
-rw-r--r--src/set/set.h83
-rw-r--r--src/set/set_api.c62
-rw-r--r--src/set/set_protocol.h19
-rw-r--r--src/set/test_set_api.c4
-rw-r--r--src/set/test_set_intersection_result_full.c2
-rw-r--r--src/set/test_set_union_result_full.c2
9 files changed, 123 insertions, 94 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index 666ba5b1b..452ded8a3 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2013 Christian Grothoff (and other contributing authors) 3 (C) 2013, 2014 Christian Grothoff (and other contributing authors)
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
@@ -17,11 +17,11 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file set/gnunet-service-set.c 21 * @file set/gnunet-service-set.c
23 * @brief two-peer set operations 22 * @brief two-peer set operations
24 * @author Florian Dold 23 * @author Florian Dold
24 * @author Christian Grothoff
25 */ 25 */
26#include "gnunet-service-set.h" 26#include "gnunet-service-set.h"
27#include "set_protocol.h" 27#include "set_protocol.h"
@@ -629,7 +629,8 @@ handle_incoming_msg (struct Operation *op,
629 spec->context_msg = GNUNET_copy_message (spec->context_msg); 629 spec->context_msg = GNUNET_copy_message (spec->context_msg);
630 spec->operation = ntohl (msg->operation); 630 spec->operation = ntohl (msg->operation);
631 spec->app_id = msg->app_id; 631 spec->app_id = msg->app_id;
632 spec->salt = ntohl (msg->salt); 632 spec->salt = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
633 UINT32_MAX);
633 spec->peer = op->state->peer; 634 spec->peer = op->state->peer;
634 spec->remote_element_count = ntohl (msg->element_count); 635 spec->remote_element_count = ntohl (msg->element_count);
635 636
@@ -729,7 +730,8 @@ handle_client_iterate (void *cls,
729 GNUNET_SERVER_client_disconnect (client); 730 GNUNET_SERVER_client_disconnect (client);
730 return; 731 return;
731 } 732 }
732 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "iterating union set with %u elements\n", 733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
734 "iterating union set with %u elements\n",
733 GNUNET_CONTAINER_multihashmap_size (set->elements)); 735 GNUNET_CONTAINER_multihashmap_size (set->elements));
734 GNUNET_SERVER_receive_done (client, GNUNET_OK); 736 GNUNET_SERVER_receive_done (client, GNUNET_OK);
735 set->iter = GNUNET_CONTAINER_multihashmap_iterator_create (set->elements); 737 set->iter = GNUNET_CONTAINER_multihashmap_iterator_create (set->elements);
@@ -767,7 +769,7 @@ handle_client_create_set (void *cls,
767 769
768 set = GNUNET_new (struct Set); 770 set = GNUNET_new (struct Set);
769 771
770 switch (ntohs (msg->operation)) 772 switch (ntohl (msg->operation))
771 { 773 {
772 case GNUNET_SET_OPERATION_INTERSECTION: 774 case GNUNET_SET_OPERATION_INTERSECTION:
773 set->vt = _GSS_intersection_vt (); 775 set->vt = _GSS_intersection_vt ();
@@ -875,9 +877,9 @@ handle_client_reject (void *cls,
875 const struct GNUNET_MessageHeader *m) 877 const struct GNUNET_MessageHeader *m)
876{ 878{
877 struct Operation *incoming; 879 struct Operation *incoming;
878 const struct GNUNET_SET_AcceptRejectMessage *msg; 880 const struct GNUNET_SET_RejectMessage *msg;
879 881
880 msg = (const struct GNUNET_SET_AcceptRejectMessage *) m; 882 msg = (const struct GNUNET_SET_RejectMessage *) m;
881 GNUNET_break (0 == ntohl (msg->request_id)); 883 GNUNET_break (0 == ntohl (msg->request_id));
882 884
883 // no matching incoming operation for this reject 885 // no matching incoming operation for this reject
@@ -1143,10 +1145,10 @@ handle_client_accept (void *cls,
1143 const struct GNUNET_MessageHeader *mh) 1145 const struct GNUNET_MessageHeader *mh)
1144{ 1146{
1145 struct Set *set; 1147 struct Set *set;
1146 const struct GNUNET_SET_AcceptRejectMessage *msg; 1148 const struct GNUNET_SET_AcceptMessage *msg;
1147 struct Operation *op; 1149 struct Operation *op;
1148 1150
1149 msg = (const struct GNUNET_SET_AcceptRejectMessage *) mh; 1151 msg = (const struct GNUNET_SET_AcceptMessage *) mh;
1150 1152
1151 // client without a set requested an operation 1153 // client without a set requested an operation
1152 set = set_get (client); 1154 set = set_get (client);
@@ -1201,7 +1203,7 @@ handle_client_accept (void *cls,
1201 op); 1203 op);
1202 1204
1203 op->spec->client_request_id = ntohl (msg->request_id); 1205 op->spec->client_request_id = ntohl (msg->request_id);
1204 op->spec->result_mode = ntohs (msg->result_mode); 1206 op->spec->result_mode = ntohl (msg->result_mode);
1205 op->generation_created = set->current_generation++; 1207 op->generation_created = set->current_generation++;
1206 op->vt = op->spec->set->vt; 1208 op->vt = op->spec->set->vt;
1207 GNUNET_assert (NULL != op->vt->accept); 1209 GNUNET_assert (NULL != op->vt->accept);
@@ -1446,7 +1448,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1446{ 1448{
1447 static const struct GNUNET_SERVER_MessageHandler server_handlers[] = { 1449 static const struct GNUNET_SERVER_MessageHandler server_handlers[] = {
1448 {handle_client_accept, NULL, GNUNET_MESSAGE_TYPE_SET_ACCEPT, 1450 {handle_client_accept, NULL, GNUNET_MESSAGE_TYPE_SET_ACCEPT,
1449 sizeof (struct GNUNET_SET_AcceptRejectMessage)}, 1451 sizeof (struct GNUNET_SET_AcceptMessage)},
1450 {handle_client_iter_ack, NULL, GNUNET_MESSAGE_TYPE_SET_ITER_ACK, 0}, 1452 {handle_client_iter_ack, NULL, GNUNET_MESSAGE_TYPE_SET_ITER_ACK, 0},
1451 {handle_client_add_remove, NULL, GNUNET_MESSAGE_TYPE_SET_ADD, 0}, 1453 {handle_client_add_remove, NULL, GNUNET_MESSAGE_TYPE_SET_ADD, 0},
1452 {handle_client_create_set, NULL, GNUNET_MESSAGE_TYPE_SET_CREATE, 1454 {handle_client_create_set, NULL, GNUNET_MESSAGE_TYPE_SET_CREATE,
@@ -1457,7 +1459,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1457 {handle_client_listen, NULL, GNUNET_MESSAGE_TYPE_SET_LISTEN, 1459 {handle_client_listen, NULL, GNUNET_MESSAGE_TYPE_SET_LISTEN,
1458 sizeof (struct GNUNET_SET_ListenMessage)}, 1460 sizeof (struct GNUNET_SET_ListenMessage)},
1459 {handle_client_reject, NULL, GNUNET_MESSAGE_TYPE_SET_REJECT, 1461 {handle_client_reject, NULL, GNUNET_MESSAGE_TYPE_SET_REJECT,
1460 sizeof (struct GNUNET_SET_AcceptRejectMessage)}, 1462 sizeof (struct GNUNET_SET_RejectMessage)},
1461 {handle_client_add_remove, NULL, GNUNET_MESSAGE_TYPE_SET_REMOVE, 0}, 1463 {handle_client_add_remove, NULL, GNUNET_MESSAGE_TYPE_SET_REMOVE, 0},
1462 {handle_client_cancel, NULL, GNUNET_MESSAGE_TYPE_SET_CANCEL, 1464 {handle_client_cancel, NULL, GNUNET_MESSAGE_TYPE_SET_CANCEL,
1463 sizeof (struct GNUNET_SET_CancelMessage)}, 1465 sizeof (struct GNUNET_SET_CancelMessage)},
diff --git a/src/set/gnunet-service-set.h b/src/set/gnunet-service-set.h
index 248b778d9..c226611ff 100644
--- a/src/set/gnunet-service-set.h
+++ b/src/set/gnunet-service-set.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2013 Christian Grothoff (and other contributing authors) 3 (C) 2013, 2014 Christian Grothoff (and other contributing authors)
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
@@ -17,7 +17,6 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @file set/gnunet-service-set.h 21 * @file set/gnunet-service-set.h
23 * @brief common components for the implementation the different set operations 22 * @brief common components for the implementation the different set operations
diff --git a/src/set/gnunet-set-profiler.c b/src/set/gnunet-set-profiler.c
index f6fdc25cf..f1b7b4b14 100644
--- a/src/set/gnunet-set-profiler.c
+++ b/src/set/gnunet-set-profiler.c
@@ -35,8 +35,6 @@ static unsigned int num_a = 5;
35static unsigned int num_b = 5; 35static unsigned int num_b = 5;
36static unsigned int num_c = 20; 36static unsigned int num_c = 20;
37 37
38static unsigned int salt = 42;
39
40static char *op_str = "union"; 38static char *op_str = "union";
41 39
42const static struct GNUNET_CONFIGURATION_Handle *config; 40const static struct GNUNET_CONFIGURATION_Handle *config;
@@ -51,13 +49,13 @@ struct SetInfo
51 int done; 49 int done;
52} info1, info2; 50} info1, info2;
53 51
54struct GNUNET_CONTAINER_MultiHashMap *common_sent; 52static struct GNUNET_CONTAINER_MultiHashMap *common_sent;
55 53
56struct GNUNET_HashCode app_id; 54static struct GNUNET_HashCode app_id;
57 55
58struct GNUNET_PeerIdentity local_peer; 56static struct GNUNET_PeerIdentity local_peer;
59 57
60struct GNUNET_SET_ListenHandle *set_listener; 58static struct GNUNET_SET_ListenHandle *set_listener;
61 59
62 60
63static int 61static int
@@ -77,6 +75,7 @@ map_remove_iterator (void *cls,
77 75
78} 76}
79 77
78
80static void 79static void
81check_all_done (void) 80check_all_done (void)
82{ 81{
@@ -270,8 +269,9 @@ run (void *cls, char *const *args, const char *cfgfile,
270 set_listener = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION, 269 set_listener = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION,
271 &app_id, set_listen_cb, NULL); 270 &app_id, set_listen_cb, NULL);
272 271
273 info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL, salt, GNUNET_SET_RESULT_ADDED, 272 info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL,
274 set_result_cb, &info1); 273 GNUNET_SET_RESULT_ADDED,
274 set_result_cb, &info1);
275 GNUNET_SET_commit (info1.oh, info1.set); 275 GNUNET_SET_commit (info1.oh, info1.set);
276 GNUNET_SET_destroy (info1.set); 276 GNUNET_SET_destroy (info1.set);
277 info1.set = NULL; 277 info1.set = NULL;
diff --git a/src/set/set.h b/src/set/set.h
index 09d1120f0..be3a7a0c6 100644
--- a/src/set/set.h
+++ b/src/set/set.h
@@ -17,11 +17,11 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 * @author Florian Dold
23 * @file set/set.h 21 * @file set/set.h
24 * @brief messages used for the set api 22 * @brief messages used for the set api
23 * @author Florian Dold
24 * @author Christian Grothoff
25 */ 25 */
26#ifndef SET_H 26#ifndef SET_H
27#define SET_H 27#define SET_H
@@ -29,6 +29,9 @@
29#include "platform.h" 29#include "platform.h"
30#include "gnunet_common.h" 30#include "gnunet_common.h"
31 31
32/**
33 * FIXME
34 */
32#define GNUNET_SET_ACK_WINDOW 10 35#define GNUNET_SET_ACK_WINDOW 10
33 36
34 37
@@ -37,27 +40,26 @@ GNUNET_NETWORK_STRUCT_BEGIN
37struct GNUNET_SET_CreateMessage 40struct GNUNET_SET_CreateMessage
38{ 41{
39 /** 42 /**
40 * Type: GNUNET_MESSAGE_TYPE_SET_CREATE 43 * Type: #GNUNET_MESSAGE_TYPE_SET_CREATE
41 */ 44 */
42 struct GNUNET_MessageHeader header; 45 struct GNUNET_MessageHeader header;
43 46
44 /** 47 /**
45 * Operation type, values of enum GNUNET_SET_OperationType 48 * Operation type, values of `enum GNUNET_SET_OperationType`
46 */ 49 */
47 // FIXME: use 32_t for 'enum'. 50 uint32_t operation GNUNET_PACKED;
48 uint16_t operation GNUNET_PACKED;
49}; 51};
50 52
51 53
52struct GNUNET_SET_ListenMessage 54struct GNUNET_SET_ListenMessage
53{ 55{
54 /** 56 /**
55 * Type: GNUNET_MESSAGE_TYPE_SET_LISTEN 57 * Type: #GNUNET_MESSAGE_TYPE_SET_LISTEN
56 */ 58 */
57 struct GNUNET_MessageHeader header; 59 struct GNUNET_MessageHeader header;
58 60
59 /** 61 /**
60 * Operation type, values of enum GNUNET_SET_OperationType 62 * Operation type, values of `enum GNUNET_SET_OperationType`
61 */ 63 */
62 uint32_t operation GNUNET_PACKED; 64 uint32_t operation GNUNET_PACKED;
63 65
@@ -69,11 +71,10 @@ struct GNUNET_SET_ListenMessage
69}; 71};
70 72
71 73
72struct GNUNET_SET_AcceptRejectMessage 74struct GNUNET_SET_AcceptMessage
73{ 75{
74 /** 76 /**
75 * Type: GNUNET_MESSAGE_TYPE_SET_ACCEPT or 77 * Type: #GNUNET_MESSAGE_TYPE_SET_ACCEPT
76 * GNUNET_MESSAGE_TYPE_SET_REJECT
77 */ 78 */
78 struct GNUNET_MessageHeader header; 79 struct GNUNET_MessageHeader header;
79 80
@@ -90,9 +91,30 @@ struct GNUNET_SET_AcceptRejectMessage
90 91
91 /** 92 /**
92 * How should results be sent to us? 93 * How should results be sent to us?
93 * See enum GNUNET_SET_ResultMode. 94 * See `enum GNUNET_SET_ResultMode`.
95 */
96 uint32_t result_mode GNUNET_PACKED;
97};
98
99
100struct GNUNET_SET_RejectMessage
101{
102 /**
103 * Type: #GNUNET_MESSAGE_TYPE_SET_REJECT
104 */
105 struct GNUNET_MessageHeader header;
106
107 /**
108 * ID of the incoming request we want to accept / reject.
109 */
110 uint32_t accept_reject_id GNUNET_PACKED;
111
112 /**
113 * Request ID to identify responses,
114 * must be 0 if we don't accept the request.
94 */ 115 */
95 uint16_t result_mode GNUNET_PACKED; 116 uint32_t request_id GNUNET_PACKED;
117
96}; 118};
97 119
98 120
@@ -102,21 +124,21 @@ struct GNUNET_SET_AcceptRejectMessage
102struct GNUNET_SET_RequestMessage 124struct GNUNET_SET_RequestMessage
103{ 125{
104 /** 126 /**
105 * Type: GNUNET_MESSAGE_TYPE_SET_Request. 127 * Type: #GNUNET_MESSAGE_TYPE_SET_REQUEST.
106 */ 128 */
107 struct GNUNET_MessageHeader header; 129 struct GNUNET_MessageHeader header;
108 130
109 /** 131 /**
110 * Identity of the requesting peer.
111 */
112 struct GNUNET_PeerIdentity peer_id;
113
114 /**
115 * ID of the to identify the request when accepting or 132 * ID of the to identify the request when accepting or
116 * rejecting it. 133 * rejecting it.
117 */ 134 */
118 uint32_t accept_id GNUNET_PACKED; 135 uint32_t accept_id GNUNET_PACKED;
119 136
137 /**
138 * Identity of the requesting peer.
139 */
140 struct GNUNET_PeerIdentity peer_id;
141
120 /* rest: nested context message */ 142 /* rest: nested context message */
121}; 143};
122 144
@@ -124,7 +146,7 @@ struct GNUNET_SET_RequestMessage
124struct GNUNET_SET_EvaluateMessage 146struct GNUNET_SET_EvaluateMessage
125{ 147{
126 /** 148 /**
127 * Type: GNUNET_MESSAGE_TYPE_SET_EVALUATE 149 * Type: #GNUNET_MESSAGE_TYPE_SET_EVALUATE
128 */ 150 */
129 struct GNUNET_MessageHeader header; 151 struct GNUNET_MessageHeader header;
130 152
@@ -144,15 +166,15 @@ struct GNUNET_SET_EvaluateMessage
144 struct GNUNET_HashCode app_id; 166 struct GNUNET_HashCode app_id;
145 167
146 /** 168 /**
147 * Salt to use for the operation 169 * Salt to use for the operation.
148 */ 170 */
149 uint16_t salt GNUNET_PACKED; 171 uint32_t salt GNUNET_PACKED;
150 172
151 /** 173 /**
152 * How should results be sent to us? 174 * How should results be sent to us?
153 * See enum GNUNET_SET_ResultMode. 175 * See `enum GNUNET_SET_ResultMode`.
154 */ 176 */
155 uint16_t result_mode GNUNET_PACKED; 177 uint32_t result_mode GNUNET_PACKED;
156 178
157 /* rest: inner message */ 179 /* rest: inner message */
158}; 180};
@@ -161,7 +183,7 @@ struct GNUNET_SET_EvaluateMessage
161struct GNUNET_SET_ResultMessage 183struct GNUNET_SET_ResultMessage
162{ 184{
163 /** 185 /**
164 * Type: GNUNET_MESSAGE_TYPE_SET_RESULT 186 * Type: #GNUNET_MESSAGE_TYPE_SET_RESULT
165 */ 187 */
166 struct GNUNET_MessageHeader header; 188 struct GNUNET_MessageHeader header;
167 189
@@ -188,8 +210,8 @@ struct GNUNET_SET_ResultMessage
188struct GNUNET_SET_ElementMessage 210struct GNUNET_SET_ElementMessage
189{ 211{
190 /** 212 /**
191 * Type: GNUNET_MESSAGE_TYPE_SET_ADD or 213 * Type: #GNUNET_MESSAGE_TYPE_SET_ADD or
192 * GNUNET_MESSAGE_TYPE_SET_REMOVE 214 * #GNUNET_MESSAGE_TYPE_SET_REMOVE
193 */ 215 */
194 struct GNUNET_MessageHeader header; 216 struct GNUNET_MessageHeader header;
195 217
@@ -208,7 +230,7 @@ struct GNUNET_SET_ElementMessage
208struct GNUNET_SET_CancelMessage 230struct GNUNET_SET_CancelMessage
209{ 231{
210 /** 232 /**
211 * Type: GNUNET_MESSAGE_TYPE_SET_CANCEL 233 * Type: #GNUNET_MESSAGE_TYPE_SET_CANCEL
212 */ 234 */
213 struct GNUNET_MessageHeader header; 235 struct GNUNET_MessageHeader header;
214 236
@@ -218,10 +240,11 @@ struct GNUNET_SET_CancelMessage
218 uint32_t request_id GNUNET_PACKED; 240 uint32_t request_id GNUNET_PACKED;
219}; 241};
220 242
243
221struct GNUNET_SET_IterResponseMessage 244struct GNUNET_SET_IterResponseMessage
222{ 245{
223 /** 246 /**
224 * Type: GNUNET_MESSAGE_TYPE_SET_ITER_RESPONSE 247 * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_RESPONSE
225 */ 248 */
226 struct GNUNET_MessageHeader header; 249 struct GNUNET_MessageHeader header;
227 250
@@ -237,7 +260,7 @@ struct GNUNET_SET_IterResponseMessage
237struct GNUNET_SET_IterAckMessage 260struct GNUNET_SET_IterAckMessage
238{ 261{
239 /** 262 /**
240 * Type: GNUNET_MESSAGE_TYPE_SET_ITER_ACK 263 * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_ACK
241 */ 264 */
242 struct GNUNET_MessageHeader header; 265 struct GNUNET_MessageHeader header;
243 266
diff --git a/src/set/set_api.c b/src/set/set_api.c
index 0c9df22e4..10421ebda 100644
--- a/src/set/set_api.c
+++ b/src/set/set_api.c
@@ -319,14 +319,16 @@ handle_result (void *cls, const struct GNUNET_MessageHeader *mh)
319 * @param mh the message 319 * @param mh the message
320 */ 320 */
321static void 321static void
322handle_request (void *cls, const struct GNUNET_MessageHeader *mh) 322handle_request (void *cls,
323 const struct GNUNET_MessageHeader *mh)
323{ 324{
324 const struct GNUNET_SET_RequestMessage *msg = (const struct GNUNET_SET_RequestMessage *) mh; 325 const struct GNUNET_SET_RequestMessage *msg = (const struct GNUNET_SET_RequestMessage *) mh;
325 struct GNUNET_SET_ListenHandle *lh = cls; 326 struct GNUNET_SET_ListenHandle *lh = cls;
326 struct GNUNET_SET_Request *req; 327 struct GNUNET_SET_Request *req;
327 struct GNUNET_MessageHeader *context_msg; 328 struct GNUNET_MessageHeader *context_msg;
328 329
329 LOG (GNUNET_ERROR_TYPE_DEBUG, "processing operation request\n"); 330 LOG (GNUNET_ERROR_TYPE_DEBUG,
331 "processing operation request\n");
330 req = GNUNET_new (struct GNUNET_SET_Request); 332 req = GNUNET_new (struct GNUNET_SET_Request);
331 req->accept_id = ntohl (msg->accept_id); 333 req->accept_id = ntohl (msg->accept_id);
332 context_msg = GNUNET_MQ_extract_nested_mh (msg); 334 context_msg = GNUNET_MQ_extract_nested_mh (msg);
@@ -339,18 +341,21 @@ handle_request (void *cls, const struct GNUNET_MessageHeader *mh)
339 if (GNUNET_NO == req->accepted) 341 if (GNUNET_NO == req->accepted)
340 { 342 {
341 struct GNUNET_MQ_Envelope *mqm; 343 struct GNUNET_MQ_Envelope *mqm;
342 struct GNUNET_SET_AcceptRejectMessage *amsg; 344 struct GNUNET_SET_RejectMessage *rmsg;
343 345
344 mqm = GNUNET_MQ_msg (amsg, GNUNET_MESSAGE_TYPE_SET_REJECT); 346 mqm = GNUNET_MQ_msg (rmsg,
347 GNUNET_MESSAGE_TYPE_SET_REJECT);
345 /* no request id, as we refused */ 348 /* no request id, as we refused */
346 amsg->request_id = htonl (0); 349 rmsg->request_id = htonl (0);
347 amsg->accept_reject_id = msg->accept_id; 350 rmsg->accept_reject_id = msg->accept_id;
348 GNUNET_MQ_send (lh->mq, mqm); 351 GNUNET_MQ_send (lh->mq, mqm);
349 LOG (GNUNET_ERROR_TYPE_DEBUG, "rejecting request\n"); 352 LOG (GNUNET_ERROR_TYPE_DEBUG,
353 "rejecting request\n");
350 } 354 }
351 GNUNET_free (req); 355 GNUNET_free (req);
352 356
353 LOG (GNUNET_ERROR_TYPE_DEBUG, "processed op request from service\n"); 357 LOG (GNUNET_ERROR_TYPE_DEBUG,
358 "processed op request from service\n");
354 359
355 /* the accept-case is handled in GNUNET_SET_accept, 360 /* the accept-case is handled in GNUNET_SET_accept,
356 * as we have the accept message available there */ 361 * as we have the accept message available there */
@@ -362,13 +367,14 @@ handle_client_listener_error (void *cls, enum GNUNET_MQ_Error error)
362{ 367{
363 struct GNUNET_SET_ListenHandle *lh = cls; 368 struct GNUNET_SET_ListenHandle *lh = cls;
364 369
365 LOG (GNUNET_ERROR_TYPE_DEBUG, "listener broke down, re-connecting\n"); 370 LOG (GNUNET_ERROR_TYPE_DEBUG,
371 "listener broke down, re-connecting\n");
366 GNUNET_CLIENT_disconnect (lh->client); 372 GNUNET_CLIENT_disconnect (lh->client);
367 lh->client = NULL; 373 lh->client = NULL;
368 GNUNET_MQ_destroy (lh->mq); 374 GNUNET_MQ_destroy (lh->mq);
369 lh->mq = NULL; 375 lh->mq = NULL;
370 376 lh->reconnect_task = GNUNET_SCHEDULER_add_delayed (lh->reconnect_backoff,
371 lh->reconnect_task = GNUNET_SCHEDULER_add_delayed (lh->reconnect_backoff, listen_connect, lh); 377 &listen_connect, lh);
372 lh->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (lh->reconnect_backoff); 378 lh->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (lh->reconnect_backoff);
373} 379}
374 380
@@ -492,15 +498,15 @@ struct GNUNET_SET_Handle *
492GNUNET_SET_create (const struct GNUNET_CONFIGURATION_Handle *cfg, 498GNUNET_SET_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
493 enum GNUNET_SET_OperationType op) 499 enum GNUNET_SET_OperationType op)
494{ 500{
495 struct GNUNET_SET_Handle *set;
496 struct GNUNET_MQ_Envelope *mqm;
497 struct GNUNET_SET_CreateMessage *msg;
498 static const struct GNUNET_MQ_MessageHandler mq_handlers[] = { 501 static const struct GNUNET_MQ_MessageHandler mq_handlers[] = {
499 {handle_result, GNUNET_MESSAGE_TYPE_SET_RESULT, 0}, 502 {handle_result, GNUNET_MESSAGE_TYPE_SET_RESULT, 0},
500 {handle_iter_element, GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT, 0}, 503 {handle_iter_element, GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT, 0},
501 {handle_iter_done, GNUNET_MESSAGE_TYPE_SET_ITER_DONE, 0}, 504 {handle_iter_done, GNUNET_MESSAGE_TYPE_SET_ITER_DONE, 0},
502 GNUNET_MQ_HANDLERS_END 505 GNUNET_MQ_HANDLERS_END
503 }; 506 };
507 struct GNUNET_SET_Handle *set;
508 struct GNUNET_MQ_Envelope *mqm;
509 struct GNUNET_SET_CreateMessage *msg;
504 510
505 set = GNUNET_new (struct GNUNET_SET_Handle); 511 set = GNUNET_new (struct GNUNET_SET_Handle);
506 set->client = GNUNET_CLIENT_connect ("set", cfg); 512 set->client = GNUNET_CLIENT_connect ("set", cfg);
@@ -510,7 +516,7 @@ GNUNET_SET_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
510 handle_client_set_error, set); 516 handle_client_set_error, set);
511 GNUNET_assert (NULL != set->mq); 517 GNUNET_assert (NULL != set->mq);
512 mqm = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_CREATE); 518 mqm = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_CREATE);
513 msg->operation = htons (op); 519 msg->operation = htonl (op);
514 GNUNET_MQ_send (set->mq, mqm); 520 GNUNET_MQ_send (set->mq, mqm);
515 return set; 521 return set;
516} 522}
@@ -607,25 +613,21 @@ GNUNET_SET_destroy (struct GNUNET_SET_Handle *set)
607/** 613/**
608 * Prepare a set operation to be evaluated with another peer. 614 * Prepare a set operation to be evaluated with another peer.
609 * The evaluation will not start until the client provides 615 * The evaluation will not start until the client provides
610 * a local set with GNUNET_SET_commit. 616 * a local set with #GNUNET_SET_commit().
611 * 617 *
612 * @param other_peer peer with the other set 618 * @param other_peer peer with the other set
613 * @param app_id hash for the application using the set 619 * @param app_id hash for the application using the set
614 * @param context_msg additional information for the request 620 * @param context_msg additional information for the request
615 * @param salt salt used for the set operation; sometimes set operations
616 * fail due to hash collisions, using a different salt for each operation
617 * makes it harder for an attacker to exploit this
618 * @param result_mode specified how results will be returned, 621 * @param result_mode specified how results will be returned,
619 * see 'GNUNET_SET_ResultMode'. 622 * see `enum GNUNET_SET_ResultMode`.
620 * @param result_cb called on error or success 623 * @param result_cb called on error or success
621 * @param result_cls closure for result_cb 624 * @param result_cls closure for @e result_cb
622 * @return a handle to cancel the operation 625 * @return a handle to cancel the operation
623 */ 626 */
624struct GNUNET_SET_OperationHandle * 627struct GNUNET_SET_OperationHandle *
625GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, 628GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer,
626 const struct GNUNET_HashCode *app_id, 629 const struct GNUNET_HashCode *app_id,
627 const struct GNUNET_MessageHeader *context_msg, 630 const struct GNUNET_MessageHeader *context_msg,
628 uint16_t salt,
629 enum GNUNET_SET_ResultMode result_mode, 631 enum GNUNET_SET_ResultMode result_mode,
630 GNUNET_SET_ResultIterator result_cb, 632 GNUNET_SET_ResultIterator result_cb,
631 void *result_cls) 633 void *result_cls)
@@ -638,12 +640,12 @@ GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer,
638 oh->result_cb = result_cb; 640 oh->result_cb = result_cb;
639 oh->result_cls = result_cls; 641 oh->result_cls = result_cls;
640 642
641 mqm = GNUNET_MQ_msg_nested_mh (msg, GNUNET_MESSAGE_TYPE_SET_EVALUATE, context_msg); 643 mqm = GNUNET_MQ_msg_nested_mh (msg,
642 644 GNUNET_MESSAGE_TYPE_SET_EVALUATE,
645 context_msg);
643 msg->app_id = *app_id; 646 msg->app_id = *app_id;
644 msg->result_mode = htons (result_mode); 647 msg->result_mode = htonl (result_mode);
645 msg->target_peer = *other_peer; 648 msg->target_peer = *other_peer;
646 msg->salt = salt;
647 oh->conclude_mqm = mqm; 649 oh->conclude_mqm = mqm;
648 oh->request_id_addr = &msg->request_id; 650 oh->request_id_addr = &msg->request_id;
649 651
@@ -767,9 +769,9 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh)
767 * 769 *
768 * @param request request to accept 770 * @param request request to accept
769 * @param result_mode specified how results will be returned, 771 * @param result_mode specified how results will be returned,
770 * see 'GNUNET_SET_ResultMode'. 772 * see `enum GNUNET_SET_ResultMode`.
771 * @param result_cb callback for the results 773 * @param result_cb callback for the results
772 * @param result_cls closure for result_cb 774 * @param result_cls closure for @a result_cb
773 * @return a handle to cancel the operation 775 * @return a handle to cancel the operation
774 */ 776 */
775struct GNUNET_SET_OperationHandle * 777struct GNUNET_SET_OperationHandle *
@@ -780,7 +782,7 @@ GNUNET_SET_accept (struct GNUNET_SET_Request *request,
780{ 782{
781 struct GNUNET_MQ_Envelope *mqm; 783 struct GNUNET_MQ_Envelope *mqm;
782 struct GNUNET_SET_OperationHandle *oh; 784 struct GNUNET_SET_OperationHandle *oh;
783 struct GNUNET_SET_AcceptRejectMessage *msg; 785 struct GNUNET_SET_AcceptMessage *msg;
784 786
785 GNUNET_assert (NULL != request); 787 GNUNET_assert (NULL != request);
786 GNUNET_assert (GNUNET_NO == request->accepted); 788 GNUNET_assert (GNUNET_NO == request->accepted);
@@ -792,7 +794,7 @@ GNUNET_SET_accept (struct GNUNET_SET_Request *request,
792 794
793 mqm = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_ACCEPT); 795 mqm = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_ACCEPT);
794 msg->accept_reject_id = htonl (request->accept_id); 796 msg->accept_reject_id = htonl (request->accept_id);
795 msg->result_mode = htons (result_mode); 797 msg->result_mode = htonl (result_mode);
796 798
797 oh->conclude_mqm = mqm; 799 oh->conclude_mqm = mqm;
798 oh->request_id_addr = &msg->request_id; 800 oh->request_id_addr = &msg->request_id;
diff --git a/src/set/set_protocol.h b/src/set/set_protocol.h
index 9ed9c57d7..73332b4c3 100644
--- a/src/set/set_protocol.h
+++ b/src/set/set_protocol.h
@@ -35,24 +35,24 @@ GNUNET_NETWORK_STRUCT_BEGIN
35struct OperationRequestMessage 35struct OperationRequestMessage
36{ 36{
37 /** 37 /**
38 * Type: GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST 38 * Type: #GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST
39 */ 39 */
40 struct GNUNET_MessageHeader header; 40 struct GNUNET_MessageHeader header;
41 41
42 /** 42 /**
43 * Operation to request, values from 'enum GNUNET_SET_OperationType' 43 * Operation to request, values from `enum GNUNET_SET_OperationType`
44 */ 44 */
45 uint32_t operation GNUNET_PACKED; 45 uint32_t operation GNUNET_PACKED;
46 46
47 /** 47 /**
48 * Salt to use for this operation. 48 * Salt to use for this operation.
49 */ 49 */
50 uint32_t salt; 50 uint32_t salt GNUNET_PACKED;
51 51
52 /** 52 /**
53 * For Intersection: my element count 53 * For Intersection: my element count
54 */ 54 */
55 uint32_t element_count; 55 uint32_t element_count GNUNET_PACKED;
56 56
57 /** 57 /**
58 * Application-specific identifier of the request. 58 * Application-specific identifier of the request.
@@ -62,10 +62,11 @@ struct OperationRequestMessage
62 /* rest: optional message */ 62 /* rest: optional message */
63}; 63};
64 64
65
65struct IBFMessage 66struct IBFMessage
66{ 67{
67 /** 68 /**
68 * Type: GNUNET_MESSAGE_TYPE_SET_P2P_IBF 69 * Type: #GNUNET_MESSAGE_TYPE_SET_P2P_IBF
69 */ 70 */
70 struct GNUNET_MessageHeader header; 71 struct GNUNET_MessageHeader header;
71 72
@@ -88,15 +89,16 @@ struct IBFMessage
88 /** 89 /**
89 * Salt used when hashing elements for this IBF. 90 * Salt used when hashing elements for this IBF.
90 */ 91 */
91 uint32_t salt; 92 uint32_t salt GNUNET_PACKED;
92 93
93 /* rest: strata */ 94 /* rest: strata */
94}; 95};
95 96
97
96struct BFMessage 98struct BFMessage
97{ 99{
98 /** 100 /**
99 * Type: GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF 101 * Type: #GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF
100 */ 102 */
101 struct GNUNET_MessageHeader header; 103 struct GNUNET_MessageHeader header;
102 104
@@ -130,10 +132,11 @@ struct BFMessage
130 */ 132 */
131}; 133};
132 134
135
133struct BFPart 136struct BFPart
134{ 137{
135 /** 138 /**
136 * Type: GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF 139 * Type: #GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF
137 */ 140 */
138 struct GNUNET_MessageHeader header; 141 struct GNUNET_MessageHeader header;
139 142
diff --git a/src/set/test_set_api.c b/src/set/test_set_api.c
index 5bbbded5d..63188eb60 100644
--- a/src/set/test_set_api.c
+++ b/src/set/test_set_api.c
@@ -130,7 +130,7 @@ start (void *cls)
130 130
131 listen_handle = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION, 131 listen_handle = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION,
132 &app_id, listen_cb, NULL); 132 &app_id, listen_cb, NULL);
133 oh = GNUNET_SET_prepare (&local_id, &app_id, &context_msg, 42, 133 oh = GNUNET_SET_prepare (&local_id, &app_id, &context_msg,
134 GNUNET_SET_RESULT_ADDED, 134 GNUNET_SET_RESULT_ADDED,
135 result_cb_set1, NULL); 135 result_cb_set1, NULL);
136 GNUNET_SET_commit (oh, set1); 136 GNUNET_SET_commit (oh, set1);
@@ -275,7 +275,7 @@ run (void *cls,
275 275
276 276
277 ///* test if canceling an uncommited request works! */ 277 ///* test if canceling an uncommited request works! */
278 my_oh = GNUNET_SET_prepare (&local_id, &app_id, NULL, 0, 278 my_oh = GNUNET_SET_prepare (&local_id, &app_id, NULL,
279 GNUNET_SET_RESULT_ADDED, NULL, NULL); 279 GNUNET_SET_RESULT_ADDED, NULL, NULL);
280 280
281 GNUNET_SET_operation_cancel (my_oh); 281 GNUNET_SET_operation_cancel (my_oh);
diff --git a/src/set/test_set_intersection_result_full.c b/src/set/test_set_intersection_result_full.c
index c59624459..3b4591bed 100644
--- a/src/set/test_set_intersection_result_full.c
+++ b/src/set/test_set_intersection_result_full.c
@@ -133,7 +133,7 @@ start (void *cls)
133 &listen_cb, NULL); 133 &listen_cb, NULL);
134 oh = GNUNET_SET_prepare (&local_id, 134 oh = GNUNET_SET_prepare (&local_id,
135 &app_id, 135 &app_id,
136 &context_msg, 42, 136 &context_msg,
137 GNUNET_SET_RESULT_FULL, 137 GNUNET_SET_RESULT_FULL,
138 &result_cb_set1, NULL); 138 &result_cb_set1, NULL);
139 GNUNET_SET_commit (oh, set1); 139 GNUNET_SET_commit (oh, set1);
diff --git a/src/set/test_set_union_result_full.c b/src/set/test_set_union_result_full.c
index b84a21f23..1ed7c7bee 100644
--- a/src/set/test_set_union_result_full.c
+++ b/src/set/test_set_union_result_full.c
@@ -131,7 +131,7 @@ start (void *cls)
131 131
132 listen_handle = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION, 132 listen_handle = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION,
133 &app_id, listen_cb, NULL); 133 &app_id, listen_cb, NULL);
134 oh = GNUNET_SET_prepare (&local_id, &app_id, &context_msg, 42, 134 oh = GNUNET_SET_prepare (&local_id, &app_id, &context_msg,
135 GNUNET_SET_RESULT_FULL, 135 GNUNET_SET_RESULT_FULL,
136 result_cb_set1, NULL); 136 result_cb_set1, NULL);
137 GNUNET_SET_commit (oh, set1); 137 GNUNET_SET_commit (oh, set1);