GNUnet 0.22.0
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"
35#include "gnunet_set_service.h"
36#include "set.h"
37
38
43struct SetState;
44
49struct OperationState;
50
54struct Set;
55
62struct ElementEntry;
63
67struct Operation;
68
69
76typedef struct SetState *
77(*SetCreateImpl) (void);
78
79
87typedef void
89 struct ElementEntry *ee);
90
91
98typedef struct SetState *
99(*SetCopyStateImpl) (struct SetState *state);
100
101
108typedef void
109(*SetDestroyImpl) (struct SetState *state);
110
111
119typedef struct OperationState *
120(*OpAcceptImpl) (struct Operation *op);
121
122
133typedef struct OperationState *
134(*OpEvaluateImpl) (struct Operation *op,
135 const struct GNUNET_MessageHeader *opaque_context);
136
144typedef void
145(*OpCancelImpl) (struct Operation *op);
146
147
153typedef void
154(*OpChannelDeathImpl) (struct Operation *op);
155
156
161struct 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{
245
251
262
266 unsigned int mutations_size;
267
273};
274
275
280struct Listener;
281
282
286struct ClientState
287{
291 struct Set *set;
292
297
302
306 struct GNUNET_MQ_Handle *mq;
307};
308
309
314{
319
324
329
334
339
344
349 struct Set *set;
350
357
363
369
373 uint32_t salt;
374
379
384
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
517struct Set
518{
522 struct Set *next;
523
527 struct Set *prev;
528
534
540
548 const struct SetVT *vt;
549
554
560
565
570
575
580 unsigned int current_generation;
581
586
591
595 unsigned int iter_generation;
596
601 uint16_t iteration_id;
602};
603
604
606
607
621void
623 int gc);
624
625
631void
633
634
640const struct SetVT *
641_GSS_union_vt (void);
642
643
649const struct SetVT *
651
652
660int
662 struct Operation *op);
663
664
665#endif
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:143
enum State state
current state of profiling
int _GSS_is_element_of_operation(struct ElementEntry *ee, struct Operation *op)
Is element ee part of the set used by op?
void(* SetAddRemoveImpl)(struct SetState *state, struct ElementEntry *ee)
Signature of functions that implement the add/remove functionality for a set supporting a specific op...
struct SetState *(* SetCopyStateImpl)(struct SetState *state)
Make a copy of a set's internal state.
struct OperationState *(* OpAcceptImpl)(struct Operation *op)
Signature of functions that implement accepting a set operation.
struct GNUNET_STATISTICS_Handle * _GSS_statistics
Statistics handle.
const struct SetVT * _GSS_intersection_vt(void)
Get the table with implementing functions for set intersection.
const struct SetVT * _GSS_union_vt(void)
Get the table with implementing functions for set union.
void(* SetDestroyImpl)(struct SetState *state)
Signature of functions that implement the destruction of the implementation-specific set state.
void _GSS_operation_destroy2(struct Operation *op)
This function probably should not exist and be replaced by inlining more specific logic in the variou...
void(* OpCancelImpl)(struct Operation *op)
Signature of functions that implement operation cancellation.
struct SetState *(* SetCreateImpl)(void)
Signature of functions that create the implementation-specific state for a set supporting a specific ...
void(* OpChannelDeathImpl)(struct Operation *op)
Signature of functions called when the CADET channel died.
struct OperationState *(* OpEvaluateImpl)(struct Operation *op, const struct GNUNET_MessageHeader *opaque_context)
Signature of functions that implement starting the evaluation of set operations.
void _GSS_operation_destroy(struct Operation *op, int gc)
Destroy the given operation.
Constants for network applications operating on top of the CADET service.
CADET service; establish channels to distant peers.
Core service; the main API for encrypted P2P communications.
Constants for network protocols.
Two-peer set operations.
GNUNET_SET_ResultMode
The way results are given to the client.
GNUNET_SET_OperationType
The operation that a set set supports.
messages used for the set api
State we keep per client.
struct GNUNET_MQ_Handle * mq
MQ to talk to client.
struct Listener * listener
Listener, if associated with the client, otherwise NULL.
struct Set * set
Set, if associated with the client, otherwise NULL.
struct GNUNET_SERVICE_Client * client
Client this is about.
Information about an element element in the set.
int remote
GNUNET_YES if the element is a remote element, and does not belong to the operation's set.
struct GNUNET_SET_Element element
The actual element.
struct MutationEvent * mutations
If mutations is not NULL, it contains a list of mutations, ordered by increasing generation.
unsigned int mutations_size
Number of elements in the array mutations.
struct GNUNET_HashCode element_hash
Hash of the element.
Opaque handle to a channel.
Definition: cadet.h:116
Internal representation of the hash map.
A 512-bit hashcode.
Handle to a message queue.
Definition: mq.c:87
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:135
Handle to a client that is connected to a service.
Definition: service.c:245
Message sent by client to the service to add or remove an element to/from the set.
Definition: set.h:281
Element stored in a set.
Handle for the service.
unsigned int start
First generation that is excluded.
unsigned int end
Generation after the last excluded generation.
A listener is inhabited by a client, and waits for evaluation requests from remote peers.
MutationEvent gives information about changes to an element (removal / addition) in a set content.
unsigned int generation
First generation affected by this mutation event.
int added
If added is GNUNET_YES, then this is a remove event, otherwise it is an add event.
State of an evaluate operation with another peer.
Operation context used to execute a set operation.
unsigned int generation_created
Generation in which the operation handle was created.
uint32_t suggest_id
Unique request id for the request from a remote peer, sent to the client, which will accept or reject...
struct GNUNET_MessageHeader * context_msg
Context message, may be NULL.
int force_delta
Always use delta operation instead of sending full sets, even it it's less efficient.
int force_full
Always send full sets, even if delta operations would be more efficient.
struct Operation * prev
Kept in a DLL of the listener, if listener is non-NULL.
struct GNUNET_CADET_Channel * channel
Channel to the peer.
struct GNUNET_MQ_Handle * mq
Message queue for the channel.
struct GNUNET_PeerIdentity peer
The identity of the requesting peer.
struct Listener * listener
Port this operation runs on.
struct Operation * next
Kept in a DLL of the listener, if listener is non-NULL.
uint32_t salt
Salt to use for the operation.
enum GNUNET_SET_ResultMode result_mode
When are elements sent to the client, and which elements are sent?
uint32_t remote_element_count
Remote peers element count.
uint32_t client_request_id
ID used to identify an operation between service and client.
int byzantine
GNUNET_YES to fail operations where Byzantine faults are suspected
struct OperationState * state
Operation-specific operation state.
int byzantine_lower_bound
Lower bound for the set size, used only when byzantine mode is enabled.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task, if the incoming peer has not been accepted after the timeout, it will be disconnected.
struct Set * set
Set associated with the operation, NULL until the spec has been associated with a set.
Information about a mutation to apply to a set.
struct GNUNET_SET_ElementMessage * msg
Message that describes the desired mutation.
struct Set * set
Set this mutation is about.
struct PendingMutation * next
Mutations are kept in a DLL.
struct PendingMutation * prev
Mutations are kept in a DLL.
SetContent stores the actual set elements, which may be shared by multiple generations derived from o...
int iterator_count
Number of concurrently active iterators.
unsigned int latest_generation
FIXME: document!
struct GNUNET_CONTAINER_MultiHashMap * elements
Maps struct GNUNET_HashCode * to struct ElementEntry *.
struct PendingMutation * pending_mutations_head
Mutations requested by the client that we're unable to execute right now because we're iterating over...
unsigned int refcount
Number of references to the content.
struct PendingMutation * pending_mutations_tail
Mutations requested by the client that we're unable to execute right now because we're iterating over...
Extra state required for efficient set intersection.
Dispatch table for a specific set operation.
SetCreateImpl create
Callback for the set creation.
SetAddRemoveImpl add
Callback for element insertion.
OpEvaluateImpl evaluate
Callback for starting evaluation with a remote peer.
OpCancelImpl cancel
Callback for canceling an operation.
SetAddRemoveImpl remove
Callback for element removal.
OpChannelDeathImpl channel_death
Callback called in case the CADET channel died.
SetCopyStateImpl copy_state
Callback for making a copy of a set's internal state.
OpAcceptImpl accept
Callback for accepting a set operation request.
SetDestroyImpl destroy_set
Callback for destruction of the set state.
A set that supports a specific operation with other peers.
unsigned int iter_generation
Generation we're currently iteration over.
struct Set * next
Sets are held in a doubly linked list (in sets_head and sets_tail).
struct Operation * ops_head
Evaluate operations are held in a linked list.
struct Operation * ops_tail
Evaluate operations are held in a linked list.
struct Set * prev
Sets are held in a doubly linked list.
struct SetState * state
Implementation-specific state.
enum GNUNET_SET_OperationType operation
Type of operation supported for this set.
uint16_t iteration_id
Each iter is assigned a unique number, so that the client can distinguish iterations.
struct GenerationRange * excluded_generations
List of generations we have to exclude, due to lazy copies.
struct SetContent * content
Content, possibly shared by multiple sets, and thus reference counted.
const struct SetVT * vt
Virtual table for this set.
struct GNUNET_CONTAINER_MultiHashMapIterator * iter
Current state of iterating elements for the client.
struct ClientState * cs
Client that owns the set.
unsigned int excluded_generations_size
Number of elements in array excluded_generations.
unsigned int current_generation
Current generation, that is, number of previously executed operations and lazy copies on the underlyi...