From 8d02205bfc76bd089189d640c4bfa3c49cfda061 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Fri, 22 Mar 2013 15:50:08 +0000 Subject: fixing ATS data --- src/transport/gnunet-service-transport.c | 25 ++++++++++++---------- src/transport/gnunet-service-transport.h | 6 ++++++ .../gnunet-service-transport_manipulation.c | 2 +- .../gnunet-service-transport_neighbours.c | 8 +++---- src/transport/test_plugin_transport.c | 12 +++++------ 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index ffe40f8c1..685113b10 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -186,16 +186,9 @@ process_payload (const struct GNUNET_PeerIdentity *peer, im->header.size = htons (size); im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); im->peer = *peer; - - fprintf (stderr, "FIX THIS: %s:%u \n", __FILE__, __LINE__); - /* - ap[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); - ap[ats_count].value = - htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value);*/ memcpy (&im[1], message, ntohs (message->size)); GNUNET_ATS_address_add (GST_ats, address, session, NULL, 0); - GNUNET_ATS_address_update (GST_ats, address, session, NULL, 0); GST_clients_broadcast (&im->header, GNUNET_YES); return ret; @@ -407,6 +400,16 @@ plugin_env_address_to_type (void *cls, return GNUNET_ATS_address_get_type(GST_ats, addr, addrlen); } +void +GST_update_ats_metrics (struct GNUNET_PeerIdentity *peer, + struct GNUNET_HELLO_Address *address, + struct Session *session, + struct GNUNET_ATS_Information *ats, + uint32_t ats_count) +{ + GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count); +} + /** * Function that will be called to figure if an address is an loopback, * LAN, WAN etc. address @@ -418,8 +421,8 @@ plugin_env_address_to_type (void *cls, */ static void plugin_env_update_metrics (void *cls, - const struct GNUNET_PeerIdentity *peer, - const char *address, + struct GNUNET_PeerIdentity *peer, + const void *address, uint16_t address_len, struct Session *session, struct GNUNET_ATS_Information *ats, @@ -437,7 +440,7 @@ plugin_env_update_metrics (void *cls, haddress.address_length = address_len; haddress.transport_name = plugin_name; - GNUNET_ATS_address_update (GST_ats, &haddress, session, ats, ats_count); + GST_update_ats_metrics (peer, &haddress, session, ats, ats_count); } @@ -688,7 +691,7 @@ key_generation_cb (void *cls, &plugin_env_address_change_notification, &plugin_env_session_end, &plugin_env_address_to_type, - &GST_manipulation_metrics_recv); + &plugin_env_update_metrics); GST_neighbours_start (NULL, &neighbours_connect_notification, &neighbours_disconnect_notification, diff --git a/src/transport/gnunet-service-transport.h b/src/transport/gnunet-service-transport.h index 4f0aa924a..9a4233f01 100644 --- a/src/transport/gnunet-service-transport.h +++ b/src/transport/gnunet-service-transport.h @@ -97,6 +97,12 @@ GST_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, const char *sender_address, uint16_t sender_address_len); +void +GST_update_ats_metrics (struct GNUNET_PeerIdentity *peer, + struct GNUNET_HELLO_Address *address, + struct Session *session, + struct GNUNET_ATS_Information *ats, + uint32_t ats_count); #endif /* end of file gnunet-service-transport_plugins.h */ diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c index c01c9d4dc..831d8fd5d 100644 --- a/src/transport/gnunet-service-transport_manipulation.c +++ b/src/transport/gnunet-service-transport_manipulation.c @@ -357,7 +357,7 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg */ void GST_manipulation_metrics_recv (void *cls, - const struct GNUNET_PeerIdentity *peer, + struct GNUNET_PeerIdentity *peer, const char *address, uint16_t address_len, struct Session *session, diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index ee23af7fc..6c51dacca 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -1543,10 +1543,10 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour) else latency = n->latency.rel_value; ats.value = htonl (latency); - fprintf (stderr, "FIX THIS: %s %u \n", __FILE__, __LINE__); - GNUNET_ATS_address_update (GST_ats, - n->primary_address.address, - n->primary_address.session, &ats, 1); + GST_update_ats_metrics (&n->id, + n->primary_address.address, + n->primary_address.session, + &ats, 1); } diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c index 3c4c6f624..93b29402e 100644 --- a/src/transport/test_plugin_transport.c +++ b/src/transport/test_plugin_transport.c @@ -484,12 +484,12 @@ env_session_end (void *cls, static void env_update_metrics (void *cls, - const struct GNUNET_PeerIdentity *peer, - const char *address, - uint16_t address_len, - struct Session *session, - struct GNUNET_ATS_Information *ats, - uint32_t ats_count) + struct GNUNET_PeerIdentity *peer, + const void *address, + uint16_t address_len, + struct Session *session, + struct GNUNET_ATS_Information *ats, + uint32_t ats_count) { } -- cgit v1.2.3