GNUnet  0.19.3
gnunet_set_service.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2013, 2014 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  */
20 
39 #ifndef GNUNET_SET_SERVICE_H
40 #define GNUNET_SET_SERVICE_H
41 
42 #ifdef __cplusplus
43 extern "C"
44 {
45 #if 0 /* keep Emacsens' auto-indent happy */
46 }
47 #endif
48 #endif
49 
50 
51 #include "gnunet_common.h"
52 #include "gnunet_time_lib.h"
54 
55 
59 #define GNUNET_SET_CONTEXT_MESSAGE_MAX_SIZE ((1 << 16) - 1024)
60 
61 
65 struct GNUNET_SET_Handle;
66 
70 struct GNUNET_SET_Request;
71 
76 
81 
82 
87 {
92 
97 
102 };
103 
104 
109 {
121 
130 
139 
145 
152 
157 };
158 
159 
164 {
171 
179 
186 
193 };
194 
195 
200 {
204  uint16_t size;
205 
209  uint16_t element_type;
210 
214  const void *data;
215 };
216 
217 
224 {
248 };
249 
250 
255 {
260 
264  union
265  {
266  uint64_t num;
267  } v;
268 };
269 
270 
276 typedef void
277 (*GNUNET_SET_Continuation) (void *cls);
278 
279 
289 typedef void
290 (*GNUNET_SET_ResultIterator) (void *cls,
291  const struct GNUNET_SET_Element *element,
292  uint64_t current_size,
294 
303 typedef int
304 (*GNUNET_SET_ElementIterator) (void *cls,
305  const struct GNUNET_SET_Element *element);
306 
307 
323 typedef void
324 (*GNUNET_SET_ListenCallback) (void *cls,
325  const struct GNUNET_PeerIdentity *other_peer,
326  const struct GNUNET_MessageHeader *context_msg,
327  struct GNUNET_SET_Request *request);
328 
329 
330 typedef void
331 (*GNUNET_SET_CopyReadyCallback) (void *cls,
332  struct GNUNET_SET_Handle *copy);
333 
334 
346 struct GNUNET_SET_Handle *
349 
350 
364 int
366  const struct GNUNET_SET_Element *element,
368  void *cont_cls);
369 
370 
384 int
386  const struct GNUNET_SET_Element *element,
388  void *cont_cls);
389 
390 
391 void
394  void *cls);
395 
396 
405 void
407 
408 
424 GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer,
425  const struct GNUNET_HashCode *app_id,
426  const struct GNUNET_MessageHeader *context_msg,
427  enum GNUNET_SET_ResultMode result_mode,
428  struct GNUNET_SET_Option options[],
430  void *result_cls);
431 
432 
449  enum GNUNET_SET_OperationType op_type,
450  const struct GNUNET_HashCode *app_id,
452  void *listen_cls);
453 
454 
463 void
465 
466 
483  enum GNUNET_SET_ResultMode result_mode,
484  struct GNUNET_SET_Option options[],
486  void *result_cls);
487 
488 
502 int
504  struct GNUNET_SET_Handle *set);
505 
506 
514 void
516 
517 
531 int
534  void *iter_cls);
535 
536 
544 void
546 
547 
555 struct GNUNET_SET_Element *
556 GNUNET_SET_element_dup (const struct GNUNET_SET_Element *element);
557 
558 
566 void
567 GNUNET_SET_element_hash (const struct GNUNET_SET_Element *element,
568  struct GNUNET_HashCode *ret_hash);
569 
570 
571 #if 0 /* keep Emacsens' auto-indent happy */
572 {
573 #endif
574 #ifdef __cplusplus
575 }
576 #endif
577 
578 #endif
579  /* end of group */
581  /* end of group addition */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static void listen_cb(void *cls)
We have been notified that our listen socket has something to read.
static struct GNUNET_TRANSPORT_OfferHelloHandle * oh
Active HELLO offering to transport service.
uint16_t status
See PRISM_STATUS_*-constants.
static struct GNUNET_HashCode app_id
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:40
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
Configuration API.
Functions related to time.
GNUNET_SET_Status
Status for the result callback.
void GNUNET_SET_destroy(struct GNUNET_SET_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: set_api.c:745
void GNUNET_SET_copy_lazy(struct GNUNET_SET_Handle *set, GNUNET_SET_CopyReadyCallback cb, void *cls)
Definition: set_api.c:1139
void GNUNET_SET_listen_cancel(struct GNUNET_SET_ListenHandle *lh)
Cancel the given listen operation.
Definition: set_api.c:1010
int GNUNET_SET_remove_element(struct GNUNET_SET_Handle *set, const struct GNUNET_SET_Element *element, GNUNET_SET_Continuation cont, void *cont_cls)
Remove an element to the given set.
Definition: set_api.c:707
struct GNUNET_SET_Element * GNUNET_SET_element_dup(const struct GNUNET_SET_Element *element)
Create a copy of an element.
Definition: set_api.c:1168
void(* GNUNET_SET_Continuation)(void *cls)
Continuation used for some of the set operations.
struct GNUNET_SET_Handle * GNUNET_SET_create(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op)
Create an empty set, supporting the specified operation.
Definition: set_api.c:656
int GNUNET_SET_iterate(struct GNUNET_SET_Handle *set, GNUNET_SET_ElementIterator iter, void *iter_cls)
Iterate over all elements in the given set.
Definition: set_api.c:1117
void(* GNUNET_SET_ResultIterator)(void *cls, const struct GNUNET_SET_Element *element, uint64_t current_size, enum GNUNET_SET_Status status)
Callback for set operation results.
GNUNET_SET_OptionType
Possible options to pass to a set operation.
void GNUNET_SET_operation_cancel(struct GNUNET_SET_OperationHandle *oh)
Cancel the given set operation.
Definition: set_api.c:516
void(* GNUNET_SET_ListenCallback)(void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SET_Request *request)
Called when another peer wants to do a set operation with the local peer.
GNUNET_SET_ResultMode
The way results are given to the client.
struct GNUNET_SET_OperationHandle * GNUNET_SET_prepare(const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
Prepare a set operation to be evaluated with another peer.
Definition: set_api.c:772
void GNUNET_SET_iterate_cancel(struct GNUNET_SET_Handle *set)
Stop iteration over all elements in the given set.
int(* GNUNET_SET_ElementIterator)(void *cls, const struct GNUNET_SET_Element *element)
Iterator for set elements.
void(* GNUNET_SET_CopyReadyCallback)(void *cls, struct GNUNET_SET_Handle *copy)
GNUNET_SET_OperationType
The operation that a set set supports.
int GNUNET_SET_commit(struct GNUNET_SET_OperationHandle *oh, struct GNUNET_SET_Handle *set)
Commit a set to be used with a set operation.
Definition: set_api.c:1073
struct GNUNET_SET_OperationHandle * GNUNET_SET_accept(struct GNUNET_SET_Request *request, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
Accept a request we got via GNUNET_SET_listen().
Definition: set_api.c:1030
struct GNUNET_SET_ListenHandle * GNUNET_SET_listen(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op_type, const struct GNUNET_HashCode *app_id, GNUNET_SET_ListenCallback listen_cb, void *listen_cls)
Wait for set operation requests for the given application ID.
Definition: set_api.c:976
int GNUNET_SET_add_element(struct GNUNET_SET_Handle *set, const struct GNUNET_SET_Element *element, GNUNET_SET_Continuation cont, void *cont_cls)
Add an element to the given set.
Definition: set_api.c:673
void GNUNET_SET_element_hash(const struct GNUNET_SET_Element *element, struct GNUNET_HashCode *ret_hash)
Hash a set element.
Definition: set_api.c:1184
@ GNUNET_SET_STATUS_OK
Everything went ok, we are transmitting an element of the result (in set, or to be removed from set,...
@ GNUNET_SET_STATUS_FAILURE
The other peer refused to to the operation with us, or something went wrong.
@ GNUNET_SET_STATUS_ADD_REMOTE
Element should be added to the result set of the remote peer, i.e.
@ GNUNET_SET_STATUS_HALF_DONE
Success, all elements have been returned (but the other peer might still be receiving some from us,...
@ GNUNET_SET_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SET_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.
@ GNUNET_SET_OPTION_END
List terminator.
@ GNUNET_SET_OPTION_FORCE_DELTA
Only use optimized set operations, even though for this particular set operation they might be much s...
@ GNUNET_SET_OPTION_BYZANTINE
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault.
@ GNUNET_SET_OPTION_FORCE_FULL
Do not use the optimized set operation, but send full sets.
@ GNUNET_SET_RESULT_REMOVED
Client gets only elements that have been removed from the set.
@ GNUNET_SET_RESULT_FULL
Client gets every element in the resulting set.
@ GNUNET_SET_RESULT_SYMMETRIC
Client gets notified of the required changes for both the local and the remote set.
@ GNUNET_SET_RESULT_ADDED
Client gets only elements that have been added to the set.
@ GNUNET_SET_OPERATION_INTERSECTION
Set intersection, only return elements that are in both sets.
@ GNUNET_SET_OPERATION_UNION
Set union, return all elements that are in at least one of the sets.
@ GNUNET_SET_OPERATION_NONE
A purely local set that does not support any operation.
A 512-bit hashcode.
Header for all communications.
The identity of the host (wraps the signing key of the peer).
Element stored in a set.
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
uint16_t element_type
Application-specific element type.
Opaque handle to a set.
Definition: set_api.c:50
Opaque handle to a listen operation.
Definition: set_api.c:187
void * listen_cls
Closure for listen_cb.
Definition: set_api.c:209
Handle to an operation.
Definition: set_api.c:136
struct GNUNET_SET_Handle * set
Local set used for the operation, NULL if no set has been provided by conclude yet.
Definition: set_api.c:152
GNUNET_SET_ResultIterator result_cb
Function to be called when we have a result, or an error.
Definition: set_api.c:141
void * result_cls
Closure for result_cb.
Definition: set_api.c:146
Option for set operations.
enum GNUNET_SET_OptionType type
Type of the option.
union GNUNET_SET_Option::@40 v
Value for the option, only used with some options.
Handle for a set operation request from another peer.
Definition: set_api.c:116