gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

commit 44bb721ef043f99e97d60231438b9e71104d99d7
parent bf716069e987193e1ee0d06bbc4af245e6ffa821
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 27 Nov 2014 09:50:41 +0000

eliminating useless salt argument, salt can be generated inside of gnunet-service-set

Diffstat:
Msrc/consensus/gnunet-service-consensus.c | 1-
Msrc/dv/gnunet-service-dv.c | 2--
Msrc/include/gnunet_set_service.h | 20+++++++++-----------
Msrc/revocation/gnunet-service-revocation.c | 6+-----
Msrc/scalarproduct/gnunet-service-scalarproduct.c | 2--
Msrc/set/gnunet-service-set.c | 26++++++++++++++------------
Msrc/set/gnunet-service-set.h | 3+--
Msrc/set/gnunet-set-profiler.c | 16++++++++--------
Msrc/set/set.h | 83++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
Msrc/set/set_api.c | 62++++++++++++++++++++++++++++++++------------------------------
Msrc/set/set_protocol.h | 19+++++++++++--------
Msrc/set/test_set_api.c | 4++--
Msrc/set/test_set_intersection_result_full.c | 2+-
Msrc/set/test_set_union_result_full.c | 2+-
14 files changed, 133 insertions(+), 115 deletions(-)

diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c @@ -812,7 +812,6 @@ subround_over (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SET_prepare (&session->partner_outgoing->peer_id, &session->global_id, (struct GNUNET_MessageHeader *) msg, - 0, /* FIXME: salt */ GNUNET_SET_RESULT_ADDED, set_result_cb, session->partner_outgoing); GNUNET_free (msg); diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c @@ -1744,7 +1744,6 @@ static void initiate_set_union (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - static uint16_t salt; struct DirectNeighbor *neighbor = cls; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1756,7 +1755,6 @@ initiate_set_union (void *cls, neighbor->set_op = GNUNET_SET_prepare (&neighbor->peer, &neighbor->real_session_id, NULL, - salt++, GNUNET_SET_RESULT_ADDED, &handle_set_union_result, neighbor); diff --git a/src/include/gnunet_set_service.h b/src/include/gnunet_set_service.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2013 Christian Grothoff (and other contributing authors) + (C) 2013, 2014 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -296,9 +296,6 @@ GNUNET_SET_destroy (struct GNUNET_SET_Handle *set); * @param other_peer peer with the other set * @param app_id hash for the application using the set * @param context_msg additional information for the request - * @param salt salt used for the set operation; sometimes set operations - * fail due to hash collisions, using a different salt for each operation - * makes it harder for an attacker to exploit this * @param result_mode specified how results will be returned, * see `enum GNUNET_SET_ResultMode`. * @param result_cb called on error or success @@ -309,7 +306,6 @@ struct GNUNET_SET_OperationHandle * GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, - uint16_t salt, enum GNUNET_SET_ResultMode result_mode, GNUNET_SET_ResultIterator result_cb, void *result_cls); @@ -326,7 +322,7 @@ GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, * @param app_id id of the application that handles set operation requests * @param listen_cb called for each incoming request matching the operation * and application id - * @param listen_cls handle for listen_cb + * @param listen_cls handle for @a listen_cb * @return a handle that can be used to cancel the listen operation */ struct GNUNET_SET_ListenHandle * @@ -389,7 +385,7 @@ GNUNET_SET_commit (struct GNUNET_SET_OperationHandle *oh, /** * Cancel the given set operation. - * May not be called after the operation's GNUNET_SET_ResultIterator has been + * May not be called after the operation's `GNUNET_SET_ResultIterator` has been * called with a status that indicates error, timeout or done. * * @param oh set operation to cancel @@ -406,12 +402,14 @@ GNUNET_SET_operation_cancel (struct GNUNET_SET_OperationHandle *oh); * * @param set the set to iterate over * @param iter the iterator to call for each element - * @param cls closure for 'iter' - * @return GNUNET_YES if the iteration started successfuly, - * GNUNET_SYSERR if the set is invalid (e.g. the server crashed, disconnected) + * @param iter_cls closure for @a iter + * @return #GNUNET_YES if the iteration started successfuly, + * #GNUNET_SYSERR if the set is invalid (e.g. the server crashed, disconnected) */ int -GNUNET_SET_iterate (struct GNUNET_SET_Handle *set, GNUNET_SET_ElementIterator iter, void *cls); +GNUNET_SET_iterate (struct GNUNET_SET_Handle *set, + GNUNET_SET_ElementIterator iter, + void *iter_cls); #if 0 /* keep Emacsens' auto-indent happy */ diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c @@ -463,18 +463,14 @@ transmit_task_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct PeerEntry *peer_entry = cls; - uint16_t salt; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting set exchange with peer `%s'\n", GNUNET_i2s (&peer_entry->id)); - - salt = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT16_MAX); peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; peer_entry->so = GNUNET_SET_prepare (&peer_entry->id, &revocation_set_union_app_id, - NULL, salt, + NULL, GNUNET_SET_RESULT_ADDED, &add_revocation, peer_entry); diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c @@ -1590,7 +1590,6 @@ client_request_complete_bob (struct ServiceSession * client_session) s->intersection_op = GNUNET_SET_prepare (&s->peer, &s->session_id, NULL, - GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT16_MAX), GNUNET_SET_RESULT_REMOVED, cb_intersection_element_removed, s); @@ -2308,7 +2307,6 @@ handle_alices_computation_request (void *cls, s->intersection_op = GNUNET_SET_prepare (&s->peer, &s->session_id, NULL, - GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT16_MAX), GNUNET_SET_RESULT_REMOVED, cb_intersection_element_removed, s); diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2013 Christian Grothoff (and other contributing authors) + (C) 2013, 2014 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -17,11 +17,11 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * @file set/gnunet-service-set.c * @brief two-peer set operations * @author Florian Dold + * @author Christian Grothoff */ #include "gnunet-service-set.h" #include "set_protocol.h" @@ -629,7 +629,8 @@ handle_incoming_msg (struct Operation *op, spec->context_msg = GNUNET_copy_message (spec->context_msg); spec->operation = ntohl (msg->operation); spec->app_id = msg->app_id; - spec->salt = ntohl (msg->salt); + spec->salt = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, + UINT32_MAX); spec->peer = op->state->peer; spec->remote_element_count = ntohl (msg->element_count); @@ -729,7 +730,8 @@ handle_client_iterate (void *cls, GNUNET_SERVER_client_disconnect (client); return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "iterating union set with %u elements\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "iterating union set with %u elements\n", GNUNET_CONTAINER_multihashmap_size (set->elements)); GNUNET_SERVER_receive_done (client, GNUNET_OK); set->iter = GNUNET_CONTAINER_multihashmap_iterator_create (set->elements); @@ -767,7 +769,7 @@ handle_client_create_set (void *cls, set = GNUNET_new (struct Set); - switch (ntohs (msg->operation)) + switch (ntohl (msg->operation)) { case GNUNET_SET_OPERATION_INTERSECTION: set->vt = _GSS_intersection_vt (); @@ -875,9 +877,9 @@ handle_client_reject (void *cls, const struct GNUNET_MessageHeader *m) { struct Operation *incoming; - const struct GNUNET_SET_AcceptRejectMessage *msg; + const struct GNUNET_SET_RejectMessage *msg; - msg = (const struct GNUNET_SET_AcceptRejectMessage *) m; + msg = (const struct GNUNET_SET_RejectMessage *) m; GNUNET_break (0 == ntohl (msg->request_id)); // no matching incoming operation for this reject @@ -1143,10 +1145,10 @@ handle_client_accept (void *cls, const struct GNUNET_MessageHeader *mh) { struct Set *set; - const struct GNUNET_SET_AcceptRejectMessage *msg; + const struct GNUNET_SET_AcceptMessage *msg; struct Operation *op; - msg = (const struct GNUNET_SET_AcceptRejectMessage *) mh; + msg = (const struct GNUNET_SET_AcceptMessage *) mh; // client without a set requested an operation set = set_get (client); @@ -1201,7 +1203,7 @@ handle_client_accept (void *cls, op); op->spec->client_request_id = ntohl (msg->request_id); - op->spec->result_mode = ntohs (msg->result_mode); + op->spec->result_mode = ntohl (msg->result_mode); op->generation_created = set->current_generation++; op->vt = op->spec->set->vt; GNUNET_assert (NULL != op->vt->accept); @@ -1446,7 +1448,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, { static const struct GNUNET_SERVER_MessageHandler server_handlers[] = { {handle_client_accept, NULL, GNUNET_MESSAGE_TYPE_SET_ACCEPT, - sizeof (struct GNUNET_SET_AcceptRejectMessage)}, + sizeof (struct GNUNET_SET_AcceptMessage)}, {handle_client_iter_ack, NULL, GNUNET_MESSAGE_TYPE_SET_ITER_ACK, 0}, {handle_client_add_remove, NULL, GNUNET_MESSAGE_TYPE_SET_ADD, 0}, {handle_client_create_set, NULL, GNUNET_MESSAGE_TYPE_SET_CREATE, @@ -1457,7 +1459,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, {handle_client_listen, NULL, GNUNET_MESSAGE_TYPE_SET_LISTEN, sizeof (struct GNUNET_SET_ListenMessage)}, {handle_client_reject, NULL, GNUNET_MESSAGE_TYPE_SET_REJECT, - sizeof (struct GNUNET_SET_AcceptRejectMessage)}, + sizeof (struct GNUNET_SET_RejectMessage)}, {handle_client_add_remove, NULL, GNUNET_MESSAGE_TYPE_SET_REMOVE, 0}, {handle_client_cancel, NULL, GNUNET_MESSAGE_TYPE_SET_CANCEL, sizeof (struct GNUNET_SET_CancelMessage)}, diff --git a/src/set/gnunet-service-set.h b/src/set/gnunet-service-set.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2013 Christian Grothoff (and other contributing authors) + (C) 2013, 2014 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -17,7 +17,6 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * @file set/gnunet-service-set.h * @brief common components for the implementation the different set operations diff --git a/src/set/gnunet-set-profiler.c b/src/set/gnunet-set-profiler.c @@ -35,8 +35,6 @@ static unsigned int num_a = 5; static unsigned int num_b = 5; static unsigned int num_c = 20; -static unsigned int salt = 42; - static char *op_str = "union"; const static struct GNUNET_CONFIGURATION_Handle *config; @@ -51,13 +49,13 @@ struct SetInfo int done; } info1, info2; -struct GNUNET_CONTAINER_MultiHashMap *common_sent; +static struct GNUNET_CONTAINER_MultiHashMap *common_sent; -struct GNUNET_HashCode app_id; +static struct GNUNET_HashCode app_id; -struct GNUNET_PeerIdentity local_peer; +static struct GNUNET_PeerIdentity local_peer; -struct GNUNET_SET_ListenHandle *set_listener; +static struct GNUNET_SET_ListenHandle *set_listener; static int @@ -77,6 +75,7 @@ map_remove_iterator (void *cls, } + static void check_all_done (void) { @@ -270,8 +269,9 @@ run (void *cls, char *const *args, const char *cfgfile, set_listener = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION, &app_id, set_listen_cb, NULL); - info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL, salt, GNUNET_SET_RESULT_ADDED, - set_result_cb, &info1); + info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL, + GNUNET_SET_RESULT_ADDED, + set_result_cb, &info1); GNUNET_SET_commit (info1.oh, info1.set); GNUNET_SET_destroy (info1.set); info1.set = NULL; diff --git a/src/set/set.h b/src/set/set.h @@ -17,11 +17,11 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** - * @author Florian Dold * @file set/set.h * @brief messages used for the set api + * @author Florian Dold + * @author Christian Grothoff */ #ifndef SET_H #define SET_H @@ -29,6 +29,9 @@ #include "platform.h" #include "gnunet_common.h" +/** + * FIXME + */ #define GNUNET_SET_ACK_WINDOW 10 @@ -37,27 +40,26 @@ GNUNET_NETWORK_STRUCT_BEGIN struct GNUNET_SET_CreateMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_CREATE + * Type: #GNUNET_MESSAGE_TYPE_SET_CREATE */ struct GNUNET_MessageHeader header; /** - * Operation type, values of enum GNUNET_SET_OperationType + * Operation type, values of `enum GNUNET_SET_OperationType` */ - // FIXME: use 32_t for 'enum'. - uint16_t operation GNUNET_PACKED; + uint32_t operation GNUNET_PACKED; }; struct GNUNET_SET_ListenMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_LISTEN + * Type: #GNUNET_MESSAGE_TYPE_SET_LISTEN */ struct GNUNET_MessageHeader header; /** - * Operation type, values of enum GNUNET_SET_OperationType + * Operation type, values of `enum GNUNET_SET_OperationType` */ uint32_t operation GNUNET_PACKED; @@ -69,11 +71,10 @@ struct GNUNET_SET_ListenMessage }; -struct GNUNET_SET_AcceptRejectMessage +struct GNUNET_SET_AcceptMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_ACCEPT or - * GNUNET_MESSAGE_TYPE_SET_REJECT + * Type: #GNUNET_MESSAGE_TYPE_SET_ACCEPT */ struct GNUNET_MessageHeader header; @@ -90,9 +91,30 @@ struct GNUNET_SET_AcceptRejectMessage /** * How should results be sent to us? - * See enum GNUNET_SET_ResultMode. + * See `enum GNUNET_SET_ResultMode`. + */ + uint32_t result_mode GNUNET_PACKED; +}; + + +struct GNUNET_SET_RejectMessage +{ + /** + * Type: #GNUNET_MESSAGE_TYPE_SET_REJECT + */ + struct GNUNET_MessageHeader header; + + /** + * ID of the incoming request we want to accept / reject. + */ + uint32_t accept_reject_id GNUNET_PACKED; + + /** + * Request ID to identify responses, + * must be 0 if we don't accept the request. */ - uint16_t result_mode GNUNET_PACKED; + uint32_t request_id GNUNET_PACKED; + }; @@ -102,21 +124,21 @@ struct GNUNET_SET_AcceptRejectMessage struct GNUNET_SET_RequestMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_Request. + * Type: #GNUNET_MESSAGE_TYPE_SET_REQUEST. */ struct GNUNET_MessageHeader header; /** - * Identity of the requesting peer. - */ - struct GNUNET_PeerIdentity peer_id; - - /** * ID of the to identify the request when accepting or * rejecting it. */ uint32_t accept_id GNUNET_PACKED; + /** + * Identity of the requesting peer. + */ + struct GNUNET_PeerIdentity peer_id; + /* rest: nested context message */ }; @@ -124,7 +146,7 @@ struct GNUNET_SET_RequestMessage struct GNUNET_SET_EvaluateMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_EVALUATE + * Type: #GNUNET_MESSAGE_TYPE_SET_EVALUATE */ struct GNUNET_MessageHeader header; @@ -144,15 +166,15 @@ struct GNUNET_SET_EvaluateMessage struct GNUNET_HashCode app_id; /** - * Salt to use for the operation + * Salt to use for the operation. */ - uint16_t salt GNUNET_PACKED; + uint32_t salt GNUNET_PACKED; /** * How should results be sent to us? - * See enum GNUNET_SET_ResultMode. + * See `enum GNUNET_SET_ResultMode`. */ - uint16_t result_mode GNUNET_PACKED; + uint32_t result_mode GNUNET_PACKED; /* rest: inner message */ }; @@ -161,7 +183,7 @@ struct GNUNET_SET_EvaluateMessage struct GNUNET_SET_ResultMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_RESULT + * Type: #GNUNET_MESSAGE_TYPE_SET_RESULT */ struct GNUNET_MessageHeader header; @@ -188,8 +210,8 @@ struct GNUNET_SET_ResultMessage struct GNUNET_SET_ElementMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_ADD or - * GNUNET_MESSAGE_TYPE_SET_REMOVE + * Type: #GNUNET_MESSAGE_TYPE_SET_ADD or + * #GNUNET_MESSAGE_TYPE_SET_REMOVE */ struct GNUNET_MessageHeader header; @@ -208,7 +230,7 @@ struct GNUNET_SET_ElementMessage struct GNUNET_SET_CancelMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_CANCEL + * Type: #GNUNET_MESSAGE_TYPE_SET_CANCEL */ struct GNUNET_MessageHeader header; @@ -218,10 +240,11 @@ struct GNUNET_SET_CancelMessage uint32_t request_id GNUNET_PACKED; }; + struct GNUNET_SET_IterResponseMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_ITER_RESPONSE + * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_RESPONSE */ struct GNUNET_MessageHeader header; @@ -237,7 +260,7 @@ struct GNUNET_SET_IterResponseMessage struct GNUNET_SET_IterAckMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_ITER_ACK + * Type: #GNUNET_MESSAGE_TYPE_SET_ITER_ACK */ struct GNUNET_MessageHeader header; diff --git 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) * @param mh the message */ static void -handle_request (void *cls, const struct GNUNET_MessageHeader *mh) +handle_request (void *cls, + const struct GNUNET_MessageHeader *mh) { const struct GNUNET_SET_RequestMessage *msg = (const struct GNUNET_SET_RequestMessage *) mh; struct GNUNET_SET_ListenHandle *lh = cls; struct GNUNET_SET_Request *req; struct GNUNET_MessageHeader *context_msg; - LOG (GNUNET_ERROR_TYPE_DEBUG, "processing operation request\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "processing operation request\n"); req = GNUNET_new (struct GNUNET_SET_Request); req->accept_id = ntohl (msg->accept_id); context_msg = GNUNET_MQ_extract_nested_mh (msg); @@ -339,18 +341,21 @@ handle_request (void *cls, const struct GNUNET_MessageHeader *mh) if (GNUNET_NO == req->accepted) { struct GNUNET_MQ_Envelope *mqm; - struct GNUNET_SET_AcceptRejectMessage *amsg; + struct GNUNET_SET_RejectMessage *rmsg; - mqm = GNUNET_MQ_msg (amsg, GNUNET_MESSAGE_TYPE_SET_REJECT); + mqm = GNUNET_MQ_msg (rmsg, + GNUNET_MESSAGE_TYPE_SET_REJECT); /* no request id, as we refused */ - amsg->request_id = htonl (0); - amsg->accept_reject_id = msg->accept_id; + rmsg->request_id = htonl (0); + rmsg->accept_reject_id = msg->accept_id; GNUNET_MQ_send (lh->mq, mqm); - LOG (GNUNET_ERROR_TYPE_DEBUG, "rejecting request\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "rejecting request\n"); } GNUNET_free (req); - LOG (GNUNET_ERROR_TYPE_DEBUG, "processed op request from service\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "processed op request from service\n"); /* the accept-case is handled in GNUNET_SET_accept, * as we have the accept message available there */ @@ -362,13 +367,14 @@ handle_client_listener_error (void *cls, enum GNUNET_MQ_Error error) { struct GNUNET_SET_ListenHandle *lh = cls; - LOG (GNUNET_ERROR_TYPE_DEBUG, "listener broke down, re-connecting\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "listener broke down, re-connecting\n"); GNUNET_CLIENT_disconnect (lh->client); lh->client = NULL; GNUNET_MQ_destroy (lh->mq); lh->mq = NULL; - - lh->reconnect_task = GNUNET_SCHEDULER_add_delayed (lh->reconnect_backoff, listen_connect, lh); + lh->reconnect_task = GNUNET_SCHEDULER_add_delayed (lh->reconnect_backoff, + &listen_connect, lh); lh->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (lh->reconnect_backoff); } @@ -492,15 +498,15 @@ struct GNUNET_SET_Handle * GNUNET_SET_create (const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op) { - struct GNUNET_SET_Handle *set; - struct GNUNET_MQ_Envelope *mqm; - struct GNUNET_SET_CreateMessage *msg; static const struct GNUNET_MQ_MessageHandler mq_handlers[] = { {handle_result, GNUNET_MESSAGE_TYPE_SET_RESULT, 0}, {handle_iter_element, GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT, 0}, {handle_iter_done, GNUNET_MESSAGE_TYPE_SET_ITER_DONE, 0}, GNUNET_MQ_HANDLERS_END }; + struct GNUNET_SET_Handle *set; + struct GNUNET_MQ_Envelope *mqm; + struct GNUNET_SET_CreateMessage *msg; set = GNUNET_new (struct GNUNET_SET_Handle); set->client = GNUNET_CLIENT_connect ("set", cfg); @@ -510,7 +516,7 @@ GNUNET_SET_create (const struct GNUNET_CONFIGURATION_Handle *cfg, handle_client_set_error, set); GNUNET_assert (NULL != set->mq); mqm = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_CREATE); - msg->operation = htons (op); + msg->operation = htonl (op); GNUNET_MQ_send (set->mq, mqm); return set; } @@ -607,25 +613,21 @@ GNUNET_SET_destroy (struct GNUNET_SET_Handle *set) /** * Prepare a set operation to be evaluated with another peer. * The evaluation will not start until the client provides - * a local set with GNUNET_SET_commit. + * a local set with #GNUNET_SET_commit(). * * @param other_peer peer with the other set * @param app_id hash for the application using the set * @param context_msg additional information for the request - * @param salt salt used for the set operation; sometimes set operations - * fail due to hash collisions, using a different salt for each operation - * makes it harder for an attacker to exploit this * @param result_mode specified how results will be returned, - * see 'GNUNET_SET_ResultMode'. + * see `enum GNUNET_SET_ResultMode`. * @param result_cb called on error or success - * @param result_cls closure for result_cb + * @param result_cls closure for @e result_cb * @return a handle to cancel the operation */ struct GNUNET_SET_OperationHandle * GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, - uint16_t salt, enum GNUNET_SET_ResultMode result_mode, GNUNET_SET_ResultIterator result_cb, void *result_cls) @@ -638,12 +640,12 @@ GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, oh->result_cb = result_cb; oh->result_cls = result_cls; - mqm = GNUNET_MQ_msg_nested_mh (msg, GNUNET_MESSAGE_TYPE_SET_EVALUATE, context_msg); - + mqm = GNUNET_MQ_msg_nested_mh (msg, + GNUNET_MESSAGE_TYPE_SET_EVALUATE, + context_msg); msg->app_id = *app_id; - msg->result_mode = htons (result_mode); + msg->result_mode = htonl (result_mode); msg->target_peer = *other_peer; - msg->salt = salt; oh->conclude_mqm = mqm; oh->request_id_addr = &msg->request_id; @@ -767,9 +769,9 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh) * * @param request request to accept * @param result_mode specified how results will be returned, - * see 'GNUNET_SET_ResultMode'. + * see `enum GNUNET_SET_ResultMode`. * @param result_cb callback for the results - * @param result_cls closure for result_cb + * @param result_cls closure for @a result_cb * @return a handle to cancel the operation */ struct GNUNET_SET_OperationHandle * @@ -780,7 +782,7 @@ GNUNET_SET_accept (struct GNUNET_SET_Request *request, { struct GNUNET_MQ_Envelope *mqm; struct GNUNET_SET_OperationHandle *oh; - struct GNUNET_SET_AcceptRejectMessage *msg; + struct GNUNET_SET_AcceptMessage *msg; GNUNET_assert (NULL != request); GNUNET_assert (GNUNET_NO == request->accepted); @@ -792,7 +794,7 @@ GNUNET_SET_accept (struct GNUNET_SET_Request *request, mqm = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SET_ACCEPT); msg->accept_reject_id = htonl (request->accept_id); - msg->result_mode = htons (result_mode); + msg->result_mode = htonl (result_mode); oh->conclude_mqm = mqm; oh->request_id_addr = &msg->request_id; diff --git a/src/set/set_protocol.h b/src/set/set_protocol.h @@ -35,24 +35,24 @@ GNUNET_NETWORK_STRUCT_BEGIN struct OperationRequestMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST + * Type: #GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST */ struct GNUNET_MessageHeader header; /** - * Operation to request, values from 'enum GNUNET_SET_OperationType' + * Operation to request, values from `enum GNUNET_SET_OperationType` */ uint32_t operation GNUNET_PACKED; /** * Salt to use for this operation. */ - uint32_t salt; + uint32_t salt GNUNET_PACKED; /** * For Intersection: my element count */ - uint32_t element_count; + uint32_t element_count GNUNET_PACKED; /** * Application-specific identifier of the request. @@ -62,10 +62,11 @@ struct OperationRequestMessage /* rest: optional message */ }; + struct IBFMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_P2P_IBF + * Type: #GNUNET_MESSAGE_TYPE_SET_P2P_IBF */ struct GNUNET_MessageHeader header; @@ -88,15 +89,16 @@ struct IBFMessage /** * Salt used when hashing elements for this IBF. */ - uint32_t salt; + uint32_t salt GNUNET_PACKED; /* rest: strata */ }; + struct BFMessage { /** - * Type: GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF + * Type: #GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF */ struct GNUNET_MessageHeader header; @@ -130,10 +132,11 @@ struct BFMessage */ }; + struct BFPart { /** - * Type: GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF + * Type: #GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF */ struct GNUNET_MessageHeader header; diff --git a/src/set/test_set_api.c b/src/set/test_set_api.c @@ -130,7 +130,7 @@ start (void *cls) listen_handle = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION, &app_id, listen_cb, NULL); - oh = GNUNET_SET_prepare (&local_id, &app_id, &context_msg, 42, + oh = GNUNET_SET_prepare (&local_id, &app_id, &context_msg, GNUNET_SET_RESULT_ADDED, result_cb_set1, NULL); GNUNET_SET_commit (oh, set1); @@ -275,7 +275,7 @@ run (void *cls, ///* test if canceling an uncommited request works! */ - my_oh = GNUNET_SET_prepare (&local_id, &app_id, NULL, 0, + my_oh = GNUNET_SET_prepare (&local_id, &app_id, NULL, GNUNET_SET_RESULT_ADDED, NULL, NULL); GNUNET_SET_operation_cancel (my_oh); diff --git a/src/set/test_set_intersection_result_full.c b/src/set/test_set_intersection_result_full.c @@ -133,7 +133,7 @@ start (void *cls) &listen_cb, NULL); oh = GNUNET_SET_prepare (&local_id, &app_id, - &context_msg, 42, + &context_msg, GNUNET_SET_RESULT_FULL, &result_cb_set1, NULL); GNUNET_SET_commit (oh, set1); diff --git a/src/set/test_set_union_result_full.c b/src/set/test_set_union_result_full.c @@ -131,7 +131,7 @@ start (void *cls) listen_handle = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION, &app_id, listen_cb, NULL); - oh = GNUNET_SET_prepare (&local_id, &app_id, &context_msg, 42, + oh = GNUNET_SET_prepare (&local_id, &app_id, &context_msg, GNUNET_SET_RESULT_FULL, result_cb_set1, NULL); GNUNET_SET_commit (oh, set1);