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 * @brief common stuff for the set service
25 #ifndef GNUNET_SERVICE_SET_H_PRIVATE
26 #define GNUNET_SERVICE_SET_H_PRIVATE
29 #include "gnunet_common.h"
30 #include "gnunet_protocols.h"
31 #include "gnunet_applications.h"
32 #include "gnunet_util_lib.h"
33 #include "gnunet_core_service.h"
34 #include "gnunet_stream_lib.h"
35 #include "gnunet_set_service.h"
41 struct IntersectionState;
45 * Extra state required for set union.
51 * A set that supports a specific operation
57 * Client that owns the set.
58 * Only one client may own a set.
60 struct GNUNET_SERVER_Client *client;
63 * Message queue for the client
65 struct GNUNET_MQ_MessageQueue *client_mq;
68 * Type of operation supported for this set
70 uint32_t operation; // use enum from API
73 * Sets are held in a doubly linked list.
78 * Sets are held in a doubly linked list.
83 * Appropriate state for each type of
87 struct IntersectionState *i;
94 * State for an evaluate operation for a set that
97 struct UnionEvaluateOperation;
101 struct IntersectionEvaluateOperation
108 * State of evaluation a set operation with
111 struct EvaluateOperation
114 * Local set the operation is evaluated on
119 * Peer with the remote set
121 struct GNUNET_PeerIdentity peer;
124 * Application-specific identifier
126 struct GNUNET_HashCode app_id;
129 * Context message, given to us
130 * by the client, may be NULL.
132 struct GNUNET_MessageHeader *context_msg;
135 * Stream socket connected to the other peer
137 struct GNUNET_STREAM_Socket *socket;
140 * Message queue for the peer on the other
143 struct GNUNET_MQ_MessageQueue *mq;
146 * Type of this operation
148 enum GNUNET_SET_OperationType operation;
151 * GNUNET_YES if we started the operation,
152 * GNUNET_NO if the other peer started it.
157 * Request id, so we can use one client handle
158 * for multiple operations
163 struct UnionEvaluateOperation *u;
164 struct IntersectionEvaluateOperation *i;
172 * Listeners are held in a doubly linked list.
174 struct Listener *next;
177 * Listeners are held in a doubly linked list.
179 struct Listener *prev;
182 * Client that owns the set.
183 * Only one client may own a set.
185 struct GNUNET_SERVER_Client *client;
188 * Message queue for the client
190 struct GNUNET_MQ_MessageQueue *client_mq;
193 * Type of operation supported for this set
195 enum GNUNET_SET_OperationType operation;
198 * Application id of intereset for this listener.
200 struct GNUNET_HashCode app_id;
205 * Peer that has connected to us, but is not yet evaluating a set operation.
206 * Once the peer has sent a request, and the client has
207 * accepted or rejected it, this information will be deleted.
212 * Incoming peers are held in a linked list
214 struct Incoming *next;
217 * Incoming peers are held in a linked list
219 struct Incoming *prev;
222 * Identity of the peer that connected to us
224 struct GNUNET_PeerIdentity peer;
227 * Socket connected to the peer
229 struct GNUNET_STREAM_Socket *socket;
232 * Message queue for the peer
234 struct GNUNET_MQ_MessageQueue *mq;
237 * App code, set once the peer has
238 * requested an operation
240 struct GNUNET_HashCode app_id;
243 * Context message, set once the peer
244 * has requested an operation.
246 struct GNUNET_MessageHeader *context_msg;
249 * Operation the other peer wants to do
251 enum GNUNET_SET_OperationType operation;
254 * Request id associated with the
255 * request coming from this client
262 * Configuration of the local peer
264 extern const struct GNUNET_CONFIGURATION_Handle *configuration;
268 * Disconnect a client and free all resources
269 * that the client allocated (e.g. Sets or Listeners)
271 * @param client the client to disconnect
274 client_disconnect (struct GNUNET_SERVER_Client *client);
278 union_set_create (void);
282 union_evaluate (struct EvaluateOperation *eo);
286 union_add (struct Set *set, struct ElementMessage *m);
290 union_accept (struct EvaluateOperation *eo, struct Incoming *incoming);