aboutsummaryrefslogtreecommitdiff
path: root/src/secretsharing/gnunet-secretsharing-profiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/secretsharing/gnunet-secretsharing-profiler.c')
-rw-r--r--src/secretsharing/gnunet-secretsharing-profiler.c502
1 files changed, 250 insertions, 252 deletions
diff --git a/src/secretsharing/gnunet-secretsharing-profiler.c b/src/secretsharing/gnunet-secretsharing-profiler.c
index 85abe154b..0bd2cc6a9 100644
--- a/src/secretsharing/gnunet-secretsharing-profiler.c
+++ b/src/secretsharing/gnunet-secretsharing-profiler.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -122,10 +122,10 @@ static int in_shutdown;
122 * @param event information about the event 122 * @param event information about the event
123 */ 123 */
124static void 124static void
125controller_cb (void *cls, 125controller_cb(void *cls,
126 const struct GNUNET_TESTBED_EventInformation *event) 126 const struct GNUNET_TESTBED_EventInformation *event)
127{ 127{
128 GNUNET_assert (0); 128 GNUNET_assert(0);
129} 129}
130 130
131 131
@@ -139,30 +139,29 @@ controller_cb (void *cls,
139 * operation has executed successfully. 139 * operation has executed successfully.
140 */ 140 */
141static void 141static void
142session_connect_complete (void *cls, 142session_connect_complete(void *cls,
143 struct GNUNET_TESTBED_Operation *op, 143 struct GNUNET_TESTBED_Operation *op,
144 void *ca_result, 144 void *ca_result,
145 const char *emsg) 145 const char *emsg)
146{ 146{
147
148 if (NULL != emsg) 147 if (NULL != emsg)
149 { 148 {
150 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 149 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
151 "testbed connect emsg: %s\n", 150 "testbed connect emsg: %s\n",
152 emsg); 151 emsg);
153 GNUNET_assert (0); 152 GNUNET_assert(0);
154 } 153 }
155 154
156 num_connected_sessions++; 155 num_connected_sessions++;
157 156
158 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 157 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
159 "dkg: session connect complete\n"); 158 "dkg: session connect complete\n");
160 159
161 if (num_connected_sessions == num_peers) 160 if (num_connected_sessions == num_peers)
162 { 161 {
163 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 162 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
164 "dkg: all peers connected\n"); 163 "dkg: all peers connected\n");
165 } 164 }
166} 165}
167 166
168 167
@@ -176,30 +175,29 @@ session_connect_complete (void *cls,
176 * operation has executed successfully. 175 * operation has executed successfully.
177 */ 176 */
178static void 177static void
179decrypt_connect_complete (void *cls, 178decrypt_connect_complete(void *cls,
180 struct GNUNET_TESTBED_Operation *op, 179 struct GNUNET_TESTBED_Operation *op,
181 void *ca_result, 180 void *ca_result,
182 const char *emsg) 181 const char *emsg)
183{ 182{
184
185 if (NULL != emsg) 183 if (NULL != emsg)
186 { 184 {
187 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 185 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
188 "testbed connect emsg: %s\n", 186 "testbed connect emsg: %s\n",
189 emsg); 187 emsg);
190 GNUNET_assert (0); 188 GNUNET_assert(0);
191 } 189 }
192 190
193 num_connected_decrypt++; 191 num_connected_decrypt++;
194 192
195 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 193 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
196 "decrypt: session connect complete\n"); 194 "decrypt: session connect complete\n");
197 195
198 if (num_connected_decrypt == num_peers) 196 if (num_connected_decrypt == num_peers)
199 { 197 {
200 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 198 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
201 "decrypt: all peers connected\n"); 199 "decrypt: all peers connected\n");
202 } 200 }
203} 201}
204 202
205 203
@@ -209,35 +207,36 @@ decrypt_connect_complete (void *cls,
209 * @param cls Plaintext 207 * @param cls Plaintext
210 * @param plaintext Plaintext 208 * @param plaintext Plaintext
211 */ 209 */
212static void decrypt_cb (void *cls, 210static void decrypt_cb(void *cls,
213 const struct GNUNET_SECRETSHARING_Plaintext *plaintext) 211 const struct GNUNET_SECRETSHARING_Plaintext *plaintext)
214{ 212{
215 struct GNUNET_SECRETSHARING_DecryptionHandle **dhp = cls; 213 struct GNUNET_SECRETSHARING_DecryptionHandle **dhp = cls;
216 unsigned int n = dhp - decrypt_handles; 214 unsigned int n = dhp - decrypt_handles;
215
217 num_decrypted++; 216 num_decrypted++;
218 217
219 *dhp = NULL; 218 *dhp = NULL;
220 219
221 // we should still be connected if this is called 220 // we should still be connected if this is called
222 GNUNET_assert (NULL != connect_ops[n]); 221 GNUNET_assert(NULL != connect_ops[n]);
223 222
224 GNUNET_TESTBED_operation_done (connect_ops[n]); 223 GNUNET_TESTBED_operation_done(connect_ops[n]);
225 224
226 if (NULL == plaintext) 225 if (NULL == plaintext)
227 { 226 {
228 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decrypt failed for peer %u\n", n); 227 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "decrypt failed for peer %u\n", n);
229 return; 228 return;
230 } 229 }
231 else if (0 == GNUNET_memcmp (&reference_plaintext, plaintext)) 230 else if (0 == GNUNET_memcmp(&reference_plaintext, plaintext))
232 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "decrypt got correct result for peer %u\n", n); 231 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "decrypt got correct result for peer %u\n", n);
233 else 232 else
234 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decrypt got wrong result for peer %u\n", n); 233 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "decrypt got wrong result for peer %u\n", n);
235 234
236 if (num_decrypted == num_peers) 235 if (num_decrypted == num_peers)
237 { 236 {
238 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "every peer decrypted\n"); 237 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "every peer decrypted\n");
239 GNUNET_SCHEDULER_shutdown (); 238 GNUNET_SCHEDULER_shutdown();
240 } 239 }
241 240
242 *dhp = NULL; 241 *dhp = NULL;
243} 242}
@@ -255,19 +254,19 @@ static void decrypt_cb (void *cls,
255 * @return service handle to return in 'op_result', NULL on error 254 * @return service handle to return in 'op_result', NULL on error
256 */ 255 */
257static void * 256static void *
258decrypt_connect_adapter (void *cls, 257decrypt_connect_adapter(void *cls,
259 const struct GNUNET_CONFIGURATION_Handle *cfg) 258 const struct GNUNET_CONFIGURATION_Handle *cfg)
260{ 259{
261 struct GNUNET_SECRETSHARING_DecryptionHandle **hp = cls; 260 struct GNUNET_SECRETSHARING_DecryptionHandle **hp = cls;
262 unsigned int n = hp - decrypt_handles; 261 unsigned int n = hp - decrypt_handles;
263 262
264 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 263 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
265 "decrypt connect adapter, %d peers\n", 264 "decrypt connect adapter, %d peers\n",
266 num_peers); 265 num_peers);
267 *hp = GNUNET_SECRETSHARING_decrypt (cfg, shares[n], &ciphertext, 266 *hp = GNUNET_SECRETSHARING_decrypt(cfg, shares[n], &ciphertext,
268 decrypt_start, decrypt_deadline, 267 decrypt_start, decrypt_deadline,
269 decrypt_cb, 268 decrypt_cb,
270 hp); 269 hp);
271 270
272 return *hp; 271 return *hp;
273} 272}
@@ -286,25 +285,25 @@ decrypt_disconnect_adapter(void *cls, void *op_result)
286 struct GNUNET_SECRETSHARING_DecryptionHandle **dh = cls; 285 struct GNUNET_SECRETSHARING_DecryptionHandle **dh = cls;
287 unsigned int n = dh - decrypt_handles; 286 unsigned int n = dh - decrypt_handles;
288 287
289 GNUNET_assert (*dh == decrypt_handles[n]); 288 GNUNET_assert(*dh == decrypt_handles[n]);
290 289
291 if (NULL != *dh) 290 if (NULL != *dh)
292 { 291 {
293 GNUNET_SECRETSHARING_decrypt_cancel (*dh); 292 GNUNET_SECRETSHARING_decrypt_cancel(*dh);
294 *dh = NULL; 293 *dh = NULL;
295 } 294 }
296 295
297 GNUNET_assert (NULL != connect_ops[n]); 296 GNUNET_assert(NULL != connect_ops[n]);
298 connect_ops[n] = NULL; 297 connect_ops[n] = NULL;
299} 298}
300 299
301 300
302static void 301static void
303secret_ready_cb (void *cls, 302secret_ready_cb(void *cls,
304 struct GNUNET_SECRETSHARING_Share *my_share, 303 struct GNUNET_SECRETSHARING_Share *my_share,
305 struct GNUNET_SECRETSHARING_PublicKey *public_key, 304 struct GNUNET_SECRETSHARING_PublicKey *public_key,
306 unsigned int num_ready_peers, 305 unsigned int num_ready_peers,
307 const struct GNUNET_PeerIdentity *ready_peers) 306 const struct GNUNET_PeerIdentity *ready_peers)
308{ 307{
309 struct GNUNET_SECRETSHARING_Session **sp = cls; 308 struct GNUNET_SECRETSHARING_Session **sp = cls;
310 unsigned int n = sp - session_handles; 309 unsigned int n = sp - session_handles;
@@ -315,36 +314,35 @@ secret_ready_cb (void *cls,
315 *sp = NULL; 314 *sp = NULL;
316 shares[n] = my_share; 315 shares[n] = my_share;
317 if (NULL == my_share) 316 if (NULL == my_share)
318 {
319 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "key generation failed for peer #%u\n", n);
320 }
321 else
322 {
323 ret = GNUNET_STRINGS_data_to_string (public_key, sizeof *public_key, pubkey_str, 1024);
324 GNUNET_assert (NULL != ret);
325 *ret = '\0';
326 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "key generation successful for peer #%u, pubkey %s\n", n,
327 pubkey_str);
328
329 /* we're the first to get the key -> store it */
330 if (num_generated == 1)
331 { 317 {
332 common_pubkey = *public_key; 318 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "key generation failed for peer #%u\n", n);
333 } 319 }
334 else if (0 != GNUNET_memcmp (public_key, &common_pubkey)) 320 else
335 { 321 {
336 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "generated public keys do not match\n"); 322 ret = GNUNET_STRINGS_data_to_string(public_key, sizeof *public_key, pubkey_str, 1024);
337 GNUNET_SCHEDULER_shutdown (); 323 GNUNET_assert(NULL != ret);
338 return; 324 *ret = '\0';
325 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "key generation successful for peer #%u, pubkey %s\n", n,
326 pubkey_str);
327
328 /* we're the first to get the key -> store it */
329 if (num_generated == 1)
330 {
331 common_pubkey = *public_key;
332 }
333 else if (0 != GNUNET_memcmp(public_key, &common_pubkey))
334 {
335 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "generated public keys do not match\n");
336 GNUNET_SCHEDULER_shutdown();
337 return;
338 }
339 } 339 }
340 }
341 340
342 // we should still be connected 341 // we should still be connected
343 GNUNET_assert (NULL != connect_ops[n]); 342 GNUNET_assert(NULL != connect_ops[n]);
344 343
345 // disconnect from the service, will call the disconnect callback 344 // disconnect from the service, will call the disconnect callback
346 GNUNET_TESTBED_operation_done (connect_ops[n]); 345 GNUNET_TESTBED_operation_done(connect_ops[n]);
347
348} 346}
349 347
350 348
@@ -359,22 +357,22 @@ secret_ready_cb (void *cls,
359 * @return service handle to return in 'op_result', NULL on error 357 * @return service handle to return in 'op_result', NULL on error
360 */ 358 */
361static void * 359static void *
362session_connect_adapter (void *cls, 360session_connect_adapter(void *cls,
363 const struct GNUNET_CONFIGURATION_Handle *cfg) 361 const struct GNUNET_CONFIGURATION_Handle *cfg)
364{ 362{
365 struct GNUNET_SECRETSHARING_Session **sp = cls; 363 struct GNUNET_SECRETSHARING_Session **sp = cls;
366 364
367 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 365 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
368 "connect adapter, %d peers\n", 366 "connect adapter, %d peers\n",
369 num_peers); 367 num_peers);
370 *sp = GNUNET_SECRETSHARING_create_session (cfg, 368 *sp = GNUNET_SECRETSHARING_create_session(cfg,
371 num_peers, 369 num_peers,
372 peer_ids, 370 peer_ids,
373 &session_id, 371 &session_id,
374 dkg_start, 372 dkg_start,
375 dkg_deadline, 373 dkg_deadline,
376 threshold, 374 threshold,
377 &secret_ready_cb, sp); 375 &secret_ready_cb, sp);
378 return *sp; 376 return *sp;
379} 377}
380 378
@@ -388,20 +386,20 @@ session_connect_adapter (void *cls,
388 * @param op_result service handle returned from the connect adapter 386 * @param op_result service handle returned from the connect adapter
389 */ 387 */
390static void 388static void
391session_disconnect_adapter (void *cls, void *op_result) 389session_disconnect_adapter(void *cls, void *op_result)
392{ 390{
393 struct GNUNET_SECRETSHARING_Session **sp = cls; 391 struct GNUNET_SECRETSHARING_Session **sp = cls;
394 unsigned int n = (sp - session_handles); 392 unsigned int n = (sp - session_handles);
395 393
396 GNUNET_assert (*sp == session_handles[n]); 394 GNUNET_assert(*sp == session_handles[n]);
397 395
398 if (NULL != *sp) 396 if (NULL != *sp)
399 { 397 {
400 GNUNET_SECRETSHARING_session_destroy (*sp); 398 GNUNET_SECRETSHARING_session_destroy(*sp);
401 *sp = NULL; 399 *sp = NULL;
402 } 400 }
403 401
404 GNUNET_assert (NULL != connect_ops[n]); 402 GNUNET_assert(NULL != connect_ops[n]);
405 connect_ops[n] = NULL; 403 connect_ops[n] = NULL;
406 404
407 if (GNUNET_YES == in_shutdown) 405 if (GNUNET_YES == in_shutdown)
@@ -409,29 +407,29 @@ session_disconnect_adapter (void *cls, void *op_result)
409 407
410 // all peers received their secret 408 // all peers received their secret
411 if (num_generated == num_peers) 409 if (num_generated == num_peers)
412 {
413 int i;
414
415 // only do decryption if requested by the user
416 if (GNUNET_NO == decrypt)
417 { 410 {
418 GNUNET_SCHEDULER_shutdown (); 411 int i;
419 return;
420 }
421 412
422 decrypt_start = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); 413 // only do decryption if requested by the user
423 decrypt_deadline = GNUNET_TIME_absolute_add (decrypt_start, timeout); 414 if (GNUNET_NO == decrypt)
415 {
416 GNUNET_SCHEDULER_shutdown();
417 return;
418 }
424 419
425 // compute g^42 as the plaintext which we will decrypt and then 420 decrypt_start = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), delay);
426 // cooperatively decrypt 421 decrypt_deadline = GNUNET_TIME_absolute_add(decrypt_start, timeout);
427 GNUNET_SECRETSHARING_plaintext_generate_i (&reference_plaintext, 42);
428 GNUNET_SECRETSHARING_encrypt (&common_pubkey, &reference_plaintext, &ciphertext);
429 422
430 for (i = 0; i < num_peers; i++) 423 // compute g^42 as the plaintext which we will decrypt and then
431 connect_ops[i] = 424 // cooperatively decrypt
432 GNUNET_TESTBED_service_connect (NULL, peers[i], "secretsharing", &decrypt_connect_complete, NULL, 425 GNUNET_SECRETSHARING_plaintext_generate_i(&reference_plaintext, 42);
433 &decrypt_connect_adapter, &decrypt_disconnect_adapter, &decrypt_handles[i]); 426 GNUNET_SECRETSHARING_encrypt(&common_pubkey, &reference_plaintext, &ciphertext);
434 } 427
428 for (i = 0; i < num_peers; i++)
429 connect_ops[i] =
430 GNUNET_TESTBED_service_connect(NULL, peers[i], "secretsharing", &decrypt_connect_complete, NULL,
431 &decrypt_connect_adapter, &decrypt_disconnect_adapter, &decrypt_handles[i]);
432 }
435} 433}
436 434
437 435
@@ -445,34 +443,34 @@ session_disconnect_adapter (void *cls, void *op_result)
445 * operation is successfull 443 * operation is successfull
446 */ 444 */
447static void 445static void
448peer_info_cb (void *cb_cls, 446peer_info_cb(void *cb_cls,
449 struct GNUNET_TESTBED_Operation *op, 447 struct GNUNET_TESTBED_Operation *op,
450 const struct GNUNET_TESTBED_PeerInformation *pinfo, 448 const struct GNUNET_TESTBED_PeerInformation *pinfo,
451 const char *emsg) 449 const char *emsg)
452{ 450{
453 struct GNUNET_PeerIdentity *p; 451 struct GNUNET_PeerIdentity *p;
454 int i; 452 int i;
455 453
456 GNUNET_assert (NULL == emsg); 454 GNUNET_assert(NULL == emsg);
457 455
458 p = (struct GNUNET_PeerIdentity *) cb_cls; 456 p = (struct GNUNET_PeerIdentity *)cb_cls;
459 457
460 if (pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY) 458 if (pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY)
461 { 459 {
462 *p = *pinfo->result.id; 460 *p = *pinfo->result.id;
463 num_retrieved_peer_ids++; 461 num_retrieved_peer_ids++;
464 if (num_retrieved_peer_ids == num_peers) 462 if (num_retrieved_peer_ids == num_peers)
465 for (i = 0; i < num_peers; i++) 463 for (i = 0; i < num_peers; i++)
466 connect_ops[i] = 464 connect_ops[i] =
467 GNUNET_TESTBED_service_connect (NULL, peers[i], "secretsharing", session_connect_complete, NULL, 465 GNUNET_TESTBED_service_connect(NULL, peers[i], "secretsharing", session_connect_complete, NULL,
468 session_connect_adapter, session_disconnect_adapter, &session_handles[i]); 466 session_connect_adapter, session_disconnect_adapter, &session_handles[i]);
469 } 467 }
470 else 468 else
471 { 469 {
472 GNUNET_assert (0); 470 GNUNET_assert(0);
473 } 471 }
474 472
475 GNUNET_TESTBED_operation_done (op); 473 GNUNET_TESTBED_operation_done(op);
476} 474}
477 475
478 476
@@ -482,21 +480,21 @@ peer_info_cb (void *cb_cls,
482 * @param cls closure 480 * @param cls closure
483 */ 481 */
484static void 482static void
485handle_shutdown (void *cls) 483handle_shutdown(void *cls)
486{ 484{
487 in_shutdown = GNUNET_YES; 485 in_shutdown = GNUNET_YES;
488 486
489 if (NULL != connect_ops) 487 if (NULL != connect_ops)
490 { 488 {
491 unsigned int i; 489 unsigned int i;
492 for (i = 0; i < num_peers; i++) 490 for (i = 0; i < num_peers; i++)
493 if (NULL != connect_ops[i]) 491 if (NULL != connect_ops[i])
494 { 492 {
495 // the disconnect callback will set the op to NULL 493 // the disconnect callback will set the op to NULL
496 GNUNET_TESTBED_operation_done (connect_ops[i]); 494 GNUNET_TESTBED_operation_done(connect_ops[i]);
497 } 495 }
498 GNUNET_free (connect_ops); 496 GNUNET_free(connect_ops);
499 } 497 }
500 498
501 // killing the testbed operation will take care of remaining 499 // killing the testbed operation will take care of remaining
502 // service handles in the disconnect callback 500 // service handles in the disconnect callback
@@ -517,131 +515,131 @@ handle_shutdown (void *cls)
517 * failed 515 * failed
518 */ 516 */
519static void 517static void
520test_master (void *cls, 518test_master(void *cls,
521 struct GNUNET_TESTBED_RunHandle *h, 519 struct GNUNET_TESTBED_RunHandle *h,
522 unsigned int num_peers, 520 unsigned int num_peers,
523 struct GNUNET_TESTBED_Peer **started_peers, 521 struct GNUNET_TESTBED_Peer **started_peers,
524 unsigned int links_succeeded, 522 unsigned int links_succeeded,
525 unsigned int links_failed) 523 unsigned int links_failed)
526{ 524{
527 int i; 525 int i;
528 526
529 GNUNET_log_setup ("gnunet-secretsharing-profiler", "INFO", NULL); 527 GNUNET_log_setup("gnunet-secretsharing-profiler", "INFO", NULL);
530 528
531 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "test master\n"); 529 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "test master\n");
532 530
533 GNUNET_SCHEDULER_add_shutdown (&handle_shutdown, NULL); 531 GNUNET_SCHEDULER_add_shutdown(&handle_shutdown, NULL);
534 532
535 peers = started_peers; 533 peers = started_peers;
536 534
537 peer_ids = GNUNET_malloc (num_peers * sizeof (struct GNUNET_PeerIdentity)); 535 peer_ids = GNUNET_malloc(num_peers * sizeof(struct GNUNET_PeerIdentity));
538 536
539 session_handles = GNUNET_new_array (num_peers, struct GNUNET_SECRETSHARING_Session *); 537 session_handles = GNUNET_new_array(num_peers, struct GNUNET_SECRETSHARING_Session *);
540 decrypt_handles = GNUNET_new_array (num_peers, struct GNUNET_SECRETSHARING_DecryptionHandle *); 538 decrypt_handles = GNUNET_new_array(num_peers, struct GNUNET_SECRETSHARING_DecryptionHandle *);
541 connect_ops = GNUNET_new_array (num_peers, struct GNUNET_TESTBED_Operation *); 539 connect_ops = GNUNET_new_array(num_peers, struct GNUNET_TESTBED_Operation *);
542 shares = GNUNET_new_array (num_peers, struct GNUNET_SECRETSHARING_Share *); 540 shares = GNUNET_new_array(num_peers, struct GNUNET_SECRETSHARING_Share *);
543 541
544 for (i = 0; i < num_peers; i++) 542 for (i = 0; i < num_peers; i++)
545 { 543 {
546 // we do not store the returned operation, as peer_info_cb 544 // we do not store the returned operation, as peer_info_cb
547 // will receive it as a parameter and call GNUNET_TESTBED_operation_done. 545 // will receive it as a parameter and call GNUNET_TESTBED_operation_done.
548 GNUNET_TESTBED_peer_get_information (peers[i], 546 GNUNET_TESTBED_peer_get_information(peers[i],
549 GNUNET_TESTBED_PIT_IDENTITY, 547 GNUNET_TESTBED_PIT_IDENTITY,
550 peer_info_cb, 548 peer_info_cb,
551 &peer_ids[i]); 549 &peer_ids[i]);
552 } 550 }
553} 551}
554 552
555 553
556static void 554static void
557run (void *cls, char *const *args, const char *cfgfile, 555run(void *cls, char *const *args, const char *cfgfile,
558 const struct GNUNET_CONFIGURATION_Handle *cfg) 556 const struct GNUNET_CONFIGURATION_Handle *cfg)
559{ 557{
560 static char *session_str = "gnunet-secretsharing/test"; 558 static char *session_str = "gnunet-secretsharing/test";
561 char *topology; 559 char *topology;
562 int topology_cmp_result; 560 int topology_cmp_result;
563 561
564 dkg_start = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); 562 dkg_start = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), delay);
565 dkg_deadline = GNUNET_TIME_absolute_add (dkg_start, timeout); 563 dkg_deadline = GNUNET_TIME_absolute_add(dkg_start, timeout);
566 564
567 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "testbed", "OVERLAY_TOPOLOGY", &topology)) 565 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "testbed", "OVERLAY_TOPOLOGY", &topology))
568 { 566 {
569 fprintf (stderr, 567 fprintf(stderr,
570 "'OVERLAY_TOPOLOGY' not found in 'testbed' config section, " 568 "'OVERLAY_TOPOLOGY' not found in 'testbed' config section, "
571 "seems like you passed the wrong configuration file\n"); 569 "seems like you passed the wrong configuration file\n");
572 return; 570 return;
573 } 571 }
574 572
575 topology_cmp_result = strcasecmp (topology, "NONE"); 573 topology_cmp_result = strcasecmp(topology, "NONE");
576 GNUNET_free (topology); 574 GNUNET_free(topology);
577 575
578 if (0 == topology_cmp_result) 576 if (0 == topology_cmp_result)
579 { 577 {
580 fprintf (stderr, 578 fprintf(stderr,
581 "'OVERLAY_TOPOLOGY' set to 'NONE', " 579 "'OVERLAY_TOPOLOGY' set to 'NONE', "
582 "seems like you passed the wrong configuration file\n"); 580 "seems like you passed the wrong configuration file\n");
583 return; 581 return;
584 } 582 }
585 583
586 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 584 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
587 "running gnunet-secretsharing-profiler\n"); 585 "running gnunet-secretsharing-profiler\n");
588 586
589 GNUNET_CRYPTO_hash (session_str, strlen (session_str), &session_id); 587 GNUNET_CRYPTO_hash(session_str, strlen(session_str), &session_id);
590 588
591 (void) GNUNET_TESTBED_test_run ("gnunet-secretsharing-profiler", 589 (void)GNUNET_TESTBED_test_run("gnunet-secretsharing-profiler",
592 cfgfile, 590 cfgfile,
593 num_peers, 591 num_peers,
594 0, 592 0,
595 controller_cb, 593 controller_cb,
596 NULL, 594 NULL,
597 test_master, 595 test_master,
598 NULL); 596 NULL);
599} 597}
600 598
601 599
602int 600int
603main (int argc, char **argv) 601main(int argc, char **argv)
604{ 602{
605 struct GNUNET_GETOPT_CommandLineOption options[] = { 603 struct GNUNET_GETOPT_CommandLineOption options[] = {
606 604 GNUNET_GETOPT_option_uint('n',
607 GNUNET_GETOPT_option_uint ('n', 605 "num-peers",
608 "num-peers", 606 NULL,
609 NULL, 607 gettext_noop("number of peers in consensus"),
610 gettext_noop ("number of peers in consensus"), 608 &num_peers),
611 &num_peers), 609
612 610 GNUNET_GETOPT_option_relative_time('D',
613 GNUNET_GETOPT_option_relative_time ('D', 611 "delay",
614 "delay", 612 NULL,
615 NULL, 613 gettext_noop("dkg start delay"),
616 gettext_noop ("dkg start delay"), 614 &delay),
617 &delay), 615
618 616 GNUNET_GETOPT_option_relative_time('t',
619 GNUNET_GETOPT_option_relative_time ('t', 617 "timeout",
620 "timeout", 618 NULL,
621 NULL, 619 gettext_noop("dkg timeout"),
622 gettext_noop ("dkg timeout"), 620 &timeout),
623 &timeout), 621
624 622 GNUNET_GETOPT_option_uint('k',
625 GNUNET_GETOPT_option_uint ('k', 623 "threshold",
626 "threshold", 624 NULL,
627 NULL, 625 gettext_noop("threshold"),
628 gettext_noop ("threshold"), 626 &threshold),
629 &threshold), 627
630 628 GNUNET_GETOPT_option_flag('d',
631 GNUNET_GETOPT_option_flag ('d', 629 "descrypt",
632 "descrypt", 630 gettext_noop("also profile decryption"),
633 gettext_noop ("also profile decryption"), 631 &decrypt),
634 &decrypt), 632
635 633
636 634 GNUNET_GETOPT_option_verbose(&verbose),
637 GNUNET_GETOPT_option_verbose (&verbose),
638 635
639 GNUNET_GETOPT_OPTION_END 636 GNUNET_GETOPT_OPTION_END
640 }; 637 };
638
641 delay = GNUNET_TIME_UNIT_ZERO; 639 delay = GNUNET_TIME_UNIT_ZERO;
642 timeout = GNUNET_TIME_UNIT_MINUTES; 640 timeout = GNUNET_TIME_UNIT_MINUTES;
643 GNUNET_PROGRAM_run2 (argc, argv, "gnunet-secretsharing-profiler", 641 GNUNET_PROGRAM_run2(argc, argv, "gnunet-secretsharing-profiler",
644 "help", 642 "help",
645 options, &run, NULL, GNUNET_YES); 643 options, &run, NULL, GNUNET_YES);
646 return 0; 644 return 0;
647} 645}