diff options
Diffstat (limited to 'src/transport/gnunet-service-transport_manipulation.c')
-rw-r--r-- | src/transport/gnunet-service-transport_manipulation.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c index 0d0249bc2..3d4701188 100644 --- a/src/transport/gnunet-service-transport_manipulation.c +++ b/src/transport/gnunet-service-transport_manipulation.c | |||
@@ -39,6 +39,7 @@ enum TRAFFIC_METRIC_DIRECTION | |||
39 | TM_SEND = 0, TM_RECEIVE = 1, TM_BOTH = 2 | 39 | TM_SEND = 0, TM_RECEIVE = 1, TM_BOTH = 2 |
40 | }; | 40 | }; |
41 | 41 | ||
42 | |||
42 | /** | 43 | /** |
43 | * Struct containing information about manipulations to a specific peer | 44 | * Struct containing information about manipulations to a specific peer |
44 | */ | 45 | */ |
@@ -105,6 +106,7 @@ struct TM_Peer | |||
105 | struct DelayQueueEntry *send_tail; | 106 | struct DelayQueueEntry *send_tail; |
106 | }; | 107 | }; |
107 | 108 | ||
109 | |||
108 | struct GST_ManipulationHandle | 110 | struct GST_ManipulationHandle |
109 | { | 111 | { |
110 | /** | 112 | /** |
@@ -487,35 +489,39 @@ GST_manipulation_send(const struct GNUNET_PeerIdentity *target, const void *msg, | |||
487 | * @param ats_count the number of ats information | 489 | * @param ats_count the number of ats information |
488 | */ | 490 | */ |
489 | struct GNUNET_ATS_Information * | 491 | struct GNUNET_ATS_Information * |
490 | GST_manipulation_manipulate_metrics(const struct GNUNET_PeerIdentity *peer, | 492 | GST_manipulation_manipulate_metrics(const struct GNUNET_HELLO_Address *address, |
491 | const struct GNUNET_HELLO_Address *address, struct Session *session, | 493 | struct Session *session, |
492 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) | 494 | const struct GNUNET_ATS_Information *ats, |
495 | uint32_t ats_count) | ||
493 | { | 496 | { |
494 | struct GNUNET_ATS_Information *ats_new = | 497 | const struct GNUNET_PeerIdentity *peer = &address->peer; |
495 | GNUNET_malloc (sizeof (struct GNUNET_ATS_Information) *ats_count); | 498 | struct GNUNET_ATS_Information *ats_new; |
496 | struct TM_Peer *tmp; | 499 | struct TM_Peer *tmp; |
497 | uint32_t m_tmp; | 500 | uint32_t m_tmp; |
498 | uint32_t g_tmp; | 501 | uint32_t g_tmp; |
499 | int d; | 502 | uint32_t d; |
500 | tmp = GNUNET_CONTAINER_multipeermap_get(man_handle.peers, peer); | ||
501 | 503 | ||
504 | if (0 == ats_count) | ||
505 | return NULL; | ||
506 | ats_new = GNUNET_malloc (sizeof (struct GNUNET_ATS_Information) * ats_count); | ||
507 | tmp = GNUNET_CONTAINER_multipeermap_get (man_handle.peers, peer); | ||
502 | for (d = 0; d < ats_count; d++) | 508 | for (d = 0; d < ats_count; d++) |
503 | { | 509 | { |
504 | ats_new[d] = ats[d]; | 510 | ats_new[d] = ats[d]; |
505 | m_tmp = UINT32_MAX; | 511 | m_tmp = UINT32_MAX; |
506 | if (NULL != tmp) | 512 | if (NULL != tmp) |
507 | m_tmp = find_metric(tmp, ntohl(ats[d].type), TM_RECEIVE); | 513 | m_tmp = find_metric(tmp, ntohl(ats[d].type), TM_RECEIVE); |
508 | g_tmp = find_metric(&man_handle.general, ntohl(ats[d].type), TM_RECEIVE); | 514 | g_tmp = find_metric(&man_handle.general, ntohl(ats[d].type), TM_RECEIVE); |
509 | 515 | ||
510 | if (UINT32_MAX != g_tmp) | 516 | if (UINT32_MAX != g_tmp) |
511 | ats_new[d].value = htonl(g_tmp); | 517 | ats_new[d].value = htonl(g_tmp); |
512 | if (UINT32_MAX != m_tmp) | 518 | if (UINT32_MAX != m_tmp) |
513 | ats_new[d].value = htonl(m_tmp); | 519 | ats_new[d].value = htonl(m_tmp); |
514 | } | 520 | } |
515 | |||
516 | return ats_new; | 521 | return ats_new; |
517 | } | 522 | } |
518 | 523 | ||
524 | |||
519 | /** | 525 | /** |
520 | * Adapter function between transport plugins and transport receive function | 526 | * Adapter function between transport plugins and transport receive function |
521 | * manipulation delays for next send. | 527 | * manipulation delays for next send. |
@@ -528,9 +534,9 @@ GST_manipulation_manipulate_metrics(const struct GNUNET_PeerIdentity *peer, | |||
528 | */ | 534 | */ |
529 | struct GNUNET_TIME_Relative | 535 | struct GNUNET_TIME_Relative |
530 | GST_manipulation_recv (void *cls, | 536 | GST_manipulation_recv (void *cls, |
531 | const struct GNUNET_HELLO_Address *address, | 537 | const struct GNUNET_HELLO_Address *address, |
532 | struct Session *session, | 538 | struct Session *session, |
533 | const struct GNUNET_MessageHeader *message) | 539 | const struct GNUNET_MessageHeader *message) |
534 | { | 540 | { |
535 | struct TM_Peer *tmp; | 541 | struct TM_Peer *tmp; |
536 | uint32_t p_recv_delay; | 542 | uint32_t p_recv_delay; |