diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-05-28 10:02:57 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-05-28 10:02:57 +0000 |
commit | b733a26ca3fc928aed04c9d1271e776e925f4c66 (patch) | |
tree | 337bd675f4160a63df03d40d1df0d57c22d6d457 | |
parent | 712084cd824652439e30455f329c9628050ec4fc (diff) | |
download | gnunet-b733a26ca3fc928aed04c9d1271e776e925f4c66.tar.gz gnunet-b733a26ca3fc928aed04c9d1271e776e925f4c66.zip |
changes
5 files changed, 61 insertions, 10 deletions
diff --git a/src/experimentation/gnunet-daemon-experimentation.h b/src/experimentation/gnunet-daemon-experimentation.h index 8a8ec67dd..8be39fa93 100644 --- a/src/experimentation/gnunet-daemon-experimentation.h +++ b/src/experimentation/gnunet-daemon-experimentation.h | |||
@@ -192,12 +192,17 @@ struct Experimentation_Request | |||
192 | /** | 192 | /** |
193 | * Experimentation response message | 193 | * Experimentation response message |
194 | * Sent if peer is running the daemon | 194 | * Sent if peer is running the daemon |
195 | * | ||
196 | * This struct is followed by issuer identities: | ||
197 | * (issuer_count * struct Experimentation_Request_Issuer) | ||
195 | */ | 198 | */ |
196 | struct Experimentation_Response | 199 | struct Experimentation_Response |
197 | { | 200 | { |
198 | struct GNUNET_MessageHeader msg; | 201 | struct GNUNET_MessageHeader msg; |
199 | 202 | ||
200 | uint32_t capabilities; | 203 | uint32_t capabilities; |
204 | |||
205 | uint32_t issuer_count; | ||
201 | }; | 206 | }; |
202 | 207 | ||
203 | 208 | ||
diff --git a/src/experimentation/gnunet-daemon-experimentation_experiments.c b/src/experimentation/gnunet-daemon-experimentation_experiments.c index fc873361d..2c0ce72c1 100644 --- a/src/experimentation/gnunet-daemon-experimentation_experiments.c +++ b/src/experimentation/gnunet-daemon-experimentation_experiments.c | |||
@@ -416,7 +416,7 @@ GNUNET_EXPERIMENTATION_experiments_start () | |||
416 | GSE_my_issuer_count = GNUNET_CONTAINER_multihashmap_size (valid_issuers); | 416 | GSE_my_issuer_count = GNUNET_CONTAINER_multihashmap_size (valid_issuers); |
417 | GSE_my_issuer = GNUNET_malloc (GSE_my_issuer_count * sizeof (struct Experimentation_Issuer)); | 417 | GSE_my_issuer = GNUNET_malloc (GSE_my_issuer_count * sizeof (struct Experimentation_Issuer)); |
418 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, &create_issuer, GSE_my_issuer); | 418 | GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, &create_issuer, GSE_my_issuer); |
419 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Daemon has %u issuers\n"), GSE_my_issuer_count); | 419 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Daemon has %u issuers\n"), GSE_my_issuer_count); |
420 | 420 | ||
421 | experiments = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | 421 | experiments = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); |
422 | /* Load experiments from file */ | 422 | /* Load experiments from file */ |
diff --git a/src/experimentation/gnunet-daemon-experimentation_nodes.c b/src/experimentation/gnunet-daemon-experimentation_nodes.c index dbc89476f..2e8628088 100644 --- a/src/experimentation/gnunet-daemon-experimentation_nodes.c +++ b/src/experimentation/gnunet-daemon-experimentation_nodes.c | |||
@@ -276,7 +276,7 @@ size_t send_response_cb (void *cls, size_t bufsize, void *buf) | |||
276 | struct Experimentation_Response msg; | 276 | struct Experimentation_Response msg; |
277 | size_t ri_size = GSE_my_issuer_count * sizeof (struct Experimentation_Issuer); | 277 | size_t ri_size = GSE_my_issuer_count * sizeof (struct Experimentation_Issuer); |
278 | size_t msg_size = sizeof (msg); | 278 | size_t msg_size = sizeof (msg); |
279 | size_t total_size = msg_size; | 279 | size_t total_size = msg_size + ri_size; |
280 | 280 | ||
281 | n->cth = NULL; | 281 | n->cth = NULL; |
282 | if (buf == NULL) | 282 | if (buf == NULL) |
@@ -290,6 +290,7 @@ size_t send_response_cb (void *cls, size_t bufsize, void *buf) | |||
290 | msg.msg.size = htons (total_size); | 290 | msg.msg.size = htons (total_size); |
291 | msg.msg.type = htons (GNUNET_MESSAGE_TYPE_EXPERIMENTATION_RESPONSE); | 291 | msg.msg.type = htons (GNUNET_MESSAGE_TYPE_EXPERIMENTATION_RESPONSE); |
292 | msg.capabilities = htonl (GSE_node_capabilities); | 292 | msg.capabilities = htonl (GSE_node_capabilities); |
293 | msg.issuer_count = htonl (GSE_my_issuer_count); | ||
293 | memcpy (buf, &msg, msg_size); | 294 | memcpy (buf, &msg, msg_size); |
294 | memcpy (&buf[msg_size], GSE_my_issuer, ri_size); | 295 | memcpy (&buf[msg_size], GSE_my_issuer, ri_size); |
295 | 296 | ||
@@ -454,19 +455,37 @@ static void handle_response (const struct GNUNET_PeerIdentity *peer, | |||
454 | const struct GNUNET_MessageHeader *message) | 455 | const struct GNUNET_MessageHeader *message) |
455 | { | 456 | { |
456 | struct Node *n; | 457 | struct Node *n; |
457 | struct Experimentation_Request *rm = (struct Experimentation_Request *) message; | 458 | struct Experimentation_Response *rm = (struct Experimentation_Response *) message; |
459 | struct Experimentation_Issuer *rmi = (struct Experimentation_Issuer *) &rm[1]; | ||
460 | uint32_t ic; | ||
461 | uint32_t ic_accepted; | ||
462 | int make_active; | ||
463 | unsigned int c1; | ||
464 | unsigned int c2; | ||
465 | |||
466 | |||
467 | if (ntohs (message->size) < sizeof (struct Experimentation_Response)) | ||
468 | { | ||
469 | GNUNET_break (0); | ||
470 | return; | ||
471 | } | ||
472 | ic = ntohl (rm->issuer_count); | ||
473 | if (ntohs (message->size) != sizeof (struct Experimentation_Response) + ic * sizeof (struct Experimentation_Issuer)) | ||
474 | { | ||
475 | GNUNET_break (0); | ||
476 | return; | ||
477 | } | ||
458 | 478 | ||
479 | make_active = GNUNET_NO; | ||
459 | if (NULL != (n = GNUNET_CONTAINER_multihashmap_get (nodes_active, &peer->hashPubKey))) | 480 | if (NULL != (n = GNUNET_CONTAINER_multihashmap_get (nodes_active, &peer->hashPubKey))) |
460 | { | 481 | { |
461 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Received %s from %s peer `%s'\n"), | 482 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Received %s from %s peer `%s'\n"), |
462 | "RESPONSE", "active", GNUNET_i2s (peer)); | 483 | "RESPONSE", "active", GNUNET_i2s (peer)); |
463 | n->capabilities = ntohl (rm->capabilities); | ||
464 | } | 484 | } |
465 | else if (NULL != (n = GNUNET_CONTAINER_multihashmap_get (nodes_requested, &peer->hashPubKey))) | 485 | else if (NULL != (n = GNUNET_CONTAINER_multihashmap_get (nodes_requested, &peer->hashPubKey))) |
466 | { | 486 | { |
467 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Received %s from %s peer `%s'\n"), | 487 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Received %s from %s peer `%s'\n"), |
468 | "RESPONSE", "requested", GNUNET_i2s (peer)); | 488 | "RESPONSE", "requested", GNUNET_i2s (peer)); |
469 | n->capabilities = ntohl (rm->capabilities); | ||
470 | GNUNET_CONTAINER_multihashmap_remove (nodes_requested, &peer->hashPubKey, n); | 489 | GNUNET_CONTAINER_multihashmap_remove (nodes_requested, &peer->hashPubKey, n); |
471 | if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task) | 490 | if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task) |
472 | { | 491 | { |
@@ -479,16 +498,15 @@ static void handle_response (const struct GNUNET_PeerIdentity *peer, | |||
479 | n->cth = NULL; | 498 | n->cth = NULL; |
480 | } | 499 | } |
481 | update_stats (nodes_requested); | 500 | update_stats (nodes_requested); |
482 | node_make_active (n); | 501 | make_active = GNUNET_YES; |
483 | } | 502 | } |
484 | else if (NULL != (n = GNUNET_CONTAINER_multihashmap_get (nodes_inactive, &peer->hashPubKey))) | 503 | else if (NULL != (n = GNUNET_CONTAINER_multihashmap_get (nodes_inactive, &peer->hashPubKey))) |
485 | { | 504 | { |
486 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Received %s from peer `%s'\n"), | 505 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Received %s from peer `%s'\n"), |
487 | "RESPONSE", "inactive", GNUNET_i2s (peer)); | 506 | "RESPONSE", "inactive", GNUNET_i2s (peer)); |
488 | n->capabilities = ntohl (rm->capabilities); | ||
489 | GNUNET_CONTAINER_multihashmap_remove (nodes_inactive, &peer->hashPubKey, n); | 507 | GNUNET_CONTAINER_multihashmap_remove (nodes_inactive, &peer->hashPubKey, n); |
490 | update_stats (nodes_inactive); | 508 | update_stats (nodes_inactive); |
491 | node_make_active (n); | 509 | make_active = GNUNET_YES; |
492 | } | 510 | } |
493 | else | 511 | else |
494 | { | 512 | { |
@@ -496,6 +514,34 @@ static void handle_response (const struct GNUNET_PeerIdentity *peer, | |||
496 | "RESPONSE", "unknown", GNUNET_i2s (peer)); | 514 | "RESPONSE", "unknown", GNUNET_i2s (peer)); |
497 | return; | 515 | return; |
498 | } | 516 | } |
517 | |||
518 | /* Update */ | ||
519 | n->capabilities = ntohl (rm->capabilities); | ||
520 | |||
521 | /* Filter accepted issuer */ | ||
522 | ic_accepted = 0; | ||
523 | for (c1 = 0; c1 < ic; c1++) | ||
524 | { | ||
525 | if (GNUNET_YES == GNUNET_EXPERIMENTATION_experiments_issuer_accepted(&rmi[c1].issuer_id)) | ||
526 | ic_accepted ++; | ||
527 | } | ||
528 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Response from peer `%s' with %u issuers, we accepted %u issuer \n"), | ||
529 | GNUNET_i2s (peer), ic, ic_accepted); | ||
530 | GNUNET_free_non_null (n->issuer_id); | ||
531 | n->issuer_id = GNUNET_malloc (ic_accepted * sizeof (struct GNUNET_PeerIdentity)); | ||
532 | c2 = 0; | ||
533 | for (c1 = 0; c1 < ic; c1++) | ||
534 | { | ||
535 | if (GNUNET_YES == GNUNET_EXPERIMENTATION_experiments_issuer_accepted(&rmi[c1].issuer_id)) | ||
536 | { | ||
537 | n->issuer_id[c2] = rmi[c1].issuer_id; | ||
538 | c2 ++; | ||
539 | } | ||
540 | } | ||
541 | n->issuer_count = ic_accepted; | ||
542 | |||
543 | if (GNUNET_YES == make_active) | ||
544 | node_make_active (n); | ||
499 | } | 545 | } |
500 | 546 | ||
501 | /** | 547 | /** |
diff --git a/src/experimentation/test_experimentation_clique.c b/src/experimentation/test_experimentation_clique.c index eee4cc072..0913c1a7f 100644 --- a/src/experimentation/test_experimentation_clique.c +++ b/src/experimentation/test_experimentation_clique.c | |||
@@ -33,7 +33,7 @@ | |||
33 | /** | 33 | /** |
34 | * Number of peers we want to start | 34 | * Number of peers we want to start |
35 | */ | 35 | */ |
36 | #define NUM_PEERS 10 | 36 | #define NUM_PEERS 20 |
37 | 37 | ||
38 | #define NUM_ISSUER 1 | 38 | #define NUM_ISSUER 1 |
39 | 39 | ||
diff --git a/src/experimentation/test_experimentation_clique.conf b/src/experimentation/test_experimentation_clique.conf index fb3d3b99e..0748f62d2 100644 --- a/src/experimentation/test_experimentation_clique.conf +++ b/src/experimentation/test_experimentation_clique.conf | |||
@@ -36,7 +36,7 @@ NEIGHBOUR_LIMIT = 50 | |||
36 | PORT = 12365 | 36 | PORT = 12365 |
37 | 37 | ||
38 | [experimentation] | 38 | [experimentation] |
39 | #PREFIX = valgrind --leak-check=full | 39 | PREFIX = valgrind --leak-check=full |
40 | ISSUERS = TFRM29O2RQNKLVBQIGODJ6GD58LSQ2NM9TNFBC6N48BRJHQO38Q73N2OM3V4CLKDM6CILQV4CU8PMJDRG0FNB0PDI057DBRANMLPLRG | 40 | ISSUERS = TFRM29O2RQNKLVBQIGODJ6GD58LSQ2NM9TNFBC6N48BRJHQO38Q73N2OM3V4CLKDM6CILQV4CU8PMJDRG0FNB0PDI057DBRANMLPLRG |
41 | EXPERIMENTS = test_experiments.exp | 41 | EXPERIMENTS = test_experiments.exp |
42 | 42 | ||