GNUnet  0.10.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 
157 
162 struct SetVT
163 {
168 
173 
178 
183 
188 
193 
198 
203 
208 
209 };
210 
211 
217 {
224  unsigned int generation;
225 
230  int added;
231 };
232 
233 
241 {
246  struct GNUNET_SET_Element element;
247 
252  struct GNUNET_HashCode element_hash;
253 
264 
268  unsigned int mutations_size;
269 
274  int remote;
275 };
276 
277 
282 struct Listener;
283 
284 
288 struct ClientState
289 {
293  struct Set *set;
294 
299 
303  struct GNUNET_SERVICE_Client *client;
304 
308  struct GNUNET_MQ_Handle *mq;
309 
310 };
311 
312 
316 struct Operation
317 {
318 
322  struct Operation *next;
323 
327  struct Operation *prev;
328 
333 
338 
343 
348 
353  struct Set *set;
354 
361 
367 
373 
377  uint32_t salt;
378 
383 
388 
392  enum GNUNET_SET_ResultMode result_mode;
393 
399 
405 
411 
417 
423  uint32_t suggest_id;
424 
429  unsigned int generation_created;
430 
431 };
432 
433 
439 {
440 
445 
452 
459 
463  unsigned int refcount;
464 
468  unsigned int latest_generation;
469 
474 };
475 
476 
478 {
482  unsigned int start;
483 
487  unsigned int end;
488 };
489 
490 
495 {
500 
505 
509  struct Set *set;
510 
517 };
518 
519 
523 struct Set
524 {
525 
529  struct Set *next;
530 
534  struct Set *prev;
535 
540  struct ClientState *cs;
541 
547 
555  const struct SetVT *vt;
556 
560  struct SetState *state;
561 
567 
572 
577 
582 
587  unsigned int current_generation;
588 
593 
597  enum GNUNET_SET_OperationType operation;
598 
602  unsigned int iter_generation;
603 
608  uint16_t iteration_id;
609 
610 };
611 
612 
614 
615 
629 void
631  int gc);
632 
633 
639 void
641 
642 
648 const struct SetVT *
649 _GSS_union_vt (void);
650 
651 
657 const struct SetVT *
658 _GSS_intersection_vt (void);
659 
660 
668 int
670  struct Operation *op);
671 
672 
673 #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:249
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:282
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:139
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.