diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-04-03 15:18:26 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-04-03 15:18:26 +0000 |
commit | b2f1b737d50733230d2897f8e3362ed5d1558912 (patch) | |
tree | fc726471c5be699469e680332fd3809cf75acae6 | |
parent | a106ca799b1905f8093f8d8e12d1996b894f8a9f (diff) | |
download | gnunet-b2f1b737d50733230d2897f8e3362ed5d1558912.tar.gz gnunet-b2f1b737d50733230d2897f8e3362ed5d1558912.zip |
changes
-rw-r--r-- | src/transport/gnunet-service-transport_manipulation.c | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c index 720b47179..0b88ad20b 100644 --- a/src/transport/gnunet-service-transport_manipulation.c +++ b/src/transport/gnunet-service-transport_manipulation.c | |||
@@ -360,11 +360,11 @@ GST_manipulation_set_metric (void *cls, struct GNUNET_SERVER_Client *client, | |||
360 | ats = (struct GNUNET_ATS_Information *) &tm[1]; | 360 | ats = (struct GNUNET_ATS_Information *) &tm[1]; |
361 | for (c = 0; c < ntohs (tm->ats_count); c++) | 361 | for (c = 0; c < ntohs (tm->ats_count); c++) |
362 | { | 362 | { |
363 | set_metric (&man_handle.general, direction, ats[c].type, ats[c].value); | ||
364 | |||
363 | type = htonl (ats[c].type); | 365 | type = htonl (ats[c].type); |
364 | value = htonl (ats[c].value); | 366 | value = htonl (ats[c].value); |
365 | 367 | ||
366 | set_metric (&man_handle.general, direction, type, value); | ||
367 | |||
368 | switch (type) { | 368 | switch (type) { |
369 | case GNUNET_ATS_QUALITY_NET_DELAY: | 369 | case GNUNET_ATS_QUALITY_NET_DELAY: |
370 | if ((TM_RECEIVE == direction) || (TM_BOTH == direction)) | 370 | if ((TM_RECEIVE == direction) || (TM_BOTH == direction)) |
@@ -409,7 +409,7 @@ GST_manipulation_set_metric (void *cls, struct GNUNET_SERVER_Client *client, | |||
409 | type = htonl (ats[c].type); | 409 | type = htonl (ats[c].type); |
410 | value = htonl (ats[c].value); | 410 | value = htonl (ats[c].value); |
411 | 411 | ||
412 | set_metric (tmp, direction, type, value); | 412 | set_metric (tmp, direction, ats[c].type, ats[c].value); |
413 | 413 | ||
414 | 414 | ||
415 | switch (type) { | 415 | switch (type) { |
@@ -473,10 +473,10 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg | |||
473 | { | 473 | { |
474 | /* Manipulate here */ | 474 | /* Manipulate here */ |
475 | /* Delay */ | 475 | /* Delay */ |
476 | if (UINT32_MAX != tmp->metrics[TM_SEND][DELAY]) | 476 | if (UINT32_MAX != ntohl (find_metric(tmp, htonl (GNUNET_ATS_QUALITY_NET_DELAY), TM_SEND))) |
477 | { | 477 | { |
478 | /* We have a delay */ | 478 | /* We have a delay */ |
479 | delay.rel_value = tmp->metrics[TM_SEND][DELAY]; | 479 | delay.rel_value = ntohl (find_metric(tmp, htonl (GNUNET_ATS_QUALITY_NET_DELAY), TM_SEND)); |
480 | dqe = GNUNET_malloc (sizeof (struct DelayQueueEntry) + msg_size); | 480 | dqe = GNUNET_malloc (sizeof (struct DelayQueueEntry) + msg_size); |
481 | dqe->tmp = tmp; | 481 | dqe->tmp = tmp; |
482 | dqe->sent_at = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), delay); | 482 | dqe->sent_at = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), delay); |
@@ -492,10 +492,10 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg | |||
492 | return; | 492 | return; |
493 | } | 493 | } |
494 | } | 494 | } |
495 | else if (man_handle.delay_send.rel_value != 0) | 495 | else if (UINT32_MAX != ntohl (find_metric (&man_handle.general, htonl (GNUNET_ATS_QUALITY_NET_DELAY), TM_SEND))) |
496 | { | 496 | { |
497 | /* We have a delay */ | 497 | /* We have a delay */ |
498 | delay = man_handle.delay_send; | 498 | delay.rel_value = ntohl (find_metric (&man_handle.general, htonl (GNUNET_ATS_QUALITY_NET_DELAY), TM_SEND)); |
499 | dqe = GNUNET_malloc (sizeof (struct DelayQueueEntry) + msg_size); | 499 | dqe = GNUNET_malloc (sizeof (struct DelayQueueEntry) + msg_size); |
500 | dqe->tmp = tmp; | 500 | dqe->tmp = tmp; |
501 | dqe->sent_at = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), delay); | 501 | dqe->sent_at = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), delay); |
@@ -618,33 +618,40 @@ GST_manipulation_recv (void *cls, | |||
618 | void | 618 | void |
619 | GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg) | 619 | GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg) |
620 | { | 620 | { |
621 | unsigned long long tmp; | ||
622 | |||
621 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, | 623 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, |
622 | "transport", "MANIPULATE_DISTANCE_IN", &man_handle.distance_recv)) | 624 | "transport", "MANIPULATE_DISTANCE_IN", &tmp)) |
625 | { | ||
623 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting inbound distance_in to %u\n", | 626 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting inbound distance_in to %u\n", |
624 | (unsigned long long) man_handle.distance_recv); | 627 | (unsigned long long) tmp); |
625 | else | 628 | set_metric (&man_handle.general, TM_RECEIVE, htonl (GNUNET_ATS_QUALITY_NET_DISTANCE), htonl(tmp)); |
626 | man_handle.distance_recv = 0; | 629 | } |
627 | 630 | ||
628 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, | 631 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, |
629 | "transport", "MANIPULATE_DISTANCE_OUT", &man_handle.distance_send)) | 632 | "transport", "MANIPULATE_DISTANCE_OUT", &tmp)) |
633 | { | ||
630 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting outbound distance_in to %u\n", | 634 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting outbound distance_in to %u\n", |
631 | (unsigned long long) man_handle.distance_send); | 635 | (unsigned long long) tmp); |
632 | else | 636 | set_metric (&man_handle.general, TM_SEND, htonl (GNUNET_ATS_QUALITY_NET_DISTANCE), htonl(tmp)); |
633 | man_handle.distance_send = 0; | 637 | } |
634 | 638 | ||
635 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg, | 639 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, |
636 | "transport", "MANIPULATE_DELAY_IN", &man_handle.delay_recv)) | 640 | "transport", "MANIPULATE_DELAY_IN", &tmp)) |
641 | { | ||
637 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Delaying inbound traffic for %llu ms\n", | 642 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Delaying inbound traffic for %llu ms\n", |
638 | (unsigned long long) man_handle.delay_recv.rel_value); | 643 | (unsigned long long) tmp); |
639 | else | 644 | set_metric (&man_handle.general, TM_RECEIVE, htonl (GNUNET_ATS_QUALITY_NET_DELAY), htonl(tmp)); |
640 | man_handle.delay_recv.rel_value = 0; | 645 | } |
646 | |||
641 | 647 | ||
642 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg, | 648 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, |
643 | "transport", "MANIPULATE_DELAY_OUT", &man_handle.delay_send)) | 649 | "transport", "MANIPULATE_DELAY_OUT", &tmp)) |
650 | { | ||
644 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Delaying outbound traffic for %llu ms\n", | 651 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Delaying outbound traffic for %llu ms\n", |
645 | (unsigned long long) man_handle.delay_send.rel_value); | 652 | (unsigned long long) tmp); |
646 | else | 653 | set_metric (&man_handle.general, TM_SEND, htonl (GNUNET_ATS_QUALITY_NET_DELAY), htonl(tmp)); |
647 | man_handle.delay_send.rel_value = 0; | 654 | } |
648 | 655 | ||
649 | man_handle.peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | 656 | man_handle.peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); |
650 | } | 657 | } |