aboutsummaryrefslogtreecommitdiff
path: root/src/experimentation
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-01 18:21:54 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-01 18:21:54 +0000
commit12dac16f3d701daa42ed4ffdea7e8bbb78b40e95 (patch)
treeb37b5ed7d9a465feb44a922dac03e1a873e55cc1 /src/experimentation
parent7997729c9e812b834b569db27eb3f9d8a6f664cf (diff)
downloadgnunet-12dac16f3d701daa42ed4ffdea7e8bbb78b40e95.tar.gz
gnunet-12dac16f3d701daa42ed4ffdea7e8bbb78b40e95.zip
-fix experimentation ftbfs
Diffstat (limited to 'src/experimentation')
-rw-r--r--src/experimentation/gnunet-daemon-experimentation.h8
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_experiments.c56
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_nodes.c27
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_storage.c1
4 files changed, 55 insertions, 37 deletions
diff --git a/src/experimentation/gnunet-daemon-experimentation.h b/src/experimentation/gnunet-daemon-experimentation.h
index cfcedcd13..9886f5d5d 100644
--- a/src/experimentation/gnunet-daemon-experimentation.h
+++ b/src/experimentation/gnunet-daemon-experimentation.h
@@ -174,6 +174,14 @@ struct Node
174 struct NodeComCtx *e_req_head; 174 struct NodeComCtx *e_req_head;
175 175
176 struct NodeComCtx *e_req_tail; 176 struct NodeComCtx *e_req_tail;
177
178 /**
179 * Array of issuers accepted by this neighbor.
180 */
181 struct GNUNET_CRYPTO_EccPublicSignKey *issuer_id;
182
183 unsigned int issuer_count;
184
177}; 185};
178 186
179 187
diff --git a/src/experimentation/gnunet-daemon-experimentation_experiments.c b/src/experimentation/gnunet-daemon-experimentation_experiments.c
index 3c00b72ab..b4db5188b 100644
--- a/src/experimentation/gnunet-daemon-experimentation_experiments.c
+++ b/src/experimentation/gnunet-daemon-experimentation_experiments.c
@@ -105,11 +105,11 @@ free_issuer (void *cls,
105 * @return #GNUNET_YES or #GNUNET_NO 105 * @return #GNUNET_YES or #GNUNET_NO
106 */ 106 */
107int 107int
108GED_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_id) 108GED_experiments_issuer_accepted (const struct GNUNET_CRYPTO_EccPublicSignKey *issuer_id)
109{ 109{
110 struct GNUNET_HashCode hash; 110 struct GNUNET_HashCode hash;
111 111
112 GNUNET_CRYPTO_hash (issuer_id, sizeof (struct GNUNET_PeerIdentity), &hash); 112 GNUNET_CRYPTO_hash (issuer_id, sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), &hash);
113 if (GNUNET_CONTAINER_multihashmap_contains (valid_issuers, &hash)) 113 if (GNUNET_CONTAINER_multihashmap_contains (valid_issuers, &hash))
114 return GNUNET_YES; 114 return GNUNET_YES;
115 return GNUNET_NO; 115 return GNUNET_NO;
@@ -121,14 +121,14 @@ GED_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_id)
121 * experiment map. 121 * experiment map.
122 */ 122 */
123static void 123static void
124get_experment_key (const struct GNUNET_PeerIdentity *issuer, 124get_experiment_key (const struct GNUNET_CRYPTO_EccPublicSignKey *issuer,
125 const char *name, 125 const char *name,
126 const struct GNUNET_TIME_Absolute version, 126 const struct GNUNET_TIME_Absolute version,
127 struct GNUNET_HashCode *key) 127 struct GNUNET_HashCode *key)
128{ 128{
129 GNUNET_assert (GNUNET_YES == 129 GNUNET_assert (GNUNET_YES ==
130 GNUNET_CRYPTO_kdf (key, sizeof (struct GNUNET_HashCode), 130 GNUNET_CRYPTO_kdf (key, sizeof (struct GNUNET_HashCode),
131 issuer, sizeof (struct GNUNET_PeerIdentity), 131 issuer, sizeof (struct GNUNET_CRYPTO_EccPublicSignKey),
132 name, strlen (name), 132 name, strlen (name),
133 &version, sizeof (version), 133 &version, sizeof (version),
134 NULL, 0)); 134 NULL, 0));
@@ -144,11 +144,11 @@ get_experment_key (const struct GNUNET_PeerIdentity *issuer,
144 * @return the experiment or NULL if not found 144 * @return the experiment or NULL if not found
145 */ 145 */
146struct Experiment * 146struct Experiment *
147GED_experiments_find (const struct GNUNET_PeerIdentity *issuer, 147GED_experiments_find (const struct GNUNET_CRYPTO_EccPublicSignKey *issuer,
148 const char *name, 148 const char *name,
149 const struct GNUNET_TIME_Absolute version) 149 const struct GNUNET_TIME_Absolute version)
150{ 150{
151 struct GNUENT_HashCode hc; 151 struct GNUNET_HashCode hc;
152 152
153 get_experiment_key (issuer, 153 get_experiment_key (issuer,
154 name, 154 name,
@@ -177,10 +177,10 @@ get_it (void *cls,
177 struct GetCtx *get_ctx = cls; 177 struct GetCtx *get_ctx = cls;
178 struct Experiment *e = value; 178 struct Experiment *e = value;
179 179
180 if (0 == memcmp (e->issuer, 180 if (0 == memcmp (&e->issuer,
181 get_ctx->issuer, 181 get_ctx->issuer,
182 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)) 182 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)))
183 get_ctx->get_cb (get_ctx->n, e); 183 get_ctx->get_cb (get_ctx->n, e);
184 return GNUNET_OK; 184 return GNUNET_OK;
185} 185}
186 186
@@ -210,7 +210,7 @@ GED_experiments_get (struct Node *n,
210int 210int
211GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i, 211GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i,
212 const char *name, 212 const char *name,
213 const struct GNUNET_CRYPTO_EccPublicKey *issuer_id, 213 const struct GNUNET_CRYPTO_EccPublicSignKey *issuer_id,
214 struct GNUNET_TIME_Absolute version, 214 struct GNUNET_TIME_Absolute version,
215 char *description, 215 char *description,
216 uint32_t required_capabilities, 216 uint32_t required_capabilities,
@@ -220,10 +220,11 @@ GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i,
220 struct GNUNET_TIME_Absolute stop) 220 struct GNUNET_TIME_Absolute stop)
221{ 221{
222 struct Experiment *e; 222 struct Experiment *e;
223 struct GNUNET_HashCode hc;
223 224
224 e = GNUNET_new (struct Experiment); 225 e = GNUNET_new (struct Experiment);
225 e->name = GNUNET_strdup (name); 226 e->name = GNUNET_strdup (name);
226 e->issuer = issuer_id; 227 e->issuer = *issuer_id;
227 e->version = version; 228 e->version = version;
228 if (NULL != description) 229 if (NULL != description)
229 e->description = GNUNET_strdup (description); 230 e->description = GNUNET_strdup (description);
@@ -252,8 +253,12 @@ GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i,
252 GNUNET_STRINGS_absolute_time_to_string (stop), 253 GNUNET_STRINGS_absolute_time_to_string (stop),
253 (long long unsigned int) frequency.rel_value_us / 1000000LL, 254 (long long unsigned int) frequency.rel_value_us / 1000000LL,
254 (long long unsigned int) duration.rel_value_us / 1000000LL); 255 (long long unsigned int) duration.rel_value_us / 1000000LL);
256 get_experiment_key (&e->issuer,
257 name,
258 version,
259 &hc);
255 GNUNET_CONTAINER_multihashmap_put (experiments, 260 GNUNET_CONTAINER_multihashmap_put (experiments,
256 &e->issuer.hashPubKey, 261 &hc,
257 e, 262 e,
258 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 263 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
259 GNUNET_STATISTICS_set (GED_stats, 264 GNUNET_STATISTICS_set (GED_stats,
@@ -279,7 +284,7 @@ exp_file_iterator (void *cls,
279 char *val; 284 char *val;
280 unsigned long long number; 285 unsigned long long number;
281 /* Experiment values */ 286 /* Experiment values */
282 struct GNUNET_PeerIdentity issuer; 287 struct GNUNET_CRYPTO_EccPublicSignKey issuer;
283 struct GNUNET_TIME_Absolute version; 288 struct GNUNET_TIME_Absolute version;
284 char *description; 289 char *description;
285 uint32_t required_capabilities; 290 uint32_t required_capabilities;
@@ -287,6 +292,7 @@ exp_file_iterator (void *cls,
287 struct GNUNET_TIME_Absolute stop; 292 struct GNUNET_TIME_Absolute stop;
288 struct GNUNET_TIME_Relative frequency; 293 struct GNUNET_TIME_Relative frequency;
289 struct GNUNET_TIME_Relative duration; 294 struct GNUNET_TIME_Relative duration;
295 struct GNUNET_HashCode phash;
290 296
291 /* Mandatory fields */ 297 /* Mandatory fields */
292 298
@@ -297,14 +303,18 @@ exp_file_iterator (void *cls,
297 _("Experiment `%s': Issuer missing\n"), name); 303 _("Experiment `%s': Issuer missing\n"), name);
298 return; 304 return;
299 } 305 }
300 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string (val, &issuer.hashPubKey)) 306 if (GNUNET_SYSERR ==
307 GNUNET_CRYPTO_ecc_public_sign_key_from_string (val,
308 strlen (val),
309 &issuer))
301 { 310 {
302 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 311 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
303 _("Experiment `%s': Issuer invalid\n"), name); 312 _("Experiment `%s': Issuer invalid\n"), name);
304 GNUNET_free (val); 313 GNUNET_free (val);
305 return; 314 return;
306 } 315 }
307 if (NULL == (i = GNUNET_CONTAINER_multihashmap_get (valid_issuers, &issuer.hashPubKey))) 316 GNUNET_CRYPTO_hash (&issuer, sizeof (issuer), &phash);
317 if (NULL == (i = GNUNET_CONTAINER_multihashmap_get (valid_issuers, &phash)))
308 { 318 {
309 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 319 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
310 _("Experiment `%s': Issuer not accepted!\n"), name); 320 _("Experiment `%s': Issuer not accepted!\n"), name);
@@ -353,7 +363,7 @@ exp_file_iterator (void *cls,
353 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "STOP", (long long unsigned int *)&stop.abs_value_us)) 363 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "STOP", (long long unsigned int *)&stop.abs_value_us))
354 stop = GNUNET_TIME_UNIT_FOREVER_ABS; 364 stop = GNUNET_TIME_UNIT_FOREVER_ABS;
355 365
356 GNUNET_EXPERIMENTATION_experiments_add (i, name, issuer, version, 366 GNUNET_EXPERIMENTATION_experiments_add (i, name, &issuer, version,
357 description, required_capabilities, 367 description, required_capabilities,
358 start, frequency, duration, stop); 368 start, frequency, duration, stop);
359 GNUNET_free_non_null (description); 369 GNUNET_free_non_null (description);
@@ -395,10 +405,8 @@ GED_experiments_start ()
395 struct Issuer *i; 405 struct Issuer *i;
396 char *issuers; 406 char *issuers;
397 char *file; 407 char *file;
398 char *pubkey;
399 char *pos; 408 char *pos;
400 struct GNUNET_PeerIdentity issuer_ID; 409 struct GNUNET_CRYPTO_EccPublicSignKey issuer_ID;
401 struct GNUNET_CRYPTO_EccPublicSignKey pub;
402 struct GNUNET_HashCode hash; 410 struct GNUNET_HashCode hash;
403 411
404 /* Load valid issuer */ 412 /* Load valid issuer */
@@ -417,13 +425,13 @@ GED_experiments_start ()
417 valid_issuers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); 425 valid_issuers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
418 for (pos = strtok (issuers, " "); pos != NULL; pos = strtok (NULL, " ")) 426 for (pos = strtok (issuers, " "); pos != NULL; pos = strtok (NULL, " "))
419 { 427 {
420 if (GNUNET_SYSERR == GNUNET_CRYPTO_ecc_public_sign_key_from_string (pos, 428 if (GNUNET_SYSERR == GNUNET_CRYPTO_ecc_public_sign_key_from_string (pos,
421 strlen (pos), 429 strlen (pos),
422 &issuer_ID)) 430 &issuer_ID))
423 { 431 {
424 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, 432 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
425 "EXPERIMENTATION", 433 "EXPERIMENTATION",
426 "ISSUERS" 434 "ISSUERS",
427 _("Invalid value for public key\n")); 435 _("Invalid value for public key\n"));
428 GED_experiments_stop (); 436 GED_experiments_stop ();
429 return GNUNET_SYSERR; 437 return GNUNET_SYSERR;
diff --git a/src/experimentation/gnunet-daemon-experimentation_nodes.c b/src/experimentation/gnunet-daemon-experimentation_nodes.c
index 2c8a0418e..5e29f5f73 100644
--- a/src/experimentation/gnunet-daemon-experimentation_nodes.c
+++ b/src/experimentation/gnunet-daemon-experimentation_nodes.c
@@ -471,7 +471,8 @@ handle_request (const struct GNUNET_PeerIdentity *peer,
471 struct Node *n; 471 struct Node *n;
472 struct NodeComCtx *e_ctx; 472 struct NodeComCtx *e_ctx;
473 const struct Experimentation_Request *rm = (const struct Experimentation_Request *) message; 473 const struct Experimentation_Request *rm = (const struct Experimentation_Request *) message;
474 const struct Experimentation_Issuer *rmi = (const struct Experimentation_Issuer *) &rm[1]; 474 const struct GNUNET_CRYPTO_EccPublicSignKey *rmi = (const struct GNUNET_CRYPTO_EccPublicSignKey *) &rm[1];
475 unsigned int my_issuer_count = GNUNET_CONTAINER_multihashmap_size (valid_issuers);
475 int c1; 476 int c1;
476 int c2; 477 int c2;
477 uint32_t ic; 478 uint32_t ic;
@@ -484,7 +485,8 @@ handle_request (const struct GNUNET_PeerIdentity *peer,
484 return; 485 return;
485 } 486 }
486 ic = ntohl (rm->issuer_count); 487 ic = ntohl (rm->issuer_count);
487 if (ntohs (message->size) != sizeof (struct Experimentation_Request) + ic * sizeof (struct Experimentation_Issuer)) 488 if (ntohs (message->size) !=
489 sizeof (struct Experimentation_Request) + ic * sizeof (struct GNUNET_CRYPTO_EccPublicSignKey))
488 { 490 {
489 GNUNET_break (0); 491 GNUNET_break (0);
490 return; 492 return;
@@ -528,20 +530,20 @@ handle_request (const struct GNUNET_PeerIdentity *peer,
528 ic_accepted = 0; 530 ic_accepted = 0;
529 for (c1 = 0; c1 < ic; c1++) 531 for (c1 = 0; c1 < ic; c1++)
530 { 532 {
531 if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id)) 533 if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1]))
532 ic_accepted ++; 534 ic_accepted ++;
533 } 535 }
534 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
535 "Request from peer `%s' with %u issuers, we accepted %u issuer \n", 537 "Request from peer `%s' with %u issuers, we accepted %u issuer \n",
536 GNUNET_i2s (peer), ic, ic_accepted); 538 GNUNET_i2s (peer), ic, ic_accepted);
537 GNUNET_free_non_null (n->issuer_id); 539 GNUNET_free_non_null (n->issuer_id);
538 n->issuer_id = GNUNET_malloc (ic_accepted * sizeof (struct GNUNET_PeerIdentity)); 540 n->issuer_id = GNUNET_malloc (ic_accepted * sizeof (struct GNUNET_CRYPTO_EccPublicSignKey));
539 c2 = 0; 541 c2 = 0;
540 for (c1 = 0; c1 < ic; c1++) 542 for (c1 = 0; c1 < ic; c1++)
541 { 543 {
542 if (GNUNET_YES == GED_experiments_issuer_accepted (&rmi[c1].issuer_id)) 544 if (GNUNET_YES == GED_experiments_issuer_accepted (&rmi[c1]))
543 { 545 {
544 n->issuer_id[c2] = rmi[c1].issuer_id; 546 n->issuer_id[c2] = rmi[c1];
545 c2 ++; 547 c2 ++;
546 } 548 }
547 } 549 }
@@ -554,7 +556,8 @@ handle_request (const struct GNUNET_PeerIdentity *peer,
554 e_ctx = GNUNET_new (struct NodeComCtx); 556 e_ctx = GNUNET_new (struct NodeComCtx);
555 e_ctx->n = n; 557 e_ctx->n = n;
556 e_ctx->e = NULL; 558 e_ctx->e = NULL;
557 e_ctx->size = sizeof (struct Experimentation_Response) + GSE_my_issuer_count * sizeof (struct Experimentation_Issuer); 559 e_ctx->size = sizeof (struct Experimentation_Response) +
560 my_issuer_count * sizeof (struct GNUNET_CRYPTO_EccPublicSignKey);
558 e_ctx->notify = &send_response_cb; 561 e_ctx->notify = &send_response_cb;
559 e_ctx->notify_cls = n; 562 e_ctx->notify_cls = n;
560 563
@@ -574,7 +577,7 @@ static void handle_response (const struct GNUNET_PeerIdentity *peer,
574{ 577{
575 struct Node *n; 578 struct Node *n;
576 const struct Experimentation_Response *rm = (const struct Experimentation_Response *) message; 579 const struct Experimentation_Response *rm = (const struct Experimentation_Response *) message;
577 const struct Experimentation_Issuer *rmi = (const struct Experimentation_Issuer *) &rm[1]; 580 const struct GNUNET_CRYPTO_EccPublicSignKey *rmi = (const struct GNUNET_CRYPTO_EccPublicSignKey *) &rm[1];
578 uint32_t ic; 581 uint32_t ic;
579 uint32_t ic_accepted; 582 uint32_t ic_accepted;
580 int make_active; 583 int make_active;
@@ -587,7 +590,7 @@ static void handle_response (const struct GNUNET_PeerIdentity *peer,
587 return; 590 return;
588 } 591 }
589 ic = ntohl (rm->issuer_count); 592 ic = ntohl (rm->issuer_count);
590 if (ntohs (message->size) != sizeof (struct Experimentation_Response) + ic * sizeof (struct Experimentation_Issuer)) 593 if (ntohs (message->size) != sizeof (struct Experimentation_Response) + ic * sizeof (struct GNUNET_CRYPTO_EccPublicSignKey))
591 { 594 {
592 GNUNET_break (0); 595 GNUNET_break (0);
593 return; 596 return;
@@ -636,7 +639,7 @@ static void handle_response (const struct GNUNET_PeerIdentity *peer,
636 ic_accepted = 0; 639 ic_accepted = 0;
637 for (c1 = 0; c1 < ic; c1++) 640 for (c1 = 0; c1 < ic; c1++)
638 { 641 {
639 if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id)) 642 if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1]))
640 ic_accepted ++; 643 ic_accepted ++;
641 } 644 }
642 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 645 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -647,9 +650,9 @@ static void handle_response (const struct GNUNET_PeerIdentity *peer,
647 c2 = 0; 650 c2 = 0;
648 for (c1 = 0; c1 < ic; c1++) 651 for (c1 = 0; c1 < ic; c1++)
649 { 652 {
650 if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1].issuer_id)) 653 if (GNUNET_YES == GED_experiments_issuer_accepted(&rmi[c1]))
651 { 654 {
652 n->issuer_id[c2] = rmi[c1].issuer_id; 655 n->issuer_id[c2] = rmi[c1];
653 c2 ++; 656 c2 ++;
654 } 657 }
655 } 658 }
diff --git a/src/experimentation/gnunet-daemon-experimentation_storage.c b/src/experimentation/gnunet-daemon-experimentation_storage.c
index 641915e66..8c6214c7b 100644
--- a/src/experimentation/gnunet-daemon-experimentation_storage.c
+++ b/src/experimentation/gnunet-daemon-experimentation_storage.c
@@ -25,7 +25,6 @@
25 * @author Matthias Wachs 25 * @author Matthias Wachs
26 */ 26 */
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_getopt_lib.h"
29#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
30#include "gnunet_core_service.h" 29#include "gnunet_core_service.h"
31#include "gnunet_statistics_service.h" 30#include "gnunet_statistics_service.h"