diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-11-27 09:50:41 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-11-27 09:50:41 +0000 |
commit | 44bb721ef043f99e97d60231438b9e71104d99d7 (patch) | |
tree | 476330cbfe2031fa3e3daecf8bf3c45a5156b800 /src/set/set_api.c | |
parent | bf716069e987193e1ee0d06bbc4af245e6ffa821 (diff) | |
download | gnunet-44bb721ef043f99e97d60231438b9e71104d99d7.tar.gz gnunet-44bb721ef043f99e97d60231438b9e71104d99d7.zip |
eliminating useless salt argument, salt can be generated inside of gnunet-service-set
Diffstat (limited to 'src/set/set_api.c')
-rw-r--r-- | src/set/set_api.c | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/src/set/set_api.c b/src/set/set_api.c index 0c9df22e4..10421ebda 100644 --- a/src/set/set_api.c +++ b/src/set/set_api.c | |||
@@ -319,14 +319,16 @@ handle_result (void *cls, const struct GNUNET_MessageHeader *mh) | |||
319 | * @param mh the message | 319 | * @param mh the message |
320 | */ | 320 | */ |
321 | static void | 321 | static void |
322 | handle_request (void *cls, const struct GNUNET_MessageHeader *mh) | 322 | handle_request (void *cls, |
323 | const struct GNUNET_MessageHeader *mh) | ||
323 | { | 324 | { |
324 | const struct GNUNET_SET_RequestMessage *msg = (const struct GNUNET_SET_RequestMessage *) mh; | 325 | const struct GNUNET_SET_RequestMessage *msg = (const struct GNUNET_SET_RequestMessage *) mh; |
325 | struct GNUNET_SET_ListenHandle *lh = cls; | 326 | struct GNUNET_SET_ListenHandle *lh = cls; |
326 | struct GNUNET_SET_Request *req; | 327 | struct GNUNET_SET_Request *req; |
327 | struct GNUNET_MessageHeader *context_msg; | 328 | struct GNUNET_MessageHeader *context_msg; |
328 | 329 | ||
329 | LOG (GNUNET_ERROR_TYPE_DEBUG, "processing operation request\n"); | 330 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
331 | "processing operation request\n"); | ||
330 | req = GNUNET_new (struct GNUNET_SET_Request); | 332 | req = GNUNET_new (struct GNUNET_SET_Request); |
331 | req->accept_id = ntohl (msg->accept_id); | 333 | req->accept_id = ntohl (msg->accept_id); |
332 | context_msg = GNUNET_MQ_extract_nested_mh (msg); | 334 | context_msg = GNUNET_MQ_extract_nested_mh (msg); |
@@ -339,18 +341,21 @@ handle_request (void *cls, const struct GNUNET_MessageHeader *mh) | |||
339 | if (GNUNET_NO == req->accepted) | 341 | if (GNUNET_NO == req->accepted) |
340 | { | 342 | { |
341 | struct GNUNET_MQ_Envelope *mqm; | 343 | struct GNUNET_MQ_Envelope *mqm; |
342 | struct GNUNET_SET_AcceptRejectMessage *amsg; | 344 | struct GNUNET_SET_RejectMessage *rmsg; |
343 | 345 | ||
344 | mqm = GNUNET_MQ_msg (amsg, GNUNET_MESSAGE_TYPE_SET_REJECT); | 346 | mqm = GNUNET_MQ_msg (rmsg, |
347 | GNUNET_MESSAGE_TYPE_SET_REJECT); | ||
345 | /* no request id, as we refused */ | 348 | /* no request id, as we refused */ |
346 | amsg->request_id = htonl (0); | 349 | rmsg->request_id = htonl (0); |
347 | amsg->accept_reject_id = msg->accept_id; | 350 | rmsg->accept_reject_id = msg->accept_id; |
348 | GNUNET_MQ_send (lh->mq, mqm); | 351 | GNUNET_MQ_send (lh->mq, mqm); |
349 | LOG (GNUNET_ERROR_TYPE_DEBUG, "rejecting request\n"); | 352 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
353 | "rejecting request\n"); | ||
350 | } | 354 | } |
351 | GNUNET_free (req); | 355 | GNUNET_free (req); |
352 | 356 | ||
353 | LOG (GNUNET_ERROR_TYPE_DEBUG, "processed op request from service\n"); | 357 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
358 | "processed op request from service\n"); | ||
354 | 359 | ||
355 | /* the accept-case is handled in GNUNET_SET_accept, | 360 | /* the accept-case is handled in GNUNET_SET_accept, |
356 | * as we have the accept message available there */ | 361 | * as we have the accept message available there */ |
@@ -362,13 +367,14 @@ handle_client_listener_error (void *cls, enum GNUNET_MQ_Error error) | |||
362 | { | 367 | { |
363 | struct GNUNET_SET_ListenHandle *lh = cls; | 368 | struct GNUNET_SET_ListenHandle *lh = cls; |
364 | 369 | ||
365 | LOG (GNUNET_ERROR_TYPE_DEBUG, "listener broke down, re-connecting\n"); | 370 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
371 | "listener broke down, re-connecting\n"); | ||
366 | GNUNET_CLIENT_disconnect (lh->client); | 372 | GNUNET_CLIENT_disconnect (lh->client); |
367 | lh->client = NULL; | 373 | lh->client = NULL; |
368 | GNUNET_MQ_destroy (lh->mq); | 374 | GNUNET_MQ_destroy (lh->mq); |
369 | lh->mq = NULL; | 375 | lh->mq = NULL; |
370 | 376 | lh->reconnect_task = GNUNET_SCHEDULER_add_delayed (lh->reconnect_backoff, | |
371 | lh->reconnect_task = GNUNET_SCHEDULER_add_delayed (lh->reconnect_backoff, listen_connect, lh); | 377 | &listen_connect, lh); |
372 | lh->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (lh->reconnect_backoff); | 378 | lh->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (lh->reconnect_backoff); |
373 | } | 379 | } |
374 | 380 | ||
@@ -492,15 +498,15 @@ struct GNUNET_SET_Handle * | |||
492 | GNUNET_SET_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | 498 | GNUNET_SET_create (const struct GNUNET_CONFIGURATION_Handle *cfg, |
493 | enum GNUNET_SET_OperationType op) | 499 | enum GNUNET_SET_OperationType op) |
494 | { | 500 | { |
495 | struct GNUNET_SET_Handle *set; | ||
496 | struct GNUNET_MQ_Envelope *mqm; | ||
497 | struct GNUNET_SET_CreateMessage *msg; | ||
498 | static const struct GNUNET_MQ_MessageHandler mq_handlers[] = { | 501 | static const struct GNUNET_MQ_MessageHandler mq_handlers[] = { |
499 | {handle_result, GNUNET_MESSAGE_TYPE_SET_RESULT, 0}, | 502 | {handle_result, GNUNET_MESSAGE_TYPE_SET_RESULT, 0}, |
500 | {handle_iter_element, GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT, 0}, | 503 | {handle_iter_element, GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT, 0}, |
501 | {handle_iter_done, GNUNET_MESSAGE_TYPE_SET_ITER_DONE, 0}, | 504 | {handle_iter_done, GNUNET_MESSAGE_TYPE_SET_ITER_DONE, 0}, |
502 | GNUNET_MQ_HANDLERS_END | 505 | GNUNET_MQ_HANDLERS_END |
503 | }; | 506 | }; |
507 | struct GNUNET_SET_Handle *set; | ||
508 | struct GNUNET_MQ_Envelope *mqm; | ||
509 | struct GNUNET_SET_CreateMessage *msg; | ||
504 | 510 | ||
505 | set = GNUNET_new (struct GNUNET_SET_Handle); | 511 | set = GNUNET_new (struct GNUNET_SET_Handle); |
506 | set->client = GNUNET_CLIENT_connect ("set", cfg); | 512 | set->client = GNUNET_CLIENT_connect ("set", cfg); |
@@ -510,7 +516,7 @@ GNUNET_SET_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
510 | handle_client_set_error, set); | 516 | handle_client_set_error, set); |
511 | GNUNET_assert (NULL != set->mq); | 517 | GNUNET_assert (NULL != set->mq); |
512 | mqm = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_CREATE); | 518 | mqm = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_CREATE); |
513 | msg->operation = htons (op); | 519 | msg->operation = htonl (op); |
514 | GNUNET_MQ_send (set->mq, mqm); | 520 | GNUNET_MQ_send (set->mq, mqm); |
515 | return set; | 521 | return set; |
516 | } | 522 | } |
@@ -607,25 +613,21 @@ GNUNET_SET_destroy (struct GNUNET_SET_Handle *set) | |||
607 | /** | 613 | /** |
608 | * Prepare a set operation to be evaluated with another peer. | 614 | * Prepare a set operation to be evaluated with another peer. |
609 | * The evaluation will not start until the client provides | 615 | * The evaluation will not start until the client provides |
610 | * a local set with GNUNET_SET_commit. | 616 | * a local set with #GNUNET_SET_commit(). |
611 | * | 617 | * |
612 | * @param other_peer peer with the other set | 618 | * @param other_peer peer with the other set |
613 | * @param app_id hash for the application using the set | 619 | * @param app_id hash for the application using the set |
614 | * @param context_msg additional information for the request | 620 | * @param context_msg additional information for the request |
615 | * @param salt salt used for the set operation; sometimes set operations | ||
616 | * fail due to hash collisions, using a different salt for each operation | ||
617 | * makes it harder for an attacker to exploit this | ||
618 | * @param result_mode specified how results will be returned, | 621 | * @param result_mode specified how results will be returned, |
619 | * see 'GNUNET_SET_ResultMode'. | 622 | * see `enum GNUNET_SET_ResultMode`. |
620 | * @param result_cb called on error or success | 623 | * @param result_cb called on error or success |
621 | * @param result_cls closure for result_cb | 624 | * @param result_cls closure for @e result_cb |
622 | * @return a handle to cancel the operation | 625 | * @return a handle to cancel the operation |
623 | */ | 626 | */ |
624 | struct GNUNET_SET_OperationHandle * | 627 | struct GNUNET_SET_OperationHandle * |
625 | GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, | 628 | GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, |
626 | const struct GNUNET_HashCode *app_id, | 629 | const struct GNUNET_HashCode *app_id, |
627 | const struct GNUNET_MessageHeader *context_msg, | 630 | const struct GNUNET_MessageHeader *context_msg, |
628 | uint16_t salt, | ||
629 | enum GNUNET_SET_ResultMode result_mode, | 631 | enum GNUNET_SET_ResultMode result_mode, |
630 | GNUNET_SET_ResultIterator result_cb, | 632 | GNUNET_SET_ResultIterator result_cb, |
631 | void *result_cls) | 633 | void *result_cls) |
@@ -638,12 +640,12 @@ GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, | |||
638 | oh->result_cb = result_cb; | 640 | oh->result_cb = result_cb; |
639 | oh->result_cls = result_cls; | 641 | oh->result_cls = result_cls; |
640 | 642 | ||
641 | mqm = GNUNET_MQ_msg_nested_mh (msg, GNUNET_MESSAGE_TYPE_SET_EVALUATE, context_msg); | 643 | mqm = GNUNET_MQ_msg_nested_mh (msg, |
642 | 644 | GNUNET_MESSAGE_TYPE_SET_EVALUATE, | |
645 | context_msg); | ||
643 | msg->app_id = *app_id; | 646 | msg->app_id = *app_id; |
644 | msg->result_mode = htons (result_mode); | 647 | msg->result_mode = htonl (result_mode); |
645 | msg->target_peer = *other_peer; | 648 | msg->target_peer = *other_peer; |
646 | msg->salt = salt; | ||
647 | oh->conclude_mqm = mqm; | 649 | oh->conclude_mqm = mqm; |
648 | oh->request_id_addr = &msg->request_id; | 650 | oh->request_id_addr = &msg->request_id; |
649 | 651 | ||
@@ -767,9 +769,9 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh) | |||
767 | * | 769 | * |
768 | * @param request request to accept | 770 | * @param request request to accept |
769 | * @param result_mode specified how results will be returned, | 771 | * @param result_mode specified how results will be returned, |
770 | * see 'GNUNET_SET_ResultMode'. | 772 | * see `enum GNUNET_SET_ResultMode`. |
771 | * @param result_cb callback for the results | 773 | * @param result_cb callback for the results |
772 | * @param result_cls closure for result_cb | 774 | * @param result_cls closure for @a result_cb |
773 | * @return a handle to cancel the operation | 775 | * @return a handle to cancel the operation |
774 | */ | 776 | */ |
775 | struct GNUNET_SET_OperationHandle * | 777 | struct GNUNET_SET_OperationHandle * |
@@ -780,7 +782,7 @@ GNUNET_SET_accept (struct GNUNET_SET_Request *request, | |||
780 | { | 782 | { |
781 | struct GNUNET_MQ_Envelope *mqm; | 783 | struct GNUNET_MQ_Envelope *mqm; |
782 | struct GNUNET_SET_OperationHandle *oh; | 784 | struct GNUNET_SET_OperationHandle *oh; |
783 | struct GNUNET_SET_AcceptRejectMessage *msg; | 785 | struct GNUNET_SET_AcceptMessage *msg; |
784 | 786 | ||
785 | GNUNET_assert (NULL != request); | 787 | GNUNET_assert (NULL != request); |
786 | GNUNET_assert (GNUNET_NO == request->accepted); | 788 | GNUNET_assert (GNUNET_NO == request->accepted); |
@@ -792,7 +794,7 @@ GNUNET_SET_accept (struct GNUNET_SET_Request *request, | |||
792 | 794 | ||
793 | mqm = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_ACCEPT); | 795 | mqm = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_ACCEPT); |
794 | msg->accept_reject_id = htonl (request->accept_id); | 796 | msg->accept_reject_id = htonl (request->accept_id); |
795 | msg->result_mode = htons (result_mode); | 797 | msg->result_mode = htonl (result_mode); |
796 | 798 | ||
797 | oh->conclude_mqm = mqm; | 799 | oh->conclude_mqm = mqm; |
798 | oh->request_id_addr = &msg->request_id; | 800 | oh->request_id_addr = &msg->request_id; |