GNUnet  0.10.x
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 
36 #ifndef GNUNET_SET_SERVICE_H
37 #define GNUNET_SET_SERVICE_H
38 
39 #ifdef __cplusplus
40 extern "C"
41 {
42 #if 0 /* keep Emacsens' auto-indent happy */
43 }
44 #endif
45 #endif
46 
47 #include "gnunet_common.h"
48 #include "gnunet_time_lib.h"
50 
51 
55 #define GNUNET_SET_CONTEXT_MESSAGE_MAX_SIZE ((1 << 16) - 1024)
56 
57 
61 struct GNUNET_SET_Handle;
62 
66 struct GNUNET_SET_Request;
67 
72 
77 
78 
87 
92 
97 };
98 
99 
115 
124 
133 
139 
146 
151 };
152 
153 
154 
165 
173 
180 
187 };
188 
189 
197  uint16_t size;
198 
202  uint16_t element_type;
203 
207  const void *data;
208 };
209 
210 
240 };
241 
242 
251 
255  union {
256  uint64_t num;
257  } v;
258 };
259 
260 
266 typedef void
267 (*GNUNET_SET_Continuation) (void *cls);
268 
269 
279 typedef void
281  const struct GNUNET_SET_Element *element,
282  uint64_t current_size,
284 
293 typedef int
295  const struct GNUNET_SET_Element *element);
296 
297 
313 typedef void
315  const struct GNUNET_PeerIdentity *other_peer,
316  const struct GNUNET_MessageHeader *context_msg,
317  struct GNUNET_SET_Request *request);
318 
319 
320 
321 typedef void
323  struct GNUNET_SET_Handle *copy);
324 
325 
337 struct GNUNET_SET_Handle *
340 
341 
355 int
357  const struct GNUNET_SET_Element *element,
359  void *cont_cls);
360 
361 
375 int
377  const struct GNUNET_SET_Element *element,
379  void *cont_cls);
380 
381 
382 void
385  void *cls);
386 
387 
396 void
398 
399 
415 GNUNET_SET_prepare(const struct GNUNET_PeerIdentity *other_peer,
416  const struct GNUNET_HashCode *app_id,
417  const struct GNUNET_MessageHeader *context_msg,
418  enum GNUNET_SET_ResultMode result_mode,
419  struct GNUNET_SET_Option options[],
421  void *result_cls);
422 
423 
440  enum GNUNET_SET_OperationType op_type,
441  const struct GNUNET_HashCode *app_id,
443  void *listen_cls);
444 
445 
454 void
456 
457 
474  enum GNUNET_SET_ResultMode result_mode,
475  struct GNUNET_SET_Option options[],
477  void *result_cls);
478 
479 
493 int
495  struct GNUNET_SET_Handle *set);
496 
497 
505 void
507 
508 
522 int
525  void *iter_cls);
526 
527 
535 void
537 
538 
546 struct GNUNET_SET_Element *
547 GNUNET_SET_element_dup(const struct GNUNET_SET_Element *element);
548 
549 
557 void
558 GNUNET_SET_element_hash(const struct GNUNET_SET_Element *element,
559  struct GNUNET_HashCode *ret_hash);
560 
561 
562 #if 0 /* keep Emacsens' auto-indent happy */
563 {
564 #endif
565 #ifdef __cplusplus
566 }
567 #endif
568 
569 #endif
570  /* end of group */
Client gets only elements that have been added to the set.
static void listen_cb(void *cls)
We have been notified that our listen socket has something to read.
A purely local set that does not support any operation.
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:1012
void * result_cls
Closure for result_cb.
Definition: set_api.c:142
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:729
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:41
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:682
Handle for a set operation request from another peer.
Definition: set_api.c:113
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
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.
Element should be added to the result set of the remote peer, i.e.
Element stored in a set.
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:652
Element should be added to the result set of the local peer, i.e.
Do not use the optimized set operation, but send full sets.
void * listen_cls
Closure for listen_cb.
Definition: set_api.c:204
void(* GNUNET_SET_CopyReadyCallback)(void *cls, struct GNUNET_SET_Handle *copy)
GNUNET_SET_OptionType
Possible options to pass to a set operation.
static struct GNUNET_HashCode app_id
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:808
Client gets every element in the resulting set.
void(* GNUNET_SET_Continuation)(void *cls)
Continuation used for some of the set operations.
void GNUNET_SET_copy_lazy(struct GNUNET_SET_Handle *set, GNUNET_SET_CopyReadyCallback cb, void *cls)
Definition: set_api.c:1189
Success, all elements have been sent (and received).
int(* GNUNET_SET_ElementIterator)(void *cls, const struct GNUNET_SET_Element *element)
Iterator for set elements.
void GNUNET_SET_element_hash(const struct GNUNET_SET_Element *element, struct GNUNET_HashCode *ret_hash)
Hash a set element.
Definition: set_api.c:1241
const void * data
Actual data of the element.
void GNUNET_SET_destroy(struct GNUNET_SET_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: set_api.c:767
GNUNET_SET_ResultIterator result_cb
Function to be called when we have a result, or an error.
Definition: set_api.c:137
Only use optimized set operations, even though for this particular set operation they might be much s...
The other peer refused to to the operation with us, or something went wrong.
Success, all elements have been returned (but the other peer might still be receiving some from us...
static struct GNUNET_TRANSPORT_OfferHelloHandle * oh
Active HELLO offering to transport service.
Everything went ok, we are transmitting an element of the result (in set, or to be removed from set...
GNUNET_SET_Status
Status for the result callback.
GNUNET_SET_ResultMode
The way results are given to the client.
uint16_t status
See PRISM_STATUS_*-constants.
A 512-bit hashcode.
Client gets notified of the required changes for both the local and the remote set.
Opaque handle to a set.
Definition: set_api.c:48
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
void GNUNET_SET_listen_cancel(struct GNUNET_SET_ListenHandle *lh)
Cancel the given listen operation.
Definition: set_api.c:1046
GNUNET_SET_OperationType
The operation that a set set supports.
Option for set operations.
Handle to an operation.
Definition: set_api.c:132
The identity of the host (wraps the signing key of the peer).
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:1123
configuration data
Definition: configuration.c:83
uint16_t size
Number of bytes in the buffer pointed to by data.
Opaque handle to a listen operation.
Definition: set_api.c:182
Client gets only elements that have been removed from the set.
void GNUNET_SET_operation_cancel(struct GNUNET_SET_OperationHandle *oh)
Cancel the given set operation.
Definition: set_api.c:511
struct GNUNET_SET_Element * GNUNET_SET_element_dup(const struct GNUNET_SET_Element *element)
Create a copy of an element.
Definition: set_api.c:1218
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Header for all communications.
Set intersection, only return elements that are in both sets.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
Set union, return all elements that are in at least one of the sets.
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:1167
void GNUNET_SET_iterate_cancel(struct GNUNET_SET_Handle *set)
Stop iteration over all elements in the given set.
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.
uint16_t element_type
Application-specific element type.
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:1080
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault...