aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-02-23 15:15:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-02-23 17:47:38 +0100
commitd5af1252b2a83d75fe4a8f6e48e1d01ab027b553 (patch)
tree3138f19a619c8b1730aafd6b31f041e64a4f2622
parent0581ec4f88a81894a17ef4619a8ac2a0c3c7d061 (diff)
downloadgnunet-d5af1252b2a83d75fe4a8f6e48e1d01ab027b553.tar.gz
gnunet-d5af1252b2a83d75fe4a8f6e48e1d01ab027b553.zip
add set operation options
-rw-r--r--src/consensus/gnunet-service-consensus.c2
-rw-r--r--src/dv/gnunet-service-dv.c2
-rw-r--r--src/include/gnunet_protocols.h7
-rw-r--r--src/include/gnunet_set_service.h51
-rw-r--r--src/revocation/gnunet-service-revocation.c2
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c1
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c1
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct_alice.c1
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct_bob.c1
-rw-r--r--src/set/gnunet-set-profiler.c4
-rw-r--r--src/set/set_api.c2
-rw-r--r--src/set/test_set_api.c3
-rw-r--r--src/set/test_set_intersection_result_full.c2
-rw-r--r--src/set/test_set_union_result_symmetric.c2
14 files changed, 80 insertions, 1 deletions
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c
index 16ca6a57f..4036d2b11 100644
--- a/src/consensus/gnunet-service-consensus.c
+++ b/src/consensus/gnunet-service-consensus.c
@@ -2013,6 +2013,7 @@ task_start_reconcile (struct TaskEntry *task)
2013 &session->global_id, 2013 &session->global_id,
2014 &rcm.header, 2014 &rcm.header,
2015 GNUNET_SET_RESULT_SYMMETRIC, 2015 GNUNET_SET_RESULT_SYMMETRIC,
2016 (struct GNUNET_SET_Option[]) { 0 },
2016 set_result_cb, 2017 set_result_cb,
2017 task); 2018 task);
2018 2019
@@ -2439,6 +2440,7 @@ set_listen_cb (void *cls,
2439 2440
2440 task->cls.setop.op = GNUNET_SET_accept (request, 2441 task->cls.setop.op = GNUNET_SET_accept (request,
2441 GNUNET_SET_RESULT_SYMMETRIC, 2442 GNUNET_SET_RESULT_SYMMETRIC,
2443 (struct GNUNET_SET_Option[]) { 0 },
2442 set_result_cb, 2444 set_result_cb,
2443 task); 2445 task);
2444 2446
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c
index 6adaa04d9..e4b664f4b 100644
--- a/src/dv/gnunet-service-dv.c
+++ b/src/dv/gnunet-service-dv.c
@@ -1528,6 +1528,7 @@ listen_set_union (void *cls,
1528 GNUNET_SET_OPERATION_UNION); 1528 GNUNET_SET_OPERATION_UNION);
1529 neighbor->set_op = GNUNET_SET_accept (request, 1529 neighbor->set_op = GNUNET_SET_accept (request,
1530 GNUNET_SET_RESULT_ADDED, 1530 GNUNET_SET_RESULT_ADDED,
1531 (struct GNUNET_SET_Option[]) { 0 },
1531 &handle_set_union_result, 1532 &handle_set_union_result,
1532 neighbor); 1533 neighbor);
1533 neighbor->consensus_insertion_offset = 0; 1534 neighbor->consensus_insertion_offset = 0;
@@ -1558,6 +1559,7 @@ initiate_set_union (void *cls)
1558 &neighbor->real_session_id, 1559 &neighbor->real_session_id,
1559 NULL, 1560 NULL,
1560 GNUNET_SET_RESULT_ADDED, 1561 GNUNET_SET_RESULT_ADDED,
1562 (struct GNUNET_SET_Option[]) { 0 },
1561 &handle_set_union_result, 1563 &handle_set_union_result,
1562 neighbor); 1564 neighbor);
1563 neighbor->consensus_insertion_offset = 0; 1565 neighbor->consensus_insertion_offset = 0;
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index eeb9a8a92..a10c0ca5d 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -1795,6 +1795,13 @@ extern "C"
1795 */ 1795 */
1796#define GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT 596 1796#define GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT 596
1797 1797
1798/**
1799 * Request all missing elements from the other peer,
1800 * based on their sets and the elements we previously sent
1801 * with #GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS.
1802 */
1803#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_GET_MISSING 597
1804
1798 1805
1799/******************************************************************************* 1806/*******************************************************************************
1800 * TESTBED LOGGER message types 1807 * TESTBED LOGGER message types
diff --git a/src/include/gnunet_set_service.h b/src/include/gnunet_set_service.h
index 52613ad59..f9b477f47 100644
--- a/src/include/gnunet_set_service.h
+++ b/src/include/gnunet_set_service.h
@@ -153,6 +153,7 @@ enum GNUNET_SET_Status
153}; 153};
154 154
155 155
156
156/** 157/**
157 * The way results are given to the client. 158 * The way results are given to the client.
158 */ 159 */
@@ -212,6 +213,54 @@ struct GNUNET_SET_Element
212 213
213 214
214/** 215/**
216 * Possible options to pass to a set operation.
217 *
218 * Used as tag for struct #GNUNET_SET_Option.
219 */
220enum GNUNET_SET_OptionType
221{
222 /**
223 * Fail set operations when the other peer shows weird behavior
224 * that might by a Byzantine fault.
225 *
226 * For set union, 'v.num' is a lower bound on elements
227 * that the other peer must have in common with us.
228 */
229 GNUNET_SET_OPTION_BYZANTINE=1,
230 /**
231 * Do not use the optimized set operation, but send full sets.
232 * Might trigger Byzantine fault detection.
233 */
234 GNUNET_SET_OPTION_FORCE_FULL=2,
235 /**
236 * Only use optimized set operations, even though for this
237 * particular set operation they might be much slower.
238 * Might trigger Byzantine fault detection.
239 */
240 GNUNET_SET_OPTION_FORCE_DELTA=4,
241};
242
243
244/**
245 * Option for set operations.
246 */
247struct GNUNET_SET_Option
248{
249 /**
250 * Type of the option.
251 */
252 enum GNUNET_SET_OptionType type;
253
254 /**
255 * Value for the option, only used with some options.
256 */
257 union {
258 uint64_t num;
259 } v;
260};
261
262
263/**
215 * Continuation used for some of the set operations 264 * Continuation used for some of the set operations
216 * 265 *
217 * @param cls closure 266 * @param cls closure
@@ -367,6 +416,7 @@ GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer,
367 const struct GNUNET_HashCode *app_id, 416 const struct GNUNET_HashCode *app_id,
368 const struct GNUNET_MessageHeader *context_msg, 417 const struct GNUNET_MessageHeader *context_msg,
369 enum GNUNET_SET_ResultMode result_mode, 418 enum GNUNET_SET_ResultMode result_mode,
419 struct GNUNET_SET_Option options[],
370 GNUNET_SET_ResultIterator result_cb, 420 GNUNET_SET_ResultIterator result_cb,
371 void *result_cls); 421 void *result_cls);
372 422
@@ -420,6 +470,7 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh);
420struct GNUNET_SET_OperationHandle * 470struct GNUNET_SET_OperationHandle *
421GNUNET_SET_accept (struct GNUNET_SET_Request *request, 471GNUNET_SET_accept (struct GNUNET_SET_Request *request,
422 enum GNUNET_SET_ResultMode result_mode, 472 enum GNUNET_SET_ResultMode result_mode,
473 struct GNUNET_SET_Option options[],
423 GNUNET_SET_ResultIterator result_cb, 474 GNUNET_SET_ResultIterator result_cb,
424 void *result_cls); 475 void *result_cls);
425 476
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c
index 2965808fa..b5669d9ea 100644
--- a/src/revocation/gnunet-service-revocation.c
+++ b/src/revocation/gnunet-service-revocation.c
@@ -509,6 +509,7 @@ transmit_task_cb (void *cls)
509 &revocation_set_union_app_id, 509 &revocation_set_union_app_id,
510 NULL, 510 NULL,
511 GNUNET_SET_RESULT_ADDED, 511 GNUNET_SET_RESULT_ADDED,
512 (struct GNUNET_SET_Option[]) { 0 },
512 &add_revocation, 513 &add_revocation,
513 peer_entry); 514 peer_entry);
514 if (GNUNET_OK != 515 if (GNUNET_OK !=
@@ -755,6 +756,7 @@ handle_revocation_union_request (void *cls,
755 } 756 }
756 peer_entry->so = GNUNET_SET_accept (request, 757 peer_entry->so = GNUNET_SET_accept (request,
757 GNUNET_SET_RESULT_ADDED, 758 GNUNET_SET_RESULT_ADDED,
759 (struct GNUNET_SET_Option[]) { 0 },
758 &add_revocation, 760 &add_revocation,
759 peer_entry); 761 peer_entry);
760 if (GNUNET_OK != 762 if (GNUNET_OK !=
diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c
index 9f8d98657..34149435c 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c
@@ -788,6 +788,7 @@ cb_intersection_request_alice (void *cls,
788 s->intersection_op 788 s->intersection_op
789 = GNUNET_SET_accept (request, 789 = GNUNET_SET_accept (request,
790 GNUNET_SET_RESULT_REMOVED, 790 GNUNET_SET_RESULT_REMOVED,
791 (struct GNUNET_SET_Option[]) { 0 },
791 &cb_intersection_element_removed, 792 &cb_intersection_element_removed,
792 s); 793 s);
793 if (NULL == s->intersection_op) 794 if (NULL == s->intersection_op)
diff --git a/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c b/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
index 7fd69a4ea..db8241bb7 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
@@ -670,6 +670,7 @@ start_intersection (struct BobServiceSession *s)
670 &set_sid, 670 &set_sid,
671 NULL, 671 NULL,
672 GNUNET_SET_RESULT_REMOVED, 672 GNUNET_SET_RESULT_REMOVED,
673 (struct GNUNET_SET_Option[]) { 0 },
673 &cb_intersection_element_removed, 674 &cb_intersection_element_removed,
674 s); 675 s);
675 if (GNUNET_OK != 676 if (GNUNET_OK !=
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c
index 779d84b60..f99ff6168 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct_alice.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct_alice.c
@@ -1022,6 +1022,7 @@ cb_intersection_request_alice (void *cls,
1022 s->intersection_op 1022 s->intersection_op
1023 = GNUNET_SET_accept (request, 1023 = GNUNET_SET_accept (request,
1024 GNUNET_SET_RESULT_REMOVED, 1024 GNUNET_SET_RESULT_REMOVED,
1025 (struct GNUNET_SET_Option[]) { 0 },
1025 &cb_intersection_element_removed, 1026 &cb_intersection_element_removed,
1026 s); 1027 s);
1027 if (NULL == s->intersection_op) 1028 if (NULL == s->intersection_op)
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_bob.c b/src/scalarproduct/gnunet-service-scalarproduct_bob.c
index a2bceba43..4da2ba50e 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct_bob.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct_bob.c
@@ -964,6 +964,7 @@ start_intersection (struct BobServiceSession *s)
964 &s->session_id, 964 &s->session_id,
965 NULL, 965 NULL,
966 GNUNET_SET_RESULT_REMOVED, 966 GNUNET_SET_RESULT_REMOVED,
967 (struct GNUNET_SET_Option[]) { 0 },
967 &cb_intersection_element_removed, 968 &cb_intersection_element_removed,
968 s); 969 s);
969 if (GNUNET_OK != 970 if (GNUNET_OK !=
diff --git a/src/set/gnunet-set-profiler.c b/src/set/gnunet-set-profiler.c
index f89817ff5..22a9d85cf 100644
--- a/src/set/gnunet-set-profiler.c
+++ b/src/set/gnunet-set-profiler.c
@@ -225,7 +225,8 @@ set_listen_cb (void *cls,
225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
226 "set listen cb called\n"); 226 "set listen cb called\n");
227 info2.oh = GNUNET_SET_accept (request, GNUNET_SET_RESULT_SYMMETRIC, 227 info2.oh = GNUNET_SET_accept (request, GNUNET_SET_RESULT_SYMMETRIC,
228 set_result_cb, &info2); 228 (struct GNUNET_SET_Option[]) { 0 },
229 set_result_cb, &info2);
229 GNUNET_SET_commit (info2.oh, info2.set); 230 GNUNET_SET_commit (info2.oh, info2.set);
230} 231}
231 232
@@ -352,6 +353,7 @@ run (void *cls,
352 353
353 info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL, 354 info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL,
354 GNUNET_SET_RESULT_SYMMETRIC, 355 GNUNET_SET_RESULT_SYMMETRIC,
356 (struct GNUNET_SET_Option[]) { 0 },
355 set_result_cb, &info1); 357 set_result_cb, &info1);
356 GNUNET_SET_commit (info1.oh, info1.set); 358 GNUNET_SET_commit (info1.oh, info1.set);
357 GNUNET_SET_destroy (info1.set); 359 GNUNET_SET_destroy (info1.set);
diff --git a/src/set/set_api.c b/src/set/set_api.c
index baeee6da0..c2e2cd1e9 100644
--- a/src/set/set_api.c
+++ b/src/set/set_api.c
@@ -766,6 +766,7 @@ GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer,
766 const struct GNUNET_HashCode *app_id, 766 const struct GNUNET_HashCode *app_id,
767 const struct GNUNET_MessageHeader *context_msg, 767 const struct GNUNET_MessageHeader *context_msg,
768 enum GNUNET_SET_ResultMode result_mode, 768 enum GNUNET_SET_ResultMode result_mode,
769 struct GNUNET_SET_Option options[],
769 GNUNET_SET_ResultIterator result_cb, 770 GNUNET_SET_ResultIterator result_cb,
770 void *result_cls) 771 void *result_cls)
771{ 772{
@@ -1006,6 +1007,7 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh)
1006struct GNUNET_SET_OperationHandle * 1007struct GNUNET_SET_OperationHandle *
1007GNUNET_SET_accept (struct GNUNET_SET_Request *request, 1008GNUNET_SET_accept (struct GNUNET_SET_Request *request,
1008 enum GNUNET_SET_ResultMode result_mode, 1009 enum GNUNET_SET_ResultMode result_mode,
1010 struct GNUNET_SET_Option options[],
1009 GNUNET_SET_ResultIterator result_cb, 1011 GNUNET_SET_ResultIterator result_cb,
1010 void *result_cls) 1012 void *result_cls)
1011{ 1013{
diff --git a/src/set/test_set_api.c b/src/set/test_set_api.c
index 21af45f8a..4bc6bd1c3 100644
--- a/src/set/test_set_api.c
+++ b/src/set/test_set_api.c
@@ -149,6 +149,7 @@ listen_cb (void *cls,
149 listen_handle = NULL; 149 listen_handle = NULL;
150 oh2 = GNUNET_SET_accept (request, 150 oh2 = GNUNET_SET_accept (request,
151 GNUNET_SET_RESULT_ADDED, 151 GNUNET_SET_RESULT_ADDED,
152 (struct GNUNET_SET_Option[]) { 0 },
152 &result_cb_set2, 153 &result_cb_set2,
153 NULL); 154 NULL);
154 GNUNET_SET_commit (oh2, 155 GNUNET_SET_commit (oh2,
@@ -179,6 +180,7 @@ start (void *cls)
179 &app_id, 180 &app_id,
180 &context_msg, 181 &context_msg,
181 GNUNET_SET_RESULT_ADDED, 182 GNUNET_SET_RESULT_ADDED,
183 (struct GNUNET_SET_Option[]) { 0 },
182 &result_cb_set1, 184 &result_cb_set1,
183 NULL); 185 NULL);
184 GNUNET_SET_commit (oh1, 186 GNUNET_SET_commit (oh1,
@@ -378,6 +380,7 @@ run (void *cls,
378 &app_id, 380 &app_id,
379 NULL, 381 NULL,
380 GNUNET_SET_RESULT_ADDED, 382 GNUNET_SET_RESULT_ADDED,
383 (struct GNUNET_SET_Option[]) { 0 },
381 NULL, 384 NULL,
382 NULL); 385 NULL);
383 386
diff --git a/src/set/test_set_intersection_result_full.c b/src/set/test_set_intersection_result_full.c
index b2d6ce8a9..cbe1ce149 100644
--- a/src/set/test_set_intersection_result_full.c
+++ b/src/set/test_set_intersection_result_full.c
@@ -133,6 +133,7 @@ listen_cb (void *cls,
133 listen_handle = NULL; 133 listen_handle = NULL;
134 oh2 = GNUNET_SET_accept (request, 134 oh2 = GNUNET_SET_accept (request,
135 GNUNET_SET_RESULT_FULL, 135 GNUNET_SET_RESULT_FULL,
136 (struct GNUNET_SET_Option[]) { 0 },
136 &result_cb_set2, 137 &result_cb_set2,
137 NULL); 138 NULL);
138 GNUNET_SET_commit (oh2, 139 GNUNET_SET_commit (oh2,
@@ -163,6 +164,7 @@ start (void *cls)
163 &app_id, 164 &app_id,
164 &context_msg, 165 &context_msg,
165 GNUNET_SET_RESULT_FULL, 166 GNUNET_SET_RESULT_FULL,
167 (struct GNUNET_SET_Option[]) { 0 },
166 &result_cb_set1, 168 &result_cb_set1,
167 NULL); 169 NULL);
168 GNUNET_SET_commit (oh1, 170 GNUNET_SET_commit (oh1,
diff --git a/src/set/test_set_union_result_symmetric.c b/src/set/test_set_union_result_symmetric.c
index ab191a34a..8dff40ec0 100644
--- a/src/set/test_set_union_result_symmetric.c
+++ b/src/set/test_set_union_result_symmetric.c
@@ -184,6 +184,7 @@ listen_cb (void *cls,
184 listen_handle = NULL; 184 listen_handle = NULL;
185 oh2 = GNUNET_SET_accept (request, 185 oh2 = GNUNET_SET_accept (request,
186 GNUNET_SET_RESULT_SYMMETRIC, 186 GNUNET_SET_RESULT_SYMMETRIC,
187 (struct GNUNET_SET_Option[]) { 0 },
187 &result_cb_set2, 188 &result_cb_set2,
188 NULL); 189 NULL);
189 GNUNET_SET_commit (oh2, 190 GNUNET_SET_commit (oh2,
@@ -212,6 +213,7 @@ start (void *cls)
212 &app_id, 213 &app_id,
213 &context_msg, 214 &context_msg,
214 GNUNET_SET_RESULT_SYMMETRIC, 215 GNUNET_SET_RESULT_SYMMETRIC,
216 (struct GNUNET_SET_Option[]) { 0 },
215 &result_cb_set1, NULL); 217 &result_cb_set1, NULL);
216 GNUNET_SET_commit (oh1, set1); 218 GNUNET_SET_commit (oh1, set1);
217} 219}