diff options
Diffstat (limited to 'src/set/set_api.c')
-rw-r--r-- | src/set/set_api.c | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/src/set/set_api.c b/src/set/set_api.c index c74933aa0..e1b6132cb 100644 --- a/src/set/set_api.c +++ b/src/set/set_api.c | |||
@@ -40,7 +40,7 @@ | |||
40 | struct GNUNET_SET_Handle | 40 | struct GNUNET_SET_Handle |
41 | { | 41 | { |
42 | struct GNUNET_CLIENT_Connection *client; | 42 | struct GNUNET_CLIENT_Connection *client; |
43 | struct GNUNET_MQ_MessageQueue *mq; | 43 | struct GNUNET_MQ_Handle *mq; |
44 | unsigned int messages_since_ack; | 44 | unsigned int messages_since_ack; |
45 | }; | 45 | }; |
46 | 46 | ||
@@ -73,7 +73,7 @@ struct GNUNET_SET_OperationHandle | |||
73 | * Message sent to the server on calling conclude, | 73 | * Message sent to the server on calling conclude, |
74 | * NULL if conclude has been called. | 74 | * NULL if conclude has been called. |
75 | */ | 75 | */ |
76 | struct GNUNET_MQ_Message *conclude_mqm; | 76 | struct GNUNET_MQ_Envelope *conclude_mqm; |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Address of the request if in the conclude message, | 79 | * Address of the request if in the conclude message, |
@@ -89,7 +89,7 @@ struct GNUNET_SET_OperationHandle | |||
89 | struct GNUNET_SET_ListenHandle | 89 | struct GNUNET_SET_ListenHandle |
90 | { | 90 | { |
91 | struct GNUNET_CLIENT_Connection *client; | 91 | struct GNUNET_CLIENT_Connection *client; |
92 | struct GNUNET_MQ_MessageQueue* mq; | 92 | struct GNUNET_MQ_Handle* mq; |
93 | GNUNET_SET_ListenCallback listen_cb; | 93 | GNUNET_SET_ListenCallback listen_cb; |
94 | void *listen_cls; | 94 | void *listen_cls; |
95 | }; | 95 | }; |
@@ -115,7 +115,7 @@ handle_result (void *cls, const struct GNUNET_MessageHeader *mh) | |||
115 | 115 | ||
116 | if (set->messages_since_ack >= GNUNET_SET_ACK_WINDOW/2) | 116 | if (set->messages_since_ack >= GNUNET_SET_ACK_WINDOW/2) |
117 | { | 117 | { |
118 | struct GNUNET_MQ_Message *mqm; | 118 | struct GNUNET_MQ_Envelope *mqm; |
119 | mqm = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_ACK); | 119 | mqm = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_ACK); |
120 | GNUNET_MQ_send (set->mq, mqm); | 120 | GNUNET_MQ_send (set->mq, mqm); |
121 | } | 121 | } |
@@ -162,7 +162,7 @@ handle_request (void *cls, const struct GNUNET_MessageHeader *mh) | |||
162 | 162 | ||
163 | if (GNUNET_NO == req->accepted) | 163 | if (GNUNET_NO == req->accepted) |
164 | { | 164 | { |
165 | struct GNUNET_MQ_Message *mqm; | 165 | struct GNUNET_MQ_Envelope *mqm; |
166 | struct GNUNET_SET_AcceptRejectMessage *amsg; | 166 | struct GNUNET_SET_AcceptRejectMessage *amsg; |
167 | 167 | ||
168 | mqm = GNUNET_MQ_msg (amsg, GNUNET_MESSAGE_TYPE_SET_REJECT); | 168 | mqm = GNUNET_MQ_msg (amsg, GNUNET_MESSAGE_TYPE_SET_REJECT); |
@@ -197,9 +197,9 @@ GNUNET_SET_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
197 | enum GNUNET_SET_OperationType op) | 197 | enum GNUNET_SET_OperationType op) |
198 | { | 198 | { |
199 | struct GNUNET_SET_Handle *set; | 199 | struct GNUNET_SET_Handle *set; |
200 | struct GNUNET_MQ_Message *mqm; | 200 | struct GNUNET_MQ_Envelope *mqm; |
201 | struct GNUNET_SET_CreateMessage *msg; | 201 | struct GNUNET_SET_CreateMessage *msg; |
202 | static const struct GNUNET_MQ_Handler mq_handlers[] = { | 202 | static const struct GNUNET_MQ_MessageHandler mq_handlers[] = { |
203 | {handle_result, GNUNET_MESSAGE_TYPE_SET_RESULT}, | 203 | {handle_result, GNUNET_MESSAGE_TYPE_SET_RESULT}, |
204 | GNUNET_MQ_HANDLERS_END | 204 | GNUNET_MQ_HANDLERS_END |
205 | }; | 205 | }; |
@@ -234,7 +234,7 @@ GNUNET_SET_add_element (struct GNUNET_SET_Handle *set, | |||
234 | GNUNET_SET_Continuation cont, | 234 | GNUNET_SET_Continuation cont, |
235 | void *cont_cls) | 235 | void *cont_cls) |
236 | { | 236 | { |
237 | struct GNUNET_MQ_Message *mqm; | 237 | struct GNUNET_MQ_Envelope *mqm; |
238 | struct GNUNET_SET_ElementMessage *msg; | 238 | struct GNUNET_SET_ElementMessage *msg; |
239 | 239 | ||
240 | mqm = GNUNET_MQ_msg_extra (msg, element->size, GNUNET_MESSAGE_TYPE_SET_ADD); | 240 | mqm = GNUNET_MQ_msg_extra (msg, element->size, GNUNET_MESSAGE_TYPE_SET_ADD); |
@@ -262,7 +262,7 @@ GNUNET_SET_remove_element (struct GNUNET_SET_Handle *set, | |||
262 | GNUNET_SET_Continuation cont, | 262 | GNUNET_SET_Continuation cont, |
263 | void *cont_cls) | 263 | void *cont_cls) |
264 | { | 264 | { |
265 | struct GNUNET_MQ_Message *mqm; | 265 | struct GNUNET_MQ_Envelope *mqm; |
266 | struct GNUNET_SET_ElementMessage *msg; | 266 | struct GNUNET_SET_ElementMessage *msg; |
267 | 267 | ||
268 | mqm = GNUNET_MQ_msg_extra (msg, element->size, GNUNET_MESSAGE_TYPE_SET_REMOVE); | 268 | mqm = GNUNET_MQ_msg_extra (msg, element->size, GNUNET_MESSAGE_TYPE_SET_REMOVE); |
@@ -287,9 +287,9 @@ GNUNET_SET_destroy (struct GNUNET_SET_Handle *set) | |||
287 | 287 | ||
288 | 288 | ||
289 | /** | 289 | /** |
290 | * Create a set operation for evaluation with another peer. | 290 | * Prepare a set operation to be evaluated with another peer. |
291 | * The evaluation will not start until the client provides | 291 | * The evaluation will not start until the client provides |
292 | * a local set with GNUNET_SET_conclude. | 292 | * a local set with GNUNET_SET_commit. |
293 | * | 293 | * |
294 | * @param other_peer peer with the other set | 294 | * @param other_peer peer with the other set |
295 | * @param app_id hash for the application using the set | 295 | * @param app_id hash for the application using the set |
@@ -304,15 +304,15 @@ GNUNET_SET_destroy (struct GNUNET_SET_Handle *set) | |||
304 | * @return a handle to cancel the operation | 304 | * @return a handle to cancel the operation |
305 | */ | 305 | */ |
306 | struct GNUNET_SET_OperationHandle * | 306 | struct GNUNET_SET_OperationHandle * |
307 | GNUNET_SET_evaluate (const struct GNUNET_PeerIdentity *other_peer, | 307 | GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, |
308 | const struct GNUNET_HashCode *app_id, | 308 | const struct GNUNET_HashCode *app_id, |
309 | const struct GNUNET_MessageHeader *context_msg, | 309 | const struct GNUNET_MessageHeader *context_msg, |
310 | uint16_t salt, | 310 | uint16_t salt, |
311 | enum GNUNET_SET_ResultMode result_mode, | 311 | enum GNUNET_SET_ResultMode result_mode, |
312 | GNUNET_SET_ResultIterator result_cb, | 312 | GNUNET_SET_ResultIterator result_cb, |
313 | void *result_cls) | 313 | void *result_cls) |
314 | { | 314 | { |
315 | struct GNUNET_MQ_Message *mqm; | 315 | struct GNUNET_MQ_Envelope *mqm; |
316 | struct GNUNET_SET_OperationHandle *oh; | 316 | struct GNUNET_SET_OperationHandle *oh; |
317 | struct GNUNET_SET_EvaluateMessage *msg; | 317 | struct GNUNET_SET_EvaluateMessage *msg; |
318 | 318 | ||
@@ -322,9 +322,6 @@ GNUNET_SET_evaluate (const struct GNUNET_PeerIdentity *other_peer, | |||
322 | 322 | ||
323 | mqm = GNUNET_MQ_msg_nested_mh (msg, GNUNET_MESSAGE_TYPE_SET_EVALUATE, context_msg); | 323 | mqm = GNUNET_MQ_msg_nested_mh (msg, GNUNET_MESSAGE_TYPE_SET_EVALUATE, context_msg); |
324 | 324 | ||
325 | if (NULL != context_msg) | ||
326 | LOG (GNUNET_ERROR_TYPE_INFO, "passed context msg\n"); | ||
327 | |||
328 | msg->app_id = *app_id; | 325 | msg->app_id = *app_id; |
329 | msg->target_peer = *other_peer; | 326 | msg->target_peer = *other_peer; |
330 | msg->salt = salt; | 327 | msg->salt = salt; |
@@ -356,9 +353,9 @@ GNUNET_SET_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
356 | void *listen_cls) | 353 | void *listen_cls) |
357 | { | 354 | { |
358 | struct GNUNET_SET_ListenHandle *lh; | 355 | struct GNUNET_SET_ListenHandle *lh; |
359 | struct GNUNET_MQ_Message *mqm; | 356 | struct GNUNET_MQ_Envelope *mqm; |
360 | struct GNUNET_SET_ListenMessage *msg; | 357 | struct GNUNET_SET_ListenMessage *msg; |
361 | static const struct GNUNET_MQ_Handler mq_handlers[] = { | 358 | static const struct GNUNET_MQ_MessageHandler mq_handlers[] = { |
362 | {handle_request, GNUNET_MESSAGE_TYPE_SET_REQUEST}, | 359 | {handle_request, GNUNET_MESSAGE_TYPE_SET_REQUEST}, |
363 | GNUNET_MQ_HANDLERS_END | 360 | GNUNET_MQ_HANDLERS_END |
364 | }; | 361 | }; |
@@ -403,7 +400,7 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh) | |||
403 | * @param result_mode specified how results will be returned, | 400 | * @param result_mode specified how results will be returned, |
404 | * see 'GNUNET_SET_ResultMode'. | 401 | * see 'GNUNET_SET_ResultMode'. |
405 | * @param result_cb callback for the results | 402 | * @param result_cb callback for the results |
406 | * @param result_cls closure for result_cb | 403 | * @param cls closure for result_cb |
407 | * @return a handle to cancel the operation | 404 | * @return a handle to cancel the operation |
408 | */ | 405 | */ |
409 | struct GNUNET_SET_OperationHandle * | 406 | struct GNUNET_SET_OperationHandle * |
@@ -412,7 +409,7 @@ GNUNET_SET_accept (struct GNUNET_SET_Request *request, | |||
412 | GNUNET_SET_ResultIterator result_cb, | 409 | GNUNET_SET_ResultIterator result_cb, |
413 | void *cls) | 410 | void *cls) |
414 | { | 411 | { |
415 | struct GNUNET_MQ_Message *mqm; | 412 | struct GNUNET_MQ_Envelope *mqm; |
416 | struct GNUNET_SET_OperationHandle *oh; | 413 | struct GNUNET_SET_OperationHandle *oh; |
417 | struct GNUNET_SET_AcceptRejectMessage *msg; | 414 | struct GNUNET_SET_AcceptRejectMessage *msg; |
418 | 415 | ||
@@ -441,7 +438,7 @@ GNUNET_SET_accept (struct GNUNET_SET_Request *request, | |||
441 | void | 438 | void |
442 | GNUNET_SET_operation_cancel (struct GNUNET_SET_OperationHandle *oh) | 439 | GNUNET_SET_operation_cancel (struct GNUNET_SET_OperationHandle *oh) |
443 | { | 440 | { |
444 | struct GNUNET_MQ_Message *mqm; | 441 | struct GNUNET_MQ_Envelope *mqm; |
445 | struct GNUNET_SET_OperationHandle *h_assoc; | 442 | struct GNUNET_SET_OperationHandle *h_assoc; |
446 | 443 | ||
447 | if (NULL != oh->set) | 444 | if (NULL != oh->set) |
@@ -460,7 +457,7 @@ GNUNET_SET_operation_cancel (struct GNUNET_SET_OperationHandle *oh) | |||
460 | 457 | ||
461 | 458 | ||
462 | /** | 459 | /** |
463 | * Conclude the given set operation using the given set. | 460 | * Commit a set to be used with a set operation. |
464 | * This function is called once we have fully constructed | 461 | * This function is called once we have fully constructed |
465 | * the set that we want to use for the operation. At this | 462 | * the set that we want to use for the operation. At this |
466 | * time, the P2P protocol can then begin to exchange the | 463 | * time, the P2P protocol can then begin to exchange the |
@@ -471,13 +468,13 @@ GNUNET_SET_operation_cancel (struct GNUNET_SET_OperationHandle *oh) | |||
471 | * @param set the set to use for the operation | 468 | * @param set the set to use for the operation |
472 | */ | 469 | */ |
473 | void | 470 | void |
474 | GNUNET_SET_conclude (struct GNUNET_SET_OperationHandle *oh, | 471 | GNUNET_SET_commit (struct GNUNET_SET_OperationHandle *oh, |
475 | struct GNUNET_SET_Handle *set) | 472 | struct GNUNET_SET_Handle *set) |
476 | { | 473 | { |
477 | GNUNET_assert (NULL == oh->set); | 474 | GNUNET_assert (NULL == oh->set); |
478 | GNUNET_assert (NULL != oh->conclude_mqm); | 475 | GNUNET_assert (NULL != oh->conclude_mqm); |
479 | oh->set = set; | 476 | oh->set = set; |
480 | oh->request_id = GNUNET_MQ_assoc_add (oh->set->mq, NULL, oh); | 477 | oh->request_id = GNUNET_MQ_assoc_add (oh->set->mq, oh); |
481 | *oh->request_id_addr = htonl (oh->request_id); | 478 | *oh->request_id_addr = htonl (oh->request_id); |
482 | GNUNET_MQ_send (oh->set->mq, oh->conclude_mqm); | 479 | GNUNET_MQ_send (oh->set->mq, oh->conclude_mqm); |
483 | oh->conclude_mqm = NULL; | 480 | oh->conclude_mqm = NULL; |