2 This file is part of GNUnet
3 (C) 2013 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file set/gnunet-service-set.h
23 * @brief common components for the implementation the different set operations
24 * @author Florian Dold
27 #ifndef GNUNET_SERVICE_SET_H_PRIVATE
28 #define GNUNET_SERVICE_SET_H_PRIVATE
31 #include "gnunet_common.h"
32 #include "gnunet_protocols.h"
33 #include "gnunet_applications.h"
34 #include "gnunet_util_lib.h"
35 #include "gnunet_core_service.h"
36 #include "gnunet_mesh_service.h"
37 #include "gnunet_set_service.h"
42 * Implementation-specific set state.
43 * Used as opaque pointer, and specified further
44 * in the respective implementation.
50 * Implementation-specific set operation.
51 * Used as opaque pointer, and specified further
52 * in the respective implementation.
54 struct OperationState;
57 /* forward declarations */
63 * Detail information about an operation.
65 struct OperationSpecification
68 * The type of the operation.
70 enum GNUNET_SET_OperationType operation;
73 * The remove peer we evaluate the operation with
75 struct GNUNET_PeerIdentity peer;
78 * Application ID for the operation, used to distinguish
79 * multiple operations of the same type with the same peer.
81 struct GNUNET_HashCode app_id;
84 * Context message, may be NULL.
86 struct GNUNET_MessageHeader *context_msg;
89 * Salt to use for the operation.
94 * ID used to identify responses to a client.
96 uint32_t client_request_id;
99 * Set associated with the operation, NULL until the spec has been associated
107 * Signature of functions that create the implementation-specific
108 * state for a set supporting a specific operation.
110 * @return a set state specific to the supported operation
112 typedef struct SetState *(*CreateImpl) (void);
116 * Signature of functions that implement the add/remove functionality
117 * for a set supporting a specific operation.
119 * @param set implementation-specific set state
120 * @param msg element message from the client
122 typedef void (*AddRemoveImpl) (struct SetState *state, const struct GNUNET_SET_Element *element);
126 * Signature of functions that handle disconnection
127 * of the remote peer.
129 * @param op the set operation, contains implementation-specific data
131 typedef void (*PeerDisconnectImpl) (struct OperationState *op);
135 * Signature of functions that implement the destruction of the
136 * implementation-specific set state.
138 * @param state the set state, contains implementation-specific data
140 typedef void (*DestroySetImpl) (struct SetState *state);
144 * Signature of functions that implement the creation of set operations
145 * (currently evaluate and accept).
147 * @param spec specification of the set operation to be created
148 * @param tunnel the tunnel with the other peer
149 * @param tc tunnel context
151 typedef void (*OpCreateImpl) (struct OperationSpecification *spec,
152 struct GNUNET_MESH_Tunnel *tunnel,
153 struct TunnelContext *tc);
157 * Signature of functions that implement the message handling for
158 * the different set operations.
160 * @param op operation state
161 * @param msg received message
162 * @return GNUNET_OK on success, GNUNET_SYSERR to
163 * destroy the operation and the tunnel
165 typedef int (*MsgHandlerImpl) (struct OperationState *op,
166 const struct GNUNET_MessageHeader *msg);
168 typedef void (*CancelImpl) (struct SetState *set,
169 uint32_t request_id);
173 * Dispatch table for a specific set operation.
174 * Every set operation has to implement the callback
180 * Callback for the set creation.
185 * Callback for element insertion
190 * Callback for element removal.
192 AddRemoveImpl remove;
195 * Callback for accepting a set operation request
200 * Callback for starting evaluation with a remote peer.
202 OpCreateImpl evaluate;
205 * Callback for destruction of the set state.
207 DestroySetImpl destroy_set;
210 * Callback for handling operation-specific messages.
212 MsgHandlerImpl msg_handler;
215 * Callback for handling the remote peer's
218 PeerDisconnectImpl peer_disconnect;
221 * Callback for canceling an operation by
229 * A set that supports a specific operation
235 * Client that owns the set.
236 * Only one client may own a set.
238 struct GNUNET_SERVER_Client *client;
241 * Message queue for the client
243 struct GNUNET_MQ_Handle *client_mq;
246 * Type of operation supported for this set
248 enum GNUNET_SET_OperationType operation;
251 * Virtual table for this set.
252 * Determined by the operation type of this set.
254 const struct SetVT *vt;
257 * Sets are held in a doubly linked list.
262 * Sets are held in a doubly linked list.
267 * Implementation-specific state.
269 struct SetState *state;
274 * Information about a tunnel we are connected to.
275 * Used as tunnel context with mesh.
280 * V-Table for the operation belonging
281 * to the tunnel contest.
283 const struct SetVT *vt;
286 * Implementation-specific operation state.
288 struct OperationState *op;
293 * Get the table with implementing functions for
297 _GSS_union_vt (void);