aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-03-21 12:09:14 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-03-21 12:09:14 +0000
commitd33854b36c74e34a67e6b8de69fd462772bf9310 (patch)
tree2989b94b7f2dc7d96532bf7733b928ead7d00472
parent15145b5d8405bf4a746ddeadc4702dee2ae6f218 (diff)
downloadgnunet-d33854b36c74e34a67e6b8de69fd462772bf9310.tar.gz
gnunet-d33854b36c74e34a67e6b8de69fd462772bf9310.zip
ats manipulation
-rw-r--r--src/transport/gnunet-service-transport.c2
-rw-r--r--src/transport/gnunet-service-transport_manipulation.c51
-rw-r--r--src/transport/gnunet-service-transport_manipulation.h2
3 files changed, 21 insertions, 34 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 8859e6ffc..da4bfbbf0 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -701,7 +701,7 @@ key_generation_cb (void *cls,
701 &plugin_env_address_change_notification, 701 &plugin_env_address_change_notification,
702 &plugin_env_session_end, 702 &plugin_env_session_end,
703 &plugin_env_address_to_type, 703 &plugin_env_address_to_type,
704 &GST_manipulation_update_metrics); 704 &GST_manipulation_metrics_recv);
705 GST_neighbours_start (NULL, 705 GST_neighbours_start (NULL,
706 &neighbours_connect_notification, 706 &neighbours_connect_notification,
707 &neighbours_disconnect_notification, 707 &neighbours_disconnect_notification,
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c
index e2bc69d0e..203a67771 100644
--- a/src/transport/gnunet-service-transport_manipulation.c
+++ b/src/transport/gnunet-service-transport_manipulation.c
@@ -356,7 +356,7 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg
356 * @return ATS Information containing the network type 356 * @return ATS Information containing the network type
357 */ 357 */
358void 358void
359GST_manipulation_update_metrics (void *cls, 359GST_manipulation_metrics_recv (void *cls,
360 const struct GNUNET_PeerIdentity *peer, 360 const struct GNUNET_PeerIdentity *peer,
361 const char *address, 361 const char *address,
362 uint16_t address_len, 362 uint16_t address_len,
@@ -364,24 +364,32 @@ GST_manipulation_update_metrics (void *cls,
364 struct GNUNET_ATS_Information *ats, 364 struct GNUNET_ATS_Information *ats,
365 uint32_t ats_count) 365 uint32_t ats_count)
366{ 366{
367#if 0 367
368 struct GNUNET_ATS_Information ats_new[ats_count]; 368 struct GNUNET_ATS_Information ats_new[ats_count];
369 struct TM_Peer *tmp; 369 struct TM_Peer *tmp;
370 uint32_t m_distance;
371 int d;
370 372
371 for (d = 0; d < ats_count; d++) 373 m_distance = 0;
374 if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, &peer->hashPubKey)))
372 { 375 {
373 ats_new[d] = ats[d]; 376 if (UINT32_MAX != tmp->metrics[TM_RECEIVE][DISTANCE])
374 if ((ntohl(ats[d].type) == GNUNET_ATS_QUALITY_NET_DISTANCE) && 377 m_distance = tmp->metrics[TM_RECEIVE][DISTANCE];
375 (man_handle.distance_recv > 0))
376 ats_new[d].value = htonl(man_handle.distance_recv); /* Global inbound distance */
377 } 378 }
378 379
379 if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, &peer->hashPubKey))) 380 for (d = 0; d < ats_count; d++)
380 { 381 {
381 382 ats_new[d] = ats[d];
383 if (ntohl(ats[d].type) == GNUNET_ATS_QUALITY_NET_DISTANCE)
384 {
385 if (m_distance > 0)
386 ats_new[d].value = htonl(m_distance);
387 else if (man_handle.distance_recv > 0)
388 ats_new[d].value = htonl(man_handle.distance_recv);
389 }
382 } 390 }
383#endif 391
384 man_handle.metric_update_cb (cls, peer, address, address_len, session, ats, ats_count); 392 man_handle.metric_update_cb (cls, peer, address, address_len, session, ats_new, ats_count);
385} 393}
386 394
387struct GNUNET_TIME_Relative 395struct GNUNET_TIME_Relative
@@ -402,29 +410,8 @@ GST_manipulation_recv (void *cls,
402 else 410 else
403 m_delay = GNUNET_TIME_UNIT_ZERO; 411 m_delay = GNUNET_TIME_UNIT_ZERO;
404 412
405#if 0
406 for (d = 0; d < ats_count; d++)
407 {
408 ats_new[d] = ats[d];
409 if ((ntohl(ats[d].type) == GNUNET_ATS_QUALITY_NET_DISTANCE) &&
410 (man_handle.distance_recv > 0))
411 ats_new[d].value = htonl(man_handle.distance_recv); /* Global inbound distance */
412 }
413#endif
414
415 if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, &peer->hashPubKey))) 413 if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, &peer->hashPubKey)))
416 { 414 {
417#if 0
418 /* Manipulate distance */
419 for (d = 0; d < ats_count; d++)
420 {
421 ats_new[d] = ats[d];
422 /* Set distance */
423 if ((ntohl(ats[d].type) == GNUNET_ATS_QUALITY_NET_DISTANCE) &&
424 (UINT32_MAX != tmp->metrics[TM_RECEIVE][DISTANCE]))
425 ats_new[d].value = htonl(tmp->metrics[TM_RECEIVE][DISTANCE]);
426 }
427#endif
428 /* Manipulate receive delay */ 415 /* Manipulate receive delay */
429 if (UINT32_MAX != tmp->metrics[TM_RECEIVE][DELAY]) 416 if (UINT32_MAX != tmp->metrics[TM_RECEIVE][DELAY])
430 m_delay.rel_value = tmp->metrics[TM_RECEIVE][DELAY]; /* Peer specific delay */ 417 m_delay.rel_value = tmp->metrics[TM_RECEIVE][DELAY]; /* Peer specific delay */
diff --git a/src/transport/gnunet-service-transport_manipulation.h b/src/transport/gnunet-service-transport_manipulation.h
index 075580116..17a0a24f3 100644
--- a/src/transport/gnunet-service-transport_manipulation.h
+++ b/src/transport/gnunet-service-transport_manipulation.h
@@ -55,7 +55,7 @@ GST_manipulation_recv (void *cls,
55 uint16_t sender_address_len); 55 uint16_t sender_address_len);
56 56
57void 57void
58GST_manipulation_update_metrics (void *cls, 58GST_manipulation_metrics_recv (void *cls,
59 const struct GNUNET_PeerIdentity *peer, 59 const struct GNUNET_PeerIdentity *peer,
60 const char *address, 60 const char *address,
61 uint16_t address_len, 61 uint16_t address_len,