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_stream_lib.h"
37 #include "gnunet_set_service.h"
43 struct IntersectionState;
47 * Extra state required for set union.
53 * A set that supports a specific operation
59 * Client that owns the set.
60 * Only one client may own a set.
62 struct GNUNET_SERVER_Client *client;
65 * Message queue for the client
67 struct GNUNET_MQ_MessageQueue *client_mq;
70 * Type of operation supported for this set
72 uint32_t operation; // use enum from API
75 * Sets are held in a doubly linked list.
80 * Sets are held in a doubly linked list.
85 * Appropriate state for each type of
89 struct IntersectionState *i;
96 * A listener is inhabited by a client, and
97 * waits for evaluation requests from remote peers.
102 * Listeners are held in a doubly linked list.
104 struct Listener *next;
107 * Listeners are held in a doubly linked list.
109 struct Listener *prev;
112 * Client that owns the set.
113 * Only one client may own a set.
115 struct GNUNET_SERVER_Client *client;
118 * Message queue for the client
120 struct GNUNET_MQ_MessageQueue *client_mq;
123 * Type of operation supported for this set
125 enum GNUNET_SET_OperationType operation;
128 * Application id of intereset for this listener.
130 struct GNUNET_HashCode app_id;
135 * Peer that has connected to us, but is not yet evaluating a set operation.
136 * Once the peer has sent a request, and the client has
137 * accepted or rejected it, this information will be deleted.
142 * Incoming peers are held in a linked list
144 struct Incoming *next;
147 * Incoming peers are held in a linked list
149 struct Incoming *prev;
152 * Identity of the peer that connected to us
154 struct GNUNET_PeerIdentity peer;
157 * Socket connected to the peer
159 struct GNUNET_STREAM_Socket *socket;
162 * Message queue for the peer
164 struct GNUNET_MQ_MessageQueue *mq;
167 * App code, set once the peer has
168 * requested an operation
170 struct GNUNET_HashCode app_id;
173 * Context message, set once the peer
174 * has requested an operation.
176 struct GNUNET_MessageHeader *context_msg;
179 * Salt the peer has requested to use for the
185 * Operation the other peer wants to do
187 enum GNUNET_SET_OperationType operation;
190 * Unique request id for the request from
198 * Configuration of the local peer
200 extern const struct GNUNET_CONFIGURATION_Handle *configuration;
204 * Disconnect a client and free all resources
205 * that the client allocated (e.g. Sets or Listeners)
207 * @param client the client to disconnect
210 _GSS_client_disconnect (struct GNUNET_SERVER_Client *client);
214 * Create a new set supporting the union operation
216 * @return the newly created set
219 _GSS_union_set_create (void);
223 * Evaluate a union operation with
226 * @param m the evaluate request message from the client
227 * @parem set the set to evaluate the operation with
230 _GSS_union_evaluate (struct EvaluateMessage *m, struct Set *set);
234 * Add the element from the given element message to the set.
236 * @param m message with the element
237 * @param set set to add the element to
240 _GSS_union_add (struct ElementMessage *m, struct Set *set);
244 * Remove the element given in the element message from the set.
245 * Only marks the element as removed, so that older set operations can still exchange it.
247 * @param m message with the element
248 * @param set set to remove the element from
251 _GSS_union_remove (struct ElementMessage *m, struct Set *set);
255 * Accept an union operation request from a remote peer
257 * @param m the accept message from the client
258 * @param set the set of the client
259 * @param incoming information about the requesting remote peer
262 _GSS_union_accept (struct AcceptMessage *m, struct Set *set,
263 struct Incoming *incoming);