aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_manipulation.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-03-21 11:01:09 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-03-21 11:01:09 +0000
commit15145b5d8405bf4a746ddeadc4702dee2ae6f218 (patch)
treef028b1e2e2ccc6e00abe676e4313bb644f178e8d /src/transport/gnunet-service-transport_manipulation.c
parent0f400440ed8e31091a40f8991fcb34769836cf2e (diff)
downloadgnunet-15145b5d8405bf4a746ddeadc4702dee2ae6f218.tar.gz
gnunet-15145b5d8405bf4a746ddeadc4702dee2ae6f218.zip
ats manipulation
Diffstat (limited to 'src/transport/gnunet-service-transport_manipulation.c')
-rw-r--r--src/transport/gnunet-service-transport_manipulation.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c
index c03456903..e2bc69d0e 100644
--- a/src/transport/gnunet-service-transport_manipulation.c
+++ b/src/transport/gnunet-service-transport_manipulation.c
@@ -52,6 +52,8 @@ struct GST_ManipulationHandle
52{ 52{
53 struct GNUNET_CONTAINER_MultiHashMap *peers; 53 struct GNUNET_CONTAINER_MultiHashMap *peers;
54 54
55 GNUNET_TRANSPORT_UpdateAddressMetrics metric_update_cb;
56
55 /** 57 /**
56 * General inbound delay 58 * General inbound delay
57 */ 59 */
@@ -343,6 +345,45 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg
343 GST_neighbours_send (target, msg, msg_size, timeout, cont, cont_cls); 345 GST_neighbours_send (target, msg, msg_size, timeout, cont, cont_cls);
344} 346}
345 347
348
349/**
350 * Function that will be called to figure if an address is an loopback,
351 * LAN, WAN etc. address
352 *
353 * @param cls closure
354 * @param addr binary address
355 * @param addrlen length of the address
356 * @return ATS Information containing the network type
357 */
358void
359GST_manipulation_update_metrics (void *cls,
360 const struct GNUNET_PeerIdentity *peer,
361 const char *address,
362 uint16_t address_len,
363 struct Session *session,
364 struct GNUNET_ATS_Information *ats,
365 uint32_t ats_count)
366{
367#if 0
368 struct GNUNET_ATS_Information ats_new[ats_count];
369 struct TM_Peer *tmp;
370
371 for (d = 0; d < ats_count; d++)
372 {
373 ats_new[d] = ats[d];
374 if ((ntohl(ats[d].type) == GNUNET_ATS_QUALITY_NET_DISTANCE) &&
375 (man_handle.distance_recv > 0))
376 ats_new[d].value = htonl(man_handle.distance_recv); /* Global inbound distance */
377 }
378
379 if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, &peer->hashPubKey)))
380 {
381
382 }
383#endif
384 man_handle.metric_update_cb (cls, peer, address, address_len, session, ats, ats_count);
385}
386
346struct GNUNET_TIME_Relative 387struct GNUNET_TIME_Relative
347GST_manipulation_recv (void *cls, 388GST_manipulation_recv (void *cls,
348 const struct GNUNET_PeerIdentity *peer, 389 const struct GNUNET_PeerIdentity *peer,
@@ -352,8 +393,7 @@ GST_manipulation_recv (void *cls,
352 uint16_t sender_address_len) 393 uint16_t sender_address_len)
353{ 394{
354 struct TM_Peer *tmp; 395 struct TM_Peer *tmp;
355 //int d; 396
356 //struct GNUNET_ATS_Information ats_new[ats_count];
357 struct GNUNET_TIME_Relative quota_delay; 397 struct GNUNET_TIME_Relative quota_delay;
358 struct GNUNET_TIME_Relative m_delay; 398 struct GNUNET_TIME_Relative m_delay;
359 399
@@ -400,8 +440,10 @@ GST_manipulation_recv (void *cls,
400} 440}
401 441
402void 442void
403GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg) 443GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg,
444 GNUNET_TRANSPORT_UpdateAddressMetrics metric_update_cb)
404{ 445{
446 man_handle.metric_update_cb = metric_update_cb;
405 447
406 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, 448 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg,
407 "transport", "MANIPULATE_DISTANCE_IN", &man_handle.distance_recv)) 449 "transport", "MANIPULATE_DISTANCE_IN", &man_handle.distance_recv))