diff options
author | Florian Dold <florian.dold@gmail.com> | 2013-06-26 10:06:52 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2013-06-26 10:06:52 +0000 |
commit | 23479fc50d94f0c29cad3b92fe8fc53e358d4025 (patch) | |
tree | 240efe571ce83c65ac27b5d885c6c2a71e61117f /src/set/gnunet-service-set.h | |
parent | f5a3f1dc90c9949c8c426f2cb2e822603b137dae (diff) | |
download | gnunet-23479fc50d94f0c29cad3b92fe8fc53e358d4025.tar.gz gnunet-23479fc50d94f0c29cad3b92fe8fc53e358d4025.zip |
- fixed tunnel context
- moved logic out of specific operations
Diffstat (limited to 'src/set/gnunet-service-set.h')
-rw-r--r-- | src/set/gnunet-service-set.h | 173 |
1 files changed, 93 insertions, 80 deletions
diff --git a/src/set/gnunet-service-set.h b/src/set/gnunet-service-set.h index 533fd0ef7..574b343d6 100644 --- a/src/set/gnunet-service-set.h +++ b/src/set/gnunet-service-set.h | |||
@@ -42,14 +42,22 @@ | |||
42 | struct IntersectionState; | 42 | struct IntersectionState; |
43 | 43 | ||
44 | 44 | ||
45 | /* FIXME: cfuchs */ | ||
46 | struct IntersectionOperation; | ||
47 | |||
48 | |||
45 | /** | 49 | /** |
46 | * Extra state required for set union. | 50 | * Extra state required for set union. |
47 | */ | 51 | */ |
48 | struct UnionState; | 52 | struct UnionState; |
49 | 53 | ||
54 | /** | ||
55 | * State of a union operation being evaluated. | ||
56 | */ | ||
50 | struct UnionEvaluateOperation; | 57 | struct UnionEvaluateOperation; |
51 | 58 | ||
52 | 59 | ||
60 | |||
53 | /** | 61 | /** |
54 | * A set that supports a specific operation | 62 | * A set that supports a specific operation |
55 | * with other peers. | 63 | * with other peers. |
@@ -94,6 +102,50 @@ struct Set | |||
94 | 102 | ||
95 | 103 | ||
96 | /** | 104 | /** |
105 | * Detail information about an operation. | ||
106 | */ | ||
107 | struct OperationSpecification | ||
108 | { | ||
109 | /** | ||
110 | * The type of the operation. | ||
111 | */ | ||
112 | enum GNUNET_SET_OperationType operation; | ||
113 | |||
114 | /** | ||
115 | * The remove peer we evaluate the operation with | ||
116 | */ | ||
117 | struct GNUNET_PeerIdentity peer; | ||
118 | |||
119 | /** | ||
120 | * Application ID for the operation, used to distinguish | ||
121 | * multiple operations of the same type with the same peer. | ||
122 | */ | ||
123 | struct GNUNET_HashCode app_id; | ||
124 | |||
125 | /** | ||
126 | * Context message, may be NULL. | ||
127 | */ | ||
128 | struct GNUNET_MessageHeader *context_msg; | ||
129 | |||
130 | /** | ||
131 | * Salt to use for the operation. | ||
132 | */ | ||
133 | uint32_t salt; | ||
134 | |||
135 | /** | ||
136 | * ID used to identify responses to a client. | ||
137 | */ | ||
138 | uint32_t client_request_id; | ||
139 | |||
140 | /** | ||
141 | * Set associated with the operation, NULL until the spec has been associated | ||
142 | * with a set. | ||
143 | */ | ||
144 | struct Set *set; | ||
145 | }; | ||
146 | |||
147 | |||
148 | /** | ||
97 | * A listener is inhabited by a client, and | 149 | * A listener is inhabited by a client, and |
98 | * waits for evaluation requests from remote peers. | 150 | * waits for evaluation requests from remote peers. |
99 | */ | 151 | */ |
@@ -121,12 +173,13 @@ struct Listener | |||
121 | struct GNUNET_MQ_Handle *client_mq; | 173 | struct GNUNET_MQ_Handle *client_mq; |
122 | 174 | ||
123 | /** | 175 | /** |
124 | * Type of operation supported for this set | 176 | * The type of the operation. |
125 | */ | 177 | */ |
126 | enum GNUNET_SET_OperationType operation; | 178 | enum GNUNET_SET_OperationType operation; |
127 | 179 | ||
128 | /** | 180 | /** |
129 | * Application id of intereset for this listener. | 181 | * Application ID for the operation, used to distinguish |
182 | * multiple operations of the same type with the same peer. | ||
130 | */ | 183 | */ |
131 | struct GNUNET_HashCode app_id; | 184 | struct GNUNET_HashCode app_id; |
132 | }; | 185 | }; |
@@ -137,79 +190,51 @@ struct Listener | |||
137 | * Once the peer has sent a request, and the client has | 190 | * Once the peer has sent a request, and the client has |
138 | * accepted or rejected it, this information will be deleted. | 191 | * accepted or rejected it, this information will be deleted. |
139 | */ | 192 | */ |
140 | struct Incoming | 193 | struct Incoming; |
141 | { | ||
142 | /** | ||
143 | * Incoming peers are held in a linked list | ||
144 | */ | ||
145 | struct Incoming *next; | ||
146 | |||
147 | /** | ||
148 | * Incoming peers are held in a linked list | ||
149 | */ | ||
150 | struct Incoming *prev; | ||
151 | 194 | ||
152 | /** | ||
153 | * Tunnel context, stores information about | ||
154 | * the tunnel and its peer. | ||
155 | */ | ||
156 | struct TunnelContext *tc; | ||
157 | |||
158 | /** | ||
159 | * GNUNET_YES if the incoming peer has sent | ||
160 | * an operation request (and we are waiting | ||
161 | * for the client to ack/nack), GNUNET_NO otherwise. | ||
162 | */ | ||
163 | int received_request; | ||
164 | 195 | ||
196 | /** | ||
197 | * Different types a tunnel can be. | ||
198 | */ | ||
199 | enum TunnelContextType { | ||
165 | /** | 200 | /** |
166 | * App code, set once the peer has | 201 | * Tunnel is waiting for a set request from the tunnel, |
167 | * requested an operation | 202 | * or for the ack/nack of the client for a received request. |
168 | */ | 203 | */ |
169 | struct GNUNET_HashCode app_id; | 204 | CONTEXT_INCOMING, |
170 | 205 | ||
171 | /** | 206 | /** |
172 | * Context message, set once the peer | 207 | * The tunnel performs a union operation. |
173 | * has requested an operation. | ||
174 | */ | 208 | */ |
175 | struct GNUNET_MessageHeader *context_msg; | 209 | CONTEXT_OPERATION_UNION, |
176 | 210 | ||
177 | /** | 211 | /** |
178 | * Salt the peer has requested to use for the | 212 | * The tunnel performs an intersection operation. |
179 | * operation | ||
180 | */ | 213 | */ |
181 | uint16_t salt; | 214 | CONTEXT_OPERATION_INTERSECTION, |
215 | }; | ||
182 | 216 | ||
183 | /** | ||
184 | * Operation the other peer wants to do | ||
185 | */ | ||
186 | enum GNUNET_SET_OperationType operation; | ||
187 | 217 | ||
218 | /** | ||
219 | * State associated with the tunnel, dependent on | ||
220 | * tunnel type. | ||
221 | */ | ||
222 | union TunnelContextData | ||
223 | { | ||
188 | /** | 224 | /** |
189 | * Has the incoming request been suggested to | 225 | * Valid for tag 'CONTEXT_INCOMING' |
190 | * a client listener yet? | ||
191 | */ | 226 | */ |
192 | int suggested; | 227 | struct Incoming *incoming; |
193 | 228 | ||
194 | /** | 229 | /** |
195 | * Unique request id for the request from | 230 | * Valid for tag 'CONTEXT_OPERATION_UNION' |
196 | * a remote peer, sent to the client, which will | ||
197 | * accept or reject the request. | ||
198 | */ | 231 | */ |
199 | uint32_t accept_id; | 232 | struct UnionEvaluateOperation *union_op; |
200 | 233 | ||
201 | /** | 234 | /** |
202 | * Timeout task, if the incoming peer has not been accepted | 235 | * Valid for tag 'CONTEXT_OPERATION_INTERSECTION' |
203 | * after the timeout, it will be disconnected. | ||
204 | */ | 236 | */ |
205 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 237 | struct IntersectionEvaluateOperation *intersection_op; |
206 | }; | ||
207 | |||
208 | |||
209 | enum TunnelContextType { | ||
210 | CONTEXT_INCOMING, | ||
211 | CONTEXT_OPERATION_UNION, | ||
212 | CONTEXT_OPERATION_INTERSECTION, | ||
213 | }; | 238 | }; |
214 | 239 | ||
215 | /** | 240 | /** |
@@ -219,21 +244,6 @@ enum TunnelContextType { | |||
219 | struct TunnelContext | 244 | struct TunnelContext |
220 | { | 245 | { |
221 | /** | 246 | /** |
222 | * The mesh tunnel that has this context | ||
223 | */ | ||
224 | struct GNUNET_MESH_Tunnel *tunnel; | ||
225 | |||
226 | /** | ||
227 | * The peer on the other side. | ||
228 | */ | ||
229 | struct GNUNET_PeerIdentity peer; | ||
230 | |||
231 | /** | ||
232 | * Handle to the message queue for the tunnel. | ||
233 | */ | ||
234 | struct GNUNET_MQ_Handle *mq; | ||
235 | |||
236 | /** | ||
237 | * Type of the tunnel. | 247 | * Type of the tunnel. |
238 | */ | 248 | */ |
239 | enum TunnelContextType type; | 249 | enum TunnelContextType type; |
@@ -242,7 +252,7 @@ struct TunnelContext | |||
242 | * State associated with the tunnel, dependent on | 252 | * State associated with the tunnel, dependent on |
243 | * tunnel type. | 253 | * tunnel type. |
244 | */ | 254 | */ |
245 | void *data; | 255 | union TunnelContextData data; |
246 | }; | 256 | }; |
247 | 257 | ||
248 | 258 | ||
@@ -268,11 +278,14 @@ _GSS_union_set_create (void); | |||
268 | * Evaluate a union operation with | 278 | * Evaluate a union operation with |
269 | * a remote peer. | 279 | * a remote peer. |
270 | * | 280 | * |
271 | * @param m the evaluate request message from the client | 281 | * @param spec specification of the operation the evaluate |
282 | * @param tunnel tunnel already connected to the partner peer | ||
272 | * @param set the set to evaluate the operation with | 283 | * @param set the set to evaluate the operation with |
284 | * @return a handle to the operation | ||
273 | */ | 285 | */ |
274 | void | 286 | struct UnionEvaluateOperation * |
275 | _GSS_union_evaluate (struct GNUNET_SET_EvaluateMessage *m, struct Set *set); | 287 | _GSS_union_evaluate (struct OperationSpecification *spec, |
288 | struct GNUNET_MESH_Tunnel *tunnel); | ||
276 | 289 | ||
277 | 290 | ||
278 | /** | 291 | /** |
@@ -308,13 +321,13 @@ _GSS_union_set_destroy (struct Set *set); | |||
308 | /** | 321 | /** |
309 | * Accept an union operation request from a remote peer | 322 | * Accept an union operation request from a remote peer |
310 | * | 323 | * |
311 | * @param m the accept message from the client | 324 | * @param spec all necessary information about the operation |
312 | * @param set the set of the client | 325 | * @param tunnel open tunnel to the partner's peer |
313 | * @param incoming information about the requesting remote peer | 326 | * @return operation |
314 | */ | 327 | */ |
315 | void | 328 | struct UnionEvaluateOperation * |
316 | _GSS_union_accept (struct GNUNET_SET_AcceptRejectMessage *m, struct Set *set, | 329 | _GSS_union_accept (struct OperationSpecification *spec, |
317 | struct Incoming *incoming); | 330 | struct GNUNET_MESH_Tunnel *tunnel); |
318 | 331 | ||
319 | 332 | ||
320 | /** | 333 | /** |