From: Florian Dold Date: Fri, 24 Feb 2017 14:50:48 +0000 (+0100) Subject: add option parsing X-Git-Tag: taler-0.2.1~70^2~2 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=592b43fdf3f3572892f4095808daf22010469d0b;p=oweals%2Fgnunet.git add option parsing --- diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index e3e1afe08..126bf02d2 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c @@ -1683,6 +1683,10 @@ handle_client_evaluate (void *cls, spec->set = set; spec->result_mode = ntohl (msg->result_mode); spec->client_request_id = ntohl (msg->request_id); + spec->byzantine = msg->byzantine; + spec->byzantine_lower_bound = msg->byzantine_lower_bound; + spec->force_full = msg->force_full; + spec->force_delta = msg->force_delta; context = GNUNET_MQ_extract_nested_mh (msg); op->spec = spec; @@ -2019,6 +2023,10 @@ handle_client_accept (void *cls, op); op->spec->client_request_id = ntohl (msg->request_id); op->spec->result_mode = ntohl (msg->result_mode); + op->spec->byzantine = msg->byzantine; + op->spec->byzantine_lower_bound = msg->byzantine_lower_bound; + op->spec->force_full = msg->force_full; + op->spec->force_delta = msg->force_delta; // Advance generation values, so that // mutations won't interfer with the running operation. diff --git a/src/set/gnunet-service-set.h b/src/set/gnunet-service-set.h index 1460707fa..68d8fe81f 100644 --- a/src/set/gnunet-service-set.h +++ b/src/set/gnunet-service-set.h @@ -119,6 +119,30 @@ struct OperationSpecification * When are elements sent to the client, and which elements are sent? */ enum GNUNET_SET_ResultMode result_mode; + + /** + * Always use delta operation instead of sending full sets, + * even it it's less efficient. + */ + int force_delta; + + /** + * Always send full sets, even if delta operations would + * be more efficient. + */ + int force_full; + + /** + * #GNUNET_YES to fail operations where Byzantine faults + * are suspected + */ + int byzantine; + + /** + * Lower bound for the set size, used only when + * byzantine mode is enabled. + */ + int byzantine_lower_bound; }; diff --git a/src/set/set.h b/src/set/set.h index f31216cb8..207f098bc 100644 --- a/src/set/set.h +++ b/src/set/set.h @@ -102,6 +102,30 @@ struct GNUNET_SET_AcceptMessage * See `enum GNUNET_SET_ResultMode`. */ uint32_t result_mode GNUNET_PACKED; + + /** + * Always use delta operation instead of sending full sets, + * even it it's less efficient. + */ + uint8_t force_delta; + + /** + * Always send full sets, even if delta operations would + * be more efficient. + */ + uint8_t force_full; + + /** + * #GNUNET_YES to fail operations where Byzantine faults + * are suspected + */ + uint8_t byzantine; + + /** + * Lower bound for the set size, used only when + * byzantine mode is enabled. + */ + uint8_t byzantine_lower_bound; }; @@ -184,6 +208,30 @@ struct GNUNET_SET_EvaluateMessage */ uint32_t request_id GNUNET_PACKED; + /** + * Always use delta operation instead of sending full sets, + * even it it's less efficient. + */ + uint8_t force_delta; + + /** + * Always send full sets, even if delta operations would + * be more efficient. + */ + uint8_t force_full; + + /** + * #GNUNET_YES to fail operations where Byzantine faults + * are suspected + */ + uint8_t byzantine; + + /** + * Lower bound for the set size, used only when + * byzantine mode is enabled. + */ + uint8_t byzantine_lower_bound; + /* rest: context message, that is, application-specific message to convince listener to pick up */ }; diff --git a/src/set/set_api.c b/src/set/set_api.c index c2e2cd1e9..2b09725e8 100644 --- a/src/set/set_api.c +++ b/src/set/set_api.c @@ -773,6 +773,7 @@ GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, struct GNUNET_MQ_Envelope *mqm; struct GNUNET_SET_OperationHandle *oh; struct GNUNET_SET_EvaluateMessage *msg; + struct GNUNET_SET_Option *opt; LOG (GNUNET_ERROR_TYPE_DEBUG, "Client prepares set operation (%d)\n", @@ -786,6 +787,25 @@ GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, msg->app_id = *app_id; msg->result_mode = htonl (result_mode); msg->target_peer = *other_peer; + for (opt = options; opt->type != 0; opt++) + { + switch (opt->type) + { + case GNUNET_SET_OPTION_BYZANTINE: + msg->byzantine = GNUNET_YES; + msg->byzantine_lower_bound = opt->v.num; + break; + case GNUNET_SET_OPTION_FORCE_FULL: + msg->force_full = GNUNET_YES; + break; + case GNUNET_SET_OPTION_FORCE_DELTA: + msg->force_delta = GNUNET_YES; + break; + default: + LOG (GNUNET_ERROR_TYPE_ERROR, + "Option with type %d not recognized\n", (int) opt->type); + } + } oh->conclude_mqm = mqm; oh->request_id_addr = &msg->request_id;