GNUnet 0.22.2
setu_api.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2012-2016, 2020 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
27#include "platform.h"
28#include "gnunet_util_lib.h"
29#include "gnunet_protocols.h"
30#include "gnunet_setu_service.h"
31#include "setu.h"
32
33
34#define LOG(kind, ...) GNUNET_log_from (kind, "set-api", __VA_ARGS__)
35
40{
45
50
55
62
67
68};
69
70
75{
80 uint32_t accept_id;
81
87};
88
89
95{
101
106
112
118
124
129
134
138 uint32_t request_id;
139};
140
141
146{
151
158
164
169
174
179
184
185};
186
187
195static int
196check_result (void *cls,
197 const struct GNUNET_SETU_ResultMessage *msg)
198{
199 /* minimum size was already checked, everything else is OK! */
200 return GNUNET_OK;
201}
202
203
210static void
211handle_result (void *cls,
212 const struct GNUNET_SETU_ResultMessage *msg)
213{
214 struct GNUNET_SETU_Handle *set = cls;
216 struct GNUNET_SETU_Element e;
217 enum GNUNET_SETU_Status result_status;
218 int destroy_set;
219
220 GNUNET_assert (NULL != set->mq);
221 result_status = ntohs (msg->result_status);
223 "Got result message with status %d\n",
224 result_status);
225 oh = GNUNET_MQ_assoc_get (set->mq,
226 ntohl (msg->request_id));
227 if (NULL == oh)
228 {
229 /* 'oh' can be NULL if we canceled the operation, but the service
230 did not get the cancel message yet. */
232 "Ignoring result from canceled operation\n");
233 return;
234 }
235
236 switch (result_status)
237 {
240 e.data = &msg[1];
241 e.size = ntohs (msg->header.size)
242 - sizeof(struct GNUNET_SETU_ResultMessage);
243 e.element_type = ntohs (msg->element_type);
244 if (NULL != oh->result_cb)
245 oh->result_cb (oh->result_cls,
246 &e,
247 GNUNET_ntohll (msg->current_size),
249 return;
253 "Treating result as final status\n");
255 ntohl (msg->request_id));
257 set->ops_tail,
258 oh);
259 /* Need to do this calculation _before_ the result callback,
260 as IF the application still has a valid set handle, it
261 may trigger destruction of the set during the callback. */
262 destroy_set = (GNUNET_YES == set->destroy_requested) &&
263 (NULL == set->ops_head);
264 if (NULL != oh->result_cb)
265 {
266 oh->result_cb (oh->result_cls,
267 NULL,
268 GNUNET_ntohll (msg->current_size),
270 }
271 else
272 {
274 "No callback for final status\n");
275 }
276 if (destroy_set)
278 GNUNET_free (oh);
279 return;
280 }
281}
282
283
289static void
291{
292 struct GNUNET_SETU_Handle *set = oh->set;
293 struct GNUNET_SETU_OperationHandle *h_assoc;
294
295 if (NULL != oh->conclude_mqm)
297 /* is the operation already committed? */
298 if (NULL != set)
299 {
301 set->ops_tail,
302 oh);
303 h_assoc = GNUNET_MQ_assoc_remove (set->mq,
304 oh->request_id);
305 GNUNET_assert ((NULL == h_assoc) ||
306 (h_assoc == oh));
307 }
308 GNUNET_free (oh);
309}
310
311
319void
321{
322 struct GNUNET_SETU_Handle *set = oh->set;
324 struct GNUNET_MQ_Envelope *mqm;
325
327 "Cancelling SET operation\n");
328 if (NULL != set)
329 {
331 m->request_id = htonl (oh->request_id);
332 GNUNET_MQ_send (set->mq, mqm);
333 }
335 if ((NULL != set) &&
336 (GNUNET_YES == set->destroy_requested) &&
337 (NULL == set->ops_head))
338 {
340 "Destroying set after operation cancel\n");
342 }
343}
344
345
353static void
355 enum GNUNET_MQ_Error error)
356{
357 struct GNUNET_SETU_Handle *set = cls;
358
360 "Handling client set error %d\n",
361 error);
362 while (NULL != set->ops_head)
363 {
364 if ((NULL != set->ops_head->result_cb) &&
367 NULL,
368 0,
371 }
372 set->invalid = GNUNET_YES;
373}
374
375
383struct GNUNET_SETU_Handle *
385{
386 struct GNUNET_SETU_Handle *set = GNUNET_new (struct GNUNET_SETU_Handle);
387 struct GNUNET_MQ_MessageHandler mq_handlers[] = {
391 set),
393 };
394 struct GNUNET_MQ_Envelope *mqm;
395 struct GNUNET_SETU_CreateMessage *create_msg;
396
398 "setu",
399 mq_handlers,
401 set);
402 if (NULL == set->mq)
403 {
404 GNUNET_free (set);
405 return NULL;
406 }
407 mqm = GNUNET_MQ_msg (create_msg,
409 GNUNET_MQ_send (set->mq,
410 mqm);
411 return set;
412}
413
414
428int
430 const struct GNUNET_SETU_Element *element,
432 void *cb_cls)
433{
434 struct GNUNET_MQ_Envelope *mqm;
436
438 "adding element of type %u to set %p\n",
439 (unsigned int) element->element_type,
440 set);
441 GNUNET_assert (NULL != set);
442 if (GNUNET_YES == set->invalid)
443 {
444 if (NULL != cb)
445 cb (cb_cls);
446 return GNUNET_SYSERR;
447 }
449 element->size,
451 msg->element_type = htons (element->element_type);
452 GNUNET_memcpy (&msg[1],
453 element->data,
454 element->size);
456 cb,
457 cb_cls);
458 GNUNET_MQ_send (set->mq,
459 mqm);
460 return GNUNET_OK;
461}
462
463
470void
472{
473 /* destroying set while iterator is active is currently
474 not supported; we should expand the API to allow
475 clients to explicitly cancel the iteration! */
476 GNUNET_assert (NULL != set);
477 if ((NULL != set->ops_head) ||
479 {
481 "Set operations are pending, delaying set destruction\n");
483 return;
484 }
486 "Really destroying set\n");
487 if (NULL != set->mq)
488 {
489 GNUNET_MQ_destroy (set->mq);
490 set->mq = NULL;
491 }
492 GNUNET_free (set);
493}
494
495
497GNUNET_SETU_prepare (const struct GNUNET_PeerIdentity *other_peer,
498 const struct GNUNET_HashCode *app_id,
499 const struct GNUNET_MessageHeader *context_msg,
500 const struct GNUNET_SETU_Option options[],
502 void *result_cls)
503{
504 struct GNUNET_MQ_Envelope *mqm;
507
509 "Client prepares set union operation\n");
511 oh->result_cb = result_cb;
512 oh->result_cls = result_cls;
515 context_msg);
516 msg->app_id = *app_id;
517 msg->target_peer = *other_peer;
518
519 /* Set default values */
520 msg->byzantine_upper_bond = UINT64_MAX;
521 msg->bandwidth_latency_tradeoff = 0;
522 msg->ibf_bucket_number_factor = 2;
523 msg->ibf_number_of_buckets_per_element = 3;
524
525
526 for (const struct GNUNET_SETU_Option *opt = options; opt->type != 0; opt++)
527 {
528 switch (opt->type)
529 {
531 msg->byzantine = GNUNET_YES;
532 msg->byzantine_lower_bound = htonl (opt->v.num);
533 break;
535 msg->byzantine_upper_bond = htonl (opt->v.num);
536 break;
538 msg->bandwidth_latency_tradeoff = htonl (opt->v.num);
539 break;
541 msg->ibf_bucket_number_factor = htonl (opt->v.num);
542 break;
544 msg->ibf_number_of_buckets_per_element = htonl (opt->v.num);
545 break;
547 msg->force_full = GNUNET_YES;
548 break;
550 msg->force_delta = GNUNET_YES;
551 break;
553 msg->symmetric = GNUNET_YES;
554 break;
555 default:
557 "Option with type %d not recognized\n",
558 (int) opt->type);
559 }
560 }
561 oh->conclude_mqm = mqm;
562 oh->request_id_addr = &msg->request_id;
563 return oh;
564}
565
566
572static void
573listen_connect (void *cls);
574
575
583static int
584check_request (void *cls,
585 const struct GNUNET_SETU_RequestMessage *msg)
586{
587 const struct GNUNET_MessageHeader *context_msg;
588
589 if (ntohs (msg->header.size) == sizeof(*msg))
590 return GNUNET_OK; /* no context message is OK */
591 context_msg = GNUNET_MQ_extract_nested_mh (msg);
592 if (NULL == context_msg)
593 {
594 /* malformed context message is NOT ok */
595 GNUNET_break_op (0);
596 return GNUNET_SYSERR;
597 }
598 return GNUNET_OK;
599}
600
601
608static void
609handle_request (void *cls,
610 const struct GNUNET_SETU_RequestMessage *msg)
611{
612 struct GNUNET_SETU_ListenHandle *lh = cls;
613 struct GNUNET_SETU_Request req;
614 const struct GNUNET_MessageHeader *context_msg;
615 struct GNUNET_MQ_Envelope *mqm;
616 struct GNUNET_SETU_RejectMessage *rmsg;
617
619 "Processing incoming operation request with id %u\n",
620 ntohl (msg->accept_id));
621 /* we got another valid request => reset the backoff */
623 req.accept_id = ntohl (msg->accept_id);
624 req.accepted = GNUNET_NO;
625 context_msg = GNUNET_MQ_extract_nested_mh (msg);
626 /* calling #GNUNET_SETU_accept() in the listen cb will set req->accepted */
627 lh->listen_cb (lh->listen_cls,
628 &msg->peer_id,
629 context_msg,
630 &req);
631 if (GNUNET_YES == req.accepted)
632 return; /* the accept-case is handled in #GNUNET_SETU_accept() */
634 "Rejected request %u\n",
635 ntohl (msg->accept_id));
636 mqm = GNUNET_MQ_msg (rmsg,
638 rmsg->accept_reject_id = msg->accept_id;
639 GNUNET_MQ_send (lh->mq,
640 mqm);
641}
642
643
651static void
653 enum GNUNET_MQ_Error error)
654{
655 struct GNUNET_SETU_ListenHandle *lh = cls;
656
658 "Listener broke down (%d), re-connecting\n",
659 (int) error);
660 GNUNET_MQ_destroy (lh->mq);
661 lh->mq = NULL;
664 lh);
666}
667
668
674static void
675listen_connect (void *cls)
676{
677 struct GNUNET_SETU_ListenHandle *lh = cls;
678 struct GNUNET_MQ_MessageHandler mq_handlers[] = {
682 lh),
684 };
685 struct GNUNET_MQ_Envelope *mqm;
687
688 lh->reconnect_task = NULL;
689 GNUNET_assert (NULL == lh->mq);
690 lh->mq = GNUNET_CLIENT_connect (lh->cfg,
691 "setu",
692 mq_handlers,
694 lh);
695 if (NULL == lh->mq)
696 return;
697 mqm = GNUNET_MQ_msg (msg,
699 msg->app_id = lh->app_id;
700 GNUNET_MQ_send (lh->mq,
701 mqm);
702}
703
704
718 const struct GNUNET_HashCode *app_id,
720 void *listen_cls)
721{
722 struct GNUNET_SETU_ListenHandle *lh;
723
725 "Starting listener for app %s\n",
728 lh->listen_cb = listen_cb;
730 lh->cfg = cfg;
731 lh->app_id = *app_id;
733 listen_connect (lh);
734 if (NULL == lh->mq)
735 {
736 GNUNET_free (lh);
737 return NULL;
738 }
739 return lh;
740}
741
742
748void
750{
752 "Canceling listener %s\n",
753 GNUNET_h2s (&lh->app_id));
754 if (NULL != lh->mq)
755 {
756 GNUNET_MQ_destroy (lh->mq);
757 lh->mq = NULL;
758 }
759 if (NULL != lh->reconnect_task)
760 {
762 lh->reconnect_task = NULL;
763 }
764 GNUNET_free (lh);
765}
766
767
770 const struct GNUNET_SETU_Option options[],
772 void *result_cls)
773{
774 struct GNUNET_MQ_Envelope *mqm;
777
778 GNUNET_assert (GNUNET_NO == request->accepted);
780 "Client accepts set union operation with id %u\n",
781 request->accept_id);
782 request->accepted = GNUNET_YES;
783 mqm = GNUNET_MQ_msg (msg,
785 msg->accept_reject_id = htonl (request->accept_id);
786
787 /* Set default values */
788 msg->byzantine_upper_bond = UINT64_MAX;
789 msg->bandwidth_latency_tradeoff = 0;
790 msg->ibf_bucket_number_factor = 2;
791 msg->ibf_number_of_buckets_per_element = 3;
792
793 for (const struct GNUNET_SETU_Option *opt = options; opt->type != 0; opt++)
794 {
795 switch (opt->type)
796 {
798 msg->byzantine = GNUNET_YES;
799 msg->byzantine_lower_bound = htonl (opt->v.num);
800 break;
802 msg->byzantine_upper_bond = htonl (opt->v.num);
803 break;
805 msg->bandwidth_latency_tradeoff = htonl (opt->v.num);
806 break;
808 msg->ibf_bucket_number_factor = htonl (opt->v.num);
809 break;
811 msg->ibf_number_of_buckets_per_element = htonl (opt->v.num);
812 break;
814 msg->force_full = GNUNET_YES;
815 break;
817 msg->force_delta = GNUNET_YES;
818 break;
820 msg->symmetric = GNUNET_YES;
821 break;
822 default:
824 "Option with type %d not recognized\n",
825 (int) opt->type);
826 }
827 }
829 oh->result_cb = result_cb;
830 oh->result_cls = result_cls;
831 oh->conclude_mqm = mqm;
832 oh->request_id_addr = &msg->request_id;
833 return oh;
834}
835
836
850int
852 struct GNUNET_SETU_Handle *set)
853{
854 if (NULL != oh->set)
855 {
856 /* Some other set was already committed for this
857 * operation, there is a logic bug in the client of this API */
858 GNUNET_break (0);
859 return GNUNET_OK;
860 }
861 GNUNET_assert (NULL != set);
862 if (GNUNET_YES == set->invalid)
863 return GNUNET_SYSERR;
865 "Client commits to SET\n");
866 GNUNET_assert (NULL != oh->conclude_mqm);
867 oh->set = set;
869 set->ops_tail,
870 oh);
872 oh);
873 *oh->request_id_addr = htonl (oh->request_id);
874 GNUNET_MQ_send (set->mq,
875 oh->conclude_mqm);
876 oh->conclude_mqm = NULL;
877 oh->request_id_addr = NULL;
878 return GNUNET_OK;
879}
880
881
889void
891 struct GNUNET_HashCode *ret_hash)
892{
894
895 /* It's not guaranteed that the element data is always after the element header,
896 so we need to hash the chunks separately. */
898 &element->size,
899 sizeof(uint16_t));
901 &element->element_type,
902 sizeof(uint16_t));
904 element->data,
905 element->size);
907 ret_hash);
908}
909
910
911/* end of setu_api.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:103
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
static void listen_cb(void *cls)
We have been notified that our listen socket has something to read.
static struct GNUNET_FS_Handle * ctx
static int result
Global testing status.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:40
Constants for network protocols.
Two-peer set union operations.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1060
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_log(kind,...)
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
Definition: crypto_hash.c:363
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
Definition: crypto_hash.c:387
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:347
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:285
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:61
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct.
void * GNUNET_MQ_assoc_get(struct GNUNET_MQ_Handle *mq, uint32_t request_id)
Get the data associated with a request_id in a queue.
Definition: mq.c:621
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
Definition: mq.c:655
uint32_t GNUNET_MQ_assoc_add(struct GNUNET_MQ_Handle *mq, void *assoc_data)
Associate the assoc_data in mq with a unique request id.
Definition: mq.c:592
void * GNUNET_MQ_assoc_remove(struct GNUNET_MQ_Handle *mq, uint32_t request_id)
Remove the association for a request_id.
Definition: mq.c:639
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:700
#define GNUNET_MQ_extract_nested_mh(var)
Return a pointer to the message at the end of the given message.
#define GNUNET_MESSAGE_TYPE_SETU_REQUEST
Notify the client of an incoming request from a remote peer.
#define GNUNET_MESSAGE_TYPE_SETU_REJECT
Reject a set request.
#define GNUNET_MESSAGE_TYPE_SETU_RESULT
Handle result message from operation.
#define GNUNET_MESSAGE_TYPE_SETU_CREATE
Create a new local set.
#define GNUNET_MESSAGE_TYPE_SETU_ADD
Add element to set.
#define GNUNET_MESSAGE_TYPE_SETU_ACCEPT
Accept an incoming set request.
#define GNUNET_MESSAGE_TYPE_SETU_CANCEL
Cancel a set operation.
#define GNUNET_MESSAGE_TYPE_SETU_LISTEN
Listen for operation requests.
#define GNUNET_MESSAGE_TYPE_SETU_EVALUATE
Evaluate a set operation.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1277
void GNUNET_SETU_element_hash(const struct GNUNET_SETU_Element *element, struct GNUNET_HashCode *ret_hash)
Hash a set element.
Definition: setu_api.c:890
struct GNUNET_SETU_Handle * GNUNET_SETU_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create an empty set, supporting the specified operation.
Definition: setu_api.c:384
void GNUNET_SETU_operation_cancel(struct GNUNET_SETU_OperationHandle *oh)
Cancel the given set operation.
Definition: setu_api.c:320
void(* GNUNET_SETU_ListenCallback)(void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETU_Request *request)
Called when another peer wants to do a set operation with the local peer.
struct GNUNET_SETU_OperationHandle * GNUNET_SETU_prepare(const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
Prepare a set operation to be evaluated with another peer.
Definition: setu_api.c:497
void GNUNET_SETU_destroy(struct GNUNET_SETU_Handle *set)
Destroy the set handle if no operations are left, mark the set for destruction otherwise.
Definition: setu_api.c:471
struct GNUNET_SETU_OperationHandle * GNUNET_SETU_accept(struct GNUNET_SETU_Request *request, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
Accept a request we got via GNUNET_SETU_listen().
Definition: setu_api.c:769
int GNUNET_SETU_commit(struct GNUNET_SETU_OperationHandle *oh, struct GNUNET_SETU_Handle *set)
Commit a set to be used with a set operation.
Definition: setu_api.c:851
struct GNUNET_SETU_ListenHandle * GNUNET_SETU_listen(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *app_id, GNUNET_SETU_ListenCallback listen_cb, void *listen_cls)
Wait for set operation requests for the given application id.
Definition: setu_api.c:717
void(* GNUNET_SETU_ResultIterator)(void *cls, const struct GNUNET_SETU_Element *element, uint64_t current_size, enum GNUNET_SETU_Status status)
Callback for set union operation results.
GNUNET_SETU_Status
Status for the result callback.
void GNUNET_SETU_listen_cancel(struct GNUNET_SETU_ListenHandle *lh)
Cancel the given listen operation.
Definition: setu_api.c:749
int GNUNET_SETU_add_element(struct GNUNET_SETU_Handle *set, const struct GNUNET_SETU_Element *element, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Add an element to the given set.
Definition: setu_api.c:429
@ GNUNET_SETU_OPTION_FORCE_DELTA
Only use optimized set operations, even though for this particular set operation they might be much s...
@ GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKETS_PER_ELEMENT
This setting determines to how many IBF buckets an single elements is mapped to.
@ GNUNET_SETU_OPTION_CUSTOM_BANDWIDTH_LATENCY_TRADEOFF
Bandwidth latency tradeoff determines how much bytes a single RTT is worth, which is a performance se...
@ GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKET_NUMBER_FACTOR
The factor determines the number of buckets an IBF has which is multiplied by the estimated setsize d...
@ GNUNET_SETU_OPTION_CUSTOM_BYZANTINE_UPPER_BOUND
Byzantine upper bound.
@ GNUNET_SETU_OPTION_SYMMETRIC
Notify client also if we are sending a value to the other peer.
@ GNUNET_SETU_OPTION_BYZANTINE
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault.
@ GNUNET_SETU_OPTION_FORCE_FULL
Do not use the optimized set operation, but send full sets.
@ GNUNET_SETU_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SETU_STATUS_ADD_REMOTE
Element should be added to the result set of the remote peer, i.e.
@ GNUNET_SETU_STATUS_FAILURE
The other peer refused to do the operation with us, or something went wrong.
@ GNUNET_SETU_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static void handle_client_listener_error(void *cls, enum GNUNET_MQ_Error error)
Our connection with the set service encountered an error, re-initialize with exponential back-off.
Definition: setu_api.c:652
static int check_result(void *cls, const struct GNUNET_SETU_ResultMessage *msg)
Check that the given msg is well-formed.
Definition: setu_api.c:196
static void handle_client_set_error(void *cls, enum GNUNET_MQ_Error error)
We encountered an error communicating with the set service while performing a set operation.
Definition: setu_api.c:354
static void listen_connect(void *cls)
Connect to the set service in order to listen for requests.
Definition: setu_api.c:675
static void set_operation_destroy(struct GNUNET_SETU_OperationHandle *oh)
Destroy the given set operation.
Definition: setu_api.c:290
static void handle_result(void *cls, const struct GNUNET_SETU_ResultMessage *msg)
Handle result message for a set operation.
Definition: setu_api.c:211
static void handle_request(void *cls, const struct GNUNET_SETU_RequestMessage *msg)
Handle request message for a listen operation.
Definition: setu_api.c:609
#define LOG(kind,...)
Definition: setu_api.c:34
static int check_request(void *cls, const struct GNUNET_SETU_RequestMessage *msg)
Check validity of request message for a listen operation.
Definition: setu_api.c:584
A 512-bit hashcode.
Handle to a message queue.
Definition: mq.c:87
Message handler for a specific message type.
Header for all communications.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition: scheduler.c:136
Message sent by a listening client to the service to accept performing the operation with the other p...
Definition: setu.h:79
Sent to the service by the client in order to cancel a set operation.
Definition: setu.h:350
Message sent by the client to the service to ask starting a new set to perform operations with.
Definition: setu.h:41
Message sent by client to the service to add an element to the set.
Definition: setu.h:326
Element stored in a set.
uint16_t element_type
Application-specific element type.
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
Message sent by client to service to initiate a set operation as a client (not as listener).
Definition: setu.h:203
struct GNUNET_HashCode app_id
Application id.
Definition: setu.h:223
Opaque handle to a set.
Definition: setu_api.c:40
struct GNUNET_SETU_OperationHandle * ops_tail
Linked list of operations on the set.
Definition: setu_api.c:54
int destroy_requested
Should the set be destroyed once all operations are gone? GNUNET_SYSERR if GNUNET_SETU_destroy() must...
Definition: setu_api.c:61
int invalid
Has the set become invalid (e.g.
Definition: setu_api.c:66
struct GNUNET_SETU_OperationHandle * ops_head
Linked list of operations on the set.
Definition: setu_api.c:49
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: setu_api.c:44
Opaque handle to a listen operation.
Definition: setu_api.c:146
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: setu_api.c:173
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Definition: setu_api.c:150
GNUNET_SETU_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
Definition: setu_api.c:163
void * listen_cls
Closure for listen_cb.
Definition: setu_api.c:168
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
Definition: setu_api.c:178
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
Definition: setu_api.c:183
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle for the listener, stored here to be able to reconnect transparently on connectio...
Definition: setu_api.c:157
Message sent by the client to the service to start listening for incoming requests to perform a certa...
Definition: setu.h:56
Handle to an operation.
Definition: setu_api.c:95
void * result_cls
Closure for result_cb.
Definition: setu_api.c:105
GNUNET_SETU_ResultIterator result_cb
Function to be called when we have a result, or an error.
Definition: setu_api.c:100
uint32_t * request_id_addr
Address of the request if in the conclude message, used to patch the request id into the message when...
Definition: setu_api.c:123
struct GNUNET_SETU_Handle * set
Local set used for the operation, NULL if no set has been provided by conclude yet.
Definition: setu_api.c:111
uint32_t request_id
Request ID to identify the operation within the set.
Definition: setu_api.c:138
struct GNUNET_MQ_Envelope * conclude_mqm
Message sent to the server on calling conclude, NULL if conclude has been called.
Definition: setu_api.c:117
struct GNUNET_SETU_OperationHandle * prev
Handles are kept in a linked list.
Definition: setu_api.c:128
struct GNUNET_SETU_OperationHandle * next
Handles are kept in a linked list.
Definition: setu_api.c:133
Option for set operations.
Message sent by a listening client to the service to reject performing the operation with the other p...
Definition: setu.h:158
uint32_t accept_reject_id
ID of the incoming request we want to reject.
Definition: setu.h:167
A request for an operation with another client.
Definition: setu.h:175
Handle for a set operation request from another peer.
Definition: setu_api.c:75
int accepted
Has the request been accepted already? GNUNET_YES/GNUNET_NO.
Definition: setu_api.c:86
uint32_t accept_id
Id of the request, used to identify the request when accepting/rejecting it.
Definition: setu_api.c:80
Message sent by the service to the client to indicate an element that is removed (set intersection) o...
Definition: setu.h:290
uint16_t result_status
Was the evaluation successful? Contains an enum GNUNET_SETU_Status in NBO.
Definition: setu.h:310
Time for relative time used by GNUnet, in microseconds.