diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-01 08:29:32 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-01 08:29:32 +0000 |
commit | 1e72e368fc1026b2afe5094891c2e41edf211877 (patch) | |
tree | 54089b3bc2e1faa162b70fa909d117971dffc2c6 /src/experimentation | |
parent | 15e69b2c40795016f3365ec2e75d3368a23d6013 (diff) | |
download | gnunet-1e72e368fc1026b2afe5094891c2e41edf211877.tar.gz gnunet-1e72e368fc1026b2afe5094891c2e41edf211877.zip |
-just indentation
Diffstat (limited to 'src/experimentation')
-rw-r--r-- | src/experimentation/gnunet-daemon-experimentation_experiments.c | 509 |
1 files changed, 276 insertions, 233 deletions
diff --git a/src/experimentation/gnunet-daemon-experimentation_experiments.c b/src/experimentation/gnunet-daemon-experimentation_experiments.c index 5ca81393f..d0dda1b1b 100644 --- a/src/experimentation/gnunet-daemon-experimentation_experiments.c +++ b/src/experimentation/gnunet-daemon-experimentation_experiments.c | |||
@@ -58,7 +58,7 @@ static uint32_t GSE_my_issuer_count; | |||
58 | * | 58 | * |
59 | * Array Experimentation_Issuer with GSE_my_issuer_count elements | 59 | * Array Experimentation_Issuer with GSE_my_issuer_count elements |
60 | */ | 60 | */ |
61 | struct Experimentation_Issuer *GSE_my_issuer; | 61 | static struct Experimentation_Issuer *GSE_my_issuer; |
62 | 62 | ||
63 | 63 | ||
64 | /** | 64 | /** |
@@ -68,7 +68,7 @@ struct Experimentation_Issuer *GSE_my_issuer; | |||
68 | * @param e experiment | 68 | * @param e experiment |
69 | * @return GNUNET_OK or GNUNET_SYSERR | 69 | * @return GNUNET_OK or GNUNET_SYSERR |
70 | */ | 70 | */ |
71 | int | 71 | static int |
72 | experiment_verify (struct Issuer *i, struct Experiment *e) | 72 | experiment_verify (struct Issuer *i, struct Experiment *e) |
73 | { | 73 | { |
74 | GNUNET_assert (NULL != i); | 74 | GNUNET_assert (NULL != i); |
@@ -79,7 +79,8 @@ experiment_verify (struct Issuer *i, struct Experiment *e) | |||
79 | return GNUNET_OK; | 79 | return GNUNET_OK; |
80 | } | 80 | } |
81 | 81 | ||
82 | int | 82 | |
83 | static int | ||
83 | free_experiment (void *cls, | 84 | free_experiment (void *cls, |
84 | const struct GNUNET_HashCode * key, | 85 | const struct GNUNET_HashCode * key, |
85 | void *value) | 86 | void *value) |
@@ -102,7 +103,7 @@ free_experiment (void *cls, | |||
102 | * @param value the issuer element to free | 103 | * @param value the issuer element to free |
103 | * @return GNUNET_OK to continue | 104 | * @return GNUNET_OK to continue |
104 | */ | 105 | */ |
105 | int | 106 | static int |
106 | free_issuer (void *cls, | 107 | free_issuer (void *cls, |
107 | const struct GNUNET_HashCode * key, | 108 | const struct GNUNET_HashCode * key, |
108 | void *value) | 109 | void *value) |
@@ -115,7 +116,7 @@ free_issuer (void *cls, | |||
115 | } | 116 | } |
116 | 117 | ||
117 | 118 | ||
118 | int | 119 | static int |
119 | create_issuer (void *cls, | 120 | create_issuer (void *cls, |
120 | const struct GNUNET_HashCode * key, | 121 | const struct GNUNET_HashCode * key, |
121 | void *value) | 122 | void *value) |
@@ -224,19 +225,19 @@ GED_experiments_get (struct Node *n, | |||
224 | struct GNUNET_PeerIdentity *issuer, | 225 | struct GNUNET_PeerIdentity *issuer, |
225 | GNUNET_EXPERIMENTATION_experiments_get_cb get_cb) | 226 | GNUNET_EXPERIMENTATION_experiments_get_cb get_cb) |
226 | { | 227 | { |
227 | struct GetCtx get_ctx; | 228 | struct GetCtx get_ctx; |
228 | 229 | ||
229 | GNUNET_assert (NULL != n); | 230 | GNUNET_assert (NULL != n); |
230 | GNUNET_assert (NULL != experiments); | 231 | GNUNET_assert (NULL != experiments); |
231 | GNUNET_assert (NULL != get_cb); | 232 | GNUNET_assert (NULL != get_cb); |
232 | 233 | ||
233 | get_ctx.n = n; | 234 | get_ctx.n = n; |
234 | get_ctx.get_cb = get_cb; | 235 | get_ctx.get_cb = get_cb; |
235 | |||
236 | GNUNET_CONTAINER_multihashmap_get_multiple (experiments, | ||
237 | &issuer->hashPubKey, &get_it, &get_ctx); | ||
238 | 236 | ||
239 | get_cb (n, NULL); | 237 | GNUNET_CONTAINER_multihashmap_get_multiple (experiments, |
238 | &issuer->hashPubKey, &get_it, &get_ctx); | ||
239 | |||
240 | get_cb (n, NULL); | ||
240 | } | 241 | } |
241 | 242 | ||
242 | 243 | ||
@@ -255,41 +256,48 @@ GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i, | |||
255 | struct GNUNET_TIME_Relative duration, | 256 | struct GNUNET_TIME_Relative duration, |
256 | struct GNUNET_TIME_Absolute stop) | 257 | struct GNUNET_TIME_Absolute stop) |
257 | { | 258 | { |
258 | struct Experiment *e; | 259 | struct Experiment *e; |
259 | 260 | ||
260 | e = GNUNET_new (struct Experiment); | 261 | e = GNUNET_new (struct Experiment); |
261 | 262 | e->name = GNUNET_strdup (name); | |
262 | e->name = GNUNET_strdup (name); | 263 | e->issuer = issuer_id; |
263 | e->issuer = issuer_id; | 264 | e->version = version; |
264 | e->version = version; | 265 | if (NULL != description) |
265 | if (NULL != description) | 266 | e->description = GNUNET_strdup (description); |
266 | e->description = GNUNET_strdup (description); | 267 | e->required_capabilities = required_capabilities; |
267 | e->required_capabilities = required_capabilities; | 268 | e->start = start; |
268 | e->start = start; | 269 | e->frequency = frequency; |
269 | e->frequency = frequency; | 270 | e->duration = duration; |
270 | e->duration = duration; | 271 | e->stop = stop; |
271 | e->stop = stop; | 272 | |
272 | 273 | /* verify experiment */ | |
273 | /* verify experiment */ | 274 | if (GNUNET_SYSERR == experiment_verify (i, e)) |
274 | if (GNUNET_SYSERR == experiment_verify (i, e)) | 275 | { |
275 | { | 276 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
276 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Experiment signature is invalid\n"), name); | 277 | _("Experiment `%s': Experiment signature is invalid\n"), |
277 | GNUNET_free (e); | 278 | name); |
278 | GNUNET_free_non_null (e->name); | 279 | GNUNET_free (e); |
279 | GNUNET_free_non_null (e->description); | 280 | GNUNET_free_non_null (e->name); |
280 | return GNUNET_SYSERR; | 281 | GNUNET_free_non_null (e->description); |
281 | } | 282 | return GNUNET_SYSERR; |
282 | 283 | } | |
283 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Adding experiment `%s' running from `%s' to `%s' every %llu sec. for %llu sec. \n"), | 284 | |
284 | e->name, | 285 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
285 | GNUNET_STRINGS_absolute_time_to_string (start), | 286 | _("Adding experiment `%s' running from `%s' to `%s' every %llu sec. for %llu sec. \n"), |
286 | GNUNET_STRINGS_absolute_time_to_string (stop), | 287 | e->name, |
287 | (long long unsigned int) frequency.rel_value_us / 1000000LL, | 288 | GNUNET_STRINGS_absolute_time_to_string (start), |
288 | (long long unsigned int) duration.rel_value_us / 1000000LL); | 289 | GNUNET_STRINGS_absolute_time_to_string (stop), |
289 | GNUNET_CONTAINER_multihashmap_put (experiments, &e->issuer.hashPubKey, e, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 290 | (long long unsigned int) frequency.rel_value_us / 1000000LL, |
290 | GNUNET_STATISTICS_set (GED_stats, "# experiments", GNUNET_CONTAINER_multihashmap_size (experiments), GNUNET_NO); | 291 | (long long unsigned int) duration.rel_value_us / 1000000LL); |
291 | 292 | GNUNET_CONTAINER_multihashmap_put (experiments, | |
292 | return GNUNET_OK; | 293 | &e->issuer.hashPubKey, |
294 | e, | ||
295 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
296 | GNUNET_STATISTICS_set (GED_stats, | ||
297 | "# experiments", | ||
298 | GNUNET_CONTAINER_multihashmap_size (experiments), GNUNET_NO); | ||
299 | |||
300 | return GNUNET_OK; | ||
293 | } | 301 | } |
294 | 302 | ||
295 | 303 | ||
@@ -299,91 +307,93 @@ GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i, | |||
299 | * @param cls configuration handle | 307 | * @param cls configuration handle |
300 | * @param name section name | 308 | * @param name section name |
301 | */ | 309 | */ |
302 | void | 310 | static void |
303 | exp_file_iterator (void *cls, | 311 | exp_file_iterator (void *cls, |
304 | const char *name) | 312 | const char *name) |
305 | { | 313 | { |
306 | struct GNUNET_CONFIGURATION_Handle *exp = cls; | 314 | struct GNUNET_CONFIGURATION_Handle *exp = cls; |
307 | struct Issuer *i; | 315 | struct Issuer *i; |
308 | 316 | char *val; | |
309 | char *val; | 317 | unsigned long long number; |
310 | unsigned long long number; | 318 | /* Experiment values */ |
311 | 319 | struct GNUNET_PeerIdentity issuer; | |
312 | /* Experiment values */ | 320 | struct GNUNET_TIME_Absolute version; |
313 | struct GNUNET_PeerIdentity issuer; | 321 | char *description; |
314 | struct GNUNET_TIME_Absolute version; | 322 | uint32_t required_capabilities; |
315 | char *description; | 323 | struct GNUNET_TIME_Absolute start ; |
316 | uint32_t required_capabilities; | 324 | struct GNUNET_TIME_Absolute stop; |
317 | struct GNUNET_TIME_Absolute start ; | 325 | struct GNUNET_TIME_Relative frequency; |
318 | struct GNUNET_TIME_Absolute stop; | 326 | struct GNUNET_TIME_Relative duration; |
319 | struct GNUNET_TIME_Relative frequency; | 327 | |
320 | struct GNUNET_TIME_Relative duration; | 328 | /* Mandatory fields */ |
321 | 329 | ||
322 | //GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Parsing section `%s'\n", name); | 330 | /* Issuer */ |
323 | 331 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (exp, name, "ISSUER", &val)) | |
324 | /* Mandatory fields */ | 332 | { |
325 | 333 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | |
326 | /* Issuer */ | 334 | _("Experiment `%s': Issuer missing\n"), name); |
327 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (exp, name, "ISSUER", &val)) | 335 | return; |
328 | { | 336 | } |
329 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Issuer missing\n"), name); | 337 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string (val, &issuer.hashPubKey)) |
330 | return; | 338 | { |
331 | } | 339 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
332 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string (val, &issuer.hashPubKey)) | 340 | _("Experiment `%s': Issuer invalid\n"), name); |
333 | { | 341 | GNUNET_free (val); |
334 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Issuer invalid\n"), name); | 342 | return; |
335 | GNUNET_free (val); | 343 | } |
336 | return; | 344 | if (NULL == (i = GNUNET_CONTAINER_multihashmap_get (valid_issuers, &issuer.hashPubKey))) |
337 | } | 345 | { |
338 | if (NULL == (i = GNUNET_CONTAINER_multihashmap_get (valid_issuers, &issuer.hashPubKey))) | 346 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
339 | { | 347 | _("Experiment `%s': Issuer not accepted!\n"), name); |
340 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Issuer not accepted!\n"), name); | 348 | GNUNET_free (val); |
341 | GNUNET_free (val); | 349 | return; |
342 | return; | 350 | } |
343 | } | 351 | GNUNET_free (val); |
344 | GNUNET_free (val); | 352 | |
345 | 353 | /* Version */ | |
346 | /* Version */ | 354 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "VERSION", &number)) |
347 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "VERSION", &number)) | 355 | { |
348 | { | 356 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
349 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Version missing or invalid \n"), name); | 357 | _("Experiment `%s': Version missing or invalid \n"), name); |
350 | return; | 358 | return; |
351 | } | 359 | } |
352 | version.abs_value_us = number; // FIXME: what is this supposed to be? Version != TIME!??? | 360 | version.abs_value_us = number; // FIXME: what is this supposed to be? Version != TIME!??? |
353 | 361 | ||
354 | /* Required capabilities */ | 362 | /* Required capabilities */ |
355 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "CAPABILITIES", &number)) | 363 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "CAPABILITIES", &number)) |
356 | { | 364 | { |
357 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Required capabilities missing \n"), name); | 365 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
358 | return; | 366 | _("Experiment `%s': Required capabilities missing \n"), name); |
359 | } | 367 | return; |
360 | if (number > UINT32_MAX) | 368 | } |
361 | { | 369 | if (number > UINT32_MAX) |
362 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Required capabilities invalid \n"), name); | 370 | { |
363 | return; | 371 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
364 | } | 372 | _("Experiment `%s': Required capabilities invalid \n"), name); |
365 | required_capabilities = number; | 373 | return; |
366 | 374 | } | |
367 | /* Optional fields */ | 375 | required_capabilities = number; |
368 | 376 | ||
369 | /* Description */ | 377 | /* Optional fields */ |
370 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (exp, name, "DESCRIPTION", &description)) | 378 | |
371 | description = NULL; | 379 | /* Description */ |
372 | 380 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (exp, name, "DESCRIPTION", &description)) | |
373 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "START", (long long unsigned int *) &start.abs_value_us)) | 381 | description = NULL; |
374 | start = GNUNET_TIME_UNIT_ZERO_ABS; | 382 | |
375 | 383 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "START", (long long unsigned int *) &start.abs_value_us)) | |
376 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (exp, name, "FREQUENCY", &frequency)) | 384 | start = GNUNET_TIME_UNIT_ZERO_ABS; |
377 | frequency = EXP_DEFAULT_EXP_FREQ; | 385 | |
378 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (exp, name, "DURATION", &duration)) | 386 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (exp, name, "FREQUENCY", &frequency)) |
379 | duration = EXP_DEFAULT_EXP_DUR; | 387 | frequency = EXP_DEFAULT_EXP_FREQ; |
380 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "STOP", (long long unsigned int *)&stop.abs_value_us)) | 388 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (exp, name, "DURATION", &duration)) |
381 | stop = GNUNET_TIME_UNIT_FOREVER_ABS; | 389 | duration = EXP_DEFAULT_EXP_DUR; |
382 | 390 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "STOP", (long long unsigned int *)&stop.abs_value_us)) | |
383 | GNUNET_EXPERIMENTATION_experiments_add (i, name, issuer, version, | 391 | stop = GNUNET_TIME_UNIT_FOREVER_ABS; |
384 | description, required_capabilities, | 392 | |
385 | start, frequency, duration, stop); | 393 | GNUNET_EXPERIMENTATION_experiments_add (i, name, issuer, version, |
386 | GNUNET_free_non_null (description); | 394 | description, required_capabilities, |
395 | start, frequency, duration, stop); | ||
396 | GNUNET_free_non_null (description); | ||
387 | } | 397 | } |
388 | 398 | ||
389 | 399 | ||
@@ -395,18 +405,21 @@ exp_file_iterator (void *cls, | |||
395 | static void | 405 | static void |
396 | load_file (const char * file) | 406 | load_file (const char * file) |
397 | { | 407 | { |
398 | struct GNUNET_CONFIGURATION_Handle *exp = GNUNET_CONFIGURATION_create(); | 408 | struct GNUNET_CONFIGURATION_Handle *exp = GNUNET_CONFIGURATION_create(); |
399 | if (NULL == exp) | 409 | |
400 | return; | 410 | if (NULL == exp) |
401 | 411 | return; | |
402 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_parse (exp, file)) | 412 | |
403 | { | 413 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_parse (exp, file)) |
404 | GNUNET_CONFIGURATION_destroy (exp); | 414 | { |
405 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to parse file `%s'\n"), file); | 415 | GNUNET_CONFIGURATION_destroy (exp); |
406 | return; | 416 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
407 | } | 417 | _("Failed to parse file `%s'\n"), |
408 | GNUNET_CONFIGURATION_iterate_sections (exp, &exp_file_iterator, exp); | 418 | file); |
409 | GNUNET_CONFIGURATION_destroy (exp); | 419 | return; |
420 | } | ||
421 | GNUNET_CONFIGURATION_iterate_sections (exp, &exp_file_iterator, exp); | ||
422 | GNUNET_CONFIGURATION_destroy (exp); | ||
410 | } | 423 | } |
411 | 424 | ||
412 | 425 | ||
@@ -416,86 +429,116 @@ load_file (const char * file) | |||
416 | int | 429 | int |
417 | GED_experiments_start () | 430 | GED_experiments_start () |
418 | { | 431 | { |
419 | struct Issuer *i; | 432 | struct Issuer *i; |
420 | char *issuers; | 433 | char *issuers; |
421 | char *file; | 434 | char *file; |
422 | char *pubkey; | 435 | char *pubkey; |
423 | char *pos; | 436 | char *pos; |
424 | struct GNUNET_PeerIdentity issuer_ID; | 437 | struct GNUNET_PeerIdentity issuer_ID; |
425 | struct GNUNET_CRYPTO_EccPublicSignKey pub; | 438 | struct GNUNET_CRYPTO_EccPublicSignKey pub; |
426 | struct GNUNET_HashCode hash; | 439 | struct GNUNET_HashCode hash; |
427 | 440 | ||
428 | /* Load valid issuer */ | 441 | /* Load valid issuer */ |
429 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (GED_cfg, "EXPERIMENTATION", "ISSUERS", &issuers)) | 442 | if (GNUNET_SYSERR == |
430 | { | 443 | GNUNET_CONFIGURATION_get_value_string (GED_cfg, "EXPERIMENTATION", "ISSUERS", &issuers)) |
431 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("No valid experiment issuers configured! Set value to peer id of issuer! Exit...\n")); | ||
432 | return GNUNET_SYSERR; | ||
433 | } | ||
434 | |||
435 | valid_issuers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | ||
436 | for (pos = strtok (issuers, " "); pos != NULL; pos = strtok (NULL, " ")) | ||
437 | { | 444 | { |
438 | 445 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | |
439 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string (pos, &issuer_ID.hashPubKey)) | 446 | _("No valid experiment issuers configured! Set value to peer id of issuer! Exit...\n")); |
440 | { | 447 | return GNUNET_SYSERR; |
441 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid value `%s'\n"), pos); | 448 | } |
442 | } | 449 | |
443 | else | 450 | valid_issuers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); |
444 | { | 451 | for (pos = strtok (issuers, " "); pos != NULL; pos = strtok (NULL, " ")) |
445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' is a valid issuer \n", GNUNET_i2s (&issuer_ID)); | 452 | { |
446 | i = GNUNET_malloc (sizeof (struct Issuer)); | 453 | if (GNUNET_SYSERR == GNUNET_CRYPTO_ecc_public_sign_key_from_string (pos, |
447 | GNUNET_CONTAINER_multihashmap_put (valid_issuers, &issuer_ID.hashPubKey, | 454 | strlen (pos), |
448 | i, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 455 | &issuer_ID)) |
449 | i = NULL; | 456 | { |
450 | } | 457 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
458 | _("Invalid value `%s'\n"), | ||
459 | pos); | ||
460 | } | ||
461 | else | ||
462 | { | ||
463 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
464 | "`%s' is a valid issuer \n", | ||
465 | GNUNET_i2s (&issuer_ID)); | ||
466 | i = GNUNET_new (struct Issuer); | ||
467 | i->pubkey = issuer_ID; | ||
468 | GNUNET_CRYPTO_hash( &issuer_ID, sizeof (issuer_ID), &hash); | ||
469 | GNUNET_CONTAINER_multihashmap_put (valid_issuers, | ||
470 | &hash, | ||
471 | i, | ||
472 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | ||
473 | } | ||
451 | } | 474 | } |
452 | GNUNET_free (issuers); | 475 | GNUNET_free (issuers); |
453 | 476 | ||
454 | if (0 == GNUNET_CONTAINER_multihashmap_size (valid_issuers)) | 477 | if (0 == GNUNET_CONTAINER_multihashmap_size (valid_issuers)) |
455 | { | 478 | { |
456 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("No valid experiment issuers configured! Set value to peer id of issuer! Exit...\n")); | 479 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
457 | GED_experiments_stop (); | 480 | _("No valid experiment issuers configured! Set value to peer id of issuer! Exit...\n")); |
458 | return GNUNET_SYSERR; | 481 | GED_experiments_stop (); |
482 | return GNUNET_SYSERR; | ||
483 | } | ||
484 | GNUNET_STATISTICS_set (GED_stats, | ||
485 | "# issuer", | ||
486 | GNUNET_CONTAINER_multihashmap_size (valid_issuers), | ||
487 | GNUNET_NO); | ||
488 | if (GNUNET_OK == | ||
489 | GNUNET_CONFIGURATION_get_value_string (GED_cfg, | ||
490 | "EXPERIMENTATION", | ||
491 | "PUBKEY", | ||
492 | &pubkey)) | ||
493 | { | ||
494 | if (GNUNET_OK != | ||
495 | GNUNET_CRYPTO_ecc_public_sign_key_from_string (pubkey, strlen (pubkey), &pub)) | ||
496 | { | ||
497 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
498 | _("Invalid public key `%s'\n"), | ||
499 | pubkey); | ||
500 | GED_experiments_stop (); | ||
501 | return GNUNET_SYSERR; | ||
502 | } | ||
503 | GNUNET_CRYPTO_hash( &pub, sizeof (pub), &hash); | ||
504 | if (NULL != (i = GNUNET_CONTAINER_multihashmap_get (valid_issuers, &hash))) | ||
505 | { | ||
506 | i->pubkey = pub; | ||
507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Found issuer for public key `%s'\n"), pubkey); | ||
508 | } | ||
509 | else | ||
510 | { | ||
511 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("No issuer for public key `%s'\n"), pubkey); | ||
512 | } | ||
513 | GNUNET_free (pubkey); | ||
459 | } | 514 | } |
460 | GNUNET_STATISTICS_set (GED_stats, "# issuer", GNUNET_CONTAINER_multihashmap_size (valid_issuers), GNUNET_NO); | 515 | |
461 | 516 | GSE_my_issuer_count = GNUNET_CONTAINER_multihashmap_size (valid_issuers); | |
462 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (GED_cfg, "EXPERIMENTATION", "PUBKEY", &pubkey)) | 517 | GSE_my_issuer = GNUNET_malloc (GSE_my_issuer_count * sizeof (struct Experimentation_Issuer)); |
463 | { | 518 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, &create_issuer, GSE_my_issuer); |
464 | if (GNUNET_OK != GNUNET_CRYPTO_ecc_public_sign_key_from_string(pubkey, strlen (pubkey), &pub)) | 519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
465 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid public key `%s'\n"), pubkey); | 520 | "Daemon has %u issuers\n", |
466 | else | 521 | GSE_my_issuer_count); |
467 | { | ||
468 | GNUNET_CRYPTO_hash( &pub, sizeof (pub), &hash); | ||
469 | if (NULL != (i = GNUNET_CONTAINER_multihashmap_get (valid_issuers, &hash))) | ||
470 | { | ||
471 | i->pubkey = pub; | ||
472 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Found issuer for public key `%s'\n"), pubkey); | ||
473 | } | ||
474 | else | ||
475 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("No issuer for public key `%s'\n"), pubkey); | ||
476 | } | ||
477 | GNUNET_free (pubkey); | ||
478 | } | ||
479 | |||
480 | GSE_my_issuer_count = GNUNET_CONTAINER_multihashmap_size (valid_issuers); | ||
481 | GSE_my_issuer = GNUNET_malloc (GSE_my_issuer_count * sizeof (struct Experimentation_Issuer)); | ||
482 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, &create_issuer, GSE_my_issuer); | ||
483 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemon has %u issuers\n", GSE_my_issuer_count); | ||
484 | 522 | ||
485 | experiments = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | 523 | experiments = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); |
486 | /* Load experiments from file */ | 524 | /* Load experiments from file */ |
487 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (GED_cfg, "EXPERIMENTATION", "EXPERIMENTS", &file)) | 525 | if (GNUNET_SYSERR == |
488 | return GNUNET_OK; | 526 | GNUNET_CONFIGURATION_get_value_string (GED_cfg, |
489 | 527 | "EXPERIMENTATION", | |
490 | if (GNUNET_YES != GNUNET_DISK_file_test (file)) | 528 | "EXPERIMENTS", |
491 | { | 529 | &file)) |
492 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Cannot read experiments file `%s'\n"), file); | 530 | return GNUNET_OK; |
493 | GNUNET_free (file); | 531 | |
494 | return GNUNET_OK; | 532 | if (GNUNET_YES != GNUNET_DISK_file_test (file)) |
495 | } | 533 | { |
496 | load_file (file); | 534 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
497 | GNUNET_free (file); | 535 | _("Cannot read experiments file `%s'\n"), file); |
498 | return GNUNET_OK; | 536 | GNUNET_free (file); |
537 | return GNUNET_OK; | ||
538 | } | ||
539 | load_file (file); | ||
540 | GNUNET_free (file); | ||
541 | return GNUNET_OK; | ||
499 | } | 542 | } |
500 | 543 | ||
501 | 544 | ||
@@ -505,24 +548,24 @@ GED_experiments_start () | |||
505 | void | 548 | void |
506 | GED_experiments_stop () | 549 | GED_experiments_stop () |
507 | { | 550 | { |
508 | if (NULL != GSE_my_issuer) | 551 | if (NULL != GSE_my_issuer) |
509 | { | 552 | { |
510 | GNUNET_free (GSE_my_issuer); | 553 | GNUNET_free (GSE_my_issuer); |
511 | GSE_my_issuer = NULL; | 554 | GSE_my_issuer = NULL; |
512 | GSE_my_issuer_count = 0; | 555 | GSE_my_issuer_count = 0; |
513 | } | 556 | } |
514 | if (NULL != valid_issuers) | 557 | if (NULL != valid_issuers) |
515 | { | 558 | { |
516 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, &free_issuer, NULL); | 559 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, &free_issuer, NULL); |
517 | GNUNET_CONTAINER_multihashmap_destroy (valid_issuers); | 560 | GNUNET_CONTAINER_multihashmap_destroy (valid_issuers); |
518 | } | 561 | } |
519 | valid_issuers = NULL; | 562 | valid_issuers = NULL; |
520 | if (NULL != experiments) | 563 | if (NULL != experiments) |
521 | { | 564 | { |
522 | GNUNET_CONTAINER_multihashmap_iterate (experiments, &free_experiment, NULL); | 565 | GNUNET_CONTAINER_multihashmap_iterate (experiments, &free_experiment, NULL); |
523 | GNUNET_CONTAINER_multihashmap_destroy (experiments); | 566 | GNUNET_CONTAINER_multihashmap_destroy (experiments); |
524 | } | 567 | } |
525 | experiments = NULL; | 568 | experiments = NULL; |
526 | } | 569 | } |
527 | 570 | ||
528 | /* end of gnunet-daemon-experimentation_experiments.c */ | 571 | /* end of gnunet-daemon-experimentation_experiments.c */ |