diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-02-24 15:50:48 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-02-24 18:10:11 +0100 |
commit | 592b43fdf3f3572892f4095808daf22010469d0b (patch) | |
tree | 74f01c52aa3a2727388f81d0b4a3fc86a08af8a9 | |
parent | 398c70fd7434f3f7891175be96b73191e49a0afe (diff) | |
download | gnunet-592b43fdf3f3572892f4095808daf22010469d0b.tar.gz gnunet-592b43fdf3f3572892f4095808daf22010469d0b.zip |
add option parsing
-rw-r--r-- | src/set/gnunet-service-set.c | 8 | ||||
-rw-r--r-- | src/set/gnunet-service-set.h | 24 | ||||
-rw-r--r-- | src/set/set.h | 48 | ||||
-rw-r--r-- | src/set/set_api.c | 20 |
4 files changed, 100 insertions, 0 deletions
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, | |||
1683 | spec->set = set; | 1683 | spec->set = set; |
1684 | spec->result_mode = ntohl (msg->result_mode); | 1684 | spec->result_mode = ntohl (msg->result_mode); |
1685 | spec->client_request_id = ntohl (msg->request_id); | 1685 | spec->client_request_id = ntohl (msg->request_id); |
1686 | spec->byzantine = msg->byzantine; | ||
1687 | spec->byzantine_lower_bound = msg->byzantine_lower_bound; | ||
1688 | spec->force_full = msg->force_full; | ||
1689 | spec->force_delta = msg->force_delta; | ||
1686 | context = GNUNET_MQ_extract_nested_mh (msg); | 1690 | context = GNUNET_MQ_extract_nested_mh (msg); |
1687 | op->spec = spec; | 1691 | op->spec = spec; |
1688 | 1692 | ||
@@ -2019,6 +2023,10 @@ handle_client_accept (void *cls, | |||
2019 | op); | 2023 | op); |
2020 | op->spec->client_request_id = ntohl (msg->request_id); | 2024 | op->spec->client_request_id = ntohl (msg->request_id); |
2021 | op->spec->result_mode = ntohl (msg->result_mode); | 2025 | op->spec->result_mode = ntohl (msg->result_mode); |
2026 | op->spec->byzantine = msg->byzantine; | ||
2027 | op->spec->byzantine_lower_bound = msg->byzantine_lower_bound; | ||
2028 | op->spec->force_full = msg->force_full; | ||
2029 | op->spec->force_delta = msg->force_delta; | ||
2022 | 2030 | ||
2023 | // Advance generation values, so that | 2031 | // Advance generation values, so that |
2024 | // mutations won't interfer with the running operation. | 2032 | // 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 | |||
119 | * When are elements sent to the client, and which elements are sent? | 119 | * When are elements sent to the client, and which elements are sent? |
120 | */ | 120 | */ |
121 | enum GNUNET_SET_ResultMode result_mode; | 121 | enum GNUNET_SET_ResultMode result_mode; |
122 | |||
123 | /** | ||
124 | * Always use delta operation instead of sending full sets, | ||
125 | * even it it's less efficient. | ||
126 | */ | ||
127 | int force_delta; | ||
128 | |||
129 | /** | ||
130 | * Always send full sets, even if delta operations would | ||
131 | * be more efficient. | ||
132 | */ | ||
133 | int force_full; | ||
134 | |||
135 | /** | ||
136 | * #GNUNET_YES to fail operations where Byzantine faults | ||
137 | * are suspected | ||
138 | */ | ||
139 | int byzantine; | ||
140 | |||
141 | /** | ||
142 | * Lower bound for the set size, used only when | ||
143 | * byzantine mode is enabled. | ||
144 | */ | ||
145 | int byzantine_lower_bound; | ||
122 | }; | 146 | }; |
123 | 147 | ||
124 | 148 | ||
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 | |||
102 | * See `enum GNUNET_SET_ResultMode`. | 102 | * See `enum GNUNET_SET_ResultMode`. |
103 | */ | 103 | */ |
104 | uint32_t result_mode GNUNET_PACKED; | 104 | uint32_t result_mode GNUNET_PACKED; |
105 | |||
106 | /** | ||
107 | * Always use delta operation instead of sending full sets, | ||
108 | * even it it's less efficient. | ||
109 | */ | ||
110 | uint8_t force_delta; | ||
111 | |||
112 | /** | ||
113 | * Always send full sets, even if delta operations would | ||
114 | * be more efficient. | ||
115 | */ | ||
116 | uint8_t force_full; | ||
117 | |||
118 | /** | ||
119 | * #GNUNET_YES to fail operations where Byzantine faults | ||
120 | * are suspected | ||
121 | */ | ||
122 | uint8_t byzantine; | ||
123 | |||
124 | /** | ||
125 | * Lower bound for the set size, used only when | ||
126 | * byzantine mode is enabled. | ||
127 | */ | ||
128 | uint8_t byzantine_lower_bound; | ||
105 | }; | 129 | }; |
106 | 130 | ||
107 | 131 | ||
@@ -184,6 +208,30 @@ struct GNUNET_SET_EvaluateMessage | |||
184 | */ | 208 | */ |
185 | uint32_t request_id GNUNET_PACKED; | 209 | uint32_t request_id GNUNET_PACKED; |
186 | 210 | ||
211 | /** | ||
212 | * Always use delta operation instead of sending full sets, | ||
213 | * even it it's less efficient. | ||
214 | */ | ||
215 | uint8_t force_delta; | ||
216 | |||
217 | /** | ||
218 | * Always send full sets, even if delta operations would | ||
219 | * be more efficient. | ||
220 | */ | ||
221 | uint8_t force_full; | ||
222 | |||
223 | /** | ||
224 | * #GNUNET_YES to fail operations where Byzantine faults | ||
225 | * are suspected | ||
226 | */ | ||
227 | uint8_t byzantine; | ||
228 | |||
229 | /** | ||
230 | * Lower bound for the set size, used only when | ||
231 | * byzantine mode is enabled. | ||
232 | */ | ||
233 | uint8_t byzantine_lower_bound; | ||
234 | |||
187 | /* rest: context message, that is, application-specific | 235 | /* rest: context message, that is, application-specific |
188 | message to convince listener to pick up */ | 236 | message to convince listener to pick up */ |
189 | }; | 237 | }; |
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, | |||
773 | struct GNUNET_MQ_Envelope *mqm; | 773 | struct GNUNET_MQ_Envelope *mqm; |
774 | struct GNUNET_SET_OperationHandle *oh; | 774 | struct GNUNET_SET_OperationHandle *oh; |
775 | struct GNUNET_SET_EvaluateMessage *msg; | 775 | struct GNUNET_SET_EvaluateMessage *msg; |
776 | struct GNUNET_SET_Option *opt; | ||
776 | 777 | ||
777 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 778 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
778 | "Client prepares set operation (%d)\n", | 779 | "Client prepares set operation (%d)\n", |
@@ -786,6 +787,25 @@ GNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, | |||
786 | msg->app_id = *app_id; | 787 | msg->app_id = *app_id; |
787 | msg->result_mode = htonl (result_mode); | 788 | msg->result_mode = htonl (result_mode); |
788 | msg->target_peer = *other_peer; | 789 | msg->target_peer = *other_peer; |
790 | for (opt = options; opt->type != 0; opt++) | ||
791 | { | ||
792 | switch (opt->type) | ||
793 | { | ||
794 | case GNUNET_SET_OPTION_BYZANTINE: | ||
795 | msg->byzantine = GNUNET_YES; | ||
796 | msg->byzantine_lower_bound = opt->v.num; | ||
797 | break; | ||
798 | case GNUNET_SET_OPTION_FORCE_FULL: | ||
799 | msg->force_full = GNUNET_YES; | ||
800 | break; | ||
801 | case GNUNET_SET_OPTION_FORCE_DELTA: | ||
802 | msg->force_delta = GNUNET_YES; | ||
803 | break; | ||
804 | default: | ||
805 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
806 | "Option with type %d not recognized\n", (int) opt->type); | ||
807 | } | ||
808 | } | ||
789 | oh->conclude_mqm = mqm; | 809 | oh->conclude_mqm = mqm; |
790 | oh->request_id_addr = &msg->request_id; | 810 | oh->request_id_addr = &msg->request_id; |
791 | 811 | ||