GNUnet  0.11.x
gnunet-service-set.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2013-2017 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  */
26 #ifndef GNUNET_SERVICE_SET_H_PRIVATE
27 #define GNUNET_SERVICE_SET_H_PRIVATE
28 
29 #include "platform.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_protocols.h"
32 #include "gnunet_applications.h"
33 #include "gnunet_core_service.h"
34 #include "gnunet_cadet_service.h"
35 #include "gnunet_set_service.h"
36 #include "set.h"
37 
38 
43 struct SetState;
44 
49 struct OperationState;
50 
54 struct Set;
55 
62 struct ElementEntry;
63 
67 struct Operation;
68 
69 
76 typedef struct SetState *
77 (*SetCreateImpl) (void);
78 
79 
87 typedef void
89  struct ElementEntry *ee);
90 
91 
98 typedef struct SetState *
99 (*SetCopyStateImpl) (struct SetState *state);
100 
101 
108 typedef void
110 
111 
119 typedef struct OperationState *
120 (*OpAcceptImpl) (struct Operation *op);
121 
122 
133 typedef struct OperationState *
134 (*OpEvaluateImpl) (struct Operation *op,
135  const struct GNUNET_MessageHeader *opaque_context);
136 
144 typedef void
145 (*OpCancelImpl) (struct Operation *op);
146 
147 
153 typedef void
155 
156 
161 struct SetVT
162 {
167 
172 
177 
182 
187 
192 
197 
202 
207 };
208 
209 
215 {
222  unsigned int generation;
223 
228  int added;
229 };
230 
231 
239 {
244  struct GNUNET_SET_Element element;
245 
250  struct GNUNET_HashCode element_hash;
251 
262 
266  unsigned int mutations_size;
267 
272  int remote;
273 };
274 
275 
280 struct Listener;
281 
282 
286 struct ClientState
287 {
291  struct Set *set;
292 
297 
301  struct GNUNET_SERVICE_Client *client;
302 
306  struct GNUNET_MQ_Handle *mq;
307 };
308 
309 
313 struct Operation
314 {
318  struct Operation *next;
319 
323  struct Operation *prev;
324 
329 
334 
339 
344 
349  struct Set *set;
350 
357 
363 
369 
373  uint32_t salt;
374 
379 
384 
388  enum GNUNET_SET_ResultMode result_mode;
389 
395 
401 
407 
413 
419  uint32_t suggest_id;
420 
425  unsigned int generation_created;
426 };
427 
428 
434 {
439 
446 
453 
457  unsigned int refcount;
458 
462  unsigned int latest_generation;
463 
468 };
469 
470 
472 {
476  unsigned int start;
477 
481  unsigned int end;
482 };
483 
484 
489 {
494 
499 
503  struct Set *set;
504 
511 };
512 
513 
517 struct Set
518 {
522  struct Set *next;
523 
527  struct Set *prev;
528 
533  struct ClientState *cs;
534 
540 
548  const struct SetVT *vt;
549 
553  struct SetState *state;
554 
560 
565 
570 
575 
580  unsigned int current_generation;
581 
586 
590  enum GNUNET_SET_OperationType operation;
591 
595  unsigned int iter_generation;
596 
601  uint16_t iteration_id;
602 };
603 
604 
606 
607 
621 void
623  int gc);
624 
625 
631 void
633 
634 
640 const struct SetVT *
641 _GSS_union_vt (void);
642 
643 
649 const struct SetVT *
650 _GSS_intersection_vt (void);
651 
652 
660 int
662  struct Operation *op);
663 
664 
665 #endif
SetAddRemoveImpl add
Callback for element insertion.
State of an evaluate operation with another peer.
const struct SetVT * _GSS_intersection_vt(void)
Get the table with implementing functions for set intersection.
OpAcceptImpl accept
Callback for accepting a set operation request.
State we keep per client.
struct GenerationRange * excluded_generations
List of generations we have to exclude, due to lazy copies.
SetDestroyImpl destroy_set
Callback for destruction of the set state.
uint32_t suggest_id
Unique request id for the request from a remote peer, sent to the client, which will accept or reject...
struct OperationState *(* OpAcceptImpl)(struct Operation *op)
Signature of functions that implement accepting a set operation.
struct MutationEvent * mutations
If mutations is not NULL, it contains a list of mutations, ordered by increasing generation.
unsigned int latest_generation
FIXME: document!
struct SetState *(* SetCreateImpl)(void)
Signature of functions that create the implementation-specific state for a set supporting a specific ...
void _GSS_operation_destroy(struct Operation *op, int gc)
Destroy the given operation.
int byzantine_lower_bound
Lower bound for the set size, used only when byzantine mode is enabled.
struct PendingMutation * pending_mutations_head
Mutations requested by the client that we&#39;re unable to execute right now because we&#39;re iterating over...
struct SetState * state
Implementation-specific state.
messages used for the set api
Element stored in a set.
unsigned int refcount
Number of references to the content.
int added
If added is GNUNET_YES, then this is a remove event, otherwise it is an add event.
struct GNUNET_CADET_Channel * channel
Channel to the peer.
unsigned int excluded_generations_size
Number of elements in array excluded_generations.
Opaque handle to a channel.
Definition: cadet_api.c:80
struct Operation * ops_head
Evaluate operations are held in a linked list.
A listener is inhabited by a client, and waits for evaluation requests from remote peers...
Information about a mutation to apply to a set.
Handle for the service.
SetCopyStateImpl copy_state
Callback for making a copy of a set&#39;s internal state.
Internal representation of the hash map.
int _GSS_is_element_of_operation(struct ElementEntry *ee, struct Operation *op)
Is element ee part of the set used by op?
unsigned int generation_created
Generation in which the operation handle was created.
struct OperationState *(* OpEvaluateImpl)(struct Operation *op, const struct GNUNET_MessageHeader *opaque_context)
Signature of functions that implement starting the evaluation of set operations.
struct Operation * prev
Kept in a DLL of the listener, if listener is non-NULL.
struct Set * prev
Sets are held in a doubly linked list.
struct PendingMutation * next
Mutations are kept in a DLL.
Handle to a client that is connected to a service.
Definition: service.c:250
struct PendingMutation * prev
Mutations are kept in a DLL.
struct GNUNET_STATISTICS_Handle * _GSS_statistics
Statistics handle.
enum State state
current state of profiling
Information about an element element in the set.
unsigned int current_generation
Current generation, that is, number of previously executed operations and lazy copies on the underlyi...
Dispatch table for a specific set operation.
int remote
GNUNET_YES if the element is a remote element, and does not belong to the operation&#39;s set...
struct Listener * listener
Port this operation runs on.
A set that supports a specific operation with other peers.
GNUNET_SET_ResultMode
The way results are given to the client.
struct SetState *(* SetCopyStateImpl)(struct SetState *state)
Make a copy of a set&#39;s internal state.
OpChannelDeathImpl channel_death
Callback called in case the CADET channel died.
struct Set * next
Sets are held in a doubly linked list (in sets_head and sets_tail).
struct PendingMutation * pending_mutations_tail
Mutations requested by the client that we&#39;re unable to execute right now because we&#39;re iterating over...
OpEvaluateImpl evaluate
Callback for starting evaluation with a remote peer.
A 512-bit hashcode.
struct GNUNET_CONTAINER_MultiHashMapIterator * iter
Current state of iterating elements for the client.
int force_delta
Always use delta operation instead of sending full sets, even it it&#39;s less efficient.
struct Listener * listener
Listener, if associated with the client, otherwise NULL.
MutationEvent gives information about changes to an element (removal / addition) in a set content...
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
void _GSS_operation_destroy2(struct Operation *op)
This function probably should not exist and be replaced by inlining more specific logic in the variou...
int byzantine
GNUNET_YES to fail operations where Byzantine faults are suspected
GNUNET_SET_OperationType
The operation that a set set supports.
Operation context used to execute a set operation.
Extra state required for efficient set intersection.
void(* SetAddRemoveImpl)(struct SetState *state, struct ElementEntry *ee)
Signature of functions that implement the add/remove functionality for a set supporting a specific op...
SetContent stores the actual set elements, which may be shared by multiple generations derived from o...
void(* OpChannelDeathImpl)(struct Operation *op)
Signature of functions called when the CADET channel died.
unsigned int generation
First generation affected by this mutation event.
Handle to a message queue.
Definition: mq.c:85
struct Operation * next
Kept in a DLL of the listener, if listener is non-NULL.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task, if the incoming peer has not been accepted after the timeout, it will be disconnected...
unsigned int iter_generation
Generation we&#39;re currently iteration over.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_MQ_Handle * mq
Message queue for the channel.
uint32_t salt
Salt to use for the operation.
uint32_t client_request_id
ID used to identify an operation between service and client.
struct GNUNET_MessageHeader * context_msg
Context message, may be NULL.
const struct SetVT * _GSS_union_vt(void)
Get the table with implementing functions for set union.
unsigned int end
Generation after the last excluded generation.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
Entry in list of pending tasks.
Definition: scheduler.c:134
Message sent by client to the service to add or remove an element to/from the set.
Definition: set.h:280
int iterator_count
Number of concurrently active iterators.
struct GNUNET_CONTAINER_MultiHashMap * elements
Maps struct GNUNET_HashCode * to struct ElementEntry *.
uint16_t iteration_id
Each iter is assigned a unique number, so that the client can distinguish iterations.
Header for all communications.
struct Operation * ops_tail
Evaluate operations are held in a linked list.
const struct SetVT * vt
Virtual table for this set.
struct ClientState * cs
Client that owns the set.
void(* OpCancelImpl)(struct Operation *op)
Signature of functions that implement operation cancelation.
uint32_t remote_element_count
Remote peers element count.
SetCreateImpl create
Callback for the set creation.
struct OperationState * state
Operation-specific operation state.
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
unsigned int start
First generation that is excluded.
unsigned int mutations_size
Number of elements in the array mutations.
struct GNUNET_SET_ElementMessage * msg
Message that describes the desired mutation.
void(* SetDestroyImpl)(struct SetState *state)
Signature of functions that implement the destruction of the implementation-specific set state...
OpCancelImpl cancel
Callback for canceling an operation.
struct SetContent * content
Content, possibly shared by multiple sets, and thus reference counted.
int force_full
Always send full sets, even if delta operations would be more efficient.