aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-03-25 14:23:36 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-03-25 14:23:36 +0000
commitcc67bae38c54cbaf2122ee3aa0762e7f2cb04edf (patch)
treefdbb9b063b160ab251750b220ff07d290cae723b /src/transport
parentee0ee4cc9515917530c6e2a60a8e90349847d4bd (diff)
downloadgnunet-cc67bae38c54cbaf2122ee3aa0762e7f2cb04edf.tar.gz
gnunet-cc67bae38c54cbaf2122ee3aa0762e7f2cb04edf.zip
ATS manipulation
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c11
-rw-r--r--src/transport/gnunet-service-transport_manipulation.c32
-rw-r--r--src/transport/gnunet-service-transport_manipulation.h14
3 files changed, 31 insertions, 26 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index a9ad57df1..58272a632 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -402,7 +402,16 @@ GST_update_ats_metrics (const struct GNUNET_PeerIdentity *peer,
402 const struct GNUNET_ATS_Information *ats, 402 const struct GNUNET_ATS_Information *ats,
403 uint32_t ats_count) 403 uint32_t ats_count)
404{ 404{
405 GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count); 405 struct GNUNET_ATS_Information *ats_new;
406 /* Call to manipulation to manipulate ATS information */
407 ats_new = GST_manipulation_manipulate_metrics (peer, address, session, ats, ats_count);
408 if (NULL == ats_new)
409 {
410 GNUNET_break (0);
411 return;
412 }
413 GNUNET_ATS_address_update (GST_ats, address, session, ats_new, ats_count);
414 GNUNET_free (ats_new);
406} 415}
407 416
408 417
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c
index e6a8f5580..2312961d0 100644
--- a/src/transport/gnunet-service-transport_manipulation.c
+++ b/src/transport/gnunet-service-transport_manipulation.c
@@ -347,8 +347,8 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg
347 347
348 348
349/** 349/**
350 * Function that will be called to figure if an address is an loopback, 350 * Function that will be called to manipulate ATS information according to
351 * LAN, WAN etc. address 351 * current manipulation settings
352 * 352 *
353 * @param cls closure 353 * @param cls closure
354 * @param peer the peer 354 * @param peer the peer
@@ -358,27 +358,22 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg
358 * @param ats the ats information 358 * @param ats the ats information
359 * @param ats_count the number of ats information 359 * @param ats_count the number of ats information
360 */ 360 */
361void 361struct GNUNET_ATS_Information *
362GST_manipulation_metrics_recv (void *cls, 362GST_manipulation_manipulate_metrics (const struct GNUNET_PeerIdentity *peer,
363 struct GNUNET_PeerIdentity *peer, 363 const struct GNUNET_HELLO_Address *address,
364 const char *address, 364 struct Session *session,
365 uint16_t address_len, 365 const struct GNUNET_ATS_Information *ats,
366 struct Session *session, 366 uint32_t ats_count)
367 struct GNUNET_ATS_Information *ats,
368 uint32_t ats_count)
369{ 367{
370 368 struct GNUNET_ATS_Information *ats_new = GNUNET_malloc (sizeof (struct GNUNET_ATS_Information) *ats_count);
371 struct GNUNET_ATS_Information ats_new[ats_count];
372 struct TM_Peer *tmp; 369 struct TM_Peer *tmp;
373 uint32_t m_distance; 370 uint32_t m_distance;
374 int d; 371 int d;
375
376
377 m_distance = 0; 372 m_distance = 0;
378 if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, &peer->hashPubKey))) 373 if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, &peer->hashPubKey)))
379 { 374 {
380 if (UINT32_MAX != tmp->metrics[TM_RECEIVE][DISTANCE]) 375 if (UINT32_MAX != tmp->metrics[TM_RECEIVE][DISTANCE])
381 m_distance = tmp->metrics[TM_RECEIVE][DISTANCE]; 376 m_distance = tmp->metrics[TM_RECEIVE][DISTANCE];
382 } 377 }
383 378
384 for (d = 0; d < ats_count; d++) 379 for (d = 0; d < ats_count; d++)
@@ -387,13 +382,17 @@ GST_manipulation_metrics_recv (void *cls,
387 if (ntohl(ats[d].type) == GNUNET_ATS_QUALITY_NET_DISTANCE) 382 if (ntohl(ats[d].type) == GNUNET_ATS_QUALITY_NET_DISTANCE)
388 { 383 {
389 if (m_distance > 0) 384 if (m_distance > 0)
385 {
390 ats_new[d].value = htonl(m_distance); 386 ats_new[d].value = htonl(m_distance);
387 }
391 else if (man_handle.distance_recv > 0) 388 else if (man_handle.distance_recv > 0)
389 {
392 ats_new[d].value = htonl(man_handle.distance_recv); 390 ats_new[d].value = htonl(man_handle.distance_recv);
391 }
393 } 392 }
394 } 393 }
395 394
396 man_handle.metric_update_cb (cls, peer, address, address_len, session, ats_new, ats_count); 395 return ats_new;
397} 396}
398 397
399struct GNUNET_TIME_Relative 398struct GNUNET_TIME_Relative
@@ -427,7 +426,6 @@ GST_manipulation_recv (void *cls,
427 return quota_delay; 426 return quota_delay;
428 else 427 else
429 return m_delay; 428 return m_delay;
430
431} 429}
432 430
433void 431void
diff --git a/src/transport/gnunet-service-transport_manipulation.h b/src/transport/gnunet-service-transport_manipulation.h
index c8e8b27e9..0f8c1156e 100644
--- a/src/transport/gnunet-service-transport_manipulation.h
+++ b/src/transport/gnunet-service-transport_manipulation.h
@@ -66,14 +66,12 @@ GST_manipulation_recv (void *cls,
66 * @param ats the ats information 66 * @param ats the ats information
67 * @param ats_count the number of ats information 67 * @param ats_count the number of ats information
68 */ 68 */
69void 69struct GNUNET_ATS_Information *
70GST_manipulation_metrics_recv (void *cls, 70GST_manipulation_manipulate_metrics (const struct GNUNET_PeerIdentity *peer,
71 struct GNUNET_PeerIdentity *peer, 71 const struct GNUNET_HELLO_Address *address,
72 const char *address, 72 struct Session *session,
73 uint16_t address_len, 73 const struct GNUNET_ATS_Information *ats,
74 struct Session *session, 74 uint32_t ats_count);
75 struct GNUNET_ATS_Information *ats,
76 uint32_t ats_count);
77 75
78void 76void
79GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg, 77GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg,