aboutsummaryrefslogtreecommitdiff
path: root/src/transport
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
parent0f400440ed8e31091a40f8991fcb34769836cf2e (diff)
downloadgnunet-15145b5d8405bf4a746ddeadc4702dee2ae6f218.tar.gz
gnunet-15145b5d8405bf4a746ddeadc4702dee2ae6f218.zip
ats manipulation
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c4
-rw-r--r--src/transport/gnunet-service-transport_manipulation.c48
-rw-r--r--src/transport/gnunet-service-transport_manipulation.h12
3 files changed, 58 insertions, 6 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index ff0d25326..8859e6ffc 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -696,12 +696,12 @@ key_generation_cb (void *cls,
696 GST_blacklist_start (GST_server); 696 GST_blacklist_start (GST_server);
697 GST_ats = 697 GST_ats =
698 GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL); 698 GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL);
699 GST_manipulation_init (GST_cfg); 699 GST_manipulation_init (GST_cfg, &plugin_env_update_metrics);
700 GST_plugins_load (&GST_manipulation_recv, 700 GST_plugins_load (&GST_manipulation_recv,
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 &plugin_env_update_metrics); 704 &GST_manipulation_update_metrics);
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 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))
diff --git a/src/transport/gnunet-service-transport_manipulation.h b/src/transport/gnunet-service-transport_manipulation.h
index 4a13abbdc..075580116 100644
--- a/src/transport/gnunet-service-transport_manipulation.h
+++ b/src/transport/gnunet-service-transport_manipulation.h
@@ -55,7 +55,17 @@ GST_manipulation_recv (void *cls,
55 uint16_t sender_address_len); 55 uint16_t sender_address_len);
56 56
57void 57void
58GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg); 58GST_manipulation_update_metrics (void *cls,
59 const struct GNUNET_PeerIdentity *peer,
60 const char *address,
61 uint16_t address_len,
62 struct Session *session,
63 struct GNUNET_ATS_Information *ats,
64 uint32_t ats_count);
65
66void
67GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg,
68 GNUNET_TRANSPORT_UpdateAddressMetrics metric_update_cb);
59 69
60void 70void
61GST_manipulation_stop (); 71GST_manipulation_stop ();